Skip to content

Commit d95dd2d

Browse files
committed
Preparation for an Issue sqlmapproject#254
1 parent 621ae58 commit d95dd2d

File tree

8 files changed

+36
-20
lines changed

8 files changed

+36
-20
lines changed

extra/shutils/_sqlmap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
'(--hex)'--hex'[Uses DBMS hex function(s) for data retrieval]' \
142142
'(--output-dir)'--output-dir=-'[Custom output directory path]:ODIR' \
143143
'(--parse-errors)'--parse-errors'[Parse and display DBMS error messages from responses]' \
144-
'(--replicate)'--replicate'[Replicate dumped data into a sqlite3 database]' \
145144
'(--save)'--save'[Save options to a configuration INI file]' \
146145
'(--tor)'--tor'[Use Tor anonymity network]' \
147146
'(--tor-port)'--tor-port=-'[Set Tor proxy port other than default]:TORPORT' \

lib/core/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"threads": 1,
2121
"level": 1,
2222
"risk": 1,
23+
"dumpFormat": "CSV",
2324
"tech": "BEUST",
2425
"torType": "HTTP"
2526
}

lib/core/dump.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from lib.core.data import logger
2727
from lib.core.dicts import DUMP_REPLACEMENTS
2828
from lib.core.enums import DBMS
29+
from lib.core.enums import DUMP_FORMAT
2930
from lib.core.exception import sqlmapGenericException
3031
from lib.core.exception import sqlmapValueException
3132
from lib.core.replication import Replication
@@ -330,7 +331,7 @@ def dbTableValues(self, tableValues):
330331
db = "All"
331332
table = tableValues["__infos__"]["table"]
332333

333-
if conf.replicate:
334+
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
334335
replication = Replication("%s%s%s.sqlite3" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db)))
335336
else:
336337
dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db))
@@ -357,7 +358,7 @@ def dbTableValues(self, tableValues):
357358
separator += "+"
358359
self._write("Database: %s\nTable: %s" % (db if db else "Current database", table))
359360

360-
if conf.replicate:
361+
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
361362
cols = []
362363

363364
for column in columns:
@@ -406,7 +407,7 @@ def dbTableValues(self, tableValues):
406407

407408
self._write("| %s%s" % (column, blank), newline=False)
408409

409-
if not conf.replicate:
410+
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
410411
if field == fields:
411412
dataToDumpFile(dumpFP, "%s" % safeCSValue(column))
412413
else:
@@ -416,10 +417,10 @@ def dbTableValues(self, tableValues):
416417

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

419-
if not conf.replicate:
420+
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
420421
dataToDumpFile(dumpFP, "\n")
421422

422-
if conf.replicate:
423+
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
423424
rtable.beginTransaction()
424425

425426
if count > TRIM_STDOUT_DUMP_SIZE:
@@ -451,28 +452,28 @@ def dbTableValues(self, tableValues):
451452
blank = " " * (maxlength - len(value))
452453
self._write("| %s%s" % (value, blank), newline=False, console=console)
453454

454-
if not conf.replicate:
455+
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
455456
if field == fields:
456457
dataToDumpFile(dumpFP, "%s" % safeCSValue(value))
457458
else:
458459
dataToDumpFile(dumpFP, "%s%s" % (safeCSValue(value), conf.csvDel))
459460

460461
field += 1
461462

462-
if conf.replicate:
463+
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
463464
try:
464465
rtable.insert(values)
465466
except sqlmapValueException:
466467
pass
467468

468469
self._write("|", console=console)
469470

470-
if not conf.replicate:
471+
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
471472
dataToDumpFile(dumpFP, "\n")
472473

473474
self._write("%s\n" % separator)
474475

475-
if conf.replicate:
476+
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
476477
rtable.endTransaction()
477478
logger.info("table '%s.%s' dumped to sqlite3 database '%s'" % (db, table, replication.dbpath))
478479

lib/core/enums.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ class PROXYTYPE:
124124
SOCKS4 = "SOCKS4"
125125
SOCKS5 = "SOCKS5"
126126

127+
class DUMP_FORMAT:
128+
CSV = "CSV"
129+
HTML = "HTML"
130+
SQLITE = "SQLITE"
131+
127132
class HTTPHEADER:
128133
ACCEPT = "Accept"
129134
ACCEPT_CHARSET = "Accept-Charset"

