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

Skip to content

Commit 6223f25

Browse files
committed
code beautification
1 parent 64cc258 commit 6223f25

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

lib/core/enums.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,11 @@ class METHOD:
9494
COMPARISON = "comparison"
9595
GREP = "grep"
9696
TIME = "time"
97+
98+
class TECHNIQUE:
99+
HEURISTIC = 0
100+
BOOLEAN = 1
101+
ERROR = 2
102+
UNION = 3
103+
STACKED = 4
104+
TIME = 5

lib/request/inject.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from lib.core.data import logger
2929
from lib.core.data import queries
3030
from lib.core.enums import DBMS
31+
from lib.core.enums import PAYLOAD
3132
from lib.core.exception import sqlmapNotVulnerableException
3233
from lib.core.settings import MIN_TIME_RESPONSES
3334
from lib.request.connect import Connect as Request
@@ -387,7 +388,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
387388
expression = expression.replace("DISTINCT ", "")
388389

389390
if inband and kb.unionTest is not None:
390-
kb.technique = 3
391+
kb.technique = PAYLOAD.TECHNIQUE.UNION
391392
value = __goInband(expression, expected, sort, resumeValue, unpack, dump)
392393

393394
if not value:
@@ -400,7 +401,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
400401
kb.unionNegative = False
401402

402403
if error and kb.errorTest and not value:
403-
kb.technique = 2
404+
kb.technique = PAYLOAD.TECHNIQUE.ERROR
404405
value = __goError(expression, resumeValue)
405406

406407
if not value:
@@ -410,11 +411,11 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
410411
logger.warn(warnMsg)
411412

412413
if blind and kb.booleanTest and not value:
413-
kb.technique = 1
414+
kb.technique = PAYLOAD.TECHNIQUE.BOOLEAN
414415
value = __goInferenceProxy(expression, fromUser, expected, batch, resumeValue, unpack, charsetType, firstChar, lastChar)
415416

416417
if time and kb.timeTest and not value:
417-
kb.technique = 5
418+
kb.technique = PAYLOAD.TECHNIQUE.TIME
418419

419420
while len(kb.responseTimes) < MIN_TIME_RESPONSES:
420421
_ = Request.queryPage(content=True)
@@ -436,7 +437,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
436437
return value
437438

438439
def goStacked(expression, silent=False):
439-
kb.technique = 4
440+
kb.technique = PAYLOAD.TECHNIQUE.STACKED
440441
expression = cleanQuery(expression)
441442

442443
if conf.direct:

lib/techniques/blind/inference.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from lib.core.data import logger
2828
from lib.core.data import queries
2929
from lib.core.enums import DBMS
30+
from lib.core.enums import PAYLOAD
3031
from lib.core.exception import sqlmapConnectionException
3132
from lib.core.exception import sqlmapValueException
3233
from lib.core.exception import sqlmapThreadException
@@ -44,7 +45,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
4445
partialValue = ""
4546
finalValue = ""
4647
asciiTbl = getCharset(charsetType)
47-
timeBasedCompare = (kb.technique == 5)
48+
timeBasedCompare = (kb.technique == PAYLOAD.TECHNIQUE.TIME)
4849

4950
# Set kb.partRun in case "common prediction" feature (a.k.a. "good
5051
# samaritan") is used

0 commit comments

Comments
 (0)