Fix for Issue #61

This commit is contained in:
Miroslav Stampar 2012-07-06 14:24:44 +02:00
parent 1ebff35b19
commit 6a05e3fd79
3 changed files with 18 additions and 2 deletions

View File

@ -1469,6 +1469,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
kb.endDetection = False
kb.explicitSettings = set()
kb.errorIsNone = True
kb.fileReadMode = False
kb.forcedDbms = None
kb.headersFp = {}
kb.heuristicTest = None

View File

@ -106,7 +106,7 @@ def __oneShotErrorUse(expression, field):
warnMsg += trimmed
logger.warn(warnMsg)
if any(map(lambda dbms: Backend.isDbms(dbms), [DBMS.MYSQL, DBMS.MSSQL])):
if any(Backend.isDbms(dbms) for dbms in (DBMS.MYSQL, DBMS.MSSQL)):
if offset == 1:
retVal = output
else:
@ -116,6 +116,14 @@ def __oneShotErrorUse(expression, field):
offset += chunk_length
else:
break
if kb.fileReadMode and output:
_ = output
try:
_ = safecharencode(output.decode("hex")).replace(r"\n", "\n")
except:
pass
finally:
dataToStdout(_)
else:
retVal = output
break
@ -161,7 +169,9 @@ def __errorFields(expression, expressionFields, expressionFieldsList, expected=N
if not kb.threadContinue:
return None
if output is not None and not (threadData.resumed and kb.suppressResumeInfo):
if kb.fileReadMode:
print
elif output is not None and not (threadData.resumed and kb.suppressResumeInfo):
dataToStdout("[%s] [INFO] %s: %s\r\n" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", safecharencode(output)))
if isinstance(num, int):

View File

@ -19,6 +19,7 @@ from lib.core.common import randomStr
from lib.core.common import readInput
from lib.core.convert import hexdecode
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.enums import DBMS
from lib.core.enums import CHARSET_TYPE
@ -191,6 +192,8 @@ class Filesystem:
self.checkDbmsOs()
kb.fileReadMode = True
if conf.direct or isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
debugMsg = "going to read the file with stacked query SQL "
@ -208,6 +211,8 @@ class Filesystem:
return None
kb.fileReadMode = False
if fileContent in ( None, "" ) and not Backend.isDbms(DBMS.PGSQL):
self.cleanup(onlyFileTbl=True)