Other Pages

Before exploitating

Always check for already existing exploits. Even if the application seems to be custom made.

Check for unnecessary enters and spaces during payload creations. Use repeater with this button pressed:

Cross Site Scripting

The most frequently used character to test for XSS injection:

HTML

JavaScript

Default payload

Img payload

Attacker side

Payload encoding

Compress the JavaScript code with JSCompress.

https://jscompress.com

Convert it into CharCode using the following JavaScript code:

Execute the encoded payload:

Command Injection

Do not forget to use urlencoding

Reflected

Blind

Blind (ping rce listener)

Kali:

Victim:

BLIND OAST

Blind redirecting the input

Command seperators

More command seperators

Inline Command Execution (Linux)

Check if command is executed via cmd or powershell

Vulnerable Software Exploits

SQL Injection

Types of SQL Injection

Exploiting SQL Injection

Fuzz String

Most of the time SQL Injections differ from the regular ones. Do not paste payloads thoughtlessly - match them to your specific case.

STACKED QUERIES


UNION Keyword

  • It has to contain same amount of columns as the original query.

  • The data types need to be compatible between each column.

  • You can try to cast string as int e.g. in PostgreSQL

Determine number of columns with order by (increase the number until it fails):

Sample final query:

If application does not return the output from given command it can me data type mismatch try to change the place of executed command.

Dumping other tables example


IN KEYWORD

Useful SQL commands

Manual Code Execution

Common locations: ('/var/www/, /var/www/html, /var/www/htdocs, /usr/local/apache2/htdocs, /usr/local/www/data, /var/apache2/htdocs, /var/www/nginx-default, /srv/www/htdocs, /usr/local/var/www')

INTO OUTFILE

In some cases you can spawn the webshell using SQL Injection.

MSSQL Hash grabing

Client:

Server:

MSSQL dir listing

File upload

Webshells

File upload bypass

Null Bytes

Path Traversal

You can also use path traversal to in file upload funcionality to send ssh key.

It be also found in filename while uploading the file. Url encoding is worth trying. Path traversal is not File Inclusion - it can only read contents of the files.

We can use this to read local files.

Default payloads

Linux

Windows

Encoded payloads

Dot url encoding

Url encoding

Bypass

PoC files

Sometimes choosing a disc does not work on Windows - try also without c:/

Exploitation files

Private SSH keys in user's home folder (you can enumerate the users by reading the /etc/passwd file)

IIS Server log files

IIS Server config files

File Inclusion

Searching for vulnerability is the same as for Path Traversal

Application include given file (local or remote) in the application running code.

We can use this to execute local or remote files.

Search for this vulnerability in parameters which refers to the another file in the system.

Local File Inclusion

The sever loads a local file.

In order to achieve code execution try to include this line of code in some file on the system:

Then include the file with the following parameter (or just urlencode reverse shell):

Remote File Inclusion

The file is loaded from a remote server (Best: You can write the code and the server will execute it). In php this is disabled by default (allow_url_include).

PHP Wrappers

Instead of executing the files you can read and review its contents using php wrappers.

Read sensitive information (hardcoded credentials, secrets) and understand application logic.

Achieve code execution.

WAF / Security Mechanisms bypass (allow_url_include setting needs to be enabled).

Template Injection

Default Payloads

Common

Common

Spring

.NET

For more information visit https://book.hacktricks.xyz/pentesting-web/ssti-server-side-template-injection

Fuzz String

Flask Jinja2

Filter bypass (newlines in urlencoding)

NTLM Relay

You can inject path to your smb server in order to capture hashes:

Last updated