code beautification

This commit is contained in:
Miroslav Stampar 2010-12-08 13:04:48 +00:00
parent 64cc2588f1
commit 6223f25dd9
3 changed files with 16 additions and 6 deletions

View File

@ -94,3 +94,11 @@ class PAYLOAD:
COMPARISON = "comparison" COMPARISON = "comparison"
GREP = "grep" GREP = "grep"
TIME = "time" TIME = "time"
class TECHNIQUE:
HEURISTIC = 0
BOOLEAN = 1
ERROR = 2
UNION = 3
STACKED = 4
TIME = 5

View File

@ -28,6 +28,7 @@ from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import queries from lib.core.data import queries
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.enums import PAYLOAD
from lib.core.exception import sqlmapNotVulnerableException from lib.core.exception import sqlmapNotVulnerableException
from lib.core.settings import MIN_TIME_RESPONSES from lib.core.settings import MIN_TIME_RESPONSES
from lib.request.connect import Connect as Request 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 ", "") expression = expression.replace("DISTINCT ", "")
if inband and kb.unionTest is not None: if inband and kb.unionTest is not None:
kb.technique = 3 kb.technique = PAYLOAD.TECHNIQUE.UNION
value = __goInband(expression, expected, sort, resumeValue, unpack, dump) value = __goInband(expression, expected, sort, resumeValue, unpack, dump)
if not value: if not value:
@ -400,7 +401,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
kb.unionNegative = False kb.unionNegative = False
if error and kb.errorTest and not value: if error and kb.errorTest and not value:
kb.technique = 2 kb.technique = PAYLOAD.TECHNIQUE.ERROR
value = __goError(expression, resumeValue) value = __goError(expression, resumeValue)
if not value: if not value:
@ -410,11 +411,11 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
logger.warn(warnMsg) logger.warn(warnMsg)
if blind and kb.booleanTest and not value: 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) value = __goInferenceProxy(expression, fromUser, expected, batch, resumeValue, unpack, charsetType, firstChar, lastChar)
if time and kb.timeTest and not value: if time and kb.timeTest and not value:
kb.technique = 5 kb.technique = PAYLOAD.TECHNIQUE.TIME
while len(kb.responseTimes) < MIN_TIME_RESPONSES: while len(kb.responseTimes) < MIN_TIME_RESPONSES:
_ = Request.queryPage(content=True) _ = Request.queryPage(content=True)
@ -436,7 +437,7 @@ def getValue(expression, blind=True, inband=True, error=True, time=True, fromUse
return value return value
def goStacked(expression, silent=False): def goStacked(expression, silent=False):
kb.technique = 4 kb.technique = PAYLOAD.TECHNIQUE.STACKED
expression = cleanQuery(expression) expression = cleanQuery(expression)
if conf.direct: if conf.direct:

View File

@ -27,6 +27,7 @@ from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.data import queries from lib.core.data import queries
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.enums import PAYLOAD
from lib.core.exception import sqlmapConnectionException from lib.core.exception import sqlmapConnectionException
from lib.core.exception import sqlmapValueException from lib.core.exception import sqlmapValueException
from lib.core.exception import sqlmapThreadException from lib.core.exception import sqlmapThreadException
@ -44,7 +45,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
partialValue = "" partialValue = ""
finalValue = "" finalValue = ""
asciiTbl = getCharset(charsetType) 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 # Set kb.partRun in case "common prediction" feature (a.k.a. "good
# samaritan") is used # samaritan") is used