Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 168aead

Browse files
committed
Adding switch --output-dir (Issue #53)
1 parent 8eefe4b commit 168aead

6 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/core/dump.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from lib.core.data import kb
2626
from lib.core.data import logger
2727
from lib.core.enums import DBMS
28+
from lib.core.exception import sqlmapGenericException
2829
from lib.core.exception import sqlmapValueException
2930
from lib.core.replication import Replication
3031
from lib.core.settings import BLANK
@@ -61,7 +62,11 @@ def _write(self, data, n=True, console=True):
6162

6263
def setOutputFile(self):
6364
self._outputFile = "%s%slog" % (conf.outputPath, os.sep)
64-
self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING)
65+
try:
66+
self._outputFP = codecs.open(self._outputFile, "ab", UNICODE_ENCODING)
67+
except IOError, ex:
68+
errMsg = "error occurred while opening log file ('%s')" % ex
69+
raise sqlmapGenericException, errMsg
6570

6671
def getOutputFile(self):
6772
return self._outputFile

lib/core/option.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,9 @@ class _(unicode): pass
13741374
if conf.torType:
13751375
conf.torType = conf.torType.upper()
13761376

1377+
if conf.oDir:
1378+
paths.SQLMAP_OUTPUT_PATH = conf.oDir
1379+
13771380
threadData = getCurrentThreadData()
13781381
threadData.reset()
13791382

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
"forms": "boolean",
174174
"freshQueries": "boolean",
175175
"hexConvert": "boolean",
176+
"oDir": "string",
176177
"parseErrors": "boolean",
177178
"replicate": "boolean",
178179
"updateAll": "boolean",

lib/core/revision.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
from subprocess import Popen as execute
1313

1414
def getRevisionNumber():
15+
"""
16+
Returns revision number in a GitHub style
17+
"""
18+
1519
retVal = None
1620
filePath = None
1721

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,10 @@ def cmdLineParser():
540540
action="store_true",
541541
help="Uses DBMS hex function(s) for data retrieval")
542542

543+
general.add_option("--output-dir", dest="oDir",
544+
action="store",
545+
help="Custom output directory path")
546+
543547
general.add_option("--parse-errors", dest="parseErrors",
544548
action="store_true",
545549
help="Parse and display DBMS error messages from responses")

sqlmap.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ freshQueries = False
596596
# Valid: True or False
597597
hexConvert = False
598598

599+
# Custom output directory path.
600+
oDir =
601+
599602
# Parse and display DBMS error messages from responses.
600603
# Valid: True or False
601604
parseErrors = False

0 commit comments

Comments
 (0)