mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2026-01-09 08:09:01 +00:00
Replacing old and deprecated raise Exception style (PEP8)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user