Minor just in case update

This commit is contained in:
Miroslav Stampar 2016-01-12 10:27:04 +01:00
parent 9b716fcce9
commit eb989469f3
6 changed files with 20 additions and 18 deletions

View File

@ -1243,7 +1243,7 @@ def identifyWaf():
found = function(_) found = function(_)
except Exception, ex: except Exception, ex:
errMsg = "exception occurred while running " errMsg = "exception occurred while running "
errMsg += "WAF script for '%s' ('%s')" % (product, ex) errMsg += "WAF script for '%s' ('%s')" % (product, getSafeExString(ex))
logger.critical(errMsg) logger.critical(errMsg)
found = False found = False

View File

@ -853,7 +853,7 @@ def dataToTrafficFile(data):
conf.trafficFP.flush() conf.trafficFP.flush()
except IOError, ex: except IOError, ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to write to the traffic file '%s' ('%s')" % (conf.trafficFile, ex) errMsg += "to write to the traffic file '%s' ('%s')" % (conf.trafficFile, getSafeExString(ex))
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
def dataToDumpFile(dumpFile, data): def dataToDumpFile(dumpFile, data):
@ -1276,7 +1276,7 @@ def parseTargetUrl():
try: try:
urlSplit = urlparse.urlsplit(conf.url) urlSplit = urlparse.urlsplit(conf.url)
except ValueError, ex: except ValueError, ex:
errMsg = "invalid URL '%s' has been given ('%s'). " % (conf.url, ex) errMsg = "invalid URL '%s' has been given ('%s'). " % (conf.url, getSafeExString(ex))
errMsg += "Please be sure that you don't have any leftover characters (e.g. '[' or ']') " errMsg += "Please be sure that you don't have any leftover characters (e.g. '[' or ']') "
errMsg += "in the hostname part" errMsg += "in the hostname part"
raise SqlmapGenericException(errMsg) raise SqlmapGenericException(errMsg)
@ -1824,7 +1824,7 @@ def parseXmlFile(xmlFile, handler):
parse(stream, handler) parse(stream, handler)
except (SAXParseException, UnicodeError), ex: except (SAXParseException, UnicodeError), ex:
errMsg = "something seems to be wrong with " errMsg = "something seems to be wrong with "
errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, ex) errMsg += "the file '%s' ('%s'). Please make " % (xmlFile, getSafeExString(ex))
errMsg += "sure that you haven't made any changes to it" errMsg += "sure that you haven't made any changes to it"
raise SqlmapInstallationException, errMsg raise SqlmapInstallationException, errMsg
@ -1885,7 +1885,7 @@ def readCachedFileContent(filename, mode='rb'):
kb.cache.content[filename] = f.read() kb.cache.content[filename] = f.read()
except (IOError, OSError, MemoryError), ex: except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, ex) errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex))
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
return kb.cache.content[filename] return kb.cache.content[filename]
@ -2004,7 +2004,7 @@ def getFileItems(filename, commentPrefix='#', unicode_=True, lowercase=False, un
retVal.append(line) retVal.append(line)
except (IOError, OSError, MemoryError), ex: except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (filename, ex) errMsg += "to read the content of file '%s' ('%s')" % (filename, getSafeExString(ex))
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
return retVal if not unique else retVal.keys() return retVal if not unique else retVal.keys()

View File

@ -341,7 +341,7 @@ def _feedTargetsDict(reqFile, addedTargetUrls):
content = f.read() content = f.read()
except (IOError, OSError, MemoryError), ex: except (IOError, OSError, MemoryError), ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to read the content of file '%s' ('%s')" % (reqFile, ex) errMsg += "to read the content of file '%s' ('%s')" % (reqFile, getSafeExString(ex))
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
if conf.scope: if conf.scope:
@ -386,7 +386,7 @@ def _loadQueries():
tree.parse(paths.QUERIES_XML) tree.parse(paths.QUERIES_XML)
except Exception, ex: except Exception, ex:
errMsg = "something seems to be wrong with " errMsg = "something seems to be wrong with "
errMsg += "the file '%s' ('%s'). Please make " % (paths.QUERIES_XML, ex) errMsg += "the file '%s' ('%s'). Please make " % (paths.QUERIES_XML, getSafeExString(ex))
errMsg += "sure that you haven't made any changes to it" errMsg += "sure that you haven't made any changes to it"
raise SqlmapInstallationException, errMsg raise SqlmapInstallationException, errMsg
@ -501,7 +501,7 @@ def _setCrawler():
status = "%d/%d links visited (%d%%)" % (i + 1, len(targets), round(100.0 * (i + 1) / len(targets))) status = "%d/%d links visited (%d%%)" % (i + 1, len(targets), round(100.0 * (i + 1) / len(targets)))
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status), True) dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status), True)
except Exception, ex: except Exception, ex:
errMsg = "problem occurred while crawling at '%s' ('%s')" % (target, ex) errMsg = "problem occurred while crawling at '%s' ('%s')" % (target, getSafeExString(ex))
logger.error(errMsg) logger.error(errMsg)
def _doSearch(): def _doSearch():
@ -1098,7 +1098,7 @@ def _setHTTPHandlers():
try: try:
_ = urlparse.urlsplit(conf.proxy) _ = urlparse.urlsplit(conf.proxy)
except Exception, ex: except Exception, ex:
errMsg = "invalid proxy address '%s' ('%s')" % (conf.proxy, ex) errMsg = "invalid proxy address '%s' ('%s')" % (conf.proxy, getSafeExString(ex))
raise SqlmapSyntaxException, errMsg raise SqlmapSyntaxException, errMsg
hostnamePort = _.netloc.split(":") hostnamePort = _.netloc.split(":")
@ -2059,7 +2059,7 @@ def _saveConfig():
config.write(confFP) config.write(confFP)
except IOError, ex: except IOError, ex:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to write to the configuration file '%s' ('%s')" % (conf.saveConfig, ex) errMsg += "to write to the configuration file '%s' ('%s')" % (conf.saveConfig, getSafeExString(ex))
raise SqlmapSystemException(errMsg) raise SqlmapSystemException(errMsg)
infoMsg = "saved command line options to the configuration file '%s'" % conf.saveConfig infoMsg = "saved command line options to the configuration file '%s'" % conf.saveConfig
@ -2368,14 +2368,14 @@ def _basicOptionValidation():
try: try:
re.compile(conf.regexp) re.compile(conf.regexp)
except re.error, ex: except re.error, ex:
errMsg = "invalid regular expression '%s' ('%s')" % (conf.regexp, ex) errMsg = "invalid regular expression '%s' ('%s')" % (conf.regexp, getSafeExString(ex))
raise SqlmapSyntaxException(errMsg) raise SqlmapSyntaxException(errMsg)
if conf.crawlExclude: if conf.crawlExclude:
try: try:
re.compile(conf.crawlExclude) re.compile(conf.crawlExclude)
except re.error, ex: except re.error, ex:
errMsg = "invalid regular expression '%s' ('%s')" % (conf.crawlExclude, ex) errMsg = "invalid regular expression '%s' ('%s')" % (conf.crawlExclude, getSafeExString(ex))
raise SqlmapSyntaxException(errMsg) raise SqlmapSyntaxException(errMsg)
if conf.dumpTable and conf.dumpAll: if conf.dumpTable and conf.dumpAll:

