#92643 - 2003-08-21 11:59 AM
Re: WMI?? Howto Remotely get @ProductType and @SysLang
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
Why I needed this...
;**************************************************************************** ; ;SCRIPT/FUNCTION : RPC.kix ; ;ACTION : Remotely installs the Q823980 - Blaster patch ; ;AUTHOR : Patrick Rutten (MightyR1@hotmail.com) ; ;CONTRIBUTORS : Paul Giebelen ; KHolm ; ;SCRIPT VERSION : ; 1.0.0.0 - 2003-08-21 ; History ; ;SYNTAX : - ; ;PARAMETERS : - ; ;RETURNS : - ; ;REMARKS : - ; ;DEPENDENCIES : RenameAdmin.exe (ra.exe) ; http://mywebpages.comcast.net/habullock/ ; PsExec.exe ; http://www.sysinternals.com ; KB823980Scan.exe ; http://www.microsoft.com ; ;EXAMPLE(S) : ; ;KNOWN ISSUES : ; ;KIXTART VERSION : ; ;KIXTART BBS : ; ;**************************************************************************** ; ;
;Enable Break to allow killing the script without logoff Break on
;Set some global options $rc=SetOption('NoVarsInStrings','ON') $rc=SetOption('HideCursor','ON') $rc=SetOption('Explicit','ON')
;Declare variables Dim $BlasterScan,$Results,$line Global $Notpatched
;assign Variables $Notpatched=@SCRIPTDIR+'\Notpatched.txt' $BlasterScan=@SCRIPTDIR+'\KB823980Scan.exe' $Results=@SCRIPTDIR+'\Vulnerable.txt' Del $NotPatched
;Scan network for Blaster vulnerabilities usin M$ tool Shell '%comspec% /c '+$BlasterScan+' /o:'+$Results+' start_scan_address-stop_scan_address' ? ? ?
;If vulnerabilities were found, read the results file containing IP addresses and apply patch If NOT Open(1,$results) $line=ReadLine(1) While $line $rc=UpdateRPC($line) $line=ReadLine(1) Loop $rc=Close(1) EndIf
;Exit the script Exit 0
;**************************************************************************** ; ;ADDITIONAL FUNCTIONS ; ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Function UpdateRPC($pc)
;Declare variables Dim $RPCver,$os,$lng,$user,$pw,$patchname,$patchsrc,$patchdst Dim $ra,$psexec,$notepadver,$notepadlng,$info
;Assign variables $ra=@SCRIPTDIR+'\ra.exe' $psexec=@SCRIPTDIR+'\psexec.exe' ;Get OS information $info=OS_Info($pc) ;Determine if OS is W2k and Dutch $os=InStr($info,'Windows 2000') $lng=InStr($info,'1043') $pc='\\'+$pc ;If C$ can be connected If Exist($pc+'\C$') $RPCver=GetFileVersion($pc+'\admin$\system32\Rpcrt4.dll','Productversion')
;If W2k and dutch and wrong RPC version copy files to workstation and apply patch If $os AND $lng AND $RPCver <> '5.00.2195.6753' $user='Administrator' $pw='adminpassword' ; If NOT Exist($pc+'\c$\patches') ;Change local administrator password using Howard Bullock's executable Shell '%comspec% /c '+$ra+' '+$pc+' '+$user+' '+$pw+' > nul' ;Make a c$\patches folder MD $pc+'\c$\patches' ; EndIf
;Copy the patch $patchname='Q823980-W2k-NLD.exe' $patchsrc='\\midict01\rm$\security\Q823980\'+$patchname $patchdst=$pc+'\c$\patches\'+$patchname Copy $patchsrc $patchdst ? ?
;Remotely execute the patch using psExec Shell '%comspec% /c '+$psexec+' '+$pc+' -u '+$user+' -p '+$pw+' -d '+$patchdst+' /q /u /z' ? $pc+Chr(9)+' Blaster patch was executed...' ;No w2k/dutch Else ? ? $pc+Chr(9)+' is not a valid machine. Take actions manually!!!' $rc=WriteProfileString($Notpatched,'Invalid',$pc,'is not a valid machine. Take actions manually!!!') EndIf ;C$ not accessible Else ? ? $pc+Chr(9)+' Has no C$ or is not accessible...' $rc=WriteProfileString($Notpatched,'Not Patched',$pc,'Has no C$ or is not accessible...') EndIf EndFunction
;Function got from KHOLM Function OS_Info($Computer) Dim $oWMIService,$ItemS,$Item $oWMIService = GetObject("winmgmts:\\" + $Computer + "\root\cimv2") $ItemS = $oWMIService.ExecQuery("Select * from Win32_OperatingSystem where Primary=True") For Each $Item In $ItemS $OS_Info = $Item.Caption $OS_Info = $OS_Info + ',' + $Item.OSLanguage Next EndFunction
_________________________
Greetz, Patrick Rutten
- We'll either find a way or make one... - Knowledge is power; knowing how to find it is more powerful... - Problems don't exist; they are challenges...
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 2630 anonymous users online.
|
|
|