Skip to content

Commit 910fccb

Browse files
committed
Fix for --dump-format=HTML with --start/--stop appending a whole new document
1 parent 2bfb538 commit 910fccb

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎lib/core/dump.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,17 @@ def dbTableValues(self, tableValues):
530530
else:
531531
count += 1
532532

533+
# Note: appending to HTML means adding rows to the existing table (i.e. not appending a whole new document)
534+
if appendToFile and conf.dumpFormat == DUMP_FORMAT.HTML:
535+
with openFile(dumpFileName, "r") as f:
536+
content = f.read()
537+
538+
if "</tbody>" in content:
539+
with openFile(dumpFileName, "w+") as f:
540+
f.write(content[:content.rindex("</tbody>")])
541+
else:
542+
appendToFile = False
543+
533544
self._dumpFiles[dumpFileName] = table
534545
dumpFP = openFile(dumpFileName, 'w' if not appendToFile else 'a', buffering=DUMP_FILE_BUFFER_SIZE)
535546

@@ -603,7 +614,7 @@ def dbTableValues(self, tableValues):
603614
cols.append((unsafeSQLIdentificatorNaming(column), colType if colType else Replication.TEXT))
604615

605616
rtable = replication.createTable(table, cols)
606-
elif conf.dumpFormat == DUMP_FORMAT.HTML:
617+
elif conf.dumpFormat == DUMP_FORMAT.HTML and not appendToFile:
607618
dataToDumpFile(dumpFP, "<!DOCTYPE html>\n<html>\n<head>\n")
608619
dataToDumpFile(dumpFP, "<meta http-equiv=\"Content-type\" content=\"text/html;charset=%s\">\n" % UNICODE_ENCODING)
609620
dataToDumpFile(dumpFP, "<meta name=\"generator\" content=\"%s\" />\n" % VERSION_STRING)
@@ -639,7 +650,7 @@ def dbTableValues(self, tableValues):
639650

640651
field += 1
641652

642-
if conf.dumpFormat == DUMP_FORMAT.HTML:
653+
if conf.dumpFormat == DUMP_FORMAT.HTML and not appendToFile:
643654
dataToDumpFile(dumpFP, "\n</tr>\n</thead>\n<tbody>\n")
644655

645656
self._write("|\n%s" % separator)

‎lib/core/settings.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from thirdparty import six
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.10.11.71"
22+
VERSION = "1.10.11.72"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

0 commit comments

Comments
 (0)