Skip to content

Commit 058a9c5

Browse files
committed
fix for a bug noticed in a multi target run (log files weren't saved properly - removed buffering as it didn't produce any noticeable results)
1 parent f94ebe3 commit 058a9c5

4 files changed

Lines changed: 5 additions & 24 deletions

File tree

_sqlmap.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from lib.core.data import kb
3535
from lib.core.data import logger
3636
from lib.core.data import paths
37-
from lib.core.dump import dumper
3837
from lib.core.common import unhandledExceptionMessage
3938
from lib.core.exception import exceptionsTuple
4039
from lib.core.exception import sqlmapSilentQuitException
@@ -123,8 +122,6 @@ def main():
123122
except KeyboardInterrupt:
124123
pass
125124

126-
dumper.flush()
127-
128125
# Reference: http://stackoverflow.com/questions/1635080/terminate-a-multi-thread-python-program
129126
if conf.get("threads", 0) > 1 or conf.get("dnsServer", None):
130127
os._exit(0)

doc/THANKS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ David Alvarez <david.alvarez.s@gmail.com>
1515
Sergio Alves <sergioalexandre.alves@gmail.com>
1616
for reporting a bug
1717

18+
Thomas Anderson <darkc0de@live.com.ph>
19+
for reporting a bug
20+
1821
Chip Andrews <chip@sqlsecurity.com>
1922
for his excellent work maintaining the SQL Server versions database
2023
at SQLSecurity.com and permission to implement the update feature

lib/core/dump.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from lib.core.exception import sqlmapValueException
3131
from lib.core.replication import Replication
3232
from lib.core.settings import BLANK
33-
from lib.core.settings import BUFFERED_LOG_SIZE
3433
from lib.core.settings import NULL
3534
from lib.core.settings import TRIM_STDOUT_DUMP_SIZE
3635
from lib.core.settings import UNICODE_ENCODING
@@ -45,7 +44,6 @@ class Dump:
4544
def __init__(self):
4645
self._outputFile = None
4746
self._outputFP = None
48-
self._outputBP = None
4947
self._lock = threading.Lock()
5048

5149
def _write(self, data, n=True, console=True):
@@ -56,41 +54,27 @@ def _write(self, data, n=True, console=True):
5654
if kb.get("multiThreadMode"):
5755
self._lock.acquire()
5856

59-
self._outputBP.write(text)
60-
61-
if self._outputBP.tell() > BUFFERED_LOG_SIZE:
62-
self.flush()
57+
self._outputFP.write(text)
6358

6459
if kb.get("multiThreadMode"):
6560
self._lock.release()
6661

6762
kb.dataOutputFlag = True
6863

69-
def flush(self):
70-
if self._outputBP and self._outputFP and self._outputBP.tell() > 0:
71-
_ = self._outputBP.getvalue()
72-
self._outputBP.truncate(0)
73-
self._outputFP.write(_)
74-
7564
def _formatString(self, inpStr):
7665
return restoreDumpMarkedChars(getUnicode(inpStr))
7766

7867
def setOutputFile(self):
7968
self._outputFile = "%s%slog" % (conf.outputPath, os.sep)
8069
self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING)
81-
self._outputBP = StringIO.StringIO()
8270

8371
def getOutputFile(self):
84-
self.flush()
8572
return self._outputFile
8673

8774
def string(self, header, data, sort=True):
8875
if isinstance(data, (list, tuple, set)):
8976
self.lister(header, data, sort)
90-
91-
return
92-
93-
if data:
77+
elif data:
9478
data = self._formatString(getUnicode(data))
9579

9680
if data[-1] == '\n':

lib/core/settings.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,6 @@
467467
# Give up on hash recognition if nothing was found in first given number of rows
468468
HASH_RECOGNITION_QUIT_THRESHOLD = 10000
469469

470-
# Size of a buffer used for log file output
471-
BUFFERED_LOG_SIZE = 10000
472-
473470
# Maximum number of redirections to any single URL - this is needed because of the state that cookies introduce
474471
MAX_SINGLE_URL_REDIRECTIONS = 4
475472

0 commit comments

Comments
 (0)