📕 FIELD MANUAL 5.2: SQL INJECTION POLYGLOTS (THE UNIVERSAL BULLET)
Objective: We will use a single complex payload capable of exploiting SQL injections in multiple syntactic contexts simultaneously.
Classification: RED TEAM EYES ONLY
Objective: We will use a single complex payload capable of exploiting SQL injections in multiple syntactic contexts simultaneously.
Targets: Mass audits, initial scans (Fuzzing).
MITRE ATT&CK: T1190.
1. INTEL & RECON: THE THEORY OF CONTROLLED CHAOS
Sección titulada «1. INTEL & RECON: LA TEORÍA DEL CAOS CONTROLADO»The Problem of Contexts
Sección titulada «El Problema de los Contextos»When we attack a parameter (id=...), we do not know what the backend query looks like:
- Integer:
WHERE id = $id - String (Single Quote):
WHERE id = '$id' - String (Double Quote):
WHERE id = "$id" - Parentheses:
WHERE id = ('$id')
If we send 1' OR 1=1, we will fail if the backend uses double quotes or pure integers (sometimes). We need something that breaks all at once.
The Anatomy of a Polyglot
Sección titulada «La Anatomía de un Polyglot»A Polyglot abuses the way SQL handles comments (/* ... */, --, #) to “consume” the syntax that bothers us and leave the payload active.
2. WEAPONIZATION: BUILDING FRANKENSTEIN
Sección titulada «2. WEAPONIZATION: CONSTRUYENDO A FRANKENSTEIN»We are going to dissect the most famous polyglot from the Seclists repository.
The Payload (The Beast)
Sección titulada «El Payload (The Beast)»SLEEP(5) /*' or SLEEP(5) or '" or SLEEP(5) or "*/(Note: This is a simplified example for Time-Based. We will move on to a more generic authentication one).
Universal Auth Bypass Payload
Sección titulada «Payload Universal de Auth Bypass»admin'/*"*/ or 1=1 -- -Behavioral Analysis:
Scenario A: Backend with Single Quotes
Sección titulada «Escenario A: Backend con Comillas Simples»Query: SELECT * FROM users WHERE user = '$input'
Injection: SELECT * FROM users WHERE user = 'admin'/*"*/ or 1=1 -- -'
- Explanation:
'admin'closes the string./*"*/is a block comment. The SQL engine ignores it completely.or 1=1executes. SUCCESS!
Scenario B: Backend with Double Quotes
Sección titulada «Escenario B: Backend con Comillas Dobles»Query: SELECT * FROM users WHERE user = "$input"
Injection: SELECT * FROM users WHERE user = "admin'/*"*/ or 1=1 -- -"
- Explanation:
"admin'/*": Here the single quote is just text inside the double quotes. BUT, the double quote within the comment/*"*/CLOSES the original string./closes the comment (or generates ignored noise).or 1=1is executed. SUCCESS! (Depending on the engine, it sometimes requires fine-tuning, but the idea is to saturate the delimiters).
The Ultimate Polyglot (XSS + SQLi + LFI)
Sección titulada «El Polyglot Definitivo (XSS + SQLi + LFI)»Sometimes we want to test EVERYTHING at once.
javascript://%250Aalert(1)//"/*\'/*"/*--/*#*/OR 1=1 OR "a"="aThis monster attempts to execute JavaScript (if reflected), break SQL (single quotes, double quotes, hash comments, and dashes) all in one.
3. AUTOMATION: BURP INTRUDER SNIPER
Sección titulada «3. AUTOMATION: BURP INTRUDER SNIPER»The Polyglot is ideal for a fast Discovery phase.
- Load: We will load Burp Intruder.
- Positions: We will mark all input parameters.
- Payloads: We will load a small list of Polyglots (3 or 4 strings).
' OR 1=1 -- -" OR 1=1 -- -admin'/*"*/ or 1=1 -- -
- Attack: We will launch the attack. If ANY work, we will see a change in response length or a delay (if we use
SLEEP). - Advantage: Instead of sending 500 payloads per parameter, we will send 3. If we have 100 parameters, we will save thousands of requests.
4. ESCALATION: FROM POLYGLOT TO DEDICATED EXPLOIT
Sección titulada «4. ESCALADA: DE POLYGLOT A EXPLOIT DEDICADO»The Polyglot is a "Mine detector".
- We will launch the Polyglot.
- If it exploits (error, delay, bypass), we WILL STOP using the Polyglot.
- We will switch to a specific payload (Module 1.1 or 3.1) for that specific context.
- Why? Because Polyglots are messy and can corrupt data if we try to use them to extract information (
UNION SELECT). We will only use them to enter or detect.
- Why? Because Polyglots are messy and can corrupt data if we try to use them to extract information (
5. PURPLE TEAM VIEW (DEFENSE)
Sección titulada «5. VISIÓN DEL EQUIPO PURPLE (DEFENSA)»🕵️ Detection (Static Signatures)
Sección titulada «🕵️ Detección (Firmas Estáticas)»Polyglots are the easiest attacks for a WAF to detect due to their "ugliness".
- High Entropy: Strings with many special characters together (
'/*"*/). - WAF Signatures: Rules like
Detect mixed quotes inside commentswill trigger immediately. - Length: They tend to be long and strange payloads.
🛡️ Mitigation
Sección titulada «🛡️ Mitigación»- Input Sanitization: We will reject inputs containing SQL comment sequences (
-,/*,#) if the field is a username or email. - Prepared Statements: As always, parameterization causes the Polyglot to be treated as a simple garbage text string
admin'/*"*/...that does not match any real user.
Status: Module 5.2 Completed. End of Phase 5. Next Step: Phase 6 - Specific Technologies (SQLite and CMS).

