Adding missing Spanner directory (#6025)

This commit is contained in:
Miroslav Stampar 2026-03-15 13:09:51 +01:00
parent 3c16bfdb3c
commit eeb16d155c
9 changed files with 254 additions and 2 deletions

View file

@ -0,0 +1,30 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.enums import DBMS
from lib.core.settings import SPANNER_SYSTEM_DBS
from lib.core.unescaper import unescaper
from plugins.dbms.spanner.enumeration import Enumeration
from plugins.dbms.spanner.filesystem import Filesystem
from plugins.dbms.spanner.fingerprint import Fingerprint
from plugins.dbms.spanner.syntax import Syntax
from plugins.dbms.spanner.takeover import Takeover
from plugins.generic.misc import Miscellaneous
class SpannerMap(Syntax, Fingerprint, Enumeration, Filesystem, Miscellaneous, Takeover):
"""
This class defines Spanner methods
"""
def __init__(self):
self.excludeDbsList = SPANNER_SYSTEM_DBS
for cls in self.__class__.__bases__:
cls.__init__(self)
unescaper[DBMS.SPANNER] = Syntax.escape

View file

@ -0,0 +1,11 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from plugins.generic.connector import Connector as GenericConnector
class Connector(GenericConnector):
pass

View file

@ -0,0 +1,46 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.data import logger
from lib.core.settings import SPANNER_DEFAULT_SCHEMA
from plugins.generic.enumeration import Enumeration as GenericEnumeration
class Enumeration(GenericEnumeration):
def getCurrentDb(self):
return SPANNER_DEFAULT_SCHEMA
def getCurrentUser(self):
warnMsg = "on Spanner it is not possible to enumerate the current user"
logger.warning(warnMsg)
def isDba(self, user=None):
warnMsg = "on Spanner it is not possible to test if current user is DBA"
logger.warning(warnMsg)
def getUsers(self):
warnMsg = "on Spanner it is not possible to enumerate the users"
logger.warning(warnMsg)
return []
def getPasswordHashes(self):
warnMsg = "on Spanner it is not possible to enumerate the user password hashes"
logger.warning(warnMsg)
return {}
def getRoles(self, *args, **kwargs):
warnMsg = "on Spanner it is not possible to enumerate the user roles"
logger.warning(warnMsg)
return {}
def getPrivileges(self, *args, **kwargs):
warnMsg = "on Spanner it is not possible to enumerate the user privileges"
logger.warning(warnMsg)
return {}

View file

@ -0,0 +1,11 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from plugins.generic.filesystem import Filesystem as GenericFilesystem
class Filesystem(GenericFilesystem):
pass

View file

@ -0,0 +1,93 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.common import Backend
from lib.core.common import Format
from lib.core.data import conf
from lib.core.data import kb
from lib.core.data import logger
from lib.core.enums import DBMS
from lib.core.session import setDbms
from lib.core.settings import SPANNER_ALIASES
from lib.request import inject
from plugins.generic.fingerprint import Fingerprint as GenericFingerprint
class Fingerprint(GenericFingerprint):
def __init__(self):
GenericFingerprint.__init__(self, DBMS.SPANNER)
def getFingerprint(self):
value = ""
wsOsFp = Format.getOs("web server", kb.headersFp)
if wsOsFp:
value += "%s\n" % wsOsFp
if kb.data.banner:
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
if dbmsOsFp:
value += "%s\n" % dbmsOsFp
value += "back-end DBMS: "
if not conf.extensiveFp:
value += DBMS.SPANNER
return value
actVer = Format.getDbms()
blank = " " * 15
value += "active fingerprint: %s" % actVer
if kb.bannerFp:
banVer = kb.bannerFp.get("dbmsVersion")
if banVer:
banVer = Format.getDbms([banVer])
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
htmlErrorFp = Format.getErrorParsedDBMSes()
if htmlErrorFp:
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
return value
def checkDbms(self):
if not conf.extensiveFp and Backend.isDbmsWithin(SPANNER_ALIASES):
setDbms(DBMS.SPANNER)
self.getBanner()
return True
infoMsg = "testing %s" % DBMS.SPANNER
logger.info(infoMsg)
result = inject.checkBooleanExpression("FARM_FINGERPRINT('sqlmap') IS NOT NULL")
if result:
infoMsg = "confirming %s" % DBMS.SPANNER
logger.info(infoMsg)
result = inject.checkBooleanExpression("SAFE_CAST(1 AS INT64)=1")
if not result:
warnMsg = "the back-end DBMS is not %s" % DBMS.SPANNER
logger.warning(warnMsg)
return False
setDbms(DBMS.SPANNER)
self.getBanner()
return True
else:
warnMsg = "the back-end DBMS is not %s" % DBMS.SPANNER
logger.warning(warnMsg)
return False

View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.convert import getOrds
from plugins.generic.syntax import Syntax as GenericSyntax
class Syntax(GenericSyntax):
@staticmethod
def escape(expression, quote=True):
"""
Note: Google Standard SQL (Spanner) natively supports converting integer arrays
to strings via CODE_POINTS_TO_STRING(). This is much cleaner and shorter
than chaining multiple CHR() functions with the || operator.
>>> Syntax.escape("SELECT 'abcdefgh' FROM foobar") == "SELECT CODE_POINTS_TO_STRING([97, 98, 99, 100, 101, 102, 103, 104]) FROM foobar"
True
"""
def escaper(value):
return "CODE_POINTS_TO_STRING([%s])" % ", ".join(str(_) for _ in getOrds(value))
return Syntax._escape(expression, quote, escaper)

View file

@ -0,0 +1,28 @@
#!/usr/bin/env python
"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""
from lib.core.exception import SqlmapUnsupportedFeatureException
from plugins.generic.takeover import Takeover as GenericTakeover
class Takeover(GenericTakeover):
def osCmd(self):
errMsg = "on Spanner it is not possible to execute commands"
raise SqlmapUnsupportedFeatureException(errMsg)
def osShell(self):
errMsg = "on Spanner it is not possible to execute commands"
raise SqlmapUnsupportedFeatureException(errMsg)
def osPwn(self):
errMsg = "on Spanner it is not possible to establish an "
errMsg += "out-of-band connection"
raise SqlmapUnsupportedFeatureException(errMsg)
def osSmb(self):
errMsg = "on Spanner it is not possible to establish an "
errMsg += "out-of-band connection"
raise SqlmapUnsupportedFeatureException(errMsg)