diff --git a/lib/core/option.py b/lib/core/option.py index 96da79346..c3b2be518 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -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 diff --git a/lib/techniques/error/use.py b/lib/techniques/error/use.py index 7b89ea01c..37ffdc252 100644 --- a/lib/techniques/error/use.py +++ b/lib/techniques/error/use.py @@ -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): diff --git a/plugins/generic/filesystem.py b/plugins/generic/filesystem.py index dec9463b7..b5cc76812 100644 --- a/plugins/generic/filesystem.py +++ b/plugins/generic/filesystem.py @@ -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)