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

Skip to content

Commit 6a05e3f

Browse files
committed
Fix for Issue #61
1 parent 1ebff35 commit 6a05e3f

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,7 @@ def __setKnowledgeBaseAttributes(flushAll=True):
14691469
kb.endDetection = False
14701470
kb.explicitSettings = set()
14711471
kb.errorIsNone = True
1472+
kb.fileReadMode = False
14721473
kb.forcedDbms = None
14731474
kb.headersFp = {}
14741475
kb.heuristicTest = None

lib/techniques/error/use.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def __oneShotErrorUse(expression, field):
106106
warnMsg += trimmed
107107
logger.warn(warnMsg)
108108

109-
if any(map(lambda dbms: Backend.isDbms(dbms), [DBMS.MYSQL, DBMS.MSSQL])):
109+
if any(Backend.isDbms(dbms) for dbms in (DBMS.MYSQL, DBMS.MSSQL)):
110110
if offset == 1:
111111
retVal = output
112112
else:
@@ -116,6 +116,14 @@ def __oneShotErrorUse(expression, field):
116116
offset += chunk_length
117117
else:
118118
break
119+
if kb.fileReadMode and output:
120+
_ = output
121+
try:
122+
_ = safecharencode(output.decode("hex")).replace(r"\n", "\n")
123+
except:
124+
pass
125+
finally:
126+
dataToStdout(_)
119127
else:
120128
retVal = output
121129
break
@@ -161,7 +169,9 @@ def __errorFields(expression, expressionFields, expressionFieldsList, expected=N
161169
if not kb.threadContinue:
162170
return None
163171

164-
if output is not None and not (threadData.resumed and kb.suppressResumeInfo):
172+
if kb.fileReadMode:
173+
print
174+
elif output is not None and not (threadData.resumed and kb.suppressResumeInfo):
165175
dataToStdout("[%s] [INFO] %s: %s\r\n" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", safecharencode(output)))
166176

167177
if isinstance(num, int):

plugins/generic/filesystem.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from lib.core.common import readInput
2020
from lib.core.convert import hexdecode
2121
from lib.core.data import conf
22+
from lib.core.data import kb
2223
from lib.core.data import logger
2324
from lib.core.enums import DBMS
2425
from lib.core.enums import CHARSET_TYPE
@@ -191,6 +192,8 @@ def readFile(self, rFile):
191192

192193
self.checkDbmsOs()
193194

195+
kb.fileReadMode = True
196+
194197
if conf.direct or isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
195198
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED):
196199
debugMsg = "going to read the file with stacked query SQL "
@@ -208,6 +211,8 @@ def readFile(self, rFile):
208211

209212
return None
210213

214+
kb.fileReadMode = False
215+
211216
if fileContent in ( None, "" ) and not Backend.isDbms(DBMS.PGSQL):
212217
self.cleanup(onlyFileTbl=True)
213218

0 commit comments

Comments
 (0)