lib/core/option.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
from lib.core.dicts import DUMP_REPLACEMENTS
6464
from lib.core.enums import ADJUST_TIME_DELAY
6565
from lib.core.enums import CUSTOM_LOGGING
66+
from lib.core.enums import DUMP_FORMAT
6667
from lib.core.enums import HTTPHEADER
6768
from lib.core.enums import HTTPMETHOD
6869
from lib.core.enums import MOBILES
@@ -1409,6 +1410,12 @@ class _(unicode): pass
14091410
for _ in DUMP_REPLACEMENTS.keys():
14101411
del DUMP_REPLACEMENTS[_]
14111412

1413+
if conf.dumpFormat:
1414+
conf.dumpFormat = conf.dumpFormat.upper()
1415+
1416+
if conf.torType:
1417+
conf.torType = conf.torType.upper()
1418+
14121419
threadData = getCurrentThreadData()
14131420
threadData.reset()
14141421

@@ -1970,6 +1977,10 @@ def __basicOptionValidation():
19701977
errMsg = "option '--tor-type' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(PROXYTYPE, True))
19711978
raise sqlmapSyntaxException, errMsg
19721979

1980+
if conf.dumpFormat not in getPublicTypeMembers(DUMP_FORMAT, True):
1981+
errMsg = "option '--dump-format' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(DUMP_FORMAT, True))
1982+
raise sqlmapSyntaxException, errMsg
1983+
19731984
if conf.skip and conf.testParameter:
19741985
errMsg = "option '--skip' is incompatible with option '-p'"
19751986
raise sqlmapSyntaxException, errMsg

lib/core/optiondict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@
175175
"crawlDepth": "integer",
176176
"csvDel": "string",
177177
"dbmsCred": "string",
178+
"dumpFormat": "string",
178179
"eta": "boolean",
179180
"flushSession": "boolean",
180181
"forms": "boolean",
181182
"freshQueries": "boolean",
182183
"hexConvert": "boolean",
183184
"oDir": "string",
184185
"parseErrors": "boolean",
185-
"replicate": "boolean",
186186
"updateAll": "boolean",
187187
"tor": "boolean",
188188
"torPort": "integer",

lib/parse/cmdline.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,9 @@ def cmdLineParser():
547547
general.add_option("--dbms-cred", dest="dbmsCred",
548548
help="DBMS authentication credentials (user:password)")
549549

550+
general.add_option("--dump-format", dest="dumpFormat",
551+
help="Format of dumped data (CSV (default), HTML or SQLITE)")
552+
550553
general.add_option("--eta", dest="eta",
551554
action="store_true",
552555
help="Display for each output the "
@@ -576,10 +579,6 @@ def cmdLineParser():
576579
action="store_true",
577580
help="Parse and display DBMS error messages from responses")
578581

579-
general.add_option("--replicate", dest="replicate",
580-
action="store_true",
581-
help="Replicate dumped data into a sqlite3 database")
582-
583582
general.add_option("--save", dest="saveCmdline",
584583
action="store_true",
585584
help="Save options to a configuration INI file")
@@ -592,7 +591,7 @@ def cmdLineParser():
592591
help="Set Tor proxy port other than default")
593592

594593
general.add_option("--tor-type", dest="torType",
595-
help="Set Tor proxy type (HTTP - default, SOCKS4 or SOCKS5)")
594+
help="Set Tor proxy type (HTTP (default), SOCKS4 or SOCKS5)")
596595

597596
general.add_option("--update", dest="updateAll",
598597
action="store_true",

sqlmap.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,10 @@ csvDel = ,
599599
# Syntax: username:password
600600
dbmsCred =
601601

602+
# Format of dumped data
603+
# Valid: CSV, HTML or SQLITE
604+
dumpFormat = CSV
605+
602606
# Retrieve each query output length and calculate the estimated time of
603607
# arrival in real time.
604608
# Valid: True or False
@@ -627,10 +631,6 @@ oDir =
627631
# Valid: True or False
628632
parseErrors = False
629633

630-
# Replicate dumped data into a sqlite3 database.
631-
# Valid: True or False
632-
replicate = False
633-
634634
# Use Use Tor anonymity network.
635635
# Valid: True or False
636636
tor = False

0 commit comments

Comments
 (0)