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

Skip to content

Commit 065d5b0

Browse files
committed
added singleValue parameter for good samaritan (same thing Bernardo wanted :)
1 parent 056d1ad commit 065d5b0

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

lib/core/common.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,16 +1219,17 @@ def initCommonOutputs():
12191219

12201220
cfile.close()
12211221

1222-
def getGoodSamaritanCharsets(part, prevValue, originalCharset):
1222+
def getGoodSamaritanParameters(part, prevValue, originalCharset):
12231223
###wild card . (dot) is supported for compatibility with threading
12241224
if kb.commonOutputs is None:
12251225
initCommonOutputs()
12261226

12271227
if not part or not prevValue: #is not None and != ""
1228-
return None, originalCharset
1228+
return None, None, originalCharset
12291229

12301230
predictionSet = set()
12311231
wildIndexes = []
1232+
singleValue = None
12321233

12331234
if prevValue[-1] != '.':
12341235
prevValue += '.'
@@ -1244,6 +1245,7 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12441245
if part in kb.commonOutputs:
12451246
for item in kb.commonOutputs[part]:
12461247
if re.search('\A%s' % prevValue, item):
1248+
singleValue = item
12471249
for index in wildIndexes:
12481250
char = item[index]
12491251

@@ -1260,10 +1262,13 @@ def getGoodSamaritanCharsets(part, prevValue, originalCharset):
12601262
predictedCharset.append(ordChar)
12611263

12621264
predictedCharset.sort()
1265+
1266+
if len(predictedCharset) > 1:
1267+
singleValue = None
12631268

1264-
return predictedCharset, otherCharset
1269+
return singleValue, predictedCharset, otherCharset
12651270
else:
1266-
return None, originalCharset
1271+
return None, None, originalCharset
12671272

12681273
def getCompiledRegex(regex):
12691274
if regex in __compiledRegularExpressions:

lib/techniques/blind/inference.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from lib.core.common import dataToSessionFile
3131
from lib.core.common import dataToStdout
3232
from lib.core.common import getCharset
33-
from lib.core.common import getGoodSamaritanCharsets
33+
from lib.core.common import getGoodSamaritanParameters
3434
from lib.core.common import replaceNewlineTabs
3535
from lib.core.common import safeStringFormat
3636
from lib.core.convert import urlencode
@@ -370,8 +370,14 @@ def downloadThread():
370370
charStart = time.time()
371371

372372
if conf.useCommonPrediction:
373-
predictedCharset, otherCharset = getGoodSamaritanCharsets(kb.partRun, finalValue, asciiTbl)
374-
val = getChar(index, predictedCharset, False) if predictedCharset else None
373+
singleValue, predictedCharset, otherCharset = getGoodSamaritanParameters(kb.partRun, finalValue, asciiTbl)
374+
if singleValue is None:
375+
val = getChar(index, predictedCharset, False) if predictedCharset else None
376+
else:
377+
##check if that's the value
378+
#finalValue = singleValue
379+
#break
380+
pass
375381
if not val:
376382
val = getChar(index, otherCharset)
377383
else:

0 commit comments

Comments
 (0)