Skip to content

Commit

Permalink
more general fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Feb 24, 2012
1 parent e8352e5 commit 570d3a1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ def dataToStdout(data, forceOutput=False):
sys.stdout.write(data.encode(UNICODE_ENCODING))
finally:
sys.stdout.flush()
setFormatterPrependFlag(len(data) == 1)
if kb.get("multiThreadMode"):
logging._releaseLock()

Expand Down
8 changes: 6 additions & 2 deletions lib/core/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,18 +394,22 @@ def __setMultipleTargets():
infoMsg += "testable requests from the targets list"
logger.info(infoMsg)

def __adjustFormatter():
def __adjustLoggingFormatter():
"""
Solves problem of line deletition caused by overlapping logging messages
and retrieved data info in inference mode
"""

if hasattr(FORMATTER, '_format'):
return

def format(record):
_ = FORMATTER._format(record)
if FORMATTER._prepend_flag:
_ = "\n%s" % _
FORMATTER._prepend_flag = False
return _

FORMATTER._format = FORMATTER.format
FORMATTER._prepend_flag = False
FORMATTER.format = format
Expand Down Expand Up @@ -1902,7 +1906,7 @@ def init(inputOptions=AttribDict(), overrideOptions=False):
__checkDependencies()
__basicOptionValidation()
__setTorProxySettings()
__adjustFormatter()
__adjustLoggingFormatter()
__setMultipleTargets()
__setTamperingFunctions()
__setTrafficOutputFP()
Expand Down
5 changes: 0 additions & 5 deletions lib/techniques/blind/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from lib.core.common import getPartRun
from lib.core.common import incrementCounter
from lib.core.common import safeStringFormat
from lib.core.common import setFormatterPrependFlag
from lib.core.common import singleTimeWarnMessage
from lib.core.data import conf
from lib.core.data import kb
Expand Down Expand Up @@ -450,7 +449,6 @@ def blindThread():
etaProgressUpdate(time.time() - charStart, len(commonValue))
elif conf.verbose in (1, 2):
dataToStdout(commonValue[index-1:])
setFormatterPrependFlag(True)

finalValue = commonValue

Expand Down Expand Up @@ -499,16 +497,13 @@ def blindThread():
etaProgressUpdate(time.time() - charStart, index)
elif conf.verbose in (1, 2):
dataToStdout(val)
setFormatterPrependFlag(True)

if len(partialValue) > INFERENCE_BLANK_BREAK and partialValue[-INFERENCE_BLANK_BREAK:].isspace():
finalValue = partialValue
break

except KeyboardInterrupt:
abortedFlag = True
finally:
setFormatterPrependFlag(False)

if conf.verbose in (1, 2) or showEta:
dataToStdout("\n")
Expand Down

0 comments on commit 570d3a1

Please sign in to comment.