Community discussions

MikroTik App
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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.
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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";
}
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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
}
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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.
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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"
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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?
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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
}
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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"
}
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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?
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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
}
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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"
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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.
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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..
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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..
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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.
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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)
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 
 
User avatar
nichky
Long time Member
Long time Member
Topic Author
Posts: 602
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.
Nikola Suminoski
MikroTik Consultan
MTCRE l MTCWE

!) Safe Mode is your friend;
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1743
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

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.
 
How to use Splunk to monitor your MikroTik Router(s)

MikroTik->Splunk
 

Who is online

Users browsing this forum: No registered users and 18 guests