Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/plugins/dbms/vertica/fingerprint.py
2992 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
from lib.core.common import Backend
9
from lib.core.common import Format
10
from lib.core.data import conf
11
from lib.core.data import kb
12
from lib.core.data import logger
13
from lib.core.enums import DBMS
14
from lib.core.session import setDbms
15
from lib.core.settings import VERTICA_ALIASES
16
from lib.request import inject
17
from plugins.generic.fingerprint import Fingerprint as GenericFingerprint
18
19
class Fingerprint(GenericFingerprint):
20
def __init__(self):
21
GenericFingerprint.__init__(self, DBMS.VERTICA)
22
23
def getFingerprint(self):
24
value = ""
25
wsOsFp = Format.getOs("web server", kb.headersFp)
26
27
if wsOsFp:
28
value += "%s\n" % wsOsFp
29
30
if kb.data.banner:
31
dbmsOsFp = Format.getOs("back-end DBMS", kb.bannerFp)
32
33
if dbmsOsFp:
34
value += "%s\n" % dbmsOsFp
35
36
value += "back-end DBMS: "
37
38
if not conf.extensiveFp:
39
value += DBMS.VERTICA
40
return value
41
42
actVer = Format.getDbms()
43
blank = " " * 15
44
value += "active fingerprint: %s" % actVer
45
46
if kb.bannerFp:
47
banVer = kb.bannerFp.get("dbmsVersion")
48
49
if banVer:
50
banVer = Format.getDbms([banVer])
51
value += "\n%sbanner parsing fingerprint: %s" % (blank, banVer)
52
53
htmlErrorFp = Format.getErrorParsedDBMSes()
54
55
if htmlErrorFp:
56
value += "\n%shtml error message fingerprint: %s" % (blank, htmlErrorFp)
57
58
return value
59
60
def checkDbms(self):
61
if not conf.extensiveFp and Backend.isDbmsWithin(VERTICA_ALIASES):
62
setDbms(DBMS.VERTICA)
63
64
self.getBanner()
65
66
return True
67
68
infoMsg = "testing %s" % DBMS.VERTICA
69
logger.info(infoMsg)
70
71
# NOTE: Vertica works too without the CONVERT_TO()
72
result = inject.checkBooleanExpression("BITSTRING_TO_BINARY(NULL) IS NULL")
73
74
if result:
75
infoMsg = "confirming %s" % DBMS.VERTICA
76
logger.info(infoMsg)
77
78
result = inject.checkBooleanExpression("HEX_TO_INTEGER(NULL) IS NULL")
79
80
if not result:
81
warnMsg = "the back-end DBMS is not %s" % DBMS.VERTICA
82
logger.warning(warnMsg)
83
84
return False
85
86
setDbms(DBMS.VERTICA)
87
88
self.getBanner()
89
90
if not conf.extensiveFp:
91
return True
92
93
infoMsg = "actively fingerprinting %s" % DBMS.VERTICA
94
logger.info(infoMsg)
95
96
if inject.checkBooleanExpression("CALENDAR_HIERARCHY_DAY(NULL) IS NULL"):
97
Backend.setVersion(">= 9.0")
98
else:
99
Backend.setVersion("< 9.0")
100
101
return True
102
else:
103
warnMsg = "the back-end DBMS is not %s" % DBMS.VERTICA
104
logger.warning(warnMsg)
105
106
return False
107
108