It uses three character source strings, the second and third are just scrambled versions of the first string. You can loop through more strings if you want.
This script takes a couple of minutes to run with the semi-random delays that are added.
Code: Select all
# MikroTik Random Password Generator
# Author: Bob Burley - April 25, 2011
#
# Total characters to choose from is 73
# Eliminated confusing characters
# '0' (zero) and Upper Case 'O'
# '1' (one) and Upper Case 'I' and Lower Case 'l' (L)
:local charStr1 "23456789ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnopqrstuvwxyz23456789"
:local charStr2 "cN47iKd2bLn8sQz4JAu2PD6Vm5RjTG4UrFY78XewHE3W9gMq62v7a9Z5yf5pC3k6xt9Bh8S3o"
:local charStr3 "uYswW92z6M5fJynQp6hGm5VSr4oR8k7A2bKq5U3FiZvc8gHP2tdL9E4jBT3X7xC6N4D8e7a93"
# set new password length here
:local newPassLength 8
:local charStrNum 1
:local newPassword ""
:local p1
:local var1
:local var2
:local var3
:for char from=1 to=$newPassLength step=1 do={
# Generate number between 0 and 72
:set var1 ([:pick [/system clock get time] 6 8])
:set p1 ([:len [/system resource get uptime]])
:set var2 ([:pick [/system resource get uptime] ($p1-2) $p1])
:set var3 (($var1 * $var2) / 48)
# pick next character to add to the new password
:if ($charStrNum=1) do={
:set newPassword ($newPassword . [:pick $charStr1 $var3])
}
:if ($charStrNum=2) do={
:set newPassword ($newPassword . [:pick $charStr2 $var3])
}
:if ($charStrNum=3) do={
:set newPassword ($newPassword . [:pick $charStr3 $var3])
}
:set charStrNum ($charStrNum + 1)
:if ($charStrNum = 4) do={
:set charStrNum 1
}
:delay (($var1 + $var2 + $var3) / 5)
}
:log info $newPassword
Code: Select all
# MikroTik Random Password Generator
# with random start offset delay for use with /System Scheduler
# Author: Bob Burley - April 25, 2011
#
:local minRtt
:local maxRtt
:local random 0
:local siteAddress
:local charStrNum 1
:local p1
:local var1
:local var2
:local var3
:local newPassword ""
# set password length here
:local newPassLength 8
# Total characters to choose from is 73
# Eliminated confusing characters
# '0' (zero) and Upper Case 'O'
# '1' (one) and Upper Case 'I' and Lower Case 'l' (L)
:local charStr1 "23456789ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnopqrstuvwxyz23456789"
:local charStr2 "cN47iKd2bLn8sQz4JAu2PD6Vm5RjTG4UrFY78XewHE3W9gMq62v7a9Z5yf5pC3k6xt9Bh8S3o"
:local charStr3 "uYswW92z6M5fJynQp6hGm5VSr4oR8k7A2bKq5U3FiZvc8gHP2tdL9E4jBT3X7xC6N4D8e7a93"
# google.ca (74.125.95.147) - google.com (74.125.95.99) - yahoo.ca (68.180.206.184) - yahoo.com (209.191.122.70)
:local arraySiteList [:toarray ("74.125.95.147","74.125.95.99","68.180.206.184","209.191.122.70")]
:foreach siteAddress in=($arraySiteList) do={
/tool flood-ping $siteAddress count=4 do={
:if ($sent=4) do={
:set minRtt $"min-rtt"
:set maxRtt $"max-rtt"
}
:set random ($random + minRtt)
:while ($random > 59) do={
:set random ($random -60)
}
:set random ($random + maxRtt)
:while ($random > 59) do={
:set random ($random -60)
}
}
}
:delay $random
:for char from=1 to=$newPassLength step=1 do={
# Generate number between 0 and 72
:set var1 ([:pick [/system clock get time] 6 8])
:set p1 ([:len [/system resource get uptime]])
:set var2 ([:pick [/system resource get uptime] ($p1-2) $p1])
:set var3 (($var1 * $var2) / 48)
# pick next character to add to the new password
:if ($charStrNum=1) do={
:set newPassword ($newPassword . [:pick $charStr1 $var3])
}
:if ($charStrNum=2) do={
:set newPassword ($newPassword . [:pick $charStr2 $var3])
}
:if ($charStrNum=3) do={
:set newPassword ($newPassword . [:pick $charStr3 $var3])
}
:set charStrNum ($charStrNum + 1)
:if ($charStrNum = 4) do={
:set charStrNum 1
}
:delay (($var1 + $var2 + $var3) / 5)
}
:log info $newPassword
The rest of the plan is to change the wireless security code every Sunday and automatically email the new code to key people. The weekly code can be given to visitors with laptops who need to check their email or surf the web. The spreading of the security code to others will be reduced with the weekly rotation.
I don't have the patience to run this thousands of times to see how good or how bad it really is. Perhaps someone with a math or statistics background will comment.
Hopefully someday MikroTik will add a real random generator in RouterOS.