mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 09:36:35 +03:00
Minor code refactoring
This commit is contained in:
parent
337973df77
commit
b03f91437b
|
@ -503,6 +503,22 @@ class Backend:
|
||||||
|
|
||||||
return kb.os
|
return kb.os
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def setOsVersion(version):
|
||||||
|
if version is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
elif kb.osVersion is None and isinstance(version, basestring):
|
||||||
|
kb.osVersion = version
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def setOsServicePack(sp):
|
||||||
|
if version is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
elif kb.osSP is None and isinstance(version, int):
|
||||||
|
kb.osSP = version
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def setArch():
|
def setArch():
|
||||||
msg = "what is the back-end database management system architecture?"
|
msg = "what is the back-end database management system architecture?"
|
||||||
|
@ -585,6 +601,14 @@ class Backend:
|
||||||
def getOs():
|
def getOs():
|
||||||
return kb.os
|
return kb.os
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getOsVersion():
|
||||||
|
return kb.osVersion
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getOsServicePack():
|
||||||
|
return kb.osSP
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getArch():
|
def getArch():
|
||||||
if kb.arch is None:
|
if kb.arch is None:
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Fingerprint(GenericFingerprint):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def checkDbmsOs(self, detailed=False):
|
def checkDbmsOs(self, detailed=False):
|
||||||
if Backend.getOs() and kb.osVersion and kb.osSP:
|
if Backend.getOs() and Backend.getOsVersion() and Backend.getOsServicePack():
|
||||||
return
|
return
|
||||||
|
|
||||||
if not Backend.getOs():
|
if not Backend.getOs():
|
||||||
|
@ -154,17 +154,17 @@ class Fingerprint(GenericFingerprint):
|
||||||
query += "LIKE '%Windows NT " + data[0] + "%')>0"
|
query += "LIKE '%Windows NT " + data[0] + "%')>0"
|
||||||
|
|
||||||
if inject.checkBooleanExpression(query):
|
if inject.checkBooleanExpression(query):
|
||||||
infoMsg += " %s" % kb.osVersion
|
Backend.setOsVersion(version)
|
||||||
kb.osVersion = version
|
infoMsg += " %s" % Backend.getOsVersion()
|
||||||
break
|
break
|
||||||
|
|
||||||
if not kb.osVersion:
|
if not Backend.getOsVersion():
|
||||||
kb.osVersion = "2003"
|
Backend.setOsVersion("2003")
|
||||||
kb.osSP = 2
|
Backend.setOsServicePack(2)
|
||||||
|
|
||||||
warnMsg = "unable to fingerprint the underlying operating "
|
warnMsg = "unable to fingerprint the underlying operating "
|
||||||
warnMsg += "system version, assuming it is Windows "
|
warnMsg += "system version, assuming it is Windows "
|
||||||
warnMsg += "%s Service Pack %d" % (kb.osVersion, kb.osSP)
|
warnMsg += "%s Service Pack %d" % (Backend.getOsVersion(), Backend.getOsServicePack())
|
||||||
logger.warn(warnMsg)
|
logger.warn(warnMsg)
|
||||||
|
|
||||||
self.cleanup(onlyFileTbl=True)
|
self.cleanup(onlyFileTbl=True)
|
||||||
|
@ -172,24 +172,24 @@ class Fingerprint(GenericFingerprint):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get back-end DBMS underlying operating system service pack
|
# Get back-end DBMS underlying operating system service pack
|
||||||
sps = versions[kb.osVersion][1]
|
sps = versions[Backend.getOsVersion()][1]
|
||||||
|
|
||||||
for sp in sps:
|
for sp in sps:
|
||||||
query = "(SELECT LEN(%s) FROM %s WHERE %s " % (self.tblField, self.fileTblName, self.tblField)
|
query = "(SELECT LEN(%s) FROM %s WHERE %s " % (self.tblField, self.fileTblName, self.tblField)
|
||||||
query += "LIKE '%Service Pack " + getUnicode(sp) + "%')>0"
|
query += "LIKE '%Service Pack " + getUnicode(sp) + "%')>0"
|
||||||
|
|
||||||
if inject.checkBooleanExpression(query):
|
if inject.checkBooleanExpression(query):
|
||||||
kb.osSP = sp
|
Backend.setOsServicePack(sp)
|
||||||
break
|
break
|
||||||
|
|
||||||
if not kb.osSP:
|
if not Backend.getOsServicePack():
|
||||||
debugMsg = "assuming the operating system has no service pack"
|
debugMsg = "assuming the operating system has no service pack"
|
||||||
logger.debug(debugMsg)
|
logger.debug(debugMsg)
|
||||||
|
|
||||||
kb.osSP = 0
|
Backend.setOsServicePack(0)
|
||||||
|
|
||||||
if kb.osVersion:
|
if Backend.getOsVersion():
|
||||||
infoMsg += " Service Pack %d" % kb.osSP
|
infoMsg += " Service Pack %d" % Backend.getOsServicePack()
|
||||||
|
|
||||||
logger.info(infoMsg)
|
logger.info(infoMsg)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ See the file 'doc/COPYING' for copying permission
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
|
from lib.core.common import Backend
|
||||||
from lib.core.data import kb
|
from lib.core.data import kb
|
||||||
from lib.core.data import logger
|
from lib.core.data import logger
|
||||||
from lib.core.exception import sqlmapUnsupportedFeatureException
|
from lib.core.exception import sqlmapUnsupportedFeatureException
|
||||||
|
@ -55,7 +56,7 @@ class Takeover(GenericTakeover):
|
||||||
version, sp = versionSp.split("-")
|
version, sp = versionSp.split("-")
|
||||||
sp = int(sp)
|
sp = int(sp)
|
||||||
|
|
||||||
if kb.osVersion == version and kb.osSP == sp:
|
if Backend.getOsVersion() == version and Backend.getOsServicePack() == sp:
|
||||||
addrs = data
|
addrs = data
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -64,7 +65,7 @@ class Takeover(GenericTakeover):
|
||||||
errMsg = "sqlmap can not exploit the stored procedure buffer "
|
errMsg = "sqlmap can not exploit the stored procedure buffer "
|
||||||
errMsg += "overflow because it does not have a valid return "
|
errMsg += "overflow because it does not have a valid return "
|
||||||
errMsg += "code for the underlying operating system (Windows "
|
errMsg += "code for the underlying operating system (Windows "
|
||||||
errMsg += "%s Service Pack %d)" % (kb.osVersion, kb.osSP)
|
errMsg += "%s Service Pack %d)" % (Backend.getOsVersion(), Backend.getOsServicePack())
|
||||||
raise sqlmapUnsupportedFeatureException(errMsg)
|
raise sqlmapUnsupportedFeatureException(errMsg)
|
||||||
|
|
||||||
shellcodeChar = ""
|
shellcodeChar = ""
|
||||||
|
|
|
@ -39,7 +39,11 @@ class Miscellaneous:
|
||||||
def getRemoteTempPath(self):
|
def getRemoteTempPath(self):
|
||||||
if not conf.tmpPath:
|
if not conf.tmpPath:
|
||||||
if Backend.isOs(OS.WINDOWS):
|
if Backend.isOs(OS.WINDOWS):
|
||||||
conf.tmpPath = "C:/WINDOWS/Temp"
|
print "Backend.getOsVersion():", type(Backend.getOsVersion()), Backend.getOsVersion()
|
||||||
|
if Backend.getOsVersion() == "2000":
|
||||||
|
conf.tmpPath = "C:/WINNT/Temp"
|
||||||
|
else:
|
||||||
|
conf.tmpPath = "C:/WINDOWS/Temp"
|
||||||
else:
|
else:
|
||||||
conf.tmpPath = "/tmp"
|
conf.tmpPath = "/tmp"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user