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

Skip to content

Commit 181c353

Browse files
committed
Patch for an Issue #237
1 parent e7e83de commit 181c353

6 files changed

Lines changed: 20 additions & 7 deletions

File tree

lib/core/option.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,9 @@ class _(unicode): pass
14081408
for _ in DUMP_REPLACEMENTS.keys():
14091409
del DUMP_REPLACEMENTS[_]
14101410

1411+
if conf.sessionFile:
1412+
conf.hashDBFile = conf.sessionFile
1413+
14111414
threadData = getCurrentThreadData()
14121415
threadData.reset()
14131416

@@ -1450,7 +1453,6 @@ def __setConfAttributes():
14501453
conf.resultsFilename = None
14511454
conf.resultsFP = None
14521455
conf.scheme = None
1453-
conf.sessionFP = None
14541456
conf.start = True
14551457
conf.tests = []
14561458
conf.trafficFP = None

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"logFile": "string",
1717
"bulkFile": "string",
1818
"requestFile": "string",
19+
"sessionFile": "string",
1920
"googleDork": "string",
2021
"configFile": "string"
2122
},

lib/core/target.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,6 @@ def initTargetEnv():
483483
"""
484484

485485
if conf.multipleTargets:
486-
if conf.sessionFP:
487-
conf.sessionFP.close()
488-
489486
if conf.hashDB:
490487
conf.hashDB.close()
491488

lib/parse/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def cmdLineParser():
5858
target.add_option("-r", dest="requestFile",
5959
help="Load HTTP request from a file")
6060

61+
target.add_option("-s", dest="sessionFile",
62+
help="Load session from a stored (.sqlite) file")
63+
6164
target.add_option("-g", dest="googleDork",
6265
help="Process Google dork results as target urls")
6366

lib/utils/hashdb.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from lib.core.common import serializeObject
1616
from lib.core.common import unserializeObject
1717
from lib.core.data import logger
18+
from lib.core.exception import sqlmapDataException
1819
from lib.core.settings import HASHDB_FLUSH_RETRIES
1920
from lib.core.settings import HASHDB_FLUSH_THRESHOLD
2021
from lib.core.settings import UNICODE_ENCODING
@@ -31,9 +32,14 @@ def _get_cursor(self):
3132
threadData = getCurrentThreadData()
3233

3334
if threadData.hashDBCursor is None:
34-
connection = sqlite3.connect(self.filepath, timeout=3, isolation_level=None)
35-
threadData.hashDBCursor = connection.cursor()
36-
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)")
35+
try:
36+
connection = sqlite3.connect(self.filepath, timeout=3, isolation_level=None)
37+
threadData.hashDBCursor = connection.cursor()
38+
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)")
39+
except Exception, ex:
40+
errMsg = "error occurred while opening a session "
41+
errMsg += "file '%s' ('%s')" % (self.filepath, ex)
42+
raise sqlmapDataException, errMsg
3743

3844
return threadData.hashDBCursor
3945

sqlmap.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ logFile =
2222
# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme
2323
requestFile =
2424

25+
# Load session from a stored (.sqlite) file
26+
# Example: output/www.target.com/session.sqlite
27+
sessionFile =
28+
2529
# Rather than providing a target url, let Google return target
2630
# hosts as result of your Google dork expression. For a list of Google
2731
# dorks see Johnny Long Google Hacking Database at

0 commit comments

Comments
 (0)