Doing some more style updating (capitalization of exception classes; using _ is enough for private members - __ is used in Python specific methods)

This commit is contained in:
Miroslav Stampar
2012-12-06 14:14:19 +01:00
parent 003d21e962
commit 974407396e
102 changed files with 1115 additions and 1091 deletions

View File

@@ -16,7 +16,7 @@ import logging
from lib.core.convert import utf8encode
from lib.core.data import conf
from lib.core.data import logger
from lib.core.exception import sqlmapConnectionException
from lib.core.exception import SqlmapConnectionException
from plugins.generic.connector import Connector as GenericConnector
class Connector(GenericConnector):
@@ -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

View File

@@ -22,7 +22,7 @@ from lib.core.data import queries
from lib.core.enums import CHARSET_TYPE
from lib.core.enums import EXPECTED
from lib.core.enums import PAYLOAD
from lib.core.exception import sqlmapNoneDataException
from lib.core.exception import SqlmapNoneDataException
from lib.core.settings import CURRENT_DB
from lib.request import inject
@@ -150,7 +150,7 @@ class Enumeration(GenericEnumeration):
if not kb.data.cachedTables:
errMsg = "unable to retrieve the tables for any database"
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

View File

@@ -21,8 +21,8 @@ from lib.core.data import logger
from lib.core.enums import CHARSET_TYPE
from lib.core.enums import EXPECTED
from lib.core.enums import PAYLOAD
from lib.core.exception import sqlmapNoneDataException
from lib.core.exception import sqlmapUnsupportedFeatureException
from lib.core.exception import SqlmapNoneDataException
from lib.core.exception import SqlmapUnsupportedFeatureException
from lib.request import inject
from plugins.generic.filesystem import Filesystem as GenericFilesystem
@@ -31,7 +31,7 @@ class Filesystem(GenericFilesystem):
def __init__(self):
GenericFilesystem.__init__(self)
def __dataToScr(self, fileContent, chunkName):
def _dataToScr(self, fileContent, chunkName):
fileLines = []
fileSize = len(fileContent)
lineAddr = 0x100
@@ -62,10 +62,10 @@ class Filesystem(GenericFilesystem):
return fileLines
def __updateDestChunk(self, fileContent, tmpPath):
def _updateDestChunk(self, fileContent, tmpPath):
randScr = "tmpf%s.scr" % randomStr(lowercase=True)
chunkName = randomStr(lowercase=True)
fileScrLines = self.__dataToScr(fileContent, chunkName)
fileScrLines = self._dataToScr(fileContent, chunkName)
logger.debug("uploading debug script to %s\%s, please wait.." % (tmpPath, randScr))
@@ -147,7 +147,7 @@ class Filesystem(GenericFilesystem):
if not isNumPosStrValue(count):
errMsg = "unable to retrieve the content of the "
errMsg += "file '%s'" % rFile
raise sqlmapNoneDataException(errMsg)
raise SqlmapNoneDataException(errMsg)
indexRange = getLimitRange(count)
@@ -162,9 +162,9 @@ class Filesystem(GenericFilesystem):
def unionWriteFile(self, wFile, dFile, fileType):
errMsg = "Microsoft SQL Server does not support file upload with "
errMsg += "UNION query SQL injection technique"
raise sqlmapUnsupportedFeatureException(errMsg)
raise SqlmapUnsupportedFeatureException(errMsg)
def __stackedWriteFilePS(self, tmpPath, wFileContent, dFile, fileType):
def _stackedWriteFilePS(self, tmpPath, wFileContent, dFile, fileType):
infoMsg = "using PowerShell to write the %s file content " % fileType
infoMsg += "to file '%s', please wait.." % dFile
logger.info(infoMsg)
@@ -191,7 +191,7 @@ class Filesystem(GenericFilesystem):
self.execCmd(complComm)
def __stackedWriteFileDebugExe(self, tmpPath, wFile, wFileContent, dFile, fileType):
def _stackedWriteFileDebugExe(self, tmpPath, wFile, wFileContent, dFile, fileType):
infoMsg = "using debug.exe to write the %s " % fileType
infoMsg += "file content to file '%s', please wait.." % dFile
logger.info(infoMsg)
@@ -202,7 +202,7 @@ class Filesystem(GenericFilesystem):
debugSize = 0xFF00
if wFileSize < debugSize:
chunkName = self.__updateDestChunk(wFileContent, tmpPath)
chunkName = self._updateDestChunk(wFileContent, tmpPath)
debugMsg = "renaming chunk file %s\%s to %s " % (tmpPath, chunkName, fileType)
debugMsg += "file %s\%s and moving it to %s" % (tmpPath, dFileName, dFile)
@@ -222,7 +222,7 @@ class Filesystem(GenericFilesystem):
for i in xrange(0, wFileSize, debugSize):
wFileChunk = wFileContent[i:i + debugSize]
chunkName = self.__updateDestChunk(wFileChunk, tmpPath)
chunkName = self._updateDestChunk(wFileChunk, tmpPath)
if i == 0:
debugMsg = "renaming chunk "
@@ -246,7 +246,7 @@ class Filesystem(GenericFilesystem):
self.execCmd(complComm)
def __stackedWriteFileVbs(self, tmpPath, wFileContent, dFile, fileType):
def _stackedWriteFileVbs(self, tmpPath, wFileContent, dFile, fileType):
infoMsg = "using a custom visual basic script to write the "
infoMsg += "%s file content to file '%s', please wait.." % (fileType, dFile)
logger.info(infoMsg)
@@ -341,7 +341,7 @@ class Filesystem(GenericFilesystem):
wFileContent = wFilePointer.read()
wFilePointer.close()
self.__stackedWriteFileVbs(tmpPath, wFileContent, dFile, fileType)
self._stackedWriteFileVbs(tmpPath, wFileContent, dFile, fileType)
sameFile = self.askCheckWrittenFile(wFile, dFile, fileType)
@@ -351,5 +351,5 @@ class Filesystem(GenericFilesystem):
choice = readInput(message, default="Y")
if not choice or choice.lower() == "y":
self.__stackedWriteFileDebugExe(tmpPath, wFile, wFileContent, dFile, fileType)
#self.__stackedWriteFilePS(tmpPath, wFileContent, dFile, fileType)
self._stackedWriteFileDebugExe(tmpPath, wFile, wFileContent, dFile, fileType)
#self._stackedWriteFilePS(tmpPath, wFileContent, dFile, fileType)

View File

@@ -5,7 +5,7 @@ Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission
"""
from lib.core.exception import sqlmapSyntaxException
from lib.core.exception import SqlmapSyntaxException
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@@ -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]
@@ -48,7 +48,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]

View File

@@ -9,7 +9,7 @@ import binascii
from lib.core.common import Backend
from lib.core.data import logger
from lib.core.exception import sqlmapUnsupportedFeatureException
from lib.core.exception import SqlmapUnsupportedFeatureException
from lib.request import inject
from plugins.generic.takeover import Takeover as GenericTakeover
@@ -62,7 +62,7 @@ class Takeover(GenericTakeover):
errMsg += "overflow because it does not have a valid return "
errMsg += "code for the underlying operating system (Windows "
errMsg += "%s Service Pack %d)" % (Backend.getOsVersion(), Backend.getOsServicePack())
raise sqlmapUnsupportedFeatureException(errMsg)
raise SqlmapUnsupportedFeatureException(errMsg)
shellcodeChar = ""
hexStr = binascii.hexlify(self.shellcodeString[:-1])