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

Skip to content

Commit 2b05ded

Browse files
committed
just a makeup
1 parent b4f4a98 commit 2b05ded

7 files changed

Lines changed: 34 additions & 36 deletions

File tree

lib/core/agent.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from lib.core.enums import PAYLOAD
2727
from lib.core.enums import PLACE
2828
from lib.core.exception import sqlmapNoneDataException
29-
from lib.core.settings import FROM_TABLE
29+
from lib.core.settings import FROM_DUMMY_TABLE
3030
from lib.core.settings import PAYLOAD_DELIMITER
3131
from lib.core.settings import URI_INJECTION_MARK_CHAR
3232
from lib.core.unescaper import unescaper
@@ -559,7 +559,7 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
559559

560560
if limited:
561561
inbandQuery += ",".join(char if _ != position else '(SELECT %s)' % query for _ in xrange(0, count))
562-
inbandQuery += FROM_TABLE.get(Backend.getIdentifiedDbms(), "")
562+
inbandQuery += FROM_DUMMY_TABLE.get(Backend.getIdentifiedDbms(), "")
563563
inbandQuery = self.suffixQuery(inbandQuery, comment, suffix)
564564

565565
return inbandQuery
@@ -576,8 +576,8 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
576576
intoRegExp = intoRegExp.group(1)
577577
query = query[:query.index(intoRegExp)]
578578

579-
if Backend.getIdentifiedDbms() in FROM_TABLE and inbandQuery.endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
580-
inbandQuery = inbandQuery[:-len(FROM_TABLE[Backend.getIdentifiedDbms()])]
579+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and inbandQuery.endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
580+
inbandQuery = inbandQuery[:-len(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()])]
581581

582582
for element in xrange(0, count):
583583
if element > 0:
@@ -596,9 +596,9 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
596596
conditionIndex = query.index(" FROM ")
597597
inbandQuery += query[conditionIndex:]
598598

599-
if Backend.getIdentifiedDbms() in FROM_TABLE:
599+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE:
600600
if " FROM " not in inbandQuery or "(CASE " in inbandQuery or "(IIF" in inbandQuery:
601-
inbandQuery += FROM_TABLE[Backend.getIdentifiedDbms()]
601+
inbandQuery += FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]
602602

603603
if intoRegExp:
604604
inbandQuery += intoRegExp
@@ -615,8 +615,8 @@ def forgeInbandQuery(self, query, position, count, comment, prefix, suffix, char
615615
else:
616616
inbandQuery += char
617617

618-
if Backend.getIdentifiedDbms() in FROM_TABLE:
619-
inbandQuery += FROM_TABLE[Backend.getIdentifiedDbms()]
618+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE:
619+
inbandQuery += FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]
620620

621621
inbandQuery = self.suffixQuery(inbandQuery, comment, suffix)
622622

@@ -747,8 +747,8 @@ def forgeCaseStatement(self, expression):
747747
if Backend.getIdentifiedDbms() is not None and hasattr(queries[Backend.getIdentifiedDbms()], "case"):
748748
caseExpression = queries[Backend.getIdentifiedDbms()].case.query % expression
749749

750-
if "(IIF" not in caseExpression and Backend.getIdentifiedDbms() in FROM_TABLE and not caseExpression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
751-
caseExpression += FROM_TABLE[Backend.getIdentifiedDbms()]
750+
if "(IIF" not in caseExpression and Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and not caseExpression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
751+
caseExpression += FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]
752752

753753
return caseExpression
754754

lib/core/common.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,13 +2370,11 @@ def aliasToDbmsEnum(dbms):
23702370

23712371
retVal = None
23722372

2373-
if dbms is None:
2374-
return None
2375-
2376-
for key, item in DBMS_DICT.items():
2377-
if dbms.lower() in item[0] or dbms.lower() == key.lower():
2378-
retVal = key
2379-
break
2373+
if dbms:
2374+
for key, item in DBMS_DICT.items():
2375+
if dbms.lower() in item[0] or dbms.lower() == key.lower():
2376+
retVal = key
2377+
break
23802378

