Community discussions

MikroTik App
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

ASK [random wifi password generator]

Tue Apr 21, 2020 5:16 am

i'm using script for "random wifi password generator."

i got two scripts. Both of them are working.

if i ll run the script every 10-15 min it does work well.

Problem:
Weekly it doesn't work.
Script sending me same wifi password from the last ran.

i have attached both scripts.
You do not have the required permissions to view the files attached to this post.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 8:12 am

When I run the script 1.txt from cli, I do get a "random" password every time.
But if you run the script scheduled, it will not be random, since it uses hour/minutes/seconds to make the random, and this will be the same if you set it to run once a week etc.

PS you should post the script using code tags </> like this:


1.txt
{
:local wifiprofile wifi_security_profile
:local toEmail yourmail@domain.com

:local time [:pick [/system clock get time] 0 2];
:local min [:pick [/system clock get time] 3 5];
:local sec [:pick [/system clock get time] 6 8];
:local char;
:set char ( $char . [ :pick $time 1 ] . [ :pick $time 0 ]);
:local char1;
:set char1 ( $char1 . [ :pick $min 1 ] . [ :pick $min 0 ]);
:local char2;
:set char2 ( $char2 . [ :pick $sec 1 ] . [ :pick $sec 0 ]);
:local arrayalpha ("2","C","h","Y","!","f","j","c","}","q","k",":","(","}","3","Y","T","|","C","v","}","n","8","I","r","4","p","V","6",":","S","V","=","p","Z","T","6",")","l",":","K","b","=","Y","7","X","c","P","@","g","m","U","T","_","g","v","N","j","E","g","f","D","h","!","W","p","U","z","T","S","}","h","M","Y","i","E","c","4","!","Q","(","<","Y","h","@","e","q","7","]","l","R","-","h","S","w","(",">","/","r","=","<","I","&","5","@","!","|","h","p","l","1","Y","U","2","J","R","T","Y","}","=","b","c","$","9","d","e","@","S","6","W","B","Q","$","S","b","p","}","3","m","X","g","8","y","j","h","S","Z","F","@","!","t","}","!","U","j","/","W","5","}","a","g","!","S","S","T","{","7","f","G","W","T","_","/","k","3","+","T","X","p","m","!","e","i","L","]","3","d","G","T","+","@","H","!","Q","k","X","@","P","Q","+","k","f","K","T","S","{","Q","W","S","<","S","z","z","k","V","@","X","{","4","g","t","X","1","h","5","k","T","_","f","i","{","]","(","Y","/","1","j","h","l","]","S","3","b","Y",":","i","T","j","h","T","7","w","g","D","X","g","T","T","i","|","S","R","!","}","D","d","c","h","d","T","l","N",")","V","u","Z","T","}",":","{","S","m","Z","d","}","Z","Z","S","Y","|","_","d","k","v","h","(","7","/","-");
:local new;
:set new ( $new . [ :pick $arrayalpha ($time+$min+$sec) ] . [ :pick $arrayalpha ($time+$sec) ] . [ :pick $arrayalpha ($min+$sec) ] . [ :pick $arrayalpha $sec ] . [ :pick $arrayalpha $char ] . [ :pick $arrayalpha $char1 ] . [ :pick $arrayalpha $char2 ] . [ :pick $arrayalpha ($char+$char1+$char2) ]);
:local arrlengh [:len $arrayalpha];
:put "Our Array Lengh is $arrlengh Your New String is $new";
}
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 8:26 am

RouterOS does not have a random function. Many has tried to make script to make random text, but all seems to be flawed.

But this should do, since it gets the string from an external site:
{
/tool fetch url="https://www.random.org/passwords/\?num=1&len=8&format=plain&rnd=new" keep-result=yes dst-path="pass.txt"
:local pass [/file get pass.txt contents]
:put $pass
}
EDIT
No need to use a file. This should do:
{
local pass ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")
:put $pass
}
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 9:28 am

if i'll use the first you edit, it will work weekly?

second part that you have posted.
So far i don't have any particular website that i can put in
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 11:32 am

You can use both script in my latest post. Only difference is that one writes to file before it sets the variable.
RouterOS needs to have access to internet for this to work, but should be better than using time to generate a random text.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 12:44 pm

What about 1.text after you have edited, would be fine?

at this point i need some script which will send email and change wifi sec profile
Last edited by nichky on Tue Apr 21, 2020 12:59 pm, edited 1 time in total.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 12:57 pm

