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

Skip to content

Commit 6dec56d

Browse files
committed
Major bug fix
1 parent bb9079a commit 6dec56d

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

lib/core/agent.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def getFields(self, query):
246246
@rtype: C{str}
247247
"""
248248

249-
if "(SELECT " in query:
249+
if query.startswith("SELECT ") and "(SELECT " in query:
250250
firstChar = "\\("
251251
else:
252252
firstChar = "\\A"
@@ -271,6 +271,9 @@ def getFields(self, query):
271271
fieldsToCastList = fieldsToCastStr.replace(", ", ",")
272272
fieldsToCastList = fieldsToCastList.split(",")
273273

274+
if query.startswith("SELECT ") and "(SELECT " in query:
275+
fieldsSelectFrom = None
276+
274277
return fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsToCastList, fieldsToCastStr
275278

276279

@@ -390,15 +393,15 @@ def forgeInbandQuery(self, query, exprPosition=None):
390393
inbandQuery += ", "
391394

392395
if element == exprPosition:
393-
if " FROM " in query:
396+
if " FROM " in query and not query.startswith("SELECT ") and not "(SELECT " in query:
394397
conditionIndex = query.rindex(" FROM ")
395398
inbandQuery += "%s" % query[:conditionIndex]
396399
else:
397400
inbandQuery += "%s" % query
398401
else:
399402
inbandQuery += "NULL"
400403

401-
if " FROM " in query:
404+
if " FROM " in query and not query.startswith("SELECT ") and not "(SELECT " in query:
402405
conditionIndex = query.rindex(" FROM ")
403406
inbandQuery += "%s" % query[conditionIndex:]
404407

lib/parse/cmdline.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ def cmdLineParser():
4343
parser = OptionParser(usage=usage, version=VERSION_STRING)
4444

4545
try:
46+
parser.add_option("-v", dest="verbose", type="int",
47+
help="Verbosity level: 0-5 (default 1)")
48+
4649
# Target options
4750
target = OptionGroup(parser, "Target", "At least one of these "
4851
"options has to be specified to set the source "
@@ -161,6 +164,7 @@ def cmdLineParser():
161164
techniques.add_option("--time-test", dest="timeTest",
162165
action="store_true",
163166
help="Test for Time based blind SQL injection")
167+
164168
techniques.add_option("--union-test", dest="unionTest",
165169
action="store_true",
166170
help="Test for UNION query (inband) SQL injection")
@@ -293,9 +297,6 @@ def cmdLineParser():
293297
"calculate the estimated time of arrival "
294298
"in real time")
295299

296-
miscellaneous.add_option("-v", dest="verbose", type="int",
297-
help="Verbosity level: 0-5 (default 1)")
298-
299300
miscellaneous.add_option("--update", dest="updateAll", action="store_true",
300301
help="Update sqlmap to the latest stable version")
301302

0 commit comments

Comments
 (0)