MikroTik RouterOS automatically changes WIFI password
Some time ago, I went to a friend's company to see their GuestWIF password according to the company name plus the year, month and day. I thought it was interesting to change it automatically, so as to prevent the WIFI password of the company from being leaked out.
Specific steps:
1: add the script as follows
# months array:local months ("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec") # get Date:local ds [/ system clock get date] # convert name of month to number:local month [: pick $ds 0 3]; local mm ([: find $months $month-1] + 1); if ($mm < 10) do= {: set mm ("0". $mm);} # set $ds to format YYYY-MM-DD:set ds ([: pick $ds 7 11]. $mm. [: pick $ds 4 6]): log info "date format: $ds sss" # so the final password is in the format XXX20161010 / interface wireless security-profilesset 1 wpa2-pre-shared-key= "XXX$ds" # where 1 is the configuration file serial number of guest
2: add scheduled tasks
/ system scheduler add interval=1d name= "update wifi pass" on-event= "/ system script run AutoUpdateGuestPasswd" policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-date=oct/20/2016 start-time=01:00:00
The most important thing is how to get the formatted date. Nothing else. Scripts are different from normal shell.