U3 Incident Response Payload |
![]() ![]() |
U3 Incident Response Payload |
Mon, 03 Nov 2008 10:22:46 +0000
Post
#1
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
So this leans more towards the white hat side of things, but I thought I would share the code from my U3 incident response payload I presented at PhreakNIC. It does require 4 third party tools to run:
PSInfo-http://technet.microsoft.com/en-us/sysinternals/bb897550.aspx PSList-http://technet.microsoft.com/en-us/sysinternals/bb896682.aspx PSLoggedon-http://technet.microsoft.com/en-us/sysinternals/bb897545.aspx MD5sums-http://www.pc-tools.net/win32/md5sums/ Everything else is command line fu. It's been a great asset to me when I've had to work with malware analysis or go investigate a machine that's been owned. Hope you enjoy and hit me up if you have questions First the go.vbs to determine where to locate the data; This file should be launched from autorun.inf (Based off Gonz0r's solution): CODE Set objFSO = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Wscript.shell") Set colDrives = objFSO.Drives For Each objDrive in colDrives If objFSO.FileExists(objDrive.DriveLetter & ":\u3ir.dat") Then strPath = objDrive.DriveLetter & ":" objShell.Run ".\u3ir\go.bat " & strPath End If Next Now the batch script: CODE REM Set log file location IF NOT EXIST %1\output ( MD %1\output ) CD u3ir REM enumerate local accounts and currently logged on users net users >> %1\output\localaccts-%computername%.txt psloggedon /accepteula >> %1\output\localaccts-%computername%.txt REM Grab network info, arp tables, open connections, and firewall status ipconfig /all >> %1\output\localnet-%computername%.txt ipconfig /displaydns >> %1\output\localnet-%computername%.txt arp -a >> %1\output\localnet-%computername%.txt netstat -ano >> %1\output\localnet-%computername%.txt route print >> %1\output\localnet-%computername%.txt type %systemroot%\system32\drivers\etc\hosts >> %1\output\localnet-%computername%.txt netsh firewall show state >> %1\output\localnet-%computername%.txt netsh firewall show service >> %1\output\localnet-%computername%.txt net use >> %1\output\localnet-%computername%.txt REM Grab a list of installed software and running processes psinfo /accepteula /h /s >> %1\output\sysinfo-%computername%.txt pslist -t /accepteula >> %1\output\sysinfo-%computername%.txt REM Grab state of all services on the machine sc query state= all >> %1\output\sysinfo-%computername%.txt REM Grab a list of the printers on the machine and properties cscript %systemroot%\system32\prnmngr.vbs -l >> %1\output\sysinfo-%computername%.txt REM Export the registry of the machine REM HKEY_LOCAL_MACHINE reg export HKLM %1\output\hklm-%computername%.reg REM HKEY_CURRENT_USER reg export HKCU %1\output\hkcu-%computername%.reg REM HKEY_CLASSES_ROOT reg export HKCR %1\output\hkcr-%computername%.reg REM HKEY_USERS reg export HKU %1\output\hku-%computername%.reg REM HKEY_CURRENT_CONFIG reg export HKCC %1\output\hkcc-%computername%.reg REM calculate MD5 hashes of the system directory md5sums %systemroot% >> %1\output\osmd5-%computername%.txt md5sums %systemroot%\system >> %1\output\osmd5-%computername%.txt md5sums %systemroot%\system32 >> %1\output\osmd5-%computername%.txt So what does all this wonderful code gather you from your target machine?
Hope this helps somebody out. Again hit me up if you have any questions. |
|
|
|
Mon, 03 Nov 2008 11:25:52 +0000
Post
#2
|
|
|
Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 166 Joined: Tue, 16 Sep 2008 22:27:22 +0000 Member No.: 10,714 |
how long does it take to run?
|
|
|
|
Mon, 03 Nov 2008 18:03:02 +0000
Post
#3
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 96 Joined: Sun, 21 Oct 2007 02:09:07 +0000 Member No.: 8,443 |
Jesus, now from a recent refresh I did for a client.. the only thing your missing is a list of installed printers and properties for them LOL
-------------------- ![]() |
|
|
|
Mon, 03 Nov 2008 22:47:01 +0000
Post
#4
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
Actually it runs really fast. On a 1st generation P4 with 512 MB of RAM it takes around 3 minutes. On a modern Athlon with 1 GB of RAM it took a little over a minute. The slowest parts are the registry export and the MD5 calculations. I think to be able to gather that much evidence in an incident, that's not too shabby, particularly considering your can write all your data to your device. Pretty nice little portable investigative tool I think.
|
|
|
|
Mon, 03 Nov 2008 23:26:07 +0000
Post
#5
|
|
![]() Hak.5 Uber fan +++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,291 Joined: Tue, 11 Mar 2008 18:11:30 +0000 From: Tennessee Member No.: 9,434 |
I concur. But this could also be used for less than legal purposes. I wouldnt need the md5 hash's though.
-------------------- |
|
|
|
Tue, 04 Nov 2008 08:33:35 +0000
Post
#6
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
I concur. But this could also be used for less than legal purposes. I wouldnt need the md5 hash's though. I agree 100%, but really that could be said of any information gathering tool. As far as not needing one piece of information or the other, that's what I like the use of batch files in this. You can just knock the lines out on the fly and rebuild your ISO image. |
|
|
|
Tue, 04 Nov 2008 12:58:11 +0000
Post
#7
|
|
![]() Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 132 Joined: Sat, 04 Oct 2008 14:12:32 +0000 From: Spain Member No.: 11,070 |
Good job Tcstool! I think it would be great to add this at the wiki... You're not responsible if the final user is using it in a white hat way or not, but I found it useful.
As HarshReality said a list of installed printers and properties from them will be very useful too. -------------------- How much can you see when you see most than 2? UC3 (only for your eyes)
|
|
|
|
Tue, 04 Nov 2008 13:41:36 +0000
Post
#8
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
Ask and you shall receive! I have added under the local machine status section a command to enumerate the printers on the machine, their ports, and certain other properties. Thanks for the suggestions!
|
|
|
|
Tue, 04 Nov 2008 14:34:15 +0000
Post
#9
|
|
![]() Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 132 Joined: Sat, 04 Oct 2008 14:12:32 +0000 From: Spain Member No.: 11,070 |
A fast work implementing the idea from HarshReality and a good work it all. Now we can add this to our payloads (yeepeyaaaaa!!!!)
So... look, you're pinned!:lol: -------------------- How much can you see when you see most than 2? UC3 (only for your eyes)
|
|
|
|
Tue, 04 Nov 2008 14:39:41 +0000
Post
#10
|
|
|
Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 166 Joined: Tue, 16 Sep 2008 22:27:22 +0000 Member No.: 10,714 |
btw, can anyon eprovide a t on how to put tis into our payload?
|
|
|
|
Tue, 04 Nov 2008 15:17:01 +0000
Post
#11
|
|
![]() Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 132 Joined: Sat, 04 Oct 2008 14:12:32 +0000 From: Spain Member No.: 11,070 |
btw, can anyon eprovide a t on how to put tis into our payload? This can be easyly implemented into everyone's payload but if the idea is doing it into the Leapo's Pocket Knife it will be very easy, of course. Maybe Leapo will do it or if he wants, I'll write (with Tcstool permission The only you have to do is to add the apps to the SYSTEM folder and modify the CODE >> %1\output\... to the Leapo's output log file.But in this stuff I think that there is some things as MD5SUM or exporting the entire Registry in Leapo's will not be very useful (not as in other payloads oriented to security audits) Leapo: What about it? -------------------- How much can you see when you see most than 2? UC3 (only for your eyes)
|
|
|
|
Tue, 04 Nov 2008 16:05:33 +0000
Post
#12
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
This can be easyly implemented into everyone's payload but if the idea is doing it into the Leapo's Pocket Knife it will be very easy, of course. Maybe Leapo will do it or if he wants, I'll write (with Tcstool permission The only you have to do is to add the apps to the SYSTEM folder and modify the CODE >> %1\output\... to the Leapo's output log file.But in this stuff I think that there is some things as MD5SUM or exporting the entire Registry in Leapo's will not be very useful (not as in other payloads oriented to security audits) Leapo: What about it? Permission granted! I would love to see this idea evolve. Since Microsoft has made COFEE only available to law enforcement, I think having a portable, self-contained audit and incident response tool like this could grow into a really nice open source project. |
|
|
|
Tue, 04 Nov 2008 16:32:05 +0000
Post
#13
|
|
![]() Rock Star ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 212 Joined: Sat, 24 Mar 2007 02:07:35 +0000 From: Virginia Beach, VA Member No.: 7,113 |
I'd like to take this and turn it into a segment if I have your permission.
Really awesome work man! -------------------- http://www.securabit.com
"Re:Any legit use for 3127? (Score:5, Funny) by nmoog (701216) on Monday February 09, @09:45PM (#8234397) Yeah, port 3127 is used for DoS attacks on Microsoft. Its best to leave it open. |
|
|
|
Tue, 04 Nov 2008 16:46:19 +0000
Post
#14
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
I'd like to take this and turn it into a segment if I have your permission. Really awesome work man! Sure man, Darren and I did a quick interview about it at PhreakNIC since this is what my presentation was about, but I really just hit the high points during that interview and didn't get into the nuts and bolts of it. You are more than welcome to dig into the technical side of it and do a presentation about it. |
|
|
|
Tue, 04 Nov 2008 19:52:47 +0000
Post
#15
|
|
|
Hak.5 Zombie ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 166 Joined: Tue, 16 Sep 2008 22:27:22 +0000 Member No.: 10,714 |
So tut plox?
|
|
|
|
Wed, 05 Nov 2008 20:45:49 +0000
Post
#16
|
|
|
Newbie Group: Members Posts: 1 Joined: Wed, 05 Nov 2008 20:38:41 +0000 Member No.: 11,545 |
Instead of having the vbs script, you can use %~d0 to find out what drive the batch file is being run from. That would work in anything from Windows 2000 forward I believe. That way you would just have one file instead of two.
|
|
|
|
Wed, 05 Nov 2008 21:55:57 +0000
Post
#17
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
Instead of having the vbs script, you can use %~d0 to find out what drive the batch file is being run from. That would work in anything from Windows 2000 forward I believe. That way you would just have one file instead of two. That's true, but the VBScript is not for finidng out which drive the batch file is executing from. You're locating the writeable partition of your U3 drive, so you still need the VB script to loop through your drives and find the u3ir.dat file. |
|
|
|
Thu, 06 Nov 2008 08:24:28 +0000
Post
#18
|
|
![]() Hak.5 Uber fan +++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,291 Joined: Tue, 11 Mar 2008 18:11:30 +0000 From: Tennessee Member No.: 9,434 |
what is the difference between:
REM HKEY_LOCAL_MACHINE reg export HKLM %1\output\hklm-%computername%.reg and regedit /e export.txt -------------------- |
|
|
|
Thu, 06 Nov 2008 10:28:41 +0000
Post
#19
|
|
![]() Hak.5 Uber fan +++ ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 1,291 Joined: Tue, 11 Mar 2008 18:11:30 +0000 From: Tennessee Member No.: 9,434 |
I was looking at some other things that could be thrown in, just because... I am no bat expert so please dont point out all the flaws.
gpresult >> "%computername%_ID.txt" driverquery >> "%computername%_ID.txt" getmac >> %computername%\%computername%_NetInfo.txt netsh show mode >> %computername%\mode.txt netsh show alais >> %computername%\mode.txt netsh show helper >> %computername%\mode.txt mkdir %computername% cd %computername%\ mkdir ect XCOPY "C:\WINDOWS\system32\drivers\etc" "C:\Documents and Settings\Administrator\Desktop\WINDOWS-38QGJLY\ect" cd .. tasklist >> %computername%\%computername%_FireWall.txt -------------------- |
|
|
|
Thu, 06 Nov 2008 14:12:55 +0000
Post
#20
|
|
![]() Hak.5 Fan ++ ![]() ![]() ![]() ![]() Group: Members Posts: 80 Joined: Sun, 26 Oct 2008 13:29:51 +0000 From: Cookeville, TN Member No.: 11,394 |
what is the difference between: REM HKEY_LOCAL_MACHINE reg export HKLM %1\output\hklm-%computername%.reg and regedit /e export.txt I was looking at some other things that could be thrown in, just because... I am no bat expert so please dont point out all the flaws. gpresult >> "%computername%_ID.txt" driverquery >> "%computername%_ID.txt" getmac >> %computername%\%computername%_NetInfo.txt netsh show mode >> %computername%\mode.txt netsh show alais >> %computername%\mode.txt netsh show helper >> %computername%\mode.txt mkdir %computername% cd %computername%\ mkdir ect XCOPY "C:\WINDOWS\system32\drivers\etc" "C:\Documents and Settings\Administrator\Desktop\WINDOWS-38QGJLY\ect" cd .. tasklist >> %computername%\%computername%_FireWall.txt Good stuff. So let's start from the top (and these are only my opinions and I think worth discussing alternate approaches such as this):
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: Sat, 21 Nov 2009 00:04:59 +0000 |