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

Skip to content

Commit f9a135e

Browse files
committed
Minor bug fix and layout adjustment regarding --threading and standard output
1 parent 9e8a108 commit f9a135e

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

lib/core/common.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,9 +500,13 @@ def checkFile(filename):
500500

501501
if not os.path.exists(filename):
502502
raise sqlmapFilePathException, "unable to read file '%s'" % filename
503-
504-
def replaceNewlineTabs(inpStr):
505-
replacedString = inpStr.replace("\n", "__NEWLINE__").replace("\t", "__TAB__")
503+
504+
def replaceNewlineTabs(inpStr, stdout=False):
505+
if stdout:
506+
replacedString = inpStr.replace("\n", " ").replace("\t", " ")
507+
else:
508+
replacedString = inpStr.replace("\n", "__NEWLINE__").replace("\t", "__TAB__")
509+
506510
replacedString = replacedString.replace(temp.delimiter, "__DEL__")
507511

508512
return replacedString

lib/core/dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def string(self, header, data, sort=True):
7070
data = data.replace("__DEL__", ", ")
7171

7272
if "\n" in data:
73-
self.__write("%s:\n---\n%s---\n" % (header, data))
73+
self.__write("%s:\n---\n%s\n---\n" % (header, data))
7474
else:
7575
self.__write("%s: '%s'\n" % (header, data))
7676
else:

lib/techniques/blind/inference.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,22 @@ def downloadThread():
204204
count = 0
205205
for i in xrange(startCharIndex, endCharIndex):
206206
output += '_' if value[i] is None else value[i]
207+
207208
for i in xrange(length):
208209
count += 1 if value[i] is not None else 0
210+
209211
if startCharIndex > 0:
210212
output = '..' + output[2:]
213+
211214
if endCharIndex - startCharIndex == conf.progressWidth:
212215
output = output[:-2] + '..'
216+
213217
output += '_' * (min(length, conf.progressWidth) - len(output))
214218
status = ' %d/%d (%d%s)' % (count, length, round(100.0*count/length), '%')
215219
output += status if count != length else " "*len(status)
220+
216221
iolock.acquire()
217-
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), output))
222+
dataToStdout("\r[%s] [INFO] retrieved: %s" % (time.strftime("%X"), replaceNewlineTabs(output, stdout=True)))
218223
iolock.release()
219224

220225
except (sqlmapConnectionException, sqlmapValueException), errMsg:

lib/utils/resume.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from lib.core.common import dataToSessionFile
2828
from lib.core.common import safeStringFormat
2929
from lib.core.common import randomStr
30+
from lib.core.common import replaceNewlineTabs
3031
from lib.core.data import conf
3132
from lib.core.data import kb
3233
from lib.core.data import logger
@@ -113,6 +114,8 @@ def resume(expression, payload):
113114
if not resumedValue:
114115
return None
115116

117+
resumedValue = resumedValue.replace("__NEWLINE__", "\n").replace("__TAB__", "\t")
118+
116119
if resumedValue[-1] == "]":
117120
resumedValue = resumedValue[:-1]
118121

@@ -154,15 +157,15 @@ def resume(expression, payload):
154157
infoMsg += "%s" % resumedValue.split("\n")[0]
155158
logger.info(infoMsg)
156159

157-
dataToSessionFile("[%s][%s][%s][%s][%s]\n" % (conf.url, kb.injPlace, conf.parameters[kb.injPlace], expression, resumedValue))
160+
dataToSessionFile("[%s][%s][%s][%s][%s]\n" % (conf.url, kb.injPlace, conf.parameters[kb.injPlace], expression, replaceNewlineTabs(resumedValue)))
158161

159162
return resumedValue
160163
elif len(resumedValue) < int(length):
161164
infoMsg = "resumed from file '%s': " % conf.sessionFile
162165
infoMsg += "%s..." % resumedValue.split("\n")[0]
163166
logger.info(infoMsg)
164167

165-
dataToSessionFile("[%s][%s][%s][%s][%s" % (conf.url, kb.injPlace, conf.parameters[kb.injPlace], expression, resumedValue))
168+
dataToSessionFile("[%s][%s][%s][%s][%s" % (conf.url, kb.injPlace, conf.parameters[kb.injPlace], expression, replaceNewlineTabs(resumedValue)))
166169

167170
if select:
168171
newExpr = expression.replace(regExpr, safeStringFormat(substringQuery, (regExpr, len(resumedValue) + 1, int(length))), 1)

0 commit comments

Comments
 (0)