Do not use. I only changed so that it show up on display.
It is not a random tool, it wil gave same code every time if its run at the same time of day.

Use this one:
local pass ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")
:put $pass
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 1:00 pm

i need some script which will send email and change wifi sec profile
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 2:43 pm

I do not have a wifi device nearby, but this may work:
# Set your wifi profile
:local wifiprofile set_your_profile

# Set your email
:local toEmail my.emai@gmail.com

# Gets a new password
:local new ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")

# Set password to wifi profile
:interface wireless security-profiles set $wifiprofile wpa-pre-shared-key="$new"
:interface wireless security-profiles set $wifiprofile wpa2-pre-shared-key="$new"

# Send email
:tool e-mail send to=$toEmail subject="$[/system identity get name] WiFi Password" body="This Week's Wireless Password Is: $new"

# Write a log line
:log info message="Wifi password for profile $wifiprofile has ben set to $new"
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 2:52 pm

unfortunately..it doesn't work
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Tue Apr 21, 2020 3:42 pm

It fail and do not run, or does not set password or does not send emai?
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 12:03 am

it doesn't do anything
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 8:17 am

Cut an past this to terminal of your Router, do you get a password:
{
:local new ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")
:put $new
}
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 10:17 am

yes im getting pass
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 11:54 am

Then try
:interface wireless security-profiles print
to get then name of your profile.

Then run after change your_profile to your profile
:interface wireless security-profiles set your_profile wpa2-pre-shared-key="test"
Does this work?

NB I do not have Wifi device so need to take on test at a time.

