Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 386e98a

Browse files
committed
using UNION SELECT for where=..NEGATIVE
1 parent c9d570c commit 386e98a

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

lib/controller/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __formatInjection(inj):
132132
if stype == PAYLOAD.TECHNIQUE.UNION:
133133
count = re.sub(r"\(.+\)", "", sdata.payload).count(",") + 1
134134
title = re.sub(r"\d+ to \d+", str(count), title)
135-
vector = agent.forgeInbandQuery("[QUERY]", vector[0], vector[1], vector[2], None, None, vector[5])
135+
vector = agent.forgeInbandQuery("[QUERY]", vector[0], vector[1], vector[2], None, None, vector[5], vector[6])
136136
if count == 1:
137137
title = title.replace("columns", "column")
138138
data += " Type: %s\n" % PAYLOAD.SQLINJECTION[stype]

lib/core/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def concatQuery(self, query, unpack=True):
528528

529529
return concatenatedQuery
530530

531-
def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char, multipleUnions=None, limited=False):
531+
def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char, where, multipleUnions=None, limited=False):
532532
"""
533533
Take in input an query (pseudo query) string and return its
534534
processed UNION ALL SELECT query.
@@ -562,7 +562,7 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
562562
if query.startswith("SELECT "):
563563
query = query[len("SELECT "):]
564564

565-
inbandQuery = self.prefixQuery("UNION ALL SELECT ", prefix=prefix)
565+
inbandQuery = self.prefixQuery("UNION ALL SELECT " if not (where == PAYLOAD.WHERE.NEGATIVE or multipleUnions) else "UNION SELECT ", prefix=prefix)
566566

567567
if limited:
568568
inbandQuery += ",".join(char if _ != position else '(SELECT %s)' % query for _ in xrange(0, count))

lib/techniques/union/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __orderByTest(cols):
107107
pages = {}
108108

109109
for count in xrange(lowerCount, upperCount+1):
110-
query = agent.forgeInbandQuery('', -1, count, comment, prefix, suffix, kb.uChar)
110+
query = agent.forgeInbandQuery('', -1, count, comment, prefix, suffix, kb.uChar, where)
111111
payload = agent.payload(place=place, parameter=parameter, newValue=query, where=where)
112112
page, headers = Request.queryPage(payload, place=place, content=True, raise404=False)
113113
if not isNullValue(kb.uChar):
@@ -181,7 +181,7 @@ def __unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYL
181181
randQueryUnescaped = unescaper.unescape(randQueryProcessed)
182182

183183
# Forge the inband SQL injection request
184-
query = agent.forgeInbandQuery(randQueryUnescaped, position, count, comment, prefix, suffix, kb.uChar)
184+
query = agent.forgeInbandQuery(randQueryUnescaped, position, count, comment, prefix, suffix, kb.uChar, where)
185185
payload = agent.payload(place=place, parameter=parameter, newValue=query, where=where)
186186

187187
# Perform the request
@@ -202,7 +202,7 @@ def __unionPosition(comment, place, parameter, prefix, suffix, count, where=PAYL
202202
randQueryUnescaped2 = unescaper.unescape(randQueryProcessed2)
203203

204204
# Confirm that it is a full inband SQL injection
205-
query = agent.forgeInbandQuery(randQueryUnescaped, position, count, comment, prefix, suffix, kb.uChar, multipleUnions=randQueryUnescaped2)
205+
query = agent.forgeInbandQuery(randQueryUnescaped, position, count, comment, prefix, suffix, kb.uChar, where, multipleUnions=randQueryUnescaped2)
206206
payload = agent.payload(place=place, parameter=parameter, newValue=query, where=PAYLOAD.WHERE.NEGATIVE)
207207

208208
# Perform the request

lib/techniques/union/use.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __oneShotUnionUse(expression, unpack=True, limited=False):
6161

6262
# Forge the inband SQL injection request
6363
vector = kb.injection.data[PAYLOAD.TECHNIQUE.UNION].vector
64-
query = agent.forgeInbandQuery(injExpression, vector[0], vector[1], vector[2], vector[3], vector[4], vector[5], None, limited)
64+
query = agent.forgeInbandQuery(injExpression, vector[0], vector[1], vector[2], vector[3], vector[4], vector[5], vector[6], None, limited)
6565
payload = agent.payload(newValue=query, where=where)
6666

6767
# Perform the request

0 commit comments

Comments
 (0)