Adding switch --output-dir (Issue #53)

This commit is contained in:
Miroslav Stampar 2012-07-03 00:50:23 +02:00
parent 8eefe4b71f
commit 168aeadf76
6 changed files with 21 additions and 1 deletions

View File

@ -25,6 +25,7 @@ from lib.core.data import conf
from lib.core.data import kb from lib.core.data import kb
from lib.core.data import logger from lib.core.data import logger
from lib.core.enums import DBMS from lib.core.enums import DBMS
from lib.core.exception import sqlmapGenericException
from lib.core.exception import sqlmapValueException from lib.core.exception import sqlmapValueException
from lib.core.replication import Replication from lib.core.replication import Replication
from lib.core.settings import BLANK from lib.core.settings import BLANK
@ -61,7 +62,11 @@ class Dump:
def setOutputFile(self): def setOutputFile(self):
self._outputFile = "%s%slog" % (conf.outputPath, os.sep) self._outputFile = "%s%slog" % (conf.outputPath, os.sep)
try:
self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING) self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING)
except IOError, ex:
errMsg = "error occurred while opening log file ('%s')" % ex
raise sqlmapGenericException, errMsg
def getOutputFile(self): def getOutputFile(self):
return self._outputFile return self._outputFile

View File

@ -1374,6 +1374,9 @@ def __cleanupOptions():
if conf.torType: if conf.torType:
conf.torType = conf.torType.upper() conf.torType = conf.torType.upper()
if conf.oDir:
paths.SQLMAP_OUTPUT_PATH = conf.oDir
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
threadData.reset() threadData.reset()

View File

@ -173,6 +173,7 @@ optDict = {
"forms": "boolean", "forms": "boolean",
"freshQueries": "boolean", "freshQueries": "boolean",
"hexConvert": "boolean", "hexConvert": "boolean",
"oDir": "string",
"parseErrors": "boolean", "parseErrors": "boolean",
"replicate": "boolean", "replicate": "boolean",
"updateAll": "boolean", "updateAll": "boolean",

View File

@ -12,6 +12,10 @@ from subprocess import PIPE
from subprocess import Popen as execute from subprocess import Popen as execute
def getRevisionNumber(): def getRevisionNumber():
"""
Returns revision number in a GitHub style
"""
retVal = None retVal = None
filePath = None filePath = None

View File

@ -540,6 +540,10 @@ def cmdLineParser():
action="store_true", action="store_true",
help="Uses DBMS hex function(s) for data retrieval") help="Uses DBMS hex function(s) for data retrieval")
general.add_option("--output-dir", dest="oDir",
action="store",
help="Custom output directory path")
general.add_option("--parse-errors", dest="parseErrors", general.add_option("--parse-errors", dest="parseErrors",
action="store_true", action="store_true",
help="Parse and display DBMS error messages from responses") help="Parse and display DBMS error messages from responses")

View File

@ -596,6 +596,9 @@ freshQueries = False
# Valid: True or False # Valid: True or False
hexConvert = False hexConvert = False
# Custom output directory path.
oDir =
# Parse and display DBMS error messages from responses. # Parse and display DBMS error messages from responses.
# Valid: True or False # Valid: True or False
parseErrors = False parseErrors = False