23812379
return retVal
23822380

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@
182182
REFERER_ALIASES = ( "ref", "referer", "referrer" )
183183
HOST_ALIASES = ( "host", )
184184

185-
FROM_TABLE = {
185+
FROM_DUMMY_TABLE = {
186186
DBMS.ORACLE: " FROM DUAL",
187187
DBMS.ACCESS: " FROM MSysAccessObjects",
188188
DBMS.FIREBIRD: " FROM RDB$DATABASE",

lib/request/inject.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from lib.core.enums import PAYLOAD
3737
from lib.core.exception import sqlmapNotVulnerableException
3838
from lib.core.exception import sqlmapUserQuitException
39-
from lib.core.settings import FROM_TABLE
39+
from lib.core.settings import FROM_DUMMY_TABLE
4040
from lib.core.settings import MIN_TIME_RESPONSES
4141
from lib.core.settings import MAX_TECHNIQUES_PER_VALUE
4242
from lib.core.settings import SQL_SCALAR_REGEX
@@ -159,8 +159,8 @@ def __goInferenceProxy(expression, fromUser=False, expected=None, batch=False, r
159159
# NOTE: I assume that only queries that get data from a table
160160
# can return multiple entries
161161
if fromUser and " FROM " in expression.upper() and ((Backend.getIdentifiedDbms() \
162-
not in FROM_TABLE) or (Backend.getIdentifiedDbms() in FROM_TABLE and not \
163-
expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]))) \
162+
not in FROM_DUMMY_TABLE) or (Backend.getIdentifiedDbms() in FROM_TABLE and not \
163+
expression.upper().endswith(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]))) \
164164
and not re.search(SQL_SCALAR_REGEX, expression, re.I):
165165

166166
limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)
@@ -215,7 +215,7 @@ def __goInferenceProxy(expression, fromUser=False, expected=None, batch=False, r
215215
stopLimit += startLimit
216216

217217
if not stopLimit or stopLimit <= 1:
218-
if Backend.getIdentifiedDbms() in FROM_TABLE and expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
218+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
219219
test = False
220220
else:
221221
test = True
@@ -318,8 +318,8 @@ def __goInferenceProxy(expression, fromUser=False, expected=None, batch=False, r
318318

319319
return outputs
320320

321-
elif Backend.getIdentifiedDbms() in FROM_TABLE and expression.upper().startswith("SELECT ") and " FROM " not in expression.upper():
322-
expression += FROM_TABLE[Backend.getIdentifiedDbms()]
321+
elif Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and expression.upper().startswith("SELECT ") and " FROM " not in expression.upper():
322+
expression += FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]
323323

324324
outputs = __goInferenceFields(expression, expressionFields, expressionFieldsList, payload, expected, resumeValue=resumeValue, charsetType=charsetType, firstChar=firstChar, lastChar=lastChar, dump=dump)
325325
returnValue = ", ".join(output for output in outputs)

lib/techniques/error/use.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from lib.core.enums import EXPECTED
3636
from lib.core.enums import PAYLOAD
3737
from lib.core.exception import sqlmapConnectionException
38-
from lib.core.settings import FROM_TABLE
38+
from lib.core.settings import FROM_DUMMY_TABLE
3939
from lib.core.settings import MYSQL_ERROR_CHUNK_LENGTH
4040
from lib.core.settings import MSSQL_ERROR_CHUNK_LENGTH
4141
from lib.core.settings import SLOW_ORDER_COUNT_THRESHOLD
@@ -227,9 +227,9 @@ def errorUse(expression, expected=None, resumeValue=True, dump=False):
227227
# NOTE: I assume that only queries that get data from a table can
228228
# return multiple entries
229229
if (dump and (conf.limitStart or conf.limitStop)) or (" FROM " in \
230-
expression.upper() and ((Backend.getIdentifiedDbms() not in FROM_TABLE) \
231-
or (Backend.getIdentifiedDbms() in FROM_TABLE and not \
232-
expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]))) \
230+
expression.upper() and ((Backend.getIdentifiedDbms() not in FROM_DUMMY_TABLE) \
231+
or (Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and not \
232+
expression.upper().endswith(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]))) \
233233
and ("(CASE" not in expression.upper() or ("(CASE" in expression.upper() and "WHEN use" in expression))) \
234234
and not re.search(SQL_SCALAR_REGEX, expression, re.I):
235235

