Page 1 of 1
password change
Posted: Thu Jul 02, 2015 10:44 am
by charuga
I have over 500 mt in the network.
Whether someone knows a way that they automatically change the admin password.
I tried this script but it does not work
/user group add name=managers policy=ftp,read,local,policy,reboot,ssh,winbox
/user add name=manager group=managers password=manager
/system script add name="change-pass" source={
/tool fetch address=WEB-SERVER-IP src-path=pass54321.txt ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
}
/system scheduler add interval=1h name="password" on-event=change-pass
Content of pass54321.txt should look like this:
SoMePasSWorD
Re: password change
Posted: Thu Jul 02, 2015 11:46 am
by charuga
/tool fetch url="
http://xx.xx.xx.xx/pass54321.txt" mode=http ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
fetch work ... just u must change fetch line...
but does not change password
Re: password change
Posted: Thu Jul 02, 2015 2:46 pm
by boen_robot
/tool fetch url="
http://xx.xx.xx.xx/pass54321.txt" mode=http ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
fetch work ... just u must change fetch line...
but does not change password
You should add a delay before reading the file's contents. RouterOS only writes to HDD every 1.5 seconds, while scripts continue to run uninterrupted.
So:
/tool fetch url="http://xx.xx.xx.xx/pass54321.txt" mode=http ;
:delay 2s ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
Posted: Thu Jul 02, 2015 4:42 pm
by jarda
Writing to disc every 1.5s is very essential information. I haven't known that. It may help to solve some of my problems with other scripts. Will need to check it.
Re: password change
Posted: Thu Jul 02, 2015 6:46 pm
by charuga
I changed this delay...
/tool fetch url="
http://xx.xx.xx.xx/pass54321.txt" mode=http ;
:delay 2s ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
but script change the password to an unknown value?
Re: password change
Posted: Thu Jul 02, 2015 6:49 pm
by boen_robot
I changed this delay...
/tool fetch url="
http://xx.xx.xx.xx/pass54321.txt" mode=http ;
:delay 2s ;
:global password [/file get pass54321.txt contents] ;
/user set manager password=$password ;
but script change the password to an unknown value?
The password should be the full contents of the pass54321.txt file, including whitespaces and newlines. Open that file, and make sure there's no new line at the end or something else like that.
Re: password change
Posted: Thu Jul 02, 2015 8:06 pm
by charuga
nope.... empty file with one line 123456789
make file with winscp on linux web server...
make file with programer notepad...
make file with edit + utf8 without boom, ansi, etc .... same thing
change the password to an unknown value...
Re: password change
Posted: Thu Jul 02, 2015 8:08 pm
by boen_robot
Try to use :local instead of :global. When using :global, the value is set to the specified value only if the variable doesn't already exist. Otherwise, it's current value is used.
Re: password change
Posted: Thu Jul 02, 2015 8:26 pm
by charuga
no Sir
same thing... uhm...
Re: password change
Posted: Thu Jul 02, 2015 8:32 pm
by boen_robot
Very odd...
Try to add
and run the script from terminal. See if you get 123456789 as output.
Re: password change
Posted: Thu Jul 02, 2015 10:50 pm
by charuga
nope, will not be executed... with :put $password;
or I 'm wrong somewhere...