Community discussions

MikroTik App
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

password change

Thu Jul 02, 2015 10:44 am

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
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

Re: password change

Thu Jul 02, 2015 11:46 am

/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
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: password change

Thu Jul 02, 2015 2:46 pm

/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 ;
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Thu Jul 02, 2015 4:42 pm

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.
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

Re: password change

Thu Jul 02, 2015 6:46 pm

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?
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: password change

Thu Jul 02, 2015 6:49 pm

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.
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

Re: password change

Thu Jul 02, 2015 8:06 pm

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...
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: password change

Thu Jul 02, 2015 8:08 pm

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.
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

Re: password change

Thu Jul 02, 2015 8:26 pm

no Sir

same thing... uhm...
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: password change

Thu Jul 02, 2015 8:32 pm

Very odd...

Try to add
:put $password;
and run the script from terminal. See if you get 123456789 as output.
 
charuga
just joined
Topic Author
Posts: 17
Joined: Sun May 28, 2006 11:11 pm

Re: password change

Thu Jul 02, 2015 10:50 pm

nope, will not be executed... with :put $password;

or I 'm wrong somewhere...