Module 13: Command Injection
Discovery of Command Injection
Accessing the Command Injection Sandbox
Start the VPN, the VM, and add IP to hosts.
Familiarizing Ourselves with the Sandbox

First command injection payload

Where is Command Injection Most Common?
Vulnerable Code Snippet
About the Chaining of Commands & System Calls
Executing a single command
Chaining our first commands
Chaining with Logical AND (Success)
Chaining with Logical AND (Failure)
Chaining with Logical OR (Failure)
Chaining with Logical OR (Success)
Inline Execution Characters
Chaining with inline execution
Dealing with Common Protections
Typical Input Normalization - Sending Clean Payloads
Starting a Netcat Listener on port 9090
Our Wrapped Payload with No URL Encoding

Our Encoded Payload result
Our Wrapped Payload with URL Encoding (ready to be sent)
The above could have just been sent in Burp Suite's Repeater after URL-encoding the request...
Receiving a root privileged shell
Typical Input Sanitization - Blocklisted Strings Bypass

A Null Statement Injection Bypass can be inserted between any characters of our choosing.
Null Statement Injection into our previous command injection

A short wordlist to work with wfuzz
Fuzzing with our Custom Wordlist
Fuzzing with our Custom Wordlist and a Suppressed Response-Size of 1156 bytes

Encoding our payload with Base64
Our Full and Complete Payload

Blind OS Command Injection Bypass
Attempting to execute the `id`command with blind command injection

Capturing the initial time
Bypassing blind sanitization wtih sleep for execution verification
Extra Mile
Do the lab.
Enumeration and Exploitation
Enumerating Command Injection Capabilities
Common Linux Capability Checks
Command
Used For
wget
File Transfer
curl
File Transfer
fetch
File Transfer
gcc
Compilation
cc
Compilation
nc
Shells, File Transfer, Port Forwarding
socat
Shells, File Transfer, Port Forwarding
ping
Networking, Code Execution Verification
netstat
Networking
ss
Networking
ifconfig
Networking
ip
Networking
hostname
Networking
php
Shells, Code Execution
python
Shells, Code Execution
python3
Shells, Code Execution
perl
Shells, Code Execution
java
Shells, Code Execution
Common Windows Capability Checks
Capability
Used For
Powershell
Code Execution, Enumeration, Movement, Payload Delivery
Visual Basic
Code Execution, Enumeration, Movement, Payload Delivery
tftp
File Transfer
ftp
File Transfer
certutil
File Transfer
Python
Code Execution, Enumeration
.NET
Code Execution, Privilege Escalation, Payload Delivery
ipconfig
Networking
netstat
Networking
hostname
Networking
systeminfo
System Information, Patches, Versioning, Arch, etc.
Custom Linux Capability Wordlist
Fuzzing and checking for capabilities with our Custom Wordlist
Enumerated capabilities
Obtaining a Shell - Netcat
Starting a Netcat listener

Endpoin for our command injection
A root shell with netcat
Obtaining a Shell - Python
Python Reverse Shell
Unfolded Python Payload
Starting a Netcat Listener on port 9090
Full endpoint with payload in the command injection sandbox
Receiving the reverse shell
Obtaining a Shell - Node.js
Chained Node.js Reverse Shell
The Full Command Injection Endpoint
The full URL-encoded command injection endpoint
Starting a Netcat listener on port 9090
Receiving our reverse shell
Obtaining a Shell - PHP
PHP Reverse Shell Examples
The first half of our PHP Payloads
Various PHP Execution Options


Starting a netcat listener on port 9090
Not encoded endpoing (including our payload)
Complete endpoint (including our payload)
Receiving the reverse shell
Obtaining a Shell - Perl
Perl Reverse Shell
Perl Reverse Shell Unfolded
Full URL Encoded Endpoint
Starting a netcat listener on port 9090
Receiving the reverse shell
File Transfer

Placing the nc binary in our Apache2 web root
Starting the Apache2 Service
The full payload (unencoded)
The full payload (encoded)
Starting a netcat listener on port 9090
Receiving the reverse shell
Extra Mile I
Transfer a different payload, permit the payload, and change the file permissions to execute it for a reverse shell.
Writing a Web Shell
Finding our present working directory

Using echo to write out our own webshell
Writing our own webshell



Extra Mile II
Case Study - OpenNetAdmin (ONA)
Accessing OpenNetAdmin
Start the VPN, VM, and add the IP to your hosts file.
Discovery and Assessment







Exploitation




Full POST Data Payload attempting command injection


Last updated