mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-11-16 12:57:25 +00:00
Fix for multiple MIN()/MAX() fields in SQL queries (e.g. SELECT MAX(id),MIN(id))
This commit is contained in:
parent
167956b61c
commit
b6c4f880a5
2 changed files with 12 additions and 8 deletions
|
|
@ -673,6 +673,10 @@ class Agent(object):
|
|||
if re.search(r"\bWHERE\b.+(MIN|MAX)", query, re.I):
|
||||
fieldsMinMaxstr = None
|
||||
|
||||
# Note: shortcut is meant only for a single MIN()/MAX() field (e.g. 'SELECT MAX(id),MIN(id) FROM users' has two)
|
||||
if fieldsMinMaxstr and fieldsSelectFrom and len(splitFields(fieldsSelectFrom.group(1))) > 1:
|
||||
fieldsMinMaxstr = None
|
||||
|
||||
fieldsToCastStr = fieldsNoSelect
|
||||
|
||||
if fieldsSubstr:
|
||||
|
|
@ -701,8 +705,8 @@ class Agent(object):
|
|||
|
||||
fieldsToCastStr = fieldsToCastStr or ""
|
||||
|
||||
# Function
|
||||
if re.search(r"\A\w+\(.*\)", fieldsToCastStr, re.I) or (fieldsSelectCase and "WHEN use" not in query) or fieldsSubstr:
|
||||
# Function (Note: a single one - e.g. 'MAX(id),MIN(id)' are two fields)
|
||||
if (re.search(r"\A\w+\(.*\)", fieldsToCastStr, re.I) and len(splitFields(fieldsToCastStr)) == 1) or (fieldsSelectCase and "WHEN use" not in query) or fieldsSubstr:
|
||||
fieldsToCastList = [fieldsToCastStr]
|
||||
else:
|
||||
fieldsToCastList = splitFields(fieldsToCastStr)
|
||||
|
|
@ -1065,11 +1069,11 @@ class Agent(object):
|
|||
startLimit = 0
|
||||
stopLimit = None
|
||||
limitCond = True
|
||||
limitClause = None
|
||||
|
||||
topLimit = re.search(r"TOP\s+([\d]+)\s+", expression, re.I)
|
||||
|
||||
limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)
|
||||
limitClause = None
|
||||
|
||||
if hasattr(queries[Backend.getIdentifiedDbms()].limitregexp, "query2"):
|
||||
limitRegExp2 = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query2, expression, re.I)
|
||||
|
|
@ -1096,16 +1100,16 @@ class Agent(object):
|
|||
# Note: query2 (LIMIT without OFFSET) always has exactly one group (the
|
||||
# count); using limitGroupStart here would IndexError for H2 (groupstart=2)
|
||||
stopLimit = limitRegExp2.group(1)
|
||||
limitCond = int(stopLimit) > 1
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
if limitRegExp:
|
||||
|
||||
# Note: standard 'LIMIT n OFFSET m' (or 'OFFSET m LIMIT n') isn't (fully) covered by limitregexp (e.g. OFFSET was silently ignored on MySQL)
|
||||
limitClause = re.search(r"(?i)\s+LIMIT\s+(?P<stop>\d+)\s+OFFSET\s+(?P<start>\d+)", expression) or re.search(r"(?i)\s+OFFSET\s+(?P<start>\d+)\s+LIMIT\s+(?P<stop>\d+)", expression)
|
||||
if limitClause:
|
||||
startLimit, stopLimit = int(limitClause.group("start")), limitClause.group("stop")
|
||||
|
||||
limitCond = int(stopLimit) > 1
|
||||
|
||||
elif Backend.getIdentifiedDbms() in (DBMS.MSSQL, DBMS.SYBASE):
|
||||
if limitRegExp:
|
||||
limitGroupStart = queries[Backend.getIdentifiedDbms()].limitgroupstart.query
|
||||
limitGroupStop = queries[Backend.getIdentifiedDbms()].limitgroupstop.query
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ from lib.core.enums import OS
|
|||
from thirdparty import six
|
||||
|
||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||
VERSION = "1.10.11.22"
|
||||
VERSION = "1.10.11.23"
|
||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue