mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-09 22:21:30 +00:00
Preparation for an Issue #254
This commit is contained in:
@@ -20,6 +20,7 @@ _defaults = {
|
||||
"threads": 1,
|
||||
"level": 1,
|
||||
"risk": 1,
|
||||
"dumpFormat": "CSV",
|
||||
"tech": "BEUST",
|
||||
"torType": "HTTP"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ from lib.core.data import kb
|
||||
from lib.core.data import logger
|
||||
from lib.core.dicts import DUMP_REPLACEMENTS
|
||||
from lib.core.enums import DBMS
|
||||
from lib.core.enums import DUMP_FORMAT
|
||||
from lib.core.exception import sqlmapGenericException
|
||||
from lib.core.exception import sqlmapValueException
|
||||
from lib.core.replication import Replication
|
||||
@@ -330,7 +331,7 @@ class Dump:
|
||||
db = "All"
|
||||
table = tableValues["__infos__"]["table"]
|
||||
|
||||
if conf.replicate:
|
||||
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||
replication = Replication("%s%s%s.sqlite3" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db)))
|
||||
else:
|
||||
dumpDbPath = "%s%s%s" % (conf.dumpPath, os.sep, unsafeSQLIdentificatorNaming(db))
|
||||
@@ -357,7 +358,7 @@ class Dump:
|
||||
separator += "+"
|
||||
self._write("Database: %s\nTable: %s" % (db if db else "Current database", table))
|
||||
|
||||
if conf.replicate:
|
||||
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||
cols = []
|
||||
|
||||
for column in columns:
|
||||
@@ -406,7 +407,7 @@ class Dump:
|
||||
|
||||
self._write("| %s%s" % (column, blank), newline=False)
|
||||
|
||||
if not conf.replicate:
|
||||
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
|
||||
if field == fields:
|
||||
dataToDumpFile(dumpFP, "%s" % safeCSValue(column))
|
||||
else:
|
||||
@@ -416,10 +417,10 @@ class Dump:
|
||||
|
||||
self._write("|\n%s" % separator)
|
||||
|
||||
if not conf.replicate:
|
||||
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
|
||||
dataToDumpFile(dumpFP, "\n")
|
||||
|
||||
if conf.replicate:
|
||||
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||
rtable.beginTransaction()
|
||||
|
||||
if count > TRIM_STDOUT_DUMP_SIZE:
|
||||
@@ -451,7 +452,7 @@ class Dump:
|
||||
blank = " " * (maxlength - len(value))
|
||||
self._write("| %s%s" % (value, blank), newline=False, console=console)
|
||||
|
||||
if not conf.replicate:
|
||||
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
|
||||
if field == fields:
|
||||
dataToDumpFile(dumpFP, "%s" % safeCSValue(value))
|
||||
else:
|
||||
@@ -459,7 +460,7 @@ class Dump:
|
||||
|
||||
field += 1
|
||||
|
||||
if conf.replicate:
|
||||
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||
try:
|
||||
rtable.insert(values)
|
||||
except sqlmapValueException:
|
||||
@@ -467,12 +468,12 @@ class Dump:
|
||||
|
||||
self._write("|", console=console)
|
||||
|
||||
if not conf.replicate:
|
||||
if conf.dumpFormat != DUMP_FORMAT.SQLITE:
|
||||
dataToDumpFile(dumpFP, "\n")
|
||||
|
||||
self._write("%s\n" % separator)
|
||||
|
||||
if conf.replicate:
|
||||
if conf.dumpFormat == DUMP_FORMAT.SQLITE:
|
||||
rtable.endTransaction()
|
||||
logger.info("table '%s.%s' dumped to sqlite3 database '%s'" % (db, table, replication.dbpath))
|
||||
|
||||
|
||||
@@ -124,6 +124,11 @@ class PROXYTYPE:
|
||||
SOCKS4 = "SOCKS4"
|
||||
SOCKS5 = "SOCKS5"
|
||||
|
||||
class DUMP_FORMAT:
|
||||
CSV = "CSV"
|
||||
HTML = "HTML"
|
||||
SQLITE = "SQLITE"
|
||||
|
||||
class HTTPHEADER:
|
||||
ACCEPT = "Accept"
|
||||
ACCEPT_CHARSET = "Accept-Charset"
|
||||
|
||||
@@ -63,6 +63,7 @@ from lib.core.dicts import DBMS_DICT
|
||||
from lib.core.dicts import DUMP_REPLACEMENTS
|
||||
from lib.core.enums import ADJUST_TIME_DELAY
|
||||
from lib.core.enums import CUSTOM_LOGGING
|
||||
from lib.core.enums import DUMP_FORMAT
|
||||
from lib.core.enums import HTTPHEADER
|
||||
from lib.core.enums import HTTPMETHOD
|
||||
from lib.core.enums import MOBILES
|
||||
@@ -1409,6 +1410,12 @@ def __cleanupOptions():
|
||||
for _ in DUMP_REPLACEMENTS.keys():
|
||||
del DUMP_REPLACEMENTS[_]
|
||||
|
||||
if conf.dumpFormat:
|
||||
conf.dumpFormat = conf.dumpFormat.upper()
|
||||
|
||||
if conf.torType:
|
||||
conf.torType = conf.torType.upper()
|
||||
|
||||
threadData = getCurrentThreadData()
|
||||
threadData.reset()
|
||||
|
||||
@@ -1970,6 +1977,10 @@ def __basicOptionValidation():
|
||||
errMsg = "option '--tor-type' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(PROXYTYPE, True))
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
if conf.dumpFormat not in getPublicTypeMembers(DUMP_FORMAT, True):
|
||||
errMsg = "option '--dump-format' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(DUMP_FORMAT, True))
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
if conf.skip and conf.testParameter:
|
||||
errMsg = "option '--skip' is incompatible with option '-p'"
|
||||
raise sqlmapSyntaxException, errMsg
|
||||
|
||||
@@ -175,6 +175,7 @@ optDict = {
|
||||
"crawlDepth": "integer",
|
||||
"csvDel": "string",
|
||||
"dbmsCred": "string",
|
||||
"dumpFormat": "string",
|
||||
"eta": "boolean",
|
||||
"flushSession": "boolean",
|
||||
"forms": "boolean",
|
||||
@@ -182,7 +183,6 @@ optDict = {
|
||||
"hexConvert": "boolean",
|
||||
"oDir": "string",
|
||||
"parseErrors": "boolean",
|
||||
"replicate": "boolean",
|
||||
"updateAll": "boolean",
|
||||
"tor": "boolean",
|
||||
"torPort": "integer",
|
||||
|
||||
Reference in New Issue
Block a user