Page 1 of 1 1
Topic Options
#76367 - 2003-08-14 08:52 PM Another W32LoveSAN patch script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
First Posted: Thursday, August 14
This is sort of a follow-up to these posts
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=004498
http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007670

The following script was written to attempt to address some of the
workstations that have eluded either LOGON/GPO/SMS attempts at installing
the KB823980 patch. This list is derived by scanning your network for vulnerable systems.

Tool to scan for vulnerable systems
http://www.eeye.com/html/Research/Tools/RPCDCOM.html
Free tool, but registration required

What the script does is takes an array of KNOWN workstation local Administrator account
passwords and attempts to establish an Administrative connection.
If successful it will then add the specified Domain Groups to the local administrators
group on the remote system. (you must add an account that you belong to)
Then it copies the patch to the local system. Then it runs
a WMI connecton to execute the patch and FORCE REBOOTS the system.
WARNING!! Any data or applications that are open and in an unsaved state
will lose data or changes as the /F switch in the batch file will force a reboot.

This is an ADMINISTRATIVE script and as such should be run from your own
local 2000/XP Workstation. You could also add the RedirectOutput function to log
the results. Normally this is run from a DOS box so that you can watch the results
at least for initial testing. Once you feel it is working as expected you can then
use the RedirectOutput function and log all of it.

EXAMPLE
C:\SCRIPT\KIX32.EXE DEPLOYPATCH.KIX

Special thanks to Radimus, Chris, and Howard for there help with this script.

Requires:
1. Win32Admin DLL by Howard Bullock
http://mywebpages.comcast.net/habullock/kix_solutions.htm
http://mywebpages.comcast.net/habullock/Library/Win32Admin.dll.txt
2. KiXtart v4.21 (many download locations)
3. Windows 2000/XP Workstation to run script from
4. Remote Administrative account or list of KNOWN passwords for your own workstations
If you don't know or have a list of KNOWN passwords to use then this script will
not be useful to you

5. WMI must be functional on remote system

This script has been tested on 2000/XP systems, it has not been tested yet on NT 4
This script is not opotimized, but should perform reasonably well if all of the
required criteria are met.

Known possible improvements:
1. Modify section where groups are added to use the Win32Admin method to determine the
remote Workstations real name for the Administrator account in case it has been renamed
2. Add an array or redline method to process multiple computers
3. More sophisticated logging method or data
4. I'm sure there are other possible improvements I have not listed






Break On
$nul=SetOption("WrapAtEOL","On")
$nul=SetOption("Explicit","On")
DIM $wksta,$Pass,$Index,$OSV,$OS,$KBFile,$KBpath,$KBBatPath,$KBBatFile
DIM $Win32Admin,$AdminAccount,$CheckAdmin,$grouptoadd1,$grouptoadd2,$group

