From e4a3c015e599a3d691a95f8fd33291b5a13d24ed Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Thu, 3 Jan 2013 23:20:55 +0100 Subject: [PATCH] Replacing old and deprecated raise Exception style (PEP8) --- lib/controller/action.py | 2 +- lib/controller/checks.py | 10 +- lib/controller/controller.py | 6 +- lib/core/agent.py | 2 +- lib/core/common.py | 42 ++++---- lib/core/datatype.py | 2 +- lib/core/dump.py | 2 +- lib/core/option.py | 134 +++++++++++++------------- lib/core/replication.py | 4 +- lib/core/subprocessng.py | 2 +- lib/core/target.py | 10 +- lib/core/threads.py | 2 +- lib/core/wordlist.py | 2 +- lib/parse/configfile.py | 6 +- lib/request/basic.py | 2 +- lib/request/comparison.py | 2 +- lib/request/connect.py | 12 +-- lib/request/httpshandler.py | 2 +- lib/request/inject.py | 2 +- lib/request/proxy.py | 6 +- lib/request/rangehandler.py | 2 +- lib/request/redirecthandler.py | 2 +- lib/takeover/abstraction.py | 6 +- lib/takeover/metasploit.py | 12 +-- lib/takeover/xp_cmdshell.py | 2 +- lib/techniques/blind/inference.py | 2 +- lib/techniques/brute/use.py | 6 +- lib/techniques/dns/test.py | 2 +- lib/techniques/union/use.py | 4 +- lib/utils/google.py | 6 +- lib/utils/hashdb.py | 2 +- lib/utils/pivotdumptable.py | 2 +- plugins/dbms/access/connector.py | 6 +- plugins/dbms/access/filesystem.py | 4 +- plugins/dbms/access/syntax.py | 4 +- plugins/dbms/access/takeover.py | 8 +- plugins/dbms/db2/connector.py | 4 +- plugins/dbms/db2/syntax.py | 4 +- plugins/dbms/firebird/connector.py | 4 +- plugins/dbms/firebird/filesystem.py | 4 +- plugins/dbms/firebird/syntax.py | 4 +- plugins/dbms/firebird/takeover.py | 8 +- plugins/dbms/maxdb/connector.py | 2 +- plugins/dbms/maxdb/enumeration.py | 4 +- plugins/dbms/maxdb/filesystem.py | 4 +- plugins/dbms/maxdb/takeover.py | 8 +- plugins/dbms/mssqlserver/connector.py | 4 +- plugins/dbms/mysql/connector.py | 4 +- plugins/dbms/mysql/filesystem.py | 2 +- plugins/dbms/mysql/syntax.py | 2 +- plugins/dbms/oracle/connector.py | 4 +- plugins/dbms/oracle/enumeration.py | 2 +- plugins/dbms/oracle/filesystem.py | 4 +- plugins/dbms/oracle/syntax.py | 4 +- plugins/dbms/oracle/takeover.py | 8 +- plugins/dbms/postgresql/connector.py | 4 +- plugins/dbms/postgresql/filesystem.py | 4 +- plugins/dbms/postgresql/syntax.py | 4 +- plugins/dbms/postgresql/takeover.py | 2 +- plugins/dbms/sqlite/connector.py | 6 +- plugins/dbms/sqlite/enumeration.py | 2 +- plugins/dbms/sqlite/filesystem.py | 4 +- plugins/dbms/sqlite/syntax.py | 2 +- plugins/dbms/sqlite/takeover.py | 8 +- plugins/dbms/sybase/connector.py | 4 +- plugins/dbms/sybase/enumeration.py | 4 +- plugins/dbms/sybase/filesystem.py | 4 +- plugins/dbms/sybase/takeover.py | 8 +- plugins/generic/connector.py | 10 +- plugins/generic/databases.py | 8 +- plugins/generic/entries.py | 6 +- plugins/generic/filesystem.py | 8 +- plugins/generic/fingerprint.py | 6 +- plugins/generic/misc.py | 4 +- plugins/generic/search.py | 2 +- plugins/generic/syntax.py | 4 +- plugins/generic/takeover.py | 6 +- plugins/generic/users.py | 8 +- 78 files changed, 260 insertions(+), 260 deletions(-) diff --git a/lib/controller/action.py b/lib/controller/action.py index 09834b48a..72ec9a819 100644 --- a/lib/controller/action.py +++ b/lib/controller/action.py @@ -51,7 +51,7 @@ def action(): errMsg += ". Support for this DBMS will be implemented at " errMsg += "some point" - raise SqlmapUnsupportedDBMSException, errMsg + raise SqlmapUnsupportedDBMSException(errMsg) conf.dumper.singleString(conf.dbmsHandler.getFingerprint()) diff --git a/lib/controller/checks.py b/lib/controller/checks.py index 7d51faaf5..4706dca97 100644 --- a/lib/controller/checks.py +++ b/lib/controller/checks.py @@ -879,7 +879,7 @@ def checkStability(): kb.nullConnection = None else: errMsg = "Empty value supplied" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) elif test and test[0] in ("r", "R"): message = "please enter value for parameter 'regex': " @@ -896,7 +896,7 @@ def checkStability(): kb.nullConnection = None else: errMsg = "Empty value supplied" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) else: checkDynamicContent(firstPage, secondPage) @@ -1027,7 +1027,7 @@ def checkNullConnection(): except SqlmapConnectionException, errMsg: errMsg = getUnicode(errMsg) - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) return kb.nullConnection is not None @@ -1037,7 +1037,7 @@ def checkConnection(suppressOutput=False): socket.getaddrinfo(conf.hostname, None) except socket.gaierror: errMsg = "host '%s' does not exist" % conf.hostname - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) if not suppressOutput: infoMsg = "testing connection to the target url" @@ -1051,7 +1051,7 @@ def checkConnection(suppressOutput=False): if not kb.originalPage and wasLastRequestHTTPError(): errMsg = "unable to retrieve page content" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) elif wasLastRequestDBMSError(): warnMsg = "there is a DBMS error found in the HTTP response body " warnMsg += "which could interfere with the results of the tests" diff --git a/lib/controller/controller.py b/lib/controller/controller.py index 160a3d719..4d30140ad 100644 --- a/lib/controller/controller.py +++ b/lib/controller/controller.py @@ -117,7 +117,7 @@ def _selectInjection(): raise SqlmapUserQuitException else: errMsg = "invalid choice" - raise SqlmapValueException, errMsg + raise SqlmapValueException(errMsg) kb.injection = kb.injections[index] @@ -496,7 +496,7 @@ def start(): if kb.vainRun and not conf.multipleTargets: errMsg = "no parameter(s) found for testing in the provided data " errMsg += "(e.g. GET parameter 'id' in 'www.site.com/index.php?id=1')" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) else: errMsg = "all tested parameters appear to be not injectable." @@ -544,7 +544,7 @@ def start(): errMsg += "expression that you have choosen " errMsg += "does not match exclusively True responses" - raise SqlmapNotVulnerableException, errMsg + raise SqlmapNotVulnerableException(errMsg) else: # Flush the flag kb.testMode = False diff --git a/lib/core/agent.py b/lib/core/agent.py index 028dfa707..7027c64b8 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -252,7 +252,7 @@ class Agent(object): else: errMsg = "invalid usage of inference payload without " errMsg += "knowledge of underlying DBMS" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) return payload diff --git a/lib/core/common.py b/lib/core/common.py index 557065f0b..dc8a2ca51 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -736,7 +736,7 @@ def dataToTrafficFile(data): except IOError, ex: errMsg = "something went wrong while trying " errMsg += "to write to the traffic file '%s' ('%s')" % (conf.trafficFile, ex) - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def dataToDumpFile(dumpFile, data): dumpFile.write(data) @@ -861,7 +861,7 @@ def checkFile(filename): """ if not os.path.isfile(filename): - raise SqlmapFilePathException, "unable to read file '%s'" % filename + raise SqlmapFilePathException("unable to read file '%s'" % filename) def banner(): """ @@ -997,7 +997,7 @@ def parseTargetDirect(): errMsg = "invalid target details, valid syntax is for instance " errMsg += "'mysql://USER:PASSWORD@DBMS_IP:DBMS_PORT/DATABASE_NAME' " errMsg += "or 'access://DATABASE_FILEPATH'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) for dbmsName, data in DBMS_DICT.items(): if conf.dbms in data[0]: @@ -1012,7 +1012,7 @@ def parseTargetDirect(): conf.port = 0 elif not remote: errMsg = "missing remote connection details" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if dbmsName in (DBMS.MSSQL, DBMS.SYBASE): import _mssql @@ -1022,7 +1022,7 @@ def parseTargetDirect(): errMsg = "'%s' third-party library must be " % data[1] errMsg += "version >= 1.0.2 to work properly. " errMsg += "Download from '%s'" % data[2] - raise SqlmapMissingDependence, errMsg + raise SqlmapMissingDependence(errMsg) elif dbmsName == DBMS.MYSQL: import pymysql @@ -1040,7 +1040,7 @@ def parseTargetDirect(): errMsg = "sqlmap requires '%s' third-party library " % data[1] errMsg += "in order to directly connect to the database " errMsg += "%s. Download from '%s'" % (dbmsName, data[2]) - raise SqlmapMissingDependence, errMsg + raise SqlmapMissingDependence(errMsg) def parseTargetUrl(): """ @@ -1055,7 +1055,7 @@ def parseTargetUrl(): if re.search("\[.+\]", conf.url) and not socket.has_ipv6: errMsg = "IPv6 addressing is not supported " errMsg += "on this platform" - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) if not re.search("^http[s]*://", conf.url, re.I): if ":443/" in conf.url: @@ -1083,14 +1083,14 @@ def parseTargetUrl(): if any((_ is None, re.search(r'\s', conf.hostname), '..' in conf.hostname, conf.hostname.startswith('.'))): errMsg = "invalid target url" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if len(hostnamePort) == 2: try: conf.port = int(hostnamePort[1]) except: errMsg = "invalid target url" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) elif conf.scheme == "https": conf.port = 443 else: @@ -1353,7 +1353,7 @@ def safeStringFormat(format_, params): if count < len(params): retVal = retVal[:index] + getUnicode(params[count]) + retVal[index + 2:] else: - raise SqlmapNoneDataException, "wrong number of parameters during string formatting" + raise SqlmapNoneDataException("wrong number of parameters during string formatting") count += 1 return retVal @@ -2377,7 +2377,7 @@ def initTechnique(technique=None): errMsg = "missing data in old session file(s). " errMsg += "Please use '--flush-session' to deal " errMsg += "with this error" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) def arrayizeValue(value): """ @@ -2496,7 +2496,7 @@ def openFile(filename, mode='r'): errMsg += "Please check %s permissions on a file " % ("write" if \ mode and ('w' in mode or 'a' in mode or '+' in mode) else "read") errMsg += "and that it's not locked by another process." - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) def decodeIntToUnicode(value): """ @@ -2810,7 +2810,7 @@ def expandMnemonics(mnemonics, parser, args): if pointer in (None, head): errMsg = "mnemonic '%s' can't be resolved to any parameter name" % name - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) elif len(pointer.current) > 1: options = {} @@ -2849,7 +2849,7 @@ def expandMnemonics(mnemonics, parser, args): setattr(args, found.dest, True) else: errMsg = "mnemonic '%s' requires value of type '%s'" % (name, found.type) - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) def safeCSValue(value): """ @@ -2997,7 +2997,7 @@ def findPageForms(content, url, raise_=False, addToTargets=False): if not content: errMsg = "can't parse forms as the page content appears to be blank" if raise_: - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) else: logger.debug(errMsg) @@ -3017,7 +3017,7 @@ def findPageForms(content, url, raise_=False, addToTargets=False): except ParseError: errMsg = "no success" if raise_: - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) else: logger.debug(errMsg) @@ -3038,7 +3038,7 @@ def findPageForms(content, url, raise_=False, addToTargets=False): errMsg = "there has been a problem while " errMsg += "processing page forms ('%s')" % ex if raise_: - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) else: logger.debug(errMsg) else: @@ -3057,7 +3057,7 @@ def findPageForms(content, url, raise_=False, addToTargets=False): else: errMsg = "there were no forms found at the given target url" if raise_: - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) else: logger.debug(errMsg) @@ -3105,7 +3105,7 @@ def checkDeprecatedOptions(args): errMsg = "switch/option '%s' is deprecated" % _ if _ in DEPRECATED_HINTS: errMsg += " (hint: %s)" % DEPRECATED_HINTS[_] - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) def evaluateCode(code, variables=None): """ @@ -3118,7 +3118,7 @@ def evaluateCode(code, variables=None): raise except Exception, ex: errMsg = "an error occured while evaluating provided code ('%s'). " % ex - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def serializeObject(object_): """ @@ -3259,7 +3259,7 @@ def resetCookieJar(cookieJar): except cookielib.LoadError, msg: errMsg = "there was a problem loading " errMsg += "cookies file ('%s')" % msg - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def prioritySortColumns(columns): """ diff --git a/lib/core/datatype.py b/lib/core/datatype.py index 62a0762e6..032176027 100644 --- a/lib/core/datatype.py +++ b/lib/core/datatype.py @@ -38,7 +38,7 @@ class AttribDict(dict): try: return self.__getitem__(item) except KeyError: - raise SqlmapDataException, "unable to access item '%s'" % item + raise SqlmapDataException("unable to access item '%s'" % item) def __setattr__(self, item, value): """ diff --git a/lib/core/dump.py b/lib/core/dump.py index b5601f4d9..688e23718 100644 --- a/lib/core/dump.py +++ b/lib/core/dump.py @@ -70,7 +70,7 @@ class Dump(object): self._outputFP = codecs.open(self._outputFile, "ab" if not conf.flushSession else "wb", UNICODE_ENCODING) except IOError, ex: errMsg = "error occurred while opening log file ('%s')" % ex - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def getOutputFile(self): return self._outputFile diff --git a/lib/core/option.py b/lib/core/option.py index 660083a6f..fe745cf82 100644 --- a/lib/core/option.py +++ b/lib/core/option.py @@ -388,7 +388,7 @@ def _setMultipleTargets(): if not os.path.exists(conf.logFile): errMsg = "the specified list of targets does not exist" - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) if os.path.isfile(conf.logFile): _feedTargetsDict(conf.logFile, addedTargetUrls) @@ -406,7 +406,7 @@ def _setMultipleTargets(): else: errMsg = "the specified list of targets is not a file " errMsg += "nor a directory" - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) updatedTargetsCount = len(kb.targets) @@ -453,7 +453,7 @@ def _setRequestFromFile(): if not os.path.isfile(conf.requestFile): errMsg = "the specified HTTP request file " errMsg += "does not exist" - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) _feedTargetsDict(conf.requestFile, addedTargetUrls) @@ -504,7 +504,7 @@ def _setGoogleDorking(): if not links: errMsg = "unable to find results for your " errMsg += "Google dork expression" - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) for link in links: link = urldecode(link) @@ -560,7 +560,7 @@ def _setBulkMultipleTargets(): if not os.path.isfile(conf.bulkFile): errMsg = "the specified bulk file " errMsg += "does not exist" - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) for line in getFileItems(conf.bulkFile): if re.search(r"[^ ]+\?(.+)", line, re.I): @@ -597,7 +597,7 @@ def _setDBMSAuthentication(): if not match: errMsg = "DBMS authentication credentials value must be in format " errMsg += "username:password" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) conf.dbmsUsername = match.group(1) conf.dbmsPassword = match.group(2) @@ -638,7 +638,7 @@ def _setMetasploit(): errMsg += "if you want to perform a SMB relay attack because " errMsg += "it will need to listen on a user-specified SMB " errMsg += "TCP port for incoming connection attempts" - raise SqlmapMissingPrivileges, errMsg + raise SqlmapMissingPrivileges(errMsg) if conf.msfPath: for path in (conf.msfPath, os.path.join(conf.msfPath, "bin")): @@ -687,7 +687,7 @@ def _setMetasploit(): if not msfEnvPathExists: errMsg = "unable to locate Metasploit Framework installation. " errMsg += "You can get it at 'http://metasploit.com/framework/download/'" - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) def _setWriteFile(): if not conf.wFile: @@ -698,12 +698,12 @@ def _setWriteFile(): if not os.path.exists(conf.wFile): errMsg = "the provided local file '%s' does not exist" % conf.wFile - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) if not conf.dFile: errMsg = "you did not provide the back-end DBMS absolute path " errMsg += "where you want to write the local file '%s'" % conf.wFile - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) conf.wFileType = getFileType(conf.wFile) @@ -722,7 +722,7 @@ def _setOS(): errMsg += "If you do not know the back-end DBMS underlying OS, " errMsg += "do not provide it and sqlmap will fingerprint it for " errMsg += "you." - raise SqlmapUnsupportedDBMSException, errMsg + raise SqlmapUnsupportedDBMSException(errMsg) debugMsg = "forcing back-end DBMS operating system to user defined " debugMsg += "value '%s'" % conf.os @@ -742,7 +742,7 @@ def _setTechnique(): errMsg = "value for --technique must be a string composed " errMsg += "by the letters %s. Refer to the " % ", ".join(validLetters) errMsg += "user's manual for details" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) for validTech, validInt in validTechniques: if letter == validTech[0]: @@ -774,7 +774,7 @@ def _setDBMS(): errMsg += "system. The supported DBMS are %s. " % ', '.join([d for d in DBMS_DICT]) errMsg += "If you do not know the back-end DBMS, do not provide " errMsg += "it and sqlmap will fingerprint it for you." - raise SqlmapUnsupportedDBMSException, errMsg + raise SqlmapUnsupportedDBMSException(errMsg) for aliases in (MSSQL_ALIASES, MYSQL_ALIASES, PGSQL_ALIASES, ORACLE_ALIASES, \ SQLITE_ALIASES, ACCESS_ALIASES, FIREBIRD_ALIASES, \ @@ -808,11 +808,11 @@ def _setTamperingFunctions(): elif not os.path.exists(tfile): errMsg = "tamper script '%s' does not exist" % tfile - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) elif not tfile.endswith('.py'): errMsg = "tamper script '%s' should have an extension '.py'" % tfile - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) dirname, filename = os.path.split(tfile) dirname = os.path.abspath(dirname) @@ -823,7 +823,7 @@ def _setTamperingFunctions(): if not os.path.exists(os.path.join(dirname, '__init__.py')): errMsg = "make sure that there is an empty file '__init__.py' " errMsg += "inside of tamper scripts directory '%s'" % dirname - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) if dirname not in sys.path: sys.path.insert(0, dirname) @@ -831,7 +831,7 @@ def _setTamperingFunctions(): try: module = __import__(filename[:-3]) except ImportError, msg: - raise SqlmapSyntaxException, "cannot import tamper script '%s' (%s)" % (filename[:-3], msg) + raise SqlmapSyntaxException("cannot import tamper script '%s' (%s)" % (filename[:-3], msg)) priority = PRIORITY.NORMAL if not hasattr(module, '__priority__') else module.__priority__ @@ -866,7 +866,7 @@ def _setTamperingFunctions(): if not found: errMsg = "missing function 'tamper(payload, headers)' " errMsg += "in tamper script '%s'" % tfile - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) if resolve_priorities and priorities: priorities.sort(reverse=True) @@ -929,14 +929,14 @@ def _setHTTPProxy(): if not all((scheme, hasattr(PROXY_TYPE, scheme), hostname, port)): errMsg = "proxy value must be in format '(%s)://url:port'" % "|".join(_[0].lower() for _ in getPublicTypeMembers(PROXY_TYPE)) - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.pCred: _ = re.search("^(.*?):(.*?)$", conf.pCred) if not _: errMsg = "Proxy authentication credentials " errMsg += "value must be in format username:password" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) else: username = _.group(1) password = _.group(2) @@ -979,7 +979,7 @@ def _setSafeUrl(): if conf.saFreq <= 0: errMsg = "please provide a valid value (>0) for safe frequency (--safe-freq) while using safe url feature" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) def _setPrefixSuffix(): if conf.prefix is not None and conf.suffix is not None: @@ -1033,12 +1033,12 @@ def _setHTTPAuthentication(): elif conf.aType and not conf.aCred: errMsg = "you specified the HTTP authentication type, but " errMsg += "did not provide the credentials" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) elif not conf.aType and conf.aCred: errMsg = "you specified the HTTP authentication credentials, " errMsg += "but did not provide the type" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if not conf.aCert: debugMsg = "setting the HTTP authentication type and credentials" @@ -1049,7 +1049,7 @@ def _setHTTPAuthentication(): if aTypeLower not in ( "basic", "digest", "ntlm" ): errMsg = "HTTP authentication type value must be " errMsg += "Basic, Digest or NTLM" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) elif aTypeLower in ( "basic", "digest" ): regExp = "^(.*?):(.*?)$" errMsg = "HTTP %s authentication credentials " % aTypeLower @@ -1062,7 +1062,7 @@ def _setHTTPAuthentication(): aCredRegExp = re.search(regExp, conf.aCred) if not aCredRegExp: - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) conf.authUsername = aCredRegExp.group(1) conf.authPassword = aCredRegExp.group(2) @@ -1084,7 +1084,7 @@ def _setHTTPAuthentication(): errMsg = "sqlmap requires Python NTLM third-party library " errMsg += "in order to authenticate via NTLM, " errMsg += "http://code.google.com/p/python-ntlm/" - raise SqlmapMissingDependence, errMsg + raise SqlmapMissingDependence(errMsg) authHandler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(kb.passwordMgr) else: @@ -1096,7 +1096,7 @@ def _setHTTPAuthentication(): if not aCertRegExp: errMsg = "HTTP authentication certificate option " errMsg += "must be in format key_file,cert_file" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) # os.path.expanduser for support of paths with ~ key_file = os.path.expanduser(aCertRegExp.group(1)) @@ -1105,7 +1105,7 @@ def _setHTTPAuthentication(): for ifile in (key_file, cert_file): if not os.path.exists(ifile): errMsg = "File '%s' does not exist" % ifile - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) authHandler = HTTPSCertAuthHandler(key_file, cert_file) @@ -1134,7 +1134,7 @@ def _setHTTPExtraHeaders(): conf.httpHeaders.append((header, value)) else: errMsg = "invalid header value: %s. Valid header format is 'name:value'" % repr(headerValue).lstrip('u') - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) elif not conf.httpHeaders or len(conf.httpHeaders) == 1: conf.httpHeaders.append((HTTPHEADER.ACCEPT_LANGUAGE, "en-us,en;q=0.5")) @@ -1810,13 +1810,13 @@ def _setDNSServer(): except socket.error, msg: errMsg = "there was an error while setting up " errMsg += "DNS server instance ('%s')" % msg - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) else: errMsg = "you need to run sqlmap as an administrator " errMsg += "if you want to perform a DNS data exfiltration attack " errMsg += "as it will need to listen on privileged UDP port 53 " errMsg += "for incoming address resolution attempts" - raise SqlmapMissingPrivileges, errMsg + raise SqlmapMissingPrivileges(errMsg) def _setTorProxySettings(): if not conf.tor: @@ -1857,7 +1857,7 @@ def _setTorHttpProxySettings(): else: errMsg += "(e.g. http://www.coresec.org/2011/04/24/sqlmap-with-tor/)" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) if not conf.checkTor: warnMsg = "use switch '--check-tor' at " @@ -1886,7 +1886,7 @@ def _checkTor(): page, _, _ = Request.getPage(url="https://check.torproject.org/", raise404=False) if not page or 'Congratulations' not in page: errMsg = "it seems that Tor is not properly set. Please try using options '--tor-type' and/or '--tor-port'" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) else: infoMsg = "Tor is properly being used" logger.info(infoMsg) @@ -1894,135 +1894,135 @@ def _checkTor(): def _basicOptionValidation(): if conf.limitStart is not None and not (isinstance(conf.limitStart, int) and conf.limitStart > 0): errMsg = "value for option '--start' (limitStart) must be an integer value greater than zero (>0)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.limitStop is not None and not (isinstance(conf.limitStop, int) and conf.limitStop > 0): errMsg = "value for option '--stop' (limitStop) must be an integer value greater than zero (>0)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.level is not None and not (isinstance(conf.level, int) and conf.level > 0): errMsg = "value for option '--level' must be an integer value greater than zero (>0)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.risk is not None and not (isinstance(conf.risk, int) and conf.risk > 0): errMsg = "value for option '--risk' must be an integer value greater than zero (>0)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.limitStart is not None and isinstance(conf.limitStart, int) and conf.limitStart > 0 and \ conf.limitStop is not None and isinstance(conf.limitStop, int) and conf.limitStop < conf.limitStart: errMsg = "value for option '--start' (limitStart) must be smaller or equal than value for --stop (limitStop) option" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.firstChar is not None and isinstance(conf.firstChar, int) and conf.firstChar > 0 and \ conf.lastChar is not None and isinstance(conf.lastChar, int) and conf.lastChar < conf.firstChar: errMsg = "value for option '--first' (firstChar) must be smaller than or equal to value for --last (lastChar) option" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.cpuThrottle is not None and isinstance(conf.cpuThrottle, int) and (conf.cpuThrottle > 100 or conf.cpuThrottle < 0): errMsg = "value for option '--cpu-throttle' (cpuThrottle) must be in range [0,100]" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.textOnly and conf.nullConnection: errMsg = "switch '--text-only' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.titles and conf.nullConnection: errMsg = "switch '--titles' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.data and conf.nullConnection: errMsg = "option '--data' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.string and conf.nullConnection: errMsg = "option '--string' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.notString and conf.nullConnection: errMsg = "option '--not-string' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.string and conf.notString: errMsg = "option '--string' is incompatible with switch '--not-string'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.regexp and conf.nullConnection: errMsg = "option '--regexp' is incompatible with switch '--null-connection'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.dumpTable and conf.dumpAll: errMsg = "switch '--dump' is incompatible with switch '--dump-all'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.predictOutput and (conf.threads > 1 or conf.optimize): errMsg = "switch '--predict-output' is incompatible with option '--threads' and switch '-o'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.threads > MAX_NUMBER_OF_THREADS: errMsg = "maximum number of used threads is %d avoiding possible connection issues" % MAX_NUMBER_OF_THREADS - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.forms and not conf.url: errMsg = "switch '--forms' requires usage of option '-u' (--url)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.requestFile and conf.url: errMsg = "option '-r' is incompatible with option '-u' (--url)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.tor and conf.ignoreProxy: errMsg = "switch '--tor' is incompatible with switch '--ignore-proxy'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.tor and conf.proxy: errMsg = "switch '--tor' is incompatible with option '--proxy'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.checkTor and not any((conf.tor, conf.proxy)): errMsg = "switch '--check-tor' requires usage of switch '--tor' (or option '--proxy' with HTTP proxy address using Tor)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.torPort is not None and not (isinstance(conf.torPort, int) and conf.torPort > 0): errMsg = "value for option '--tor-port' must be a positive integer" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.torType not in getPublicTypeMembers(PROXY_TYPE, True): errMsg = "option '--tor-type' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(PROXY_TYPE, True)) - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.dumpFormat not in getPublicTypeMembers(DUMP_FORMAT, True): errMsg = "option '--dump-format' accepts one of following values: %s" % ", ".join(getPublicTypeMembers(DUMP_FORMAT, True)) - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.skip and conf.testParameter: errMsg = "option '--skip' is incompatible with option '-p'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.mobile and conf.agent: errMsg = "switch '--mobile' is incompatible with option '--user-agent'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.proxy and conf.ignoreProxy: errMsg = "option '--proxy' is incompatible with switch '--ignore-proxy'" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.forms and any([conf.logFile, conf.bulkFile, conf.direct, conf.requestFile, conf.googleDork]): errMsg = "switch '--forms' is compatible only with option '-u' (--url)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.timeSec < 1: errMsg = "value for option '--time-sec' must be a positive integer" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.uChar and not re.match(UNION_CHAR_REGEX, conf.uChar): errMsg = "value for option '--union-char' must be an alpha-numeric value (e.g. 1)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if isinstance(conf.uCols, basestring): if not conf.uCols.isdigit() and ("-" not in conf.uCols or len(conf.uCols.split("-")) != 2): errMsg = "value for option '--union-cols' must be a range with hyphon " errMsg += "(e.g. 1-10) or integer value (e.g. 5)" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.charset: _ = checkCharEncoding(conf.charset, False) @@ -2030,14 +2030,14 @@ def _basicOptionValidation(): errMsg = "unknown charset '%s'. Please visit " % conf.charset errMsg += "'%s' to get the full list of " % CODECS_LIST_PAGE errMsg += "supported charsets" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) else: conf.charset = _ if conf.loadCookies: if not os.path.exists(conf.loadCookies): errMsg = "cookies file '%s' does not exist" % conf.loadCookies - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) def _resolveCrossReferences(): lib.core.threads.readInput = readInput diff --git a/lib/core/replication.py b/lib/core/replication.py index 48e27c8ab..2c40af316 100644 --- a/lib/core/replication.py +++ b/lib/core/replication.py @@ -64,7 +64,7 @@ class Replication(object): self.execute('INSERT INTO "%s" VALUES (%s)' % (self.name, ','.join(['?']*len(values))), safechardecode(values)) else: errMsg = "wrong number of columns used in replicating insert" - raise SqlmapValueException, errMsg + raise SqlmapValueException(errMsg) def execute(self, sql, parameters=[]): try: @@ -73,7 +73,7 @@ class Replication(object): errMsg = "problem occurred ('%s') while accessing sqlite database " % ex errMsg += "located at '%s'. Please make sure that " % self.parent.dbpath errMsg += "it's not used by some other program" - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def beginTransaction(self): """ diff --git a/lib/core/subprocessng.py b/lib/core/subprocessng.py index 0edfd7385..da5232efd 100644 --- a/lib/core/subprocessng.py +++ b/lib/core/subprocessng.py @@ -40,7 +40,7 @@ def blockingReadFromFD(fd): break if not output: - raise EOFError, "fd %s has been closed." % fd + raise EOFError("fd %s has been closed." % fd ) return output diff --git a/lib/core/target.py b/lib/core/target.py index d8df227ee..b47891f0b 100644 --- a/lib/core/target.py +++ b/lib/core/target.py @@ -79,7 +79,7 @@ def _setRequestParams(): # Perform checks on POST parameters if conf.method == HTTPMETHOD.POST and conf.data is None: errMsg = "HTTP POST method depends on HTTP data value to be posted" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if conf.data is not None: conf.method = HTTPMETHOD.POST @@ -237,12 +237,12 @@ def _setRequestParams(): if not conf.parameters: errMsg = "you did not provide any GET, POST and Cookie " errMsg += "parameter, neither an User-Agent, Referer or Host header value" - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) elif not testableParameters: errMsg = "all testable parameters you provided are not present " errMsg += "within the GET, POST and Cookie parameters" - raise SqlmapGenericException, errMsg + raise SqlmapGenericException(errMsg) def _setHashDB(): """ @@ -259,7 +259,7 @@ def _setHashDB(): logger.info("flushing session file") except OSError, msg: errMsg = "unable to flush the session file (%s)" % msg - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) conf.hashDB = HashDB(conf.hashDBFile) @@ -460,7 +460,7 @@ def _createTargetDirs(): errMsg = "something went wrong while trying " errMsg += "to write to the output directory '%s' (%s)" % (paths.SQLMAP_OUTPUT_PATH, ex) - raise SqlmapMissingPrivileges, errMsg + raise SqlmapMissingPrivileges(errMsg) _createDumpDir() _createFilesDir() diff --git a/lib/core/threads.py b/lib/core/threads.py index 99c9c9b5a..528ba0aa3 100644 --- a/lib/core/threads.py +++ b/lib/core/threads.py @@ -165,7 +165,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio pass except KeyboardInterrupt: - raise SqlmapThreadException, "user aborted (Ctrl+C was pressed multiple times)" + raise SqlmapThreadException("user aborted (Ctrl+C was pressed multiple times)") if forwardException: raise diff --git a/lib/core/wordlist.py b/lib/core/wordlist.py index 54965a697..685bd841c 100644 --- a/lib/core/wordlist.py +++ b/lib/core/wordlist.py @@ -42,7 +42,7 @@ class Wordlist(object): _ = zipfile.ZipFile(current, 'r') if len(_.namelist()) == 0: errMsg = "no file(s) inside '%s'" % current - raise SqlmapDataException, errMsg + raise SqlmapDataException(errMsg) self.fp = _.open(_.namelist()[0]) else: self.fp = open(current, 'r') diff --git a/lib/parse/configfile.py b/lib/parse/configfile.py index 8b2c5955b..0e8264910 100644 --- a/lib/parse/configfile.py +++ b/lib/parse/configfile.py @@ -66,11 +66,11 @@ def configFileParser(configFile): config.readfp(configFP) except MissingSectionHeaderError: errMsg = "you have provided an invalid configuration file" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) if not config.has_section("Target"): errMsg = "missing a mandatory section 'Target' in the configuration file" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) condition = not config.has_option("Target", "url") condition &= not config.has_option("Target", "logFile") @@ -82,7 +82,7 @@ def configFileParser(configFile): if condition: errMsg = "missing a mandatory option in the configuration file " errMsg += "(url, logFile, bulkFile, googleDork, requestFile or wizard)" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) for family, optionData in optDict.items(): for option, datatype in optionData.items(): diff --git a/lib/request/basic.py b/lib/request/basic.py index c75ed64ef..320828e8d 100644 --- a/lib/request/basic.py +++ b/lib/request/basic.py @@ -199,7 +199,7 @@ def decodePage(page, contentEncoding, contentType): data = gzip.GzipFile("", "rb", 9, StringIO.StringIO(page)) size = struct.unpack(" MAX_CONNECTION_TOTAL_SIZE: - raise Exception, "size too large" + raise Exception("size too large") page = data.read() except Exception, msg: diff --git a/lib/request/comparison.py b/lib/request/comparison.py index 4ac7d7b68..5c8eb365d 100644 --- a/lib/request/comparison.py +++ b/lib/request/comparison.py @@ -92,7 +92,7 @@ def _comparison(page, headers, code, getRatioValue, pageLength): errMsg = "problem occured while retrieving original page content " errMsg += "which prevents sqlmap from continuation. Please rerun, " errMsg += "and if the problem persists turn off any optimization switches" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) ratio = 1. * pageLength / len(seqMatcher.a) diff --git a/lib/request/connect.py b/lib/request/connect.py index c100b8481..b6a186b83 100644 --- a/lib/request/connect.py +++ b/lib/request/connect.py @@ -466,11 +466,11 @@ class Connect(object): if e.code == httplib.UNAUTHORIZED: errMsg = "not authorized, try to provide right HTTP " errMsg += "authentication type and valid credentials (%d)" % code - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) elif e.code == httplib.NOT_FOUND: if raise404: errMsg = "page not found (%d)" % code - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) else: debugMsg = "page not found (%d)" % code logger.debug(debugMsg) @@ -488,7 +488,7 @@ class Connect(object): logger.critical(warnMsg) return None, None, None else: - raise SqlmapConnectionException, warnMsg + raise SqlmapConnectionException(warnMsg) else: debugMsg = "got HTTP error code: %d (%s)" % (code, status) logger.debug(debugMsg) @@ -498,7 +498,7 @@ class Connect(object): if "no host given" in tbMsg: warnMsg = "invalid url address used (%s)" % repr(url) - raise SqlmapSyntaxException, warnMsg + raise SqlmapSyntaxException(warnMsg) elif "forcibly closed" in tbMsg: warnMsg = "connection was forcibly closed by the target url" elif "timed out" in tbMsg: @@ -531,7 +531,7 @@ class Connect(object): logger.critical(warnMsg) return None, None, None else: - raise SqlmapConnectionException, warnMsg + raise SqlmapConnectionException(warnMsg) finally: page = page if isinstance(page, unicode) else getUnicode(page) @@ -600,7 +600,7 @@ class Connect(object): if not isinstance(payload, basestring): errMsg = "tamper function '%s' returns " % function.func_name errMsg += "invalid payload type ('%s')" % type(payload) - raise SqlmapValueException, errMsg + raise SqlmapValueException(errMsg) value = agent.replacePayload(value, payload) diff --git a/lib/request/httpshandler.py b/lib/request/httpshandler.py index 918c1c6c0..d4972c6b9 100644 --- a/lib/request/httpshandler.py +++ b/lib/request/httpshandler.py @@ -57,7 +57,7 @@ class HTTPSConnection(httplib.HTTPSConnection): logger.debug("SSL connection error occured ('%s')" % errMsg) if not success: - raise SqlmapConnectionException, "can't establish SSL connection" + raise SqlmapConnectionException("can't establish SSL connection") class HTTPSHandler(urllib2.HTTPSHandler): def https_open(self, req): diff --git a/lib/request/inject.py b/lib/request/inject.py index bab81c138..fa74bd8d2 100644 --- a/lib/request/inject.py +++ b/lib/request/inject.py @@ -394,7 +394,7 @@ def getValue(expression, blind=True, union=True, error=True, time=True, fromUser else: errMsg = "none of the injection types identified can be " errMsg += "leveraged to retrieve queries output" - raise SqlmapNotVulnerableException, errMsg + raise SqlmapNotVulnerableException(errMsg) finally: kb.resumeValues = True diff --git a/lib/request/proxy.py b/lib/request/proxy.py index 5b72ef721..7fc32b506 100644 --- a/lib/request/proxy.py +++ b/lib/request/proxy.py @@ -25,7 +25,7 @@ class ProxyHTTPConnection(httplib.HTTPConnection): proto, rest = urllib.splittype(url) if proto is None: - raise ValueError, "unknown URL type: %s" % url + raise ValueError("unknown URL type: %s" % url) # Get host host, rest = urllib.splithost(rest) @@ -38,7 +38,7 @@ class ProxyHTTPConnection(httplib.HTTPConnection): try: port = self._ports[proto] except KeyError: - raise ValueError, "unknown protocol for: %s" % url + raise ValueError("unknown protocol for: %s" % url) self._real_host = host self._real_port = int(port) @@ -117,4 +117,4 @@ else: class ProxyHTTPSHandler: def __init__(self, *args, **kwargs): errMsg = "unsupported feature on versions of Python before 2.6" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/lib/request/rangehandler.py b/lib/request/rangehandler.py index 4ec6d821c..3b421cc59 100644 --- a/lib/request/rangehandler.py +++ b/lib/request/rangehandler.py @@ -47,4 +47,4 @@ class HTTPRangeHandler(urllib2.BaseHandler): def http_error_416(self, req, fp, code, msg, hdrs): # HTTP's Range Not Satisfiable error errMsg = "Invalid range" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) diff --git a/lib/request/redirecthandler.py b/lib/request/redirecthandler.py index d6ea03e5c..8988e6588 100644 --- a/lib/request/redirecthandler.py +++ b/lib/request/redirecthandler.py @@ -110,4 +110,4 @@ class SmartRedirectHandler(urllib2.HTTPRedirectHandler): if hasattr(req, 'redirect_dict') and (req.redirect_dict.get(req.get_full_url(), 0) >= MAX_SINGLE_URL_REDIRECTIONS or len(req.redirect_dict) >= MAX_TOTAL_REDIRECTIONS): errMsg = "infinite redirect loop detected (%s). " % ", ".join(item for item in req.redirect_dict.keys()) errMsg += "please check all provided parameters and/or provide missing ones." - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) diff --git a/lib/takeover/abstraction.py b/lib/takeover/abstraction.py index 62c480195..0ce567909 100644 --- a/lib/takeover/abstraction.py +++ b/lib/takeover/abstraction.py @@ -49,7 +49,7 @@ class Abstraction(Web, UDF, Xp_cmdshell): else: errMsg = "Feature not yet implemented for the back-end DBMS" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def evalCmd(self, cmd, first=None, last=None): retVal = None @@ -65,7 +65,7 @@ class Abstraction(Web, UDF, Xp_cmdshell): else: errMsg = "Feature not yet implemented for the back-end DBMS" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) return safechardecode(retVal) @@ -110,7 +110,7 @@ class Abstraction(Web, UDF, Xp_cmdshell): else: errMsg = "feature not yet implemented for the back-end DBMS" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) infoMsg = "calling %s OS shell. To quit type " % (Backend.getOs() or "Windows") infoMsg += "'x' or 'q' and press ENTER" diff --git a/lib/takeover/metasploit.py b/lib/takeover/metasploit.py index 5adc87585..da78210fb 100644 --- a/lib/takeover/metasploit.py +++ b/lib/takeover/metasploit.py @@ -280,7 +280,7 @@ class Metasploit: return None else: - raise SqlmapDataException, "unexpected connection type" + raise SqlmapDataException("unexpected connection type") def _selectLhost(self): if self.connectionStr.startswith("reverse"): @@ -296,7 +296,7 @@ class Metasploit: return None else: - raise SqlmapDataException, "unexpected connection type" + raise SqlmapDataException("unexpected connection type") def _selectConnection(self): return self._skeletonSelection("connection type", self._msfConnectionsList) @@ -320,7 +320,7 @@ class Metasploit: elif self.connectionStr.startswith("reverse"): self._cliCmd += " LHOST=%s" % self.lhostStr else: - raise SqlmapDataException, "unexpected connection type" + raise SqlmapDataException("unexpected connection type") if Backend.isOs(OS.WINDOWS) and self.payloadStr == "windows/vncinject": self._cliCmd += " DisableCourtesyShell=true" @@ -341,7 +341,7 @@ class Metasploit: elif self.connectionStr.startswith("reverse"): self._cliCmd += " LHOST=%s" % self.lhostStr else: - raise SqlmapDataException, "unexpected connection type" + raise SqlmapDataException("unexpected connection type") self._cliCmd += " E" @@ -353,7 +353,7 @@ class Metasploit: if self.connectionStr.startswith("reverse"): self._payloadCmd += " LHOST=%s" % self.lhostStr elif not self.connectionStr.startswith("bind"): - raise SqlmapDataException, "unexpected connection type" + raise SqlmapDataException("unexpected connection type") if Backend.isOs(OS.LINUX) and conf.privEsc: self._payloadCmd += " PrependChrootBreak=true PrependSetuid=true" @@ -525,7 +525,7 @@ class Metasploit: logger.debug(debugMsg) else: errMsg = "failed to create the shellcode (%s)" % payloadStderr.replace("\n", " ").replace("\r", "") - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) self._shellcodeFP = open(self._shellcodeFilePath, "rb") self.shellcodeString = self._shellcodeFP.read() diff --git a/lib/takeover/xp_cmdshell.py b/lib/takeover/xp_cmdshell.py index d75612d0f..a1c3ef02a 100644 --- a/lib/takeover/xp_cmdshell.py +++ b/lib/takeover/xp_cmdshell.py @@ -276,7 +276,7 @@ class Xp_cmdshell: if not kb.xpCmdshellAvailable: errMsg = "unable to proceed without xp_cmdshell" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) debugMsg = "creating a support table to write commands standard " debugMsg += "output to" diff --git a/lib/techniques/blind/inference.py b/lib/techniques/blind/inference.py index fb50bbc44..c5aebfc98 100644 --- a/lib/techniques/blind/inference.py +++ b/lib/techniques/blind/inference.py @@ -549,7 +549,7 @@ def bisection(payload, expression, length=None, charsetType=None, firstChar=None logger.info(infoMsg) if kb.threadException: - raise SqlmapThreadException, "something unexpected happened inside the threads" + raise SqlmapThreadException("something unexpected happened inside the threads") if abortedFlag: raise KeyboardInterrupt diff --git a/lib/techniques/brute/use.py b/lib/techniques/brute/use.py index d438ea50d..47a086738 100644 --- a/lib/techniques/brute/use.py +++ b/lib/techniques/brute/use.py @@ -53,7 +53,7 @@ def tableExists(tableFile, regex=None): errMsg = "can't use table existence check because of detected invalid results " errMsg += "(most probably caused by inability of the used injection " errMsg += "to distinguish errornous results)" - raise SqlmapDataException, errMsg + raise SqlmapDataException(errMsg) tables = getFileItems(tableFile, lowercase=Backend.getIdentifiedDbms() in (DBMS.ACCESS,), unique=True) @@ -138,14 +138,14 @@ def tableExists(tableFile, regex=None): def columnExists(columnFile, regex=None): if not conf.tbl: errMsg = "missing table parameter" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) result = inject.checkBooleanExpression(safeStringFormat(BRUTE_COLUMN_EXISTS_TEMPLATE, (randomStr(), randomStr()))) if result: errMsg = "can't use column existence check because of detected invalid results " errMsg += "(most probably caused by inability of the used injection " errMsg += "to distinguish errornous results)" - raise SqlmapDataException, errMsg + raise SqlmapDataException(errMsg) infoMsg = "checking column existence using items from '%s'" % columnFile logger.info(infoMsg) diff --git a/lib/techniques/dns/test.py b/lib/techniques/dns/test.py index 529f5e0a2..bdb8a21c7 100644 --- a/lib/techniques/dns/test.py +++ b/lib/techniques/dns/test.py @@ -28,7 +28,7 @@ def dnsTest(payload): errMsg += ". Turning off DNS exfiltration support" logger.error(errMsg) else: - raise SqlmapNotVulnerableException, errMsg + raise SqlmapNotVulnerableException(errMsg) else: infoMsg = "data retrieval through DNS channel was successful" logger.info(infoMsg) diff --git a/lib/techniques/union/use.py b/lib/techniques/union/use.py index c047e92c4..3233be39b 100644 --- a/lib/techniques/union/use.py +++ b/lib/techniques/union/use.py @@ -128,14 +128,14 @@ def configUnion(char=None, columns=None): colsStart, colsStop = columns, columns if not colsStart.isdigit() or not colsStop.isdigit(): - raise SqlmapSyntaxException, "--union-cols must be a range of integers" + raise SqlmapSyntaxException("--union-cols must be a range of integers") conf.uColsStart, conf.uColsStop = int(colsStart), int(colsStop) if conf.uColsStart > conf.uColsStop: errMsg = "--union-cols range has to be from lower to " errMsg += "higher number of columns" - raise SqlmapSyntaxException, errMsg + raise SqlmapSyntaxException(errMsg) _configUnionChar(char) _configUnionCols(conf.uCols or columns) diff --git a/lib/utils/google.py b/lib/utils/google.py index 912ca7269..b47e104d7 100644 --- a/lib/utils/google.py +++ b/lib/utils/google.py @@ -44,7 +44,7 @@ class Google(object): e.info() except urllib2.URLError: errMsg = "unable to connect to Google" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) def search(self, dork): """ @@ -94,13 +94,13 @@ class Google(object): return None except (urllib2.URLError, socket.error, socket.timeout): errMsg = "unable to connect to Google" - raise SqlmapConnectionException, errMsg + raise SqlmapConnectionException(errMsg) retVal = [urllib.unquote(match.group(1)) for match in re.finditer(GOOGLE_REGEX, page, re.I | re.S)] if not retVal and "detected unusual traffic" in page: warnMsg = "Google has detected 'unusual' traffic from " warnMsg += "this computer disabling further searches" - raise SqlmapGenericException, warnMsg + raise SqlmapGenericException(warnMsg) return retVal diff --git a/lib/utils/hashdb.py b/lib/utils/hashdb.py index 8a4ca4ecc..f527d28c2 100644 --- a/lib/utils/hashdb.py +++ b/lib/utils/hashdb.py @@ -39,7 +39,7 @@ class HashDB(object): except Exception, ex: errMsg = "error occurred while opening a session " errMsg += "file '%s' ('%s')" % (self.filepath, ex) - raise SqlmapDataException, errMsg + raise SqlmapDataException(errMsg) return threadData.hashDBCursor diff --git a/lib/utils/pivotdumptable.py b/lib/utils/pivotdumptable.py index 694f38008..a48f87903 100644 --- a/lib/utils/pivotdumptable.py +++ b/lib/utils/pivotdumptable.py @@ -83,7 +83,7 @@ def pivotDumpTable(table, colList, count=None, blind=True): if not validColumnList: errMsg = "all column name(s) provided are non-existent" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) if not validPivotValue: warnMsg = "no proper pivot column provided (with unique values)." diff --git a/plugins/dbms/access/connector.py b/plugins/dbms/access/connector.py index 673732d83..e7334edeb 100644 --- a/plugins/dbms/access/connector.py +++ b/plugins/dbms/access/connector.py @@ -35,7 +35,7 @@ class Connector(GenericConnector): if not IS_WIN: errMsg = "currently, direct connection to Microsoft Access database(s) " errMsg += "is restricted to Windows platforms" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) self.initConnection() self.checkFileDb() @@ -43,7 +43,7 @@ class Connector(GenericConnector): try: self.connector = pyodbc.connect('Driver={Microsoft Access Driver (*.mdb)};Dbq=%s;Uid=Admin;Pwd=;' % self.db) except (pyodbc.Error, pyodbc.OperationalError), msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.setCursor() self.connected() @@ -61,7 +61,7 @@ class Connector(GenericConnector): except (pyodbc.OperationalError, pyodbc.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except pyodbc.Error, msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.connector.commit() diff --git a/plugins/dbms/access/filesystem.py b/plugins/dbms/access/filesystem.py index 16797211f..c537952cb 100644 --- a/plugins/dbms/access/filesystem.py +++ b/plugins/dbms/access/filesystem.py @@ -14,8 +14,8 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "on Microsoft Access it is not possible to read files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "on Microsoft Access it is not possible to write files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/access/syntax.py b/plugins/dbms/access/syntax.py index 627673b51..6d40b5647 100644 --- a/plugins/dbms/access/syntax.py +++ b/plugins/dbms/access/syntax.py @@ -24,7 +24,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index old = "'%s'" % expression[firstIndex:lastIndex] @@ -56,7 +56,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find(")") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/access/takeover.py b/plugins/dbms/access/takeover.py index 41be6551a..e842e60b7 100644 --- a/plugins/dbms/access/takeover.py +++ b/plugins/dbms/access/takeover.py @@ -14,18 +14,18 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "on Microsoft Access it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "on Microsoft Access it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "on Microsoft Access it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "on Microsoft Access it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/db2/connector.py b/plugins/dbms/db2/connector.py index 0af5f72aa..d80e1d026 100644 --- a/plugins/dbms/db2/connector.py +++ b/plugins/dbms/db2/connector.py @@ -35,7 +35,7 @@ class Connector(GenericConnector): database = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=%s;HOSTNAME=%s;PORT=%s;PROTOCOL=TCPIP;" % (self.db, self.hostname, self.port) self.connector = ibm_db_dbi.connect(database, self.user, self.password) except ibm_db_dbi.OperationalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.setCursor() @@ -54,7 +54,7 @@ class Connector(GenericConnector): except (ibm_db_dbi.OperationalError, ibm_db_dbi.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except ibm_db_dbi.InternalError, msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.connector.commit() diff --git a/plugins/dbms/db2/syntax.py b/plugins/dbms/db2/syntax.py index b3d3b58ab..f666494e3 100644 --- a/plugins/dbms/db2/syntax.py +++ b/plugins/dbms/db2/syntax.py @@ -25,7 +25,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index old = "'%s'" % expression[firstIndex:lastIndex] @@ -55,7 +55,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find(")") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/firebird/connector.py b/plugins/dbms/firebird/connector.py index 00e0419c5..5eebaeac0 100644 --- a/plugins/dbms/firebird/connector.py +++ b/plugins/dbms/firebird/connector.py @@ -42,7 +42,7 @@ class Connector(GenericConnector): self.connector = kinterbasdb.connect(host=self.hostname.encode(UNICODE_ENCODING), database=self.db.encode(UNICODE_ENCODING), \ user=self.user.encode(UNICODE_ENCODING), password=self.password.encode(UNICODE_ENCODING), charset="UTF8") #http://www.daniweb.com/forums/thread248499.html except kinterbasdb.OperationalError, msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.setCursor() self.connected() @@ -59,7 +59,7 @@ class Connector(GenericConnector): except kinterbasdb.OperationalError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except kinterbasdb.Error, msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.connector.commit() diff --git a/plugins/dbms/firebird/filesystem.py b/plugins/dbms/firebird/filesystem.py index 732a1f89a..2f61cfc07 100644 --- a/plugins/dbms/firebird/filesystem.py +++ b/plugins/dbms/firebird/filesystem.py @@ -14,8 +14,8 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "on Firebird it is not possible to read files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "on Firebird it is not possible to write files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/firebird/syntax.py b/plugins/dbms/firebird/syntax.py index a8e66242b..001eb0bbe 100644 --- a/plugins/dbms/firebird/syntax.py +++ b/plugins/dbms/firebird/syntax.py @@ -26,7 +26,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index old = "'%s'" % expression[firstIndex:lastIndex] @@ -58,7 +58,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find(")") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/firebird/takeover.py b/plugins/dbms/firebird/takeover.py index b41d27770..536b5c350 100644 --- a/plugins/dbms/firebird/takeover.py +++ b/plugins/dbms/firebird/takeover.py @@ -14,18 +14,18 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "on Firebird it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "on Firebird it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "on Firebird it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "on Firebird it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/maxdb/connector.py b/plugins/dbms/maxdb/connector.py index af2a015f8..9dfc3200b 100644 --- a/plugins/dbms/maxdb/connector.py +++ b/plugins/dbms/maxdb/connector.py @@ -15,4 +15,4 @@ class Connector(GenericConnector): def connect(self): errMsg = "on SAP MaxDB it is not possible to establish a " errMsg += "direct connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/maxdb/enumeration.py b/plugins/dbms/maxdb/enumeration.py index 06b98abdb..b17675dd3 100644 --- a/plugins/dbms/maxdb/enumeration.py +++ b/plugins/dbms/maxdb/enumeration.py @@ -107,7 +107,7 @@ class Enumeration(GenericEnumeration): if ',' in conf.db: errMsg = "only one database name is allowed when enumerating " errMsg += "the tables' columns" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) conf.db = safeSQLIdentificatorNaming(conf.db) @@ -124,7 +124,7 @@ class Enumeration(GenericEnumeration): else: errMsg = "unable to retrieve the tables " errMsg += "on database '%s'" % unsafeSQLIdentificatorNaming(conf.db) - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) for tbl in tblList: tblList[tblList.index(tbl)] = safeSQLIdentificatorNaming(tbl, True) diff --git a/plugins/dbms/maxdb/filesystem.py b/plugins/dbms/maxdb/filesystem.py index 2ed932b9b..2951e50f7 100644 --- a/plugins/dbms/maxdb/filesystem.py +++ b/plugins/dbms/maxdb/filesystem.py @@ -14,8 +14,8 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "on SAP MaxDB reading of files is not supported" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "on SAP MaxDB writing of files is not supported" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/maxdb/takeover.py b/plugins/dbms/maxdb/takeover.py index cb7fb1d3b..01ee9dfd7 100644 --- a/plugins/dbms/maxdb/takeover.py +++ b/plugins/dbms/maxdb/takeover.py @@ -14,18 +14,18 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "on SAP MaxDB it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "on SAP MaxDB it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "on SAP MaxDB it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "on SAP MaxDB it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/mssqlserver/connector.py b/plugins/dbms/mssqlserver/connector.py index a332d138e..203aa7053 100644 --- a/plugins/dbms/mssqlserver/connector.py +++ b/plugins/dbms/mssqlserver/connector.py @@ -42,7 +42,7 @@ class Connector(GenericConnector): try: self.connector = pymssql.connect(host="%s:%d" % (self.hostname, self.port), user=self.user, password=self.password, database=self.db, login_timeout=conf.timeout, timeout=conf.timeout) except pymssql.OperationalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.setCursor() self.connected() @@ -63,7 +63,7 @@ class Connector(GenericConnector): except (pymssql.OperationalError, pymssql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % str(msg).replace("\n", " ")) except pymssql.InternalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) return retVal diff --git a/plugins/dbms/mysql/connector.py b/plugins/dbms/mysql/connector.py index 4e46b0f1b..7eb81d734 100644 --- a/plugins/dbms/mysql/connector.py +++ b/plugins/dbms/mysql/connector.py @@ -37,7 +37,7 @@ class Connector(GenericConnector): try: self.connector = pymysql.connect(host=self.hostname, user=self.user, passwd=self.password, db=self.db, port=self.port, connect_timeout=conf.timeout, use_unicode=True) except (pymysql.OperationalError, pymysql.InternalError), msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.setCursor() self.connected() @@ -58,7 +58,7 @@ class Connector(GenericConnector): except (pymysql.OperationalError, pymysql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[1]) except pymysql.InternalError, msg: - raise SqlmapConnectionException, msg[1] + raise SqlmapConnectionException(msg[1]) self.connector.commit() diff --git a/plugins/dbms/mysql/filesystem.py b/plugins/dbms/mysql/filesystem.py index 98af85896..d2ef4f715 100644 --- a/plugins/dbms/mysql/filesystem.py +++ b/plugins/dbms/mysql/filesystem.py @@ -63,7 +63,7 @@ class Filesystem(GenericFilesystem): logger.warn(warnMsg) result = self.nonStackedReadFile(rFile) else: - raise SqlmapNoneDataException, warnMsg + raise SqlmapNoneDataException(warnMsg) else: length = int(length) sustrLen = 1024 diff --git a/plugins/dbms/mysql/syntax.py b/plugins/dbms/mysql/syntax.py index 64347347b..53f600901 100644 --- a/plugins/dbms/mysql/syntax.py +++ b/plugins/dbms/mysql/syntax.py @@ -41,7 +41,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find(")") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/oracle/connector.py b/plugins/dbms/oracle/connector.py index b9e5689b1..55c2dab00 100644 --- a/plugins/dbms/oracle/connector.py +++ b/plugins/dbms/oracle/connector.py @@ -46,7 +46,7 @@ class Connector(GenericConnector): try: self.connector = cx_Oracle.connect(dsn=self.__dsn, user=self.user, password=self.password) except (cx_Oracle.OperationalError, cx_Oracle.DatabaseError), msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.setCursor() self.connected() @@ -67,7 +67,7 @@ class Connector(GenericConnector): except (cx_Oracle.DatabaseError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) except cx_Oracle.InternalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.connector.commit() diff --git a/plugins/dbms/oracle/enumeration.py b/plugins/dbms/oracle/enumeration.py index 87a619cb0..66c676cb2 100644 --- a/plugins/dbms/oracle/enumeration.py +++ b/plugins/dbms/oracle/enumeration.py @@ -160,6 +160,6 @@ class Enumeration(GenericEnumeration): if not kb.data.cachedUsersRoles: errMsg = "unable to retrieve the roles " errMsg += "for the database users" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) return kb.data.cachedUsersRoles, areAdmins diff --git a/plugins/dbms/oracle/filesystem.py b/plugins/dbms/oracle/filesystem.py index 06b9bf0de..3f784a347 100644 --- a/plugins/dbms/oracle/filesystem.py +++ b/plugins/dbms/oracle/filesystem.py @@ -15,9 +15,9 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "File system read access not yet implemented for " errMsg += "Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "File system write access not yet implemented for " errMsg += "Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/oracle/syntax.py b/plugins/dbms/oracle/syntax.py index eb159b4b1..c68f8a66a 100644 --- a/plugins/dbms/oracle/syntax.py +++ b/plugins/dbms/oracle/syntax.py @@ -24,7 +24,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index old = "'%s'" % expression[firstIndex:lastIndex] @@ -47,7 +47,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("))") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/oracle/takeover.py b/plugins/dbms/oracle/takeover.py index 60b4c46a0..934bc76e2 100644 --- a/plugins/dbms/oracle/takeover.py +++ b/plugins/dbms/oracle/takeover.py @@ -15,19 +15,19 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "Operating system command execution functionality not " errMsg += "yet implemented for Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "Operating system shell functionality not yet " errMsg += "implemented for Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "Operating system out-of-band control functionality " errMsg += "not yet implemented for Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "One click operating system out-of-band control " errMsg += "functionality not yet implemented for Oracle" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/postgresql/connector.py b/plugins/dbms/postgresql/connector.py index 74b61f5b9..b53e232bf 100644 --- a/plugins/dbms/postgresql/connector.py +++ b/plugins/dbms/postgresql/connector.py @@ -37,7 +37,7 @@ class Connector(GenericConnector): try: self.connector = psycopg2.connect(host=self.hostname, user=self.user, password=self.password, database=self.db, port=self.port) except psycopg2.OperationalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.connector.set_client_encoding('UNICODE') @@ -60,7 +60,7 @@ class Connector(GenericConnector): except (psycopg2.OperationalError, psycopg2.ProgrammingError), msg: logger.warn(("(remote) %s" % msg).strip()) except psycopg2.InternalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.connector.commit() diff --git a/plugins/dbms/postgresql/filesystem.py b/plugins/dbms/postgresql/filesystem.py index 5dbc11451..ddbedeae2 100644 --- a/plugins/dbms/postgresql/filesystem.py +++ b/plugins/dbms/postgresql/filesystem.py @@ -31,7 +31,7 @@ class Filesystem(GenericFilesystem): def unionWriteFile(self, wFile, dFile, fileType): errMsg = "PostgreSQL does not support file upload with UNION " errMsg += "query SQL injection technique" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def stackedWriteFile(self, wFile, dFile, fileType): wFileSize = os.path.getsize(wFile) @@ -39,7 +39,7 @@ class Filesystem(GenericFilesystem): if wFileSize > 8192: errMsg = "on PostgreSQL it is not possible to write files " errMsg += "bigger than 8192 bytes at the moment" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) self.oid = randomInt() diff --git a/plugins/dbms/postgresql/syntax.py b/plugins/dbms/postgresql/syntax.py index 31ca0435c..76c11c244 100644 --- a/plugins/dbms/postgresql/syntax.py +++ b/plugins/dbms/postgresql/syntax.py @@ -29,7 +29,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index old = "'%s'" % expression[firstIndex:lastIndex] @@ -52,7 +52,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex:].find("))") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ) in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ) in '%s'" % expression) lastIndex = firstIndex + index + 1 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/postgresql/takeover.py b/plugins/dbms/postgresql/takeover.py index 6451b640b..5e9119ac5 100644 --- a/plugins/dbms/postgresql/takeover.py +++ b/plugins/dbms/postgresql/takeover.py @@ -53,7 +53,7 @@ class Takeover(GenericTakeover): majorVer = "8.2" else: errMsg = "unsupported feature on versions of PostgreSQL before 8.2" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) if Backend.isOs(OS.WINDOWS): self.udfLocalFile += "/postgresql/windows/%d/%s/lib_postgresqludf_sys.dll" % (Backend.getArch(), majorVer) diff --git a/plugins/dbms/sqlite/connector.py b/plugins/dbms/sqlite/connector.py index 0f148a257..55584dbfd 100644 --- a/plugins/dbms/sqlite/connector.py +++ b/plugins/dbms/sqlite/connector.py @@ -56,12 +56,12 @@ class Connector(GenericConnector): except ImportError: errMsg = "sqlmap requires 'python-sqlite2' third-party library " errMsg += "in order to directly connect to the database '%s'" % self.db - raise SqlmapMissingDependence, errMsg + raise SqlmapMissingDependence(errMsg) self.__sqlite = sqlite self.connector = self.__sqlite.connect(database=self.db, check_same_thread=False, timeout=conf.timeout) except (self.__sqlite.DatabaseError, self.__sqlite.OperationalError), msg: - raise SqlmapConnectionException, msg[0] + raise SqlmapConnectionException(msg[0]) self.setCursor() self.connected() @@ -79,7 +79,7 @@ class Connector(GenericConnector): except self.__sqlite.OperationalError, msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg[0]) except self.__sqlite.DatabaseError, msg: - raise SqlmapConnectionException, msg[0] + raise SqlmapConnectionException(msg[0]) self.connector.commit() diff --git a/plugins/dbms/sqlite/enumeration.py b/plugins/dbms/sqlite/enumeration.py index cba0cac73..9a43db908 100644 --- a/plugins/dbms/sqlite/enumeration.py +++ b/plugins/dbms/sqlite/enumeration.py @@ -57,7 +57,7 @@ class Enumeration(GenericEnumeration): def searchColumn(self): errMsg = "on SQLite you must specify the table and columns to dump" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def getHostname(self): warnMsg = "on SQLite it is not possible to enumerate the hostname" diff --git a/plugins/dbms/sqlite/filesystem.py b/plugins/dbms/sqlite/filesystem.py index 75562cf28..d94a5dabd 100644 --- a/plugins/dbms/sqlite/filesystem.py +++ b/plugins/dbms/sqlite/filesystem.py @@ -14,8 +14,8 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "on SQLite it is not possible to read files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "on SQLite it is not possible to write files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/sqlite/syntax.py b/plugins/dbms/sqlite/syntax.py index 2b952b982..0cc609d18 100644 --- a/plugins/dbms/sqlite/syntax.py +++ b/plugins/dbms/sqlite/syntax.py @@ -42,7 +42,7 @@ class Syntax(GenericSyntax): index = expression[firstIndex+2:].find("'") if index == -1: - raise SqlmapSyntaxException, "Unenclosed ' in '%s'" % expression + raise SqlmapSyntaxException("Unenclosed ' in '%s'" % expression) lastIndex = firstIndex + index + 3 old = expression[firstIndex:lastIndex] diff --git a/plugins/dbms/sqlite/takeover.py b/plugins/dbms/sqlite/takeover.py index f2593573b..e0bbdce4a 100644 --- a/plugins/dbms/sqlite/takeover.py +++ b/plugins/dbms/sqlite/takeover.py @@ -14,18 +14,18 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "on SQLite it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "on SQLite it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "on SQLite it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "on SQLite it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/sybase/connector.py b/plugins/dbms/sybase/connector.py index d33c40591..b490eec72 100644 --- a/plugins/dbms/sybase/connector.py +++ b/plugins/dbms/sybase/connector.py @@ -42,7 +42,7 @@ class Connector(GenericConnector): try: self.connector = pymssql.connect(host="%s:%d" % (self.hostname, self.port), user=self.user, password=self.password, database=self.db, login_timeout=conf.timeout, timeout=conf.timeout) except pymssql.OperationalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) self.setCursor() self.connected() @@ -60,7 +60,7 @@ class Connector(GenericConnector): except (pymssql.OperationalError, pymssql.ProgrammingError), msg: logger.log(logging.WARN if conf.dbmsHandler else logging.DEBUG, "(remote) %s" % msg) except pymssql.InternalError, msg: - raise SqlmapConnectionException, msg + raise SqlmapConnectionException(msg) def select(self, query): self.execute(query) diff --git a/plugins/dbms/sybase/enumeration.py b/plugins/dbms/sybase/enumeration.py index 814cb2fc2..4ead48e7c 100644 --- a/plugins/dbms/sybase/enumeration.py +++ b/plugins/dbms/sybase/enumeration.py @@ -172,7 +172,7 @@ class Enumeration(GenericEnumeration): if ',' in conf.db: errMsg = "only one database name is allowed when enumerating " errMsg += "the tables' columns" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) conf.db = safeSQLIdentificatorNaming(conf.db) @@ -197,7 +197,7 @@ class Enumeration(GenericEnumeration): else: errMsg = "unable to retrieve the tables " errMsg += "on database '%s'" % unsafeSQLIdentificatorNaming(conf.db) - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) for tbl in tblList: tblList[tblList.index(tbl)] = safeSQLIdentificatorNaming(tbl) diff --git a/plugins/dbms/sybase/filesystem.py b/plugins/dbms/sybase/filesystem.py index ab8c0e1a3..ba37e7917 100644 --- a/plugins/dbms/sybase/filesystem.py +++ b/plugins/dbms/sybase/filesystem.py @@ -14,8 +14,8 @@ class Filesystem(GenericFilesystem): def readFile(self, rFile): errMsg = "on Sybase it is not possible to read files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def writeFile(self, wFile, dFile, fileType=None): errMsg = "on Sybase it is not possible to write files" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/dbms/sybase/takeover.py b/plugins/dbms/sybase/takeover.py index 97322271c..3442cf523 100644 --- a/plugins/dbms/sybase/takeover.py +++ b/plugins/dbms/sybase/takeover.py @@ -14,18 +14,18 @@ class Takeover(GenericTakeover): def osCmd(self): errMsg = "on Sybase it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osShell(self): errMsg = "on Sybase it is not possible to execute commands" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osPwn(self): errMsg = "on Sybase it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) def osSmb(self): errMsg = "on Sybase it is not possible to establish an " errMsg += "out-of-band connection" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) diff --git a/plugins/generic/connector.py b/plugins/generic/connector.py index df1478b7e..92f57ee61 100644 --- a/plugins/generic/connector.py +++ b/plugins/generic/connector.py @@ -59,24 +59,24 @@ class Connector: def checkFileDb(self): if not os.path.exists(self.db): errMsg = "the provided database file '%s' does not exist" % self.db - raise SqlmapFilePathException, errMsg + raise SqlmapFilePathException(errMsg) def connect(self): errMsg = "'connect' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def fetchall(self): errMsg = "'fetchall' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def execute(self, query): errMsg = "'execute' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def select(self, query): errMsg = "'select' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) diff --git a/plugins/generic/databases.py b/plugins/generic/databases.py index 82106b8a3..ead255d3f 100644 --- a/plugins/generic/databases.py +++ b/plugins/generic/databases.py @@ -166,7 +166,7 @@ class Databases: kb.data.cachedDbs = [kb.data.currentDb] else: errMsg = "unable to retrieve the database names" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) else: kb.data.cachedDbs.sort() @@ -354,7 +354,7 @@ class Databases: logger.error(errMsg) return self.getTables(bruteForce=True) else: - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) else: for db, tables in kb.data.cachedTables.items(): kb.data.cachedTables[db] = sorted(tables) if tables else tables @@ -384,7 +384,7 @@ class Databases: if ',' in conf.db: errMsg = "only one database name is allowed when enumerating " errMsg += "the tables' columns" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) conf.db = safeSQLIdentificatorNaming(conf.db) @@ -422,7 +422,7 @@ class Databases: else: errMsg = "unable to retrieve the tables " errMsg += "in database '%s'" % unsafeSQLIdentificatorNaming(conf.db) - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) for tbl in tblList: tblList[tblList.index(tbl)] = safeSQLIdentificatorNaming(tbl, True) diff --git a/plugins/generic/entries.py b/plugins/generic/entries.py index bfbb0b18f..5586b6d51 100644 --- a/plugins/generic/entries.py +++ b/plugins/generic/entries.py @@ -67,7 +67,7 @@ class Entries: if ',' in conf.db: errMsg = "only one database name is allowed when enumerating " errMsg += "the tables' columns" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) conf.db = safeSQLIdentificatorNaming(conf.db) @@ -87,7 +87,7 @@ class Entries: else: errMsg = "unable to retrieve the tables " errMsg += "in database '%s'" % unsafeSQLIdentificatorNaming(conf.db) - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) for tbl in tblList: tblList[tblList.index(tbl)] = safeSQLIdentificatorNaming(tbl, True) @@ -329,7 +329,7 @@ class Entries: if Backend.isDbms(DBMS.MYSQL) and not kb.data.has_information_schema: errMsg = "information_schema not available, " errMsg += "back-end DBMS is MySQL < 5.0" - raise SqlmapUnsupportedFeatureException, errMsg + raise SqlmapUnsupportedFeatureException(errMsg) infoMsg = "sqlmap will dump entries of all tables from all databases now" logger.info(infoMsg) diff --git a/plugins/generic/filesystem.py b/plugins/generic/filesystem.py index 36f80eafe..15c7d007e 100644 --- a/plugins/generic/filesystem.py +++ b/plugins/generic/filesystem.py @@ -161,22 +161,22 @@ class Filesystem: def nonStackedReadFile(self, remoteFile): errMsg = "'nonStackedReadFile' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def stackedReadFile(self, remoteFile): errMsg = "'stackedReadFile' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def unionWriteFile(self, localFile, remoteFile, fileType): errMsg = "'unionWriteFile' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def stackedWriteFile(self, localFile, remoteFile, fileType): errMsg = "'stackedWriteFile' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def readFile(self, remoteFiles): localFilePaths = [] diff --git a/plugins/generic/fingerprint.py b/plugins/generic/fingerprint.py index 4de7110d1..85a7d43c8 100644 --- a/plugins/generic/fingerprint.py +++ b/plugins/generic/fingerprint.py @@ -22,17 +22,17 @@ class Fingerprint: def getFingerprint(self): errMsg = "'getFingerprint' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def checkDbms(self): errMsg = "'checkDbms' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def checkDbmsOs(self, detailed=False): errMsg = "'checkDbmsOs' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def forceDbmsEnum(self): pass diff --git a/plugins/generic/misc.py b/plugins/generic/misc.py index 2ab1a9cc4..502f40e41 100644 --- a/plugins/generic/misc.py +++ b/plugins/generic/misc.py @@ -79,7 +79,7 @@ class Miscellaneous: first, last = 29, 9 else: - raise SqlmapUnsupportedFeatureException, "unsupported DBMS" + raise SqlmapUnsupportedFeatureException("unsupported DBMS") query = queries[Backend.getIdentifiedDbms()].substring.query % (queries[Backend.getIdentifiedDbms()].banner.query, first, last) @@ -189,6 +189,6 @@ class Miscellaneous: condParam = "='%s'" else: errMsg = "invalid value" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) return choice, condParam diff --git a/plugins/generic/search.py b/plugins/generic/search.py index f25836764..4edbfa8c6 100644 --- a/plugins/generic/search.py +++ b/plugins/generic/search.py @@ -558,4 +558,4 @@ class Search: else: errMsg = "missing parameter, provide -D, -T or -C along " errMsg += "with --search" - raise SqlmapMissingMandatoryOptionException, errMsg + raise SqlmapMissingMandatoryOptionException(errMsg) diff --git a/plugins/generic/syntax.py b/plugins/generic/syntax.py index 3724b8d62..508ebfc4e 100644 --- a/plugins/generic/syntax.py +++ b/plugins/generic/syntax.py @@ -19,10 +19,10 @@ class Syntax: def unescape(expression, quote=True): errMsg = "'unescape' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) @staticmethod def escape(expression): errMsg = "'escape' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) diff --git a/plugins/generic/takeover.py b/plugins/generic/takeover.py index 649cde307..ee23c5ad9 100644 --- a/plugins/generic/takeover.py +++ b/plugins/generic/takeover.py @@ -124,7 +124,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous): errMsg += "if you want to establish an out-of-band ICMP " errMsg += "tunnel because icmpsh uses raw sockets to " errMsg += "sniff and craft ICMP packets" - raise SqlmapMissingPrivileges, errMsg + raise SqlmapMissingPrivileges(errMsg) try: from impacket import ImpactDecoder @@ -133,7 +133,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous): errMsg = "sqlmap requires 'impacket' third-party library " errMsg += "in order to run icmpsh master. Download from " errMsg += "http://oss.coresecurity.com/projects/impacket.html" - raise SqlmapMissingDependence, errMsg + raise SqlmapMissingDependence(errMsg) sysIgnoreIcmp = "/proc/sys/net/ipv4/icmp_echo_ignore_all" @@ -325,7 +325,7 @@ class Takeover(Abstraction, Metasploit, ICMPsh, Registry, Miscellaneous): def uncPathRequest(self): errMsg = "'uncPathRequest' method must be defined " errMsg += "into the specific DBMS plugin" - raise SqlmapUndefinedMethod, errMsg + raise SqlmapUndefinedMethod(errMsg) def _regInit(self): if not isTechniqueAvailable(PAYLOAD.TECHNIQUE.STACKED) and not conf.direct: diff --git a/plugins/generic/users.py b/plugins/generic/users.py index 2edeba796..ac65e55dc 100644 --- a/plugins/generic/users.py +++ b/plugins/generic/users.py @@ -116,7 +116,7 @@ class Users: if not isNumPosStrValue(count): errMsg = "unable to retrieve the number of database users" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) plusOne = Backend.getIdentifiedDbms() in (DBMS.ORACLE, DBMS.DB2) indexRange = getLimitRange(count, plusOne=plusOne) @@ -135,7 +135,7 @@ class Users: if not kb.data.cachedUsers: errMsg = "unable to retrieve the database users" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) return kb.data.cachedUsers @@ -296,7 +296,7 @@ class Users: errMsg += "database users (most probably because the session " errMsg += "user has no read privileges over the relevant " errMsg += "system database table)" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) else: for user in kb.data.cachedUsersPasswords: kb.data.cachedUsersPasswords[user] = list(set(kb.data.cachedUsersPasswords[user])) @@ -585,7 +585,7 @@ class Users: if not kb.data.cachedUsersPrivileges: errMsg = "unable to retrieve the privileges " errMsg += "for the database users" - raise SqlmapNoneDataException, errMsg + raise SqlmapNoneDataException(errMsg) return (kb.data.cachedUsersPrivileges, areAdmins)