Patch for an Issue #237

This commit is contained in:
Miroslav Stampar 2012-11-08 19:16:37 +01:00
parent e7e83defaa
commit 181c3534f0
6 changed files with 20 additions and 7 deletions

View File

@ -1408,6 +1408,9 @@ def __cleanupOptions():
for _ in DUMP_REPLACEMENTS.keys(): for _ in DUMP_REPLACEMENTS.keys():
del DUMP_REPLACEMENTS[_] del DUMP_REPLACEMENTS[_]
if conf.sessionFile:
conf.hashDBFile = conf.sessionFile
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
threadData.reset() threadData.reset()
@ -1450,7 +1453,6 @@ def __setConfAttributes():
conf.resultsFilename = None conf.resultsFilename = None
conf.resultsFP = None conf.resultsFP = None
conf.scheme = None conf.scheme = None
conf.sessionFP = None
conf.start = True conf.start = True
conf.tests = [] conf.tests = []
conf.trafficFP = None conf.trafficFP = None

View File

@ -16,6 +16,7 @@ optDict = {
"logFile": "string", "logFile": "string",
"bulkFile": "string", "bulkFile": "string",
"requestFile": "string", "requestFile": "string",
"sessionFile": "string",
"googleDork": "string", "googleDork": "string",
"configFile": "string" "configFile": "string"
}, },

View File

@ -483,9 +483,6 @@ def initTargetEnv():
""" """
if conf.multipleTargets: if conf.multipleTargets:
if conf.sessionFP:
conf.sessionFP.close()
if conf.hashDB: if conf.hashDB:
conf.hashDB.close() conf.hashDB.close()

View File

@ -58,6 +58,9 @@ def cmdLineParser():
target.add_option("-r", dest="requestFile", target.add_option("-r", dest="requestFile",
help="Load HTTP request from a file") help="Load HTTP request from a file")
target.add_option("-s", dest="sessionFile",
help="Load session from a stored (.sqlite) file")
target.add_option("-g", dest="googleDork", target.add_option("-g", dest="googleDork",
help="Process Google dork results as target urls") help="Process Google dork results as target urls")

View File

@ -15,6 +15,7 @@ from lib.core.common import getUnicode
from lib.core.common import serializeObject from lib.core.common import serializeObject
from lib.core.common import unserializeObject from lib.core.common import unserializeObject
from lib.core.data import logger from lib.core.data import logger
from lib.core.exception import sqlmapDataException
from lib.core.settings import HASHDB_FLUSH_RETRIES from lib.core.settings import HASHDB_FLUSH_RETRIES
from lib.core.settings import HASHDB_FLUSH_THRESHOLD from lib.core.settings import HASHDB_FLUSH_THRESHOLD
from lib.core.settings import UNICODE_ENCODING from lib.core.settings import UNICODE_ENCODING
@ -31,9 +32,14 @@ class HashDB(object):
threadData = getCurrentThreadData() threadData = getCurrentThreadData()
if threadData.hashDBCursor is None: if threadData.hashDBCursor is None:
connection = sqlite3.connect(self.filepath, timeout=3, isolation_level=None) try:
threadData.hashDBCursor = connection.cursor() connection = sqlite3.connect(self.filepath, timeout=3, isolation_level=None)
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)") threadData.hashDBCursor = connection.cursor()
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)")
except Exception, ex:
errMsg = "error occurred while opening a session "
errMsg += "file '%s' ('%s')" % (self.filepath, ex)
raise sqlmapDataException, errMsg
return threadData.hashDBCursor return threadData.hashDBCursor

View File

@ -22,6 +22,10 @@ logFile =
# Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme # Example (file content): POST /login.jsp HTTP/1.1\nHost: example.com\nUser-Agent: Mozilla/4.0\n\nuserid=joe&password=guessme
requestFile = requestFile =
# Load session from a stored (.sqlite) file
# Example: output/www.target.com/session.sqlite
sessionFile =
# Rather than providing a target url, let Google return target # Rather than providing a target url, let Google return target
# hosts as result of your Google dork expression. For a list of Google # hosts as result of your Google dork expression. For a list of Google
# dorks see Johnny Long Google Hacking Database at # dorks see Johnny Long Google Hacking Database at