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

Skip to content

Commit 7f0db26

Browse files
committed
more code updates regarding good samaritan (common output) feature
1 parent 8ed76b3 commit 7f0db26

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

lib/core/common.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import codecs
2626
import cProfile
27+
import inspect
2728
import os
2829
import random
2930
import re
@@ -1270,10 +1271,23 @@ def getGoodSamaritanParameters(part, prevValue, originalCharset):
12701271
else:
12711272
return None, None, originalCharset
12721273

1273-
def getCompiledRegex(regex):
1274+
def getCompiledRegex(regex, args=()):
12741275
if regex in __compiledRegularExpressions:
12751276
return __compiledRegularExpressions[regex]
12761277
else:
1277-
retVal = re.compile(regex)
1278+
retVal = re.compile(regex, *args)
12781279
__compiledRegularExpressions[regex] = retVal
12791280
return retVal
1281+
1282+
#dumper.dbTableValues(conf.dbmsHandler.dumpTable()) -> dumpTable
1283+
def getPartRun():
1284+
commonPartsDict = { "dumpTable":"Tables", "getColumns":"Columns", "getUsers":"Users", "getBanner":"Banners" }
1285+
retVal = None
1286+
stack = [item[4][0] if isinstance(item[4], list) else '' for item in inspect.stack()]
1287+
reobj = getCompiledRegex('conf\.dbmsHandler\.([^(]+)\(\)')
1288+
for i in xrange(len(stack) - 1, 0, -1):
1289+
match = reobj.search(stack[i])
1290+
if match:
1291+
retVal = match.groups()[0]
1292+
break
1293+
return commonPartsDict[retVal] if retVal in commonPartsDict else retVal

lib/techniques/blind/inference.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from lib.core.common import dataToStdout
3232
from lib.core.common import getCharset
3333
from lib.core.common import getGoodSamaritanParameters
34+
from lib.core.common import getPartRun
3435
from lib.core.common import replaceNewlineTabs
3536
from lib.core.common import safeStringFormat
3637
from lib.core.convert import urlencode
@@ -56,6 +57,8 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None
5657

5758
asciiTbl = getCharset(charsetType)
5859

60+
kb.partRun = getPartRun() if conf.useCommonPrediction else None
61+
5962
if "LENGTH(" in expression or "LEN(" in expression:
6063
firstChar = 0
6164
elif conf.firstChar is not None and ( isinstance(conf.firstChar, int) or ( isinstance(conf.firstChar, basestring) and conf.firstChar.isdigit() ) ):
@@ -376,13 +379,13 @@ def downloadThread():
376379
if singleValue is None:
377380
val = getChar(index, predictedCharset, False) if predictedCharset else None
378381
else:
379-
#forgedPayload = safeStringFormat('AND (%s) = \'%s\'', (expressionUnescaped, singleValue))
380-
#result = Request.queryPage(urlencode(forgedPayload))
381-
#if result:
382-
# finalValue = singleValue
383-
# break
384-
pass
385-
382+
query = agent.prefixQuery(" %s" % safeStringFormat('AND (%s) = \'%s\'', (expressionUnescaped, singleValue)))
383+
query = agent.postfixQuery(query)
384+
payload = agent.payload(newValue=query)
385+
result = Request.queryPage(urlencode(payload))
386+
if result:
387+
finalValue = singleValue
388+
break
386389
if not val:
387390
val = getChar(index, otherCharset)
388391
else:

txt/common-outputs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
users
33

44
[Users]
5-
luther
5+
'root'@'127.0.0.1'

0 commit comments

Comments
 (0)