diff --git a/lib/core/enums.py b/lib/core/enums.py index 49a9e01ec..e24e2d1a8 100644 --- a/lib/core/enums.py +++ b/lib/core/enums.py @@ -94,3 +94,11 @@ class PAYLOAD: COMPARISON = "comparison" GREP = "grep" TIME = "time" + + class TECHNIQUE: + HEURISTIC = 0 + BOOLEAN = 1 + ERROR = 2 + UNION = 3 + STACKED = 4 + TIME = 5 diff --git a/lib/request/inject.py b/lib/request/inject.py index 530d433f6..a1338d836 100644 --- a/lib/request/inject.py +++ b/lib/request/inject.py @@ -28,6 +28,7 @@ from lib.core.data import kb from lib.core.data import logger from lib.core.data import queries from lib.core.enums import DBMS +from lib.core.enums import PAYLOAD from lib.core.exception import sqlmapNotVulnerableException from lib.core.settings import MIN_TIME_RESPONSES from lib.request.connect import Connect as Request @@ -387,7 +388,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse expression = expression.replace("DISTINCT ", "") if inband and kb.unionTest is not None: - kb.technique = 3 + kb.technique = PAYLOAD.TECHNIQUE.UNION value = __goInband(expression, expected, sort, resumeValue, unpack, dump) if not value: @@ -400,7 +401,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse kb.unionNegative = False if error and kb.errorTest and not value: - kb.technique = 2 + kb.technique = PAYLOAD.TECHNIQUE.ERROR value = __goError(expression, resumeValue) if not value: @@ -410,11 +411,11 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse logger.warn(warnMsg) if blind and kb.booleanTest and not value: - kb.technique = 1 + kb.technique = PAYLOAD.TECHNIQUE.BOOLEAN value = __goInferenceProxy(expression, fromUser, expected, batch, resumeValue, unpack, charsetType, firstChar, lastChar) if time and kb.timeTest and not value: - kb.technique = 5 + kb.technique = PAYLOAD.TECHNIQUE.TIME while len(kb.responseTimes) < MIN_TIME_RESPONSES: _ = Request.queryPage(content=True) @@ -436,7 +437,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse return value def goStacked(expression, silent=False): - kb.technique = 4 + kb.technique = PAYLOAD.TECHNIQUE.STACKED expression = cleanQuery(expression) if conf.direct: diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index f1b423eee..142df3269 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -27,6 +27,7 @@ from lib.core.data import kb from lib.core.data import logger from lib.core.data import queries from lib.core.enums import DBMS +from lib.core.enums import PAYLOAD from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapValueException from lib.core.exception import sqlmapThreadException @@ -44,7 +45,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None partialValue = "" finalValue = "" asciiTbl = getCharset(charsetType) - timeBasedCompare = (kb.technique == 5) + timeBasedCompare = (kb.technique == PAYLOAD.TECHNIQUE.TIME) # Set kb.partRun in case "common prediction" feature (a.k.a. "good # samaritan") is used