Shell Cheatsheet
Reverse Shell
Socat
Listener:
Victim:
Shell
When -c
works:
With /dev/tcp
Using FIFO (Doesn't work with upgrading?)
Using telnet
(When no nc
and no /dev/tcp
available). Listen with nc -n -vv -l -p 2222
Python
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-256color
Switch to background with CTRL+Z
Configure local shell:
stty raw -echo
Execute
fg
In 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