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

Skip to content

Commit 98e449e

Browse files
committed
Adding plus2fnconcat tamper script (Issue #2396)
1 parent 9acf122 commit 98e449e

4 files changed

Lines changed: 96 additions & 3 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.core.enums import OS
2020

2121
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
22-
VERSION = "1.1.2.9"
22+
VERSION = "1.1.2.10"
2323
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2424
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2525
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

tamper/plus2concat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def tamper(payload, **kwargs):
3030
3131
>>> tamper('SELECT CHAR(113)+CHAR(114)+CHAR(115) FROM DUAL')
3232
'SELECT CONCAT(CHAR(113),CHAR(114),CHAR(115)) FROM DUAL'
33+
34+
>>> tamper('SELECT (CHAR(113)+CHAR(114)+CHAR(115)) FROM DUAL')
35+
'SELECT CONCAT(CHAR(113),CHAR(114),CHAR(115)) FROM DUAL'
3336
"""
3437

3538
retVal = payload

tamper/plus2fnconcat.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2017 sqlmap developers (http://sqlmap.org/)
5+
See the file 'doc/COPYING' for copying permission
6+
"""
7+
8+
import re
9+
10+
from lib.core.common import zeroDepthSearch
11+
from lib.core.enums import PRIORITY
12+
13+
__priority__ = PRIORITY.HIGHEST
14+
15+
def dependencies():
16+
pass
17+
18+
def tamper(payload, **kwargs):
19+
"""
20+
Replaces plus ('+') character with ODBC function {fn CONCAT()}
21+
22+
Tested against:
23+
* Microsoft SQL Server 2008
24+
25+
Requirements:
26+
* Microsoft SQL Server 2008+
27+
28+
Notes:
29+
* Useful in case ('+') character is filtered
30+
* https://msdn.microsoft.com/en-us/library/bb630290.aspx
31+
32+
>>> tamper('SELECT CHAR(113)+CHAR(114)+CHAR(115) FROM DUAL')
33+
'SELECT {fn CONCAT({fn CONCAT(CHAR(113),CHAR(114))},CHAR(115))} FROM DUAL'
34+
35+
>>> tamper('SELECT (CHAR(113)+CHAR(114)+CHAR(115)) FROM DUAL')
36+
'SELECT {fn CONCAT({fn CONCAT(CHAR(113),CHAR(114))},CHAR(115))} FROM DUAL'
37+
"""
38+
39+
retVal = payload
40+
41+
if payload:
42+
while True:
43+
indexes = zeroDepthSearch(retVal, '+')
44+
45+
if indexes:
46+
first, last = 0, 0
47+
for i in xrange(1, len(indexes)):
48+
if ' ' in retVal[indexes[0]:indexes[i]]:
49+
break
50+
else:
51+
last = i
52+
53+
start = retVal[:indexes[first]].rfind(' ') + 1
54+
end = (retVal[indexes[last] + 1:].find(' ') + indexes[last] + 1) if ' ' in retVal[indexes[last] + 1:] else len(retVal) - 1
55+
56+
count = 0
57+
chars = [char for char in retVal]
58+
for index in indexes[first:last + 1]:
59+
if count == 0:
60+
chars[index] = ','
61+
else:
62+
chars[index] = '\x01'
63+
count += 1
64+
65+
retVal = "%s%s%s)}%s" % (retVal[:start], "{fn CONCAT(" * count, ''.join(chars)[start:end].replace('\x01', ")},"), retVal[end:])
66+
else:
67+
match = re.search(r"\((CHAR\(\d+.+CHAR\(\d+\))\)", retVal)
68+
if match:
69+
part = match.group(0)
70+
indexes = set(zeroDepthSearch(match.group(1), '+'))
71+
if not indexes:
72+
break
73+
74+
count = 0
75+
chars = [char for char in part]
76+
for i in xrange(1, len(chars)):
77+
if i - 1 in indexes:
78+
if count == 0:
79+
chars[i] = ','
80+
else:
81+
chars[i] = '\x01'
82+
count += 1
83+
84+
replacement = "%s%s}" % (("{fn CONCAT(" * count)[:-1], "".join(chars).replace('\x01', ")},"))
85+
retVal = retVal.replace(part, replacement)
86+
else:
87+
break
88+
89+
return retVal

txt/checksum.md5

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ e544108e2238d756c94a240e8a1ce061 lib/core/optiondict.py
4545
d8e9250f3775119df07e9070eddccd16 lib/core/replication.py
4646
785f86e3f963fa3798f84286a4e83ff2 lib/core/revision.py
4747
40c80b28b3a5819b737a5a17d4565ae9 lib/core/session.py
48-
f108158ecd5c238a5f94f6f80d5f4c1a lib/core/settings.py
48+
001e41795dfa7fe8c8cea3dfba9f7d60 lib/core/settings.py
4949
d91291997d2bd2f6028aaf371bf1d3b6 lib/core/shell.py
5050
2ad85c130cc5f2b3701ea85c2f6bbf20 lib/core/subprocessng.py
5151
afd0636d2e93c23f4f0a5c9b6023ea17 lib/core/target.py
@@ -252,7 +252,8 @@ a3a0e76922b4f40f422a0daca4e71af3 tamper/htmlencode.py
252252
54e1793f30c755202ee1acaacfac45fb tamper/nonrecursivereplacement.py
253253
00ba60e5869055aaa7ba0cd23b5ed1f4 tamper/overlongutf8.py
254254
3cadacb0f39de03e0f8612c656104e03 tamper/percentage.py
255-
dfaa889d125c34c7b2b468012d2b5279 tamper/plus2concat.py
255+
3e09fc9f1a6f3fee03f9213aaee97191 tamper/plus2concat.py
256+
7a18480b27d62eb574cf0150a57e81b1 tamper/plus2fnconcat.py
256257
24753ed4e8ceab6f1a1fc13ee621943b tamper/randomcase.py
257258
4d5fdfe77668fa44967e1d44f8a50ce7 tamper/randomcomments.py
258259
22561b429f41fc0bdd23e36b9a8de9e5 tamper/securesphere.py

0 commit comments

Comments
 (0)