mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-07 13:11:29 +00:00
Baby steps (2 to 3 at a time)
This commit is contained in:
@@ -95,7 +95,7 @@ class Database(object):
|
||||
self.cursor.execute(statement, arguments)
|
||||
else:
|
||||
self.cursor.execute(statement)
|
||||
except sqlite3.OperationalError, ex:
|
||||
except sqlite3.OperationalError as ex:
|
||||
if "locked" not in getSafeExString(ex):
|
||||
raise
|
||||
else:
|
||||
@@ -266,7 +266,7 @@ def setRestAPILog():
|
||||
try:
|
||||
conf.databaseCursor = Database(conf.database)
|
||||
conf.databaseCursor.connect("client")
|
||||
except sqlite3.OperationalError, ex:
|
||||
except sqlite3.OperationalError as ex:
|
||||
raise SqlmapConnectionException("%s ('%s')" % (ex, conf.database))
|
||||
|
||||
# Set a logging handler that writes log messages to a IPC database
|
||||
@@ -689,7 +689,7 @@ def server(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, adapter=REST
|
||||
eventlet.monkey_patch()
|
||||
logger.debug("Using adapter '%s' to run bottle" % adapter)
|
||||
run(host=host, port=port, quiet=True, debug=True, server=adapter)
|
||||
except socket.error, ex:
|
||||
except socket.error as ex:
|
||||
if "already in use" in getSafeExString(ex):
|
||||
logger.error("Address already in use ('%s:%s')" % (host, port))
|
||||
else:
|
||||
@@ -743,7 +743,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
|
||||
|
||||
try:
|
||||
_client(addr)
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
if not isinstance(ex, urllib2.HTTPError) or ex.code == httplib.UNAUTHORIZED:
|
||||
errMsg = "There has been a problem while connecting to the "
|
||||
errMsg += "REST-JSON API server at '%s' " % addr
|
||||
@@ -798,7 +798,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
|
||||
|
||||
try:
|
||||
argv = ["sqlmap.py"] + shlex.split(command)[1:]
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
logger.error("Error occurred while parsing arguments ('%s')" % ex)
|
||||
taskid = None
|
||||
continue
|
||||
|
||||
@@ -63,14 +63,14 @@ def crawl(target):
|
||||
try:
|
||||
if current:
|
||||
content = Request.getPage(url=current, crawling=True, raise404=False)[0]
|
||||
except SqlmapConnectionException, ex:
|
||||
except SqlmapConnectionException as ex:
|
||||
errMsg = "connection exception detected ('%s'). skipping " % getSafeExString(ex)
|
||||
errMsg += "URL '%s'" % current
|
||||
logger.critical(errMsg)
|
||||
except SqlmapSyntaxException:
|
||||
errMsg = "invalid URL detected. skipping '%s'" % current
|
||||
logger.critical(errMsg)
|
||||
except httplib.InvalidURL, ex:
|
||||
except httplib.InvalidURL as ex:
|
||||
errMsg = "invalid URL detected ('%s'). skipping " % getSafeExString(ex)
|
||||
errMsg += "URL '%s'" % current
|
||||
logger.critical(errMsg)
|
||||
@@ -138,7 +138,7 @@ def crawl(target):
|
||||
url = urlparse.urljoin(target, "/sitemap.xml")
|
||||
try:
|
||||
items = parseSitemap(url)
|
||||
except SqlmapConnectionException, ex:
|
||||
except SqlmapConnectionException as ex:
|
||||
if "page not found" in getSafeExString(ex):
|
||||
found = False
|
||||
logger.warn("'sitemap.xml' not found")
|
||||
|
||||
@@ -998,7 +998,7 @@ def dictionaryAttack(attack_dict):
|
||||
|
||||
kb.wordlists = dictPaths
|
||||
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
warnMsg = "there was a problem while loading dictionaries"
|
||||
warnMsg += " ('%s')" % getSafeExString(ex)
|
||||
logger.critical(warnMsg)
|
||||
|
||||
@@ -41,7 +41,7 @@ class HashDB(object):
|
||||
threadData.hashDBCursor = connection.cursor()
|
||||
threadData.hashDBCursor.execute("CREATE TABLE IF NOT EXISTS storage (id INTEGER PRIMARY KEY, value TEXT)")
|
||||
connection.commit()
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
errMsg = "error occurred while opening a session "
|
||||
errMsg += "file '%s' ('%s')" % (self.filepath, getSafeExString(ex))
|
||||
raise SqlmapConnectionException(errMsg)
|
||||
@@ -81,7 +81,7 @@ class HashDB(object):
|
||||
try:
|
||||
for row in self.cursor.execute("SELECT value FROM storage WHERE id=?", (hash_,)):
|
||||
retVal = row[0]
|
||||
except sqlite3.OperationalError, ex:
|
||||
except sqlite3.OperationalError as ex:
|
||||
if any(_ in getSafeExString(ex) for _ in ("locked", "no such table")):
|
||||
warnMsg = "problem occurred while accessing session file '%s' ('%s')" % (self.filepath, getSafeExString(ex))
|
||||
singleTimeWarnMessage(warnMsg)
|
||||
@@ -89,7 +89,7 @@ class HashDB(object):
|
||||
break
|
||||
else:
|
||||
raise
|
||||
except sqlite3.DatabaseError, ex:
|
||||
except sqlite3.DatabaseError as ex:
|
||||
errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, getSafeExString(ex))
|
||||
errMsg += "If the problem persists please rerun with '--flush-session'"
|
||||
raise SqlmapConnectionException(errMsg)
|
||||
@@ -141,7 +141,7 @@ class HashDB(object):
|
||||
self.cursor.execute("INSERT INTO storage VALUES (?, ?)", (hash_, value,))
|
||||
except sqlite3.IntegrityError:
|
||||
self.cursor.execute("UPDATE storage SET value=? WHERE id=?", (value, hash_,))
|
||||
except sqlite3.DatabaseError, ex:
|
||||
except sqlite3.DatabaseError as ex:
|
||||
if not os.path.exists(self.filepath):
|
||||
debugMsg = "session file '%s' does not exist" % self.filepath
|
||||
logger.debug(debugMsg)
|
||||
|
||||
@@ -175,7 +175,7 @@ def pivotDumpTable(table, colList, count=None, blind=True, alias=None):
|
||||
warnMsg += "will display partial output"
|
||||
logger.warn(warnMsg)
|
||||
|
||||
except SqlmapConnectionException, ex:
|
||||
except SqlmapConnectionException as ex:
|
||||
errMsg = "connection exception detected ('%s'). sqlmap " % getSafeExString(ex)
|
||||
errMsg += "will display partial output"
|
||||
|
||||
|
||||
@@ -79,5 +79,5 @@ def purge(directory):
|
||||
|
||||
try:
|
||||
shutil.rmtree(directory)
|
||||
except OSError, ex:
|
||||
except OSError as ex:
|
||||
logger.error("problem occurred while removing directory '%s' ('%s')" % (directory, getSafeExString(ex)))
|
||||
|
||||
@@ -54,7 +54,7 @@ def _search(dork):
|
||||
try:
|
||||
req = urllib2.Request("https://www.google.com/ncr", headers=headers)
|
||||
conn = urllib2.urlopen(req)
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
errMsg = "unable to connect to Google ('%s')" % getSafeExString(ex)
|
||||
raise SqlmapConnectionException(errMsg)
|
||||
|
||||
@@ -91,7 +91,7 @@ def _search(dork):
|
||||
except urllib2.HTTPError, e:
|
||||
try:
|
||||
page = e.read()
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
warnMsg = "problem occurred while trying to get "
|
||||
warnMsg += "an error page information (%s)" % getSafeExString(ex)
|
||||
logger.critical(warnMsg)
|
||||
@@ -183,7 +183,7 @@ def search(dork):
|
||||
|
||||
try:
|
||||
return _search(dork)
|
||||
except SqlmapBaseException, ex:
|
||||
except SqlmapBaseException as ex:
|
||||
if conf.proxyList:
|
||||
logger.critical(getSafeExString(ex))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user