$wksta = 'computer to run against'
$Pass = 'pass1','pass2','pass3','pass4' ; etc... array of known passwords
$Win32Admin = createobject("Win32Admin")
$AdminAccount = $Win32Admin.GetAdminAccount("$wksta");
$CheckAdmin = RemoteAdmin($wksta)
$KBBatPath='\\SERVER\SHARE\KB823980.bat'
; Contents of batch is:
; KB823980.exe /q /f
$KBBatFile='KB823980.bat'
SELECT
CASE $CheckAdmin
? 'You have admin rights on '+$wksta
$OSV = OSVer($wksta)
SELECT
CASE $OSV = '4.0'
$KBpath='\\SERVER\SHARE\Q823980i.EXE'
$KBFile='Q823980i.EXE'
CASE $OSV = '5.0'
$KBpath='\\SERVER\SHARE\Windows2000-KB823980-x86-ENU.exe'
$KBFile='Windows2000-KB823980-x86-ENU.exe'
CASE $OSV = '5.1'
$KBpath='\\SERVER\SHARE\WindowsXP-KB823980-x86-ENU.exe'
$KBFile='WindowsXP-KB823980-x86-ENU.exe'
CASE 1
EXIT @ERROR
ENDSELECT
USE P: '\\'+$wksta+'\Admin$$'
COPY $KBpath 'P:\SYSTEM32\KB823980.exe'
COPY $KBBatPath 'P:\SYSTEM32'
$grouptoadd1="Domain Admins"
$grouptoadd2="Desktop Support"
$group = getobject("WinNT://$wksta/administrators")
$group.add("WinNT://Domain/$grouptoadd1")
? 'Adding group '+$grouptoadd1+ 'error was: '+@error+' : '+@serror
$group.add("WinNT://Domain/$grouptoadd2")
? 'Adding group '+$grouptoadd2+ 'error was: '+@error+' : '+@serror
$group=0
RemoteExec($KBBatFile,$wksta)
? 'Remote Execute error was: '+@error+' : '+@serror
USE 'P:' /DEL
CASE NOT $CheckAdmin
Do
USE P: '\\'+$wksta+'\Admin$$' /user:$wksta+'\'+$AdminAccount /password:$Pass[$Index]
? 'Mapping with password "'+$Pass[$Index]+'" was: '+@ERROR+' - '+@SERROR
$Index = $Index + 1
Until @ERROR = 0 or $Index = Ubound($Pass)+1
IF @ERROR = 0
? 'You successfully mapped the Admin$ share as an admin - with password "'+$Pass[$Index-1]+'"'
$OSV = OSVer($wksta)
SELECT
CASE $OSV = '4.0'
$KBpath='\\SERVER\SHARE\Q823980i.EXE'
$KBFile='Q823980i.EXE'
CASE $OSV = '5.0'
$KBpath='\\SERVER\SHARE\Windows2000-KB823980-x86-ENU.exe'
$KBFile='Windows2000-KB823980-x86-ENU.exe'
CASE $OSV = '5.1'
$KBpath='\\SERVER\SHARE\WindowsXP-KB823980-x86-ENU.exe'
$KBFile='WindowsXP-KB823980-x86-ENU.exe'
CASE 1
EXIT @ERROR
ENDSELECT
COPY $KBpath 'P:\SYSTEM32\KB823980.exe'
COPY $KBBatPath 'P:\SYSTEM32'
$grouptoadd1="Domain Admins"
$grouptoadd2="Desktop Support"
$group = getobject("WinNT://$wksta/administrators")
$group.add("WinNT://Domain/$grouptoadd1")
? 'Adding group '+$grouptoadd1+ 'error was: '+@error+' : '+@serror
$group.add("WinNT://Domain/$grouptoadd2")
? 'Adding group '+$grouptoadd2+ 'error was: '+@error+' : '+@serror
$group=0
RemoteExec($KBBatFile,$wksta)
? 'Remote Execute error was: '+@error+' : '+@serror
USE 'P:' /DEL
Else
? 'Tried all known passwords - Unable to map as an Administrator'
EndIf
CASE 1
ENDSELECT
$Win32Admin = 0
EXIT @ERROR

Function RemoteAdmin($wksta)
dim $dir,$err
$dir=dir('\\'+$wksta+'\admin$$')
$err=@error
$RemoteAdmin=iif(not $err,1,0)
exit $err
endfunction

Function OSVer(Optional $wksta)
If $wksta = ""
$OSVer = @DOS
Exit @ERROR
Else
If Left($wksta,2) <> "\\" $wksta = "\\" + $wksta EndIf
If Right($wksta,1) <> "\" $wksta = $wksta + "\" EndIf
$OSVer = ReadValue($wksta + "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion")
Exit @ERROR
EndIf
EndFunction