If all above work try to cut and past this (aftter change to your_profile
{
:local new ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")
:interface wireless security-profiles set your_profile wpa2-pre-shared-key="$new"
}
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 1:17 pm

Then try
:interface wireless security-profiles print
to get then name of your profile.

Then run after change your_profile to your profile
:interface wireless security-profiles set your_profile wpa2-pre-shared-key="test"
Does this work?
YES it does work,any pass i put will change to test

NB I do not have Wifi device so need to take on test at a time.

If all above work try to cut and past this (aftter change to your_profile
{
:local new ([/tool fetch url="https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new" output=user as-value]->"data")
:interface wireless security-profiles set your_profile wpa2-pre-shared-key="$new"
}
how can i combine all together?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Wed Apr 22, 2020 8:39 pm

I split it up, so I could see what does not work.

If you have more than one line of commands, you need to wrap then in {} or [] to run from terminal. In script this is not needed.

Not work on terminal
:local test 123
:put $test
This work
{
:local test 123
:put $test
}
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Thu Apr 23, 2020 2:06 am

i found this one it does work. Any update that you can do on this?
it will work weekly?

# Set your wifi profile
:local wifiprofile set_your_profile

# Set your email
:local toEmail mail@gmail.com

# Gets a new password
:local pass ([/tool fetch url="https://www.random.org/passwords/\?num= ... in&rnd=new" output=user as-value]->"data")
:put $pass

# Set password to wifi profile
:interface wireless security-profiles set $wifiprofile wpa-pre-shared-key="$pass"
:interface wireless security-profiles set $wifiprofile wpa2-pre-shared-key="$pass"

# Send email
:tool e-mail send to=$toEmail subject="$[/system identity get name] WiFi Password" body="This Week's Wireless Password Is: $pass"

# Write a log line
:log info message="Wifi password for profile $wifiprofile has ben set to $pass"
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Thu Apr 23, 2020 8:27 am

Its more or less the same as I wrote above. Use code tags around your script. Select code and click the </> button.

:put $pass
is not needed.

You need to create a schedule for it to run weekly.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Fri Apr 24, 2020 12:43 am

Its more or less the same as I wrote above. Use code tags around your script. Select code and click the </> button.
please give me an example?

:put $pass
is not needed.

You need to create a schedule for it to run weekly.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Apr 26, 2020 1:03 am

Hi Jotne,

can we do some more easy password?
The current one is much complicated..
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Sun Apr 26, 2020 9:50 am

You could change the
len=20
to
 len=5
in the URL to get a shorter one, or try to find an other web page that you have more control of the password generation.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jun 07, 2020 9:06 am

Thanks a lot Jotne does work.well done
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 9:34 am

Hi Jotne


after a while that script it stoops to work.
Currently it doesn't work at all.

im getting error :

<503 Service Temporarily Unavailable>

Why is so hard to tha script to send out email and change the sec-pass?
even the previous scripts..
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 9:46 am

I can not explain why a script stops working. Try to run it on the terminal to see what is going on.
Upgrade your RouterOS if you do run an older version.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 9:57 am

see what im getting...
You do not have the required permissions to view the files attached to this post.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 10:08 am

im using 6.44.6 (long-term)

everything was fine until this morning..is not the version issus for sure
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 11:33 am

When you past it to terminal, you do wrap it on brackets? { }
{
your code
}
If not it will not work.

6.44.6 are getting some old. Oktober 2019. It should work with the script.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 2:44 pm

even like that im getting:

failure: closing connection: <503 Service Temporarily Unavailable> 104.20.45.7:443 (4)
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Sun Jun 28, 2020 5:34 pm

Did you try the url in a browser?
https://www.random.org/passwords/\?num=1&len=20&format=plain&rnd=new
It seems that they have added some DDoS protection using java.
DDoS protection by Cloudflare

So it may prevent the download to work from Mikrotik.
Try to find another password site.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Mon Jun 29, 2020 1:05 am

can we modificate the previous scripts to sent password weekly?
using website it seems like that will work temporary.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Mon Jun 29, 2020 9:44 am

Script creating password based on time will never work on RouterOS. Send an request to MikroTik to add a random password generator.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Sun Jul 26, 2020 10:50 am

Hi Jotne

one thing i found..interesting
When im activating the script by clicking manually the system/script it does work perfectly.

The problem is when i need to do by system/scheduler, then script sending same pasword..always and always.

i have no idea why..it does that?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Sun Jul 26, 2020 6:40 pm

If you use the time base password script it will be the same all time.
Did you try this?

viewtopic.php?p=807658
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Mon Jul 27, 2020 12:30 am

how can i combine that in my case?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Mon Jul 27, 2020 8:05 am

Some like this?
{
:local new ([/certificate scep-server otp generate minutes-valid=0 as-value]->"password")
:interface wireless security-profiles set your_profile wpa2-pre-shared-key="$new"
}
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Mon Jul 27, 2020 9:37 am

see what im getting.
but also that pass want to be sent to email
You do not have the required permissions to view the files attached to this post.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Mon Jul 27, 2020 10:30 am

You need to try an test and learn some scripting.
I just give you idea on how to solve it.

your_profile need to be set to an real profile.
 
User avatar
nichky
Forum Guru
Forum Guru
Topic Author
Posts: 1281
Joined: Tue Jun 23, 2015 2:35 pm

Re: ASK [random wifi password generator]

Mon Jul 27, 2020 11:48 am

has been implemented
we will see the result
 
msatter
Forum Guru
Forum Guru
Posts: 2912
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: ASK [random wifi password generator]

Fri Aug 07, 2020 4:01 pm

To avoid the weekly to be the same also add the weeknumber to one of the values.

Or change the runtime of the script by adding the weeknumber to the seconds of the interval time at the end of the script.
:local $weeknumber=(calculate weeknumber[1-52]);
set scriptname interval=(7d - $weeknumber)
 
SvSx10
just joined
Posts: 3
Joined: Thu Oct 17, 2019 8:54 pm

Re: ASK [random wifi password generator]

Tue Aug 18, 2020 11:09 pm

:local wifiprofile "You wireless security-profiles name"
# "len=" in the url it is the number of characters for in the generated password
/tool fetch url="https://www.random.org/passwords/\?num=1&len=10&format=plain&rnd=new" keep-result=yes dst-path="pass.txt"
delay 3
# The last digit before the closing square bracket must be "len=" from url
:local newPassword [put [pick ([/file get [/file find name=pass.txt] contents]) 0 10]];
:interface wireless security-profiles set $wifiprofile wpa-pre-shared-key="$newPassword";
:interface wireless security-profiles set $wifiprofile wpa2-pre-shared-key="$newPassword";
/file remove [find name="pass.txt"];
/log info message="New Wi-Fi Pass = $newPassword"
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: ASK [random wifi password generator]

Mon Aug 24, 2020 12:06 pm

Instead of relay on an external service to get password, you can use this solution.
viewtopic.php?f=9&t=164114

Who is online

Users browsing this forum: SGBIPL, tryrtryrtryrt, vaio73 and 38 guests