#76634 - 2003-09-12 01:58 AM
Change LUser Administrator Password
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
I put together an admin script that, run as a task scheduled script, will scan the network for machines advertised to be on and will reach out over the network and change the passwords. I use Howard's RenameAdmin.exe utility http://home.comcast.net/~habullock/Perlutilities.htm and store the results in an INI file. I also use a config.ini files to store the passwords and an exclude list. The script will change the passwords every month. I also "borrowed" Shawn's phone.kix http://www.kixforms.org/archive/scripts/phone.kix and after a few small mods, it will read in and display the results.ini output.
; Script to reset passwords on remote machines ; by Les Ligetfalvy ;@error + '[' + @SError + ']' ?
break on dim $,$computer,$domain,$comp,$ConfigINI,$ResultsINI,$exclude,$Month,$last,$RenCmdPre,$RenCmdPost,$Pwd,$ShellCMD $ = setoption('explicit','on') $ = setoption('wrapateol','on')
$ConfigINI = @ScriptDir + '\config.ini' $ResultsINI = @ScriptDir + '\results.ini' $Month = @Month $Pwd = ReadProfileString($ConfigINI,'Passwords',$Month) $domain = 'FF' $exclude = split(ReadProfileString($ConfigINI,'Exclude',''),chr(10)) $RenCmdPre = @ScriptDir + '\RenameAdmin.exe --computer ' $RenCmdPost = ' --pwd ' + $Pwd + ' --nolog --quiet'
for each $computer in netview2($domain,1) $comp = split($computer,',')[0] if ascan($exclude,$comp) = -1 $last = ReadProfileString($ResultsINI,$comp,'LastPwdChanged') if @error = 0 and $last <> $Month $ShellCMD = $RenCmdPre + $comp + $RenCmdPost ;shell $ShellCMD if @error = 0 $ = WriteProfileString($ResultsINI,$comp,'LastPwdChanged',$Month) $ = WriteProfileString($ResultsINI,$comp,'LastSeen',@Date) else $ = WriteProfileString($ResultsINI,$comp,'LastError',@Date + ', ' + @Time + ' - ' + @SError) endif else $ = WriteProfileString($ResultsINI,$comp,'LastSeen',@Date) endif endif next ;============================== function NetView2(optional $domain, optional $commentflag) ;http://81.17.37.55/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000202 dim $array[255] dim $redim, $i, $j, $tempfile dim $filehandle, $retcode dim $name, $comment, $line $redim = 255 $i = 0 $j = 0 $tempfile = '%temp%\netview.tmp' if $domain $domain = '/domain:'+trim($domain) endif if vartype($commentflag) $commentflag=val($commentflag) else $commentflag=0 endif if exist($tempfile) del $tempfile endif shell '%comspec% /c net view $domain >"'+$tempfile+'"' if @error = 0 $filehandle=1 do $retcode=open($filehandle,$tempfile) $filehandle=$filehandle+1 until $retcode=0 or $filehandle=11 select case $retcode=-3 exit 4 case $retcode=-2 exit 6 case $retcode=-1 exit 123 case $retcode=0 $filehandle=$filehandle-1 case $retcode>0 exit @ERROR case $filehandle=11 exit 4 endselect for $j = 1 to 5 $line = readline($filehandle) ; skip headings next while @error = 0 $name= trim(substr($line,3,instr($line,' ')-1)) $comment = trim(right($line,len($line)-instr($line,' '))) if $commentflag $array[$i]=$name+','+$comment else $array[$i]=$name endif $i=$i+1 if $i = $redim $redim=$redim*2 redim preserve $array[$redim] endif $line = readline($filehandle) loop $retcode=close($filehandle) del $tempfile if $i redim preserve $array[$i-4] $netview2 = $array exit @error endif endif $netview2 = 0 exit @error endfunction
Then there is the config.ini file:
code:
[Exclude] FFMRTG=1 FFCDTOWER=1 FFPDC=1 FFBDC=1
[Passwords] January=12345678 February=23456789 March=34567890 April=45678901 May=56789012 June=67890123 July=78901234 August=89012345 September=90123456 October=01234567 November=87654321 December=98765432
[ 12. September 2003, 19:53: Message edited by: LLigetfa ]
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 809 anonymous users online.
|
|
|