FUNCTION RemoteExec($command, optional $computer)
dim $Connect, $Process
if not $computer $computer='.' endif
if instr($computer,'\')
$computer=substr($computer,instrrev($computer,'\')+1)
endif
$Connect = GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$computer+'/root/cimv2:Win32_Process')
$Process = $Connect.Create($Command)
? 'Processed the remote command '+@error+' : '+@serror
exit @error
ENDFUNCTION



[ 03. September 2003, 19:57: Message edited by: NTDOC ]

Top
#76368 - 2003-08-14 08:55 PM Re: Another W32LoveSAN patch script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
FoundStone at http://www.foundstone.com/index.htm?subnav=resources/navigation. htm&subcontent=/resources/proddesc/rpcscan.htm has a free tool, too, however, no registration is required.

[ 14. August 2003, 20:55: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#76369 - 2003-08-14 09:35 PM Re: Another W32LoveSAN patch script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Yes, true they do. However it falsely labels NT 4 systems as being vulnerable when in fact they are not. Since you get no other data back from this scan you don't know the OS version and may have a lot of false reports.

The 2000/XP scans seem to be accurate though so if you only have 2000/XP systems then it may be a better tool. It is faster and does allow larger network scans.

Top
#76370 - 2003-08-14 11:39 PM Re: Another W32LoveSAN patch script
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
? WMIQuery('Description','Win32_QuickFixEngineering',$computer,'HotFixID','KB823980')

[ 14. August 2003, 23:39: Message edited by: Radimus ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#76371 - 2003-08-15 12:48 AM Re: Another W32LoveSAN patch script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
I'll trust you that it works Rad.. however you can't perform a WMI query against systems that you don't have Admin rights on, and WMI for 1,000s of machines is WAY SLOW
Top
#76372 - 2003-08-15 04:58 PM Re: Another W32LoveSAN patch script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
New command-line scanning tool from Microsoft

A little late, but I guess better late then never.

MS03-026 Scanning Tool - Download page
http://www.microsoft.com/downloads/details.aspx?FamilyID=c8f04c6c-b71b-4992-91f1-aaa785e709da&DisplayLang=en

Information for your Home Users
http://www.microsoft.com/security/incident/blast.asp

How to Use the KB 823980 Scanning Tool to Identify Host Computers That Do Not Have the 823980 Security Patch (MS03-026) Installed
http://support.microsoft.com/?kbid=826369&reason=0

Top
#76373 - 2003-08-15 05:00 PM Re: Another W32LoveSAN patch script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Drawback: Windows NT (neither Workstation nor Server) is not being supported by this tool.

[ 15. August 2003, 17:01: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#76374 - 2003-08-15 05:07 PM Re: Another W32LoveSAN patch script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
doh, didn't I hear someone saying that NT is not even infected.
_________________________
!

download KiXnet

Top
#76375 - 2003-08-15 05:10 PM Re: Another W32LoveSAN patch script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
A supported patch is available for Windows NT Server, thus one should expect that the scanner will also check Windows NT Server.
_________________________
There are two types of vessels, submarines and targets.

Top
#76376 - 2003-08-17 02:05 PM Re: Another W32LoveSAN patch script
gwgaston Offline
Fresh Scripter

Registered: 2002-02-06
Posts: 13
Another thing to note with the Microsoft tool is that it will (like the eEye tool prior to v1.04) report Win9x with DCOM 1.3 installed as vulnerable.

-Gerald

Top
#76377 - 2003-08-17 02:25 PM Re: Another W32LoveSAN patch script
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
quote:

doh, didn't I hear someone saying that NT is not even infected.

Then they are wrong. Check this M$ quote. Full story available here.

quote:

Who Is Vulnerable?
Users of the following products could be affected by this worm:

Microsoft® Windows NT® 4.0
Microsoft Windows® 2000
Microsoft Windows XP
Microsoft Windows Server™ 2003



[ 17. August 2003, 14:26: Message edited by: R2D2 ]
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#76378 - 2003-08-18 03:30 AM Re: Another W32LoveSAN patch script
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Actually, both statements are true. Windows NT doe shave the vulnerability, but the initial worm is designed to only infect Windows 2000/XP/2003.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.064 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org