Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd0d413

Browse files
committed
implemented --banner for MaxDB and some minor fixes
1 parent 49bf34f commit cd0d413

7 files changed

Lines changed: 17 additions & 59 deletions

File tree

extra/xmlobject/xmlobject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ def __getitem__(self, idx):
479479
else:
480480
raise IndexError(idx)
481481

482+
def __contains__(self, k):
483+
return self._has_key(k)
484+
482485
def _addNode(self, child):
483486
"""
484487
Tries to append a child node to the tree, and returns it

lib/core/dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def dbTables(self, dbTables):
148148

149149
dbTables.sort(key=lambda x: x.lower())
150150

151-
self.__write("Brute-forced databases:")
151+
self.__write("Brute-forced tables:")
152152

153153
if len(dbTables) == 1:
154154
self.__write("[1 table]")

lib/techniques/blind/inference.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from lib.core.exception import sqlmapThreadException
3232
from lib.core.exception import unhandledException
3333
from lib.core.progress import ProgressBar
34+
from lib.core.settings import DBMS
3435
from lib.core.unescaper import unescaper
3536
from lib.request.connect import Connect as Request
3637

@@ -114,7 +115,7 @@ def tryHint(idx):
114115
hintlock.release()
115116

116117
if hintValue is not None and len(hintValue) >= idx:
117-
if kb.dbms in ("SQLite", "Microsoft Access", "SAP MaxDB"):
118+
if kb.dbms in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB):
118119
posValue = hintValue[idx-1]
119120
else:
120121
posValue = ord(hintValue[idx-1])
@@ -166,7 +167,7 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True, expand=charsetType is N
166167
position = (len(charTbl) >> 1)
167168
posValue = charTbl[position]
168169

169-
if kb.dbms in ("SQLite", "Microsoft Access", "SAP MaxDB"):
170+
if kb.dbms in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB):
170171
pushValue(posValue)
171172
posValue = chr(posValue) if posValue < 128 else unichr(posValue)
172173

@@ -175,7 +176,7 @@ def getChar(idx, charTbl=asciiTbl, continuousOrder=True, expand=charsetType is N
175176
queriesCount[0] += 1
176177
result = Request.queryPage(forgedPayload)
177178

178-
if kb.dbms in ("SQLite", "Microsoft Access", "SAP MaxDB"):
179+
if kb.dbms in (DBMS.SQLITE, DBMS.ACCESS, DBMS.MAXDB):
179180
posValue = popValue()
180181

181182
if result:
@@ -491,6 +492,9 @@ def downloadThread():
491492
if val is None or ( lastChar > 0 and index > lastChar ):
492493
break
493494

495+
if kb.data.processChar:
496+
val = kb.data.processChar(val)
497+
494498
finalValue += val
495499
dataToSessionFile(replaceNewlineTabs(val))
496500

plugins/dbms/maxdb/enumeration.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
See the file 'doc/COPYING' for copying permission
88
"""
99

10+
from lib.core.data import kb
1011
from lib.core.data import logger
1112
from lib.core.settings import DBMS
1213

@@ -15,19 +16,15 @@
1516
class Enumeration(GenericEnumeration):
1617
def __init__(self):
1718
GenericEnumeration.__init__(self, DBMS.MAXDB)
19+
20+
kb.data.processChar = lambda x: x.replace('_', ' ') if x else x
1821

1922
def getDbs(self):
2023
warnMsg = "on SAP MaxDB it is not possible to enumerate databases"
2124
logger.warn(warnMsg)
2225

2326
return []
2427

25-
def getBanner(self):
26-
warnMsg = "on SAP MaxDB it is not possible to get a banner"
27-
logger.warn(warnMsg)
28-
29-
return None
30-
3128
def getPasswordHashes(self):
3229
warnMsg = "on SAP MaxDB it is not possible to enumerate the user password hashes"
3330
logger.warn(warnMsg)

plugins/dbms/maxdb/syntax.py

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,55 +16,8 @@ def __init__(self):
1616

1717
@staticmethod
1818
def unescape(expression, quote=True):
19-
if quote:
20-
while True:
21-
index = expression.find("'")
22-
if index == -1:
23-
break
24-
25-
firstIndex = index + 1
26-
index = expression[firstIndex:].find("'")
27-
28-
if index == -1:
29-
raise sqlmapSyntaxException, "Unenclosed ' in '%s'" % expression
30-
31-
lastIndex = firstIndex + index
32-
old = "'%s'" % expression[firstIndex:lastIndex]
33-
#unescaped = "("
34-
unescaped = ""
35-
36-
for i in range(firstIndex, lastIndex):
37-
unescaped += "CHR(%d)" % (ord(expression[i]))
38-
if i < lastIndex - 1:
39-
unescaped += "||"
40-
41-
#unescaped += ")"
42-
expression = expression.replace(old, unescaped)
43-
else:
44-
expression = "||".join("CHR(%d)" % ord(c) for c in expression)
45-
4619
return expression
4720

4821
@staticmethod
4922
def escape(expression):
50-
while True:
51-
index = expression.find("CHR(")
52-
if index == -1:
53-
break
54-
55-
firstIndex = index
56-
index = expression[firstIndex:].find("))")
57-
58-
if index == -1:
59-
raise sqlmapSyntaxException, "Unenclosed ) in '%s'" % expression
60-
61-
lastIndex = firstIndex + index + 1
62-
old = expression[firstIndex:lastIndex]
63-
oldUpper = old.upper()
64-
oldUpper = oldUpper.replace("CHR(", "").replace(")", "")
65-
oldUpper = oldUpper.split("||")
66-
67-
escaped = "'%s'" % "".join([chr(int(char)) for char in oldUpper])
68-
expression = expression.replace(old, escaped)
69-
7023
return expression

plugins/generic/enumeration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, dbms):
6363
kb.data.cachedTables = {}
6464
kb.data.cachedColumns = {}
6565
kb.data.dumpedTable = {}
66+
kb.data.processChar = None
6667
kb.misc.testedDbms = dbms
6768

6869
def getBanner(self):

xml/queries.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@
420420
<!-- SAP MaxDB -->
421421
<dbms value="SAP MaxDB">
422422
<length query="LENGTH(%s)"/>
423-
<inference/>
424423
<timedelay/>
425424
<banner query="SELECT ID FROM SYSINFO.VERSION"/>
426425
<isnull query="VALUE(%s,' ')" query2="IFNULL(%s, ' ')"/>
427426
<comment query="--" query2="#"/>
428427
<count query="COUNT(%s)"/>
429-
<cast query="CHR(%s)"/>
428+
<!-- No real cast on SAP MaxDB -->
429+
<cast query="REPLACE(%s, ' ', '_')"/>
430430
<current_user query="SELECT USER() FROM DUAL"/>
431431
<current_db query="SELECT DATABASE() FROM DUAL"/>
432432
<order query="ORDER BY %s ASC"/>

0 commit comments

Comments
 (0)