lib/techniques/union/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from lib.core.data import queries
3636
from lib.core.enums import DBMS
3737
from lib.core.enums import PAYLOAD
38-
from lib.core.settings import FROM_TABLE
38+
from lib.core.settings import FROM_DUMMY_TABLE
3939
from lib.core.settings import UNION_MIN_RESPONSE_CHARS
4040
from lib.core.settings import UNION_STDEV_COEFF
4141
from lib.core.settings import MIN_RATIO
@@ -257,14 +257,14 @@ def __unionTestByCharBruteforce(comment, place, parameter, value, prefix, suffix
257257
count = __findUnionCharCount(comment, place, parameter, value, prefix, suffix, PAYLOAD.WHERE.ORIGINAL if isNullValue(kb.uChar) else PAYLOAD.WHERE.NEGATIVE)
258258

259259
if count:
260-
if Backend.getIdentifiedDbms() in FROM_TABLE and query.endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
261-
query = query[:-len(FROM_TABLE[Backend.getIdentifiedDbms()])]
260+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE and query.endswith(FROM_TABLE[Backend.getIdentifiedDbms()]):
261+
query = query[:-len(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()])]
262262

263263
if count:
264264
query += ", %s" % kb.uChar
265265

266-
if Backend.getIdentifiedDbms() in FROM_TABLE:
267-
query += FROM_TABLE[Backend.getIdentifiedDbms()]
266+
if Backend.getIdentifiedDbms() in FROM_DUMMY_TABLE:
267+
query += FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]
268268

269269
validPayload, vector = __unionConfirm(comment, place, parameter, prefix, suffix, count)
270270

lib/techniques/union/use.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from lib.core.enums import PAYLOAD
3737
from lib.core.exception import sqlmapConnectionException
3838
from lib.core.exception import sqlmapSyntaxException
39-
from lib.core.settings import FROM_TABLE
39+
from lib.core.settings import FROM_DUMMY_TABLE
4040
from lib.core.settings import SQL_SCALAR_REGEX
4141
from lib.core.settings import TURN_OFF_RESUME_INFO_LIMIT
4242
from lib.core.threads import getCurrentThreadData
@@ -165,8 +165,8 @@ def unionUse(expression, unpack=True, dump=False):
165165
if (kb.injection.data[PAYLOAD.TECHNIQUE.UNION].where == PAYLOAD.WHERE.NEGATIVE or \
166166
(dump and (conf.limitStart or conf.limitStop))) and \
167167
" FROM " in expression.upper() and ((Backend.getIdentifiedDbms() \
168-
not in FROM_TABLE) or (Backend.getIdentifiedDbms() in FROM_TABLE \
169-
and not expression.upper().endswith(FROM_TABLE[Backend.getIdentifiedDbms()]))) \
168+
not in FROM_DUMMY_TABLE) or (Backend.getIdentifiedDbms() in FROM_TABLE \
169+
and not expression.upper().endswith(FROM_DUMMY_TABLE[Backend.getIdentifiedDbms()]))) \
170170
and not re.search(SQL_SCALAR_REGEX, expression, re.I):
171171

172172
limitRegExp = re.search(queries[Backend.getIdentifiedDbms()].limitregexp.query, expression, re.I)

0 commit comments

Comments
 (0)