View File

@ -14,6 +14,7 @@ import time
import urlparse import urlparse
from lib.core.common import Backend from lib.core.common import Backend
from lib.core.common import getSafeExString
from lib.core.common import getUnicode from lib.core.common import getUnicode
from lib.core.common import hashDBRetrieve from lib.core.common import hashDBRetrieve
from lib.core.common import intersect from lib.core.common import intersect
@ -658,7 +659,7 @@ def _createTargetDirs():
errMsg = "you don't have enough permissions " errMsg = "you don't have enough permissions "
else: else:
errMsg = "something went wrong while trying " errMsg = "something went wrong while trying "
errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, ex) errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, getSafeExString(ex))
raise SqlmapMissingPrivileges(errMsg) raise SqlmapMissingPrivileges(errMsg)

View File

@ -8,6 +8,7 @@ See the file 'doc/COPYING' for copying permission
import os import os
import zipfile import zipfile
from lib.core.common import getSafeExString
from lib.core.exception import SqlmapDataException from lib.core.exception import SqlmapDataException
from lib.core.exception import SqlmapInstallationException from lib.core.exception import SqlmapInstallationException
from lib.core.settings import UNICODE_ENCODING from lib.core.settings import UNICODE_ENCODING
@ -45,7 +46,7 @@ class Wordlist(object):
_ = zipfile.ZipFile(self.current, 'r') _ = zipfile.ZipFile(self.current, 'r')
except zipfile.error, ex: except zipfile.error, ex:
errMsg = "something seems to be wrong with " errMsg = "something seems to be wrong with "
errMsg += "the file '%s' ('%s'). Please make " % (self.current, ex) errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
errMsg += "sure that you haven't made any changes to it" errMsg += "sure that you haven't made any changes to it"
raise SqlmapInstallationException, errMsg raise SqlmapInstallationException, errMsg
if len(_.namelist()) == 0: if len(_.namelist()) == 0:
@ -71,7 +72,7 @@ class Wordlist(object):
retVal = self.iter.next().rstrip() retVal = self.iter.next().rstrip()
except zipfile.error, ex: except zipfile.error, ex:
errMsg = "something seems to be wrong with " errMsg = "something seems to be wrong with "
errMsg += "the file '%s' ('%s'). Please make " % (self.current, ex) errMsg += "the file '%s' ('%s'). Please make " % (self.current, getSafeExString(ex))
errMsg += "sure that you haven't made any changes to it" errMsg += "sure that you haven't made any changes to it"
raise SqlmapInstallationException, errMsg raise SqlmapInstallationException, errMsg
except StopIteration: except StopIteration:

View File

@ -41,7 +41,7 @@ class HashDB(object):
connection.commit() connection.commit()
except Exception, ex: except Exception, ex:
errMsg = "error occurred while opening a session " errMsg = "error occurred while opening a session "
errMsg += "file '%s' ('%s')" % (self.filepath, ex) errMsg += "file '%s' ('%s')" % (self.filepath, getSafeExString(ex))
raise SqlmapDataException(errMsg) raise SqlmapDataException(errMsg)
return threadData.hashDBCursor return threadData.hashDBCursor
@ -83,7 +83,7 @@ class HashDB(object):
if not "locked" in getSafeExString(ex): if not "locked" in getSafeExString(ex):
raise raise
except sqlite3.DatabaseError, ex: except sqlite3.DatabaseError, ex:
errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, ex) errMsg = "error occurred while accessing session file '%s' ('%s'). " % (self.filepath, getSafeExString(ex))
errMsg += "If the problem persists please rerun with `--flush-session`" errMsg += "If the problem persists please rerun with `--flush-session`"
raise SqlmapDataException, errMsg raise SqlmapDataException, errMsg
else: else: