mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-05 21:53:11 +03:00
some comments added
This commit is contained in:
parent
1a3dfd8ced
commit
ce29c841cf
|
@ -1221,7 +1221,13 @@ def initCommonOutputs():
|
||||||
cfile.close()
|
cfile.close()
|
||||||
|
|
||||||
def getGoodSamaritanParameters(part, prevValue, originalCharset):
|
def getGoodSamaritanParameters(part, prevValue, originalCharset):
|
||||||
###wild card . (dot) is supported for compatibility with threading
|
"""
|
||||||
|
Function for retrieving parameters needed for good samaritan (common outputs) feature.
|
||||||
|
Returns singleValue if there is a complete single match (in part of common-outputs.txt set by parameter 'part')
|
||||||
|
regarding parameter prevValue. If there is no single value match, but multiple, predictedCharset is returned
|
||||||
|
containing more probable characters (retrieved from matched items in common-outputs.txt) together with the
|
||||||
|
rest of charset as otherCharset
|
||||||
|
"""
|
||||||
if kb.commonOutputs is None:
|
if kb.commonOutputs is None:
|
||||||
initCommonOutputs()
|
initCommonOutputs()
|
||||||
|
|
||||||
|
@ -1272,6 +1278,9 @@ def getGoodSamaritanParameters(part, prevValue, originalCharset):
|
||||||
return None, None, originalCharset
|
return None, None, originalCharset
|
||||||
|
|
||||||
def getCompiledRegex(regex, args=()):
|
def getCompiledRegex(regex, args=()):
|
||||||
|
"""
|
||||||
|
Returns compiled regular expression and stores it in cache for further usage
|
||||||
|
"""
|
||||||
if regex in __compiledRegularExpressions:
|
if regex in __compiledRegularExpressions:
|
||||||
return __compiledRegularExpressions[regex]
|
return __compiledRegularExpressions[regex]
|
||||||
else:
|
else:
|
||||||
|
@ -1279,8 +1288,10 @@ def getCompiledRegex(regex, args=()):
|
||||||
__compiledRegularExpressions[regex] = retVal
|
__compiledRegularExpressions[regex] = retVal
|
||||||
return retVal
|
return retVal
|
||||||
|
|
||||||
#dumper.dbTableValues(conf.dbmsHandler.dumpTable()) -> dumpTable
|
|
||||||
def getPartRun():
|
def getPartRun():
|
||||||
|
"""
|
||||||
|
Goes through call stack and finds constructs matching conf.dmbsHandler.*. Returns it or it's alias used in common-outputs.txt
|
||||||
|
"""
|
||||||
commonPartsDict = { "getTables":"Tables", "getColumns":"Columns", "getUsers":"Users", "getBanner":"Banners", "getDbs":"Databases" }
|
commonPartsDict = { "getTables":"Tables", "getColumns":"Columns", "getUsers":"Users", "getBanner":"Banners", "getDbs":"Databases" }
|
||||||
retVal = None
|
retVal = None
|
||||||
stack = [item[4][0] if isinstance(item[4], list) else '' for item in inspect.stack()]
|
stack = [item[4][0] if isinstance(item[4], list) else '' for item in inspect.stack()]
|
||||||
|
|
|
@ -57,7 +57,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||||
|
|
||||||
asciiTbl = getCharset(charsetType)
|
asciiTbl = getCharset(charsetType)
|
||||||
|
|
||||||
kb.partRun = getPartRun() if conf.useCommonPrediction else None
|
kb.partRun = getPartRun() if conf.useCommonPrediction else None #set kb.partRun in case common-prediction used
|
||||||
|
|
||||||
if "LENGTH(" in expression or "LEN(" in expression:
|
if "LENGTH(" in expression or "LEN(" in expression:
|
||||||
firstChar = 0
|
firstChar = 0
|
||||||
|
@ -372,16 +372,20 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||||
index += 1
|
index += 1
|
||||||
charStart = time.time()
|
charStart = time.time()
|
||||||
|
|
||||||
|
#common prediction (a.k.a. good samaritan)
|
||||||
if conf.useCommonPrediction:
|
if conf.useCommonPrediction:
|
||||||
singleValue, predictedCharset, otherCharset = getGoodSamaritanParameters(kb.partRun, finalValue, asciiTbl)
|
singleValue, predictedCharset, otherCharset = getGoodSamaritanParameters(kb.partRun, finalValue, asciiTbl)
|
||||||
val = None
|
val = None
|
||||||
|
|
||||||
|
#if there is no singleValue (single match from common-outputs.txt) use the returned predictedCharset
|
||||||
if singleValue is None:
|
if singleValue is None:
|
||||||
val = getChar(index, predictedCharset, False) if predictedCharset else None
|
val = getChar(index, predictedCharset, False) if predictedCharset else None
|
||||||
else:
|
else:
|
||||||
|
#one shot query containing equals singleValue
|
||||||
query = agent.prefixQuery(" %s" % safeStringFormat('AND (%s) = %s', (expressionUnescaped, unescaper.unescape('\'%s\'' % singleValue))))
|
query = agent.prefixQuery(" %s" % safeStringFormat('AND (%s) = %s', (expressionUnescaped, unescaper.unescape('\'%s\'' % singleValue))))
|
||||||
query = agent.postfixQuery(query)
|
query = agent.postfixQuery(query)
|
||||||
result = Request.queryPage(urlencode(agent.payload(newValue=query)))
|
result = Request.queryPage(urlencode(agent.payload(newValue=query)))
|
||||||
|
#did we have luck?
|
||||||
if result:
|
if result:
|
||||||
dataToSessionFile(replaceNewlineTabs(singleValue[index-1:]))
|
dataToSessionFile(replaceNewlineTabs(singleValue[index-1:]))
|
||||||
if showEta:
|
if showEta:
|
||||||
|
@ -390,6 +394,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
|
||||||
dataToStdout(singleValue[index-1:])
|
dataToStdout(singleValue[index-1:])
|
||||||
finalValue = singleValue
|
finalValue = singleValue
|
||||||
break
|
break
|
||||||
|
#if we had no luck with singleValue and predictedCharset use the returned otherCharset
|
||||||
if not val:
|
if not val:
|
||||||
val = getChar(index, otherCharset)
|
val = getChar(index, otherCharset)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user