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

Skip to content

Commit b719b96

Browse files
committed
Adding new tamper script
1 parent 84bc264 commit b719b96

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

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

tamper/binary.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2020 sqlmap developers (http://sqlmap.org/)
5+
See the file 'LICENSE' for copying permission
6+
"""
7+
8+
import re
9+
10+
from lib.core.enums import PRIORITY
11+
12+
__priority__ = PRIORITY.HIGHEST
13+
14+
def dependencies():
15+
pass
16+
17+
def tamper(payload, **kwargs):
18+
"""
19+
Injects keyword binary where possible
20+
21+
Requirement:
22+
* MySQL
23+
24+
>>> tamper('1 UNION ALL SELECT NULL, NULL, NULL')
25+
'1 UNION ALL SELECT binary NULL, binary NULL, binary NULL'
26+
>>> tamper('1 AND 2>1')
27+
'1 AND binary 2>binary 1'
28+
>>> tamper('CASE WHEN (1=1) THEN 1 ELSE 0x28 END')
29+
'CASE WHEN (binary 1=binary 1) THEN binary 1 ELSE binary 0x28 END'
30+
"""
31+
32+
retVal = payload
33+
34+
if payload:
35+
retVal = re.sub(r"\bNULL\b", "binary NULL", retVal)
36+
retVal = re.sub(r"\b(THEN\s+)(\d+|0x[0-9a-f]+)(\s+ELSE\s+)(\d+|0x[0-9a-f]+)", r"\g<1>binary \g<2>\g<3>binary \g<4>", retVal)
37+
retVal = re.sub(r"(\d+\s*[>=]\s*)(\d+)", r"binary \g<1>binary \g<2>", retVal)
38+
retVal = re.sub(r"\b((AND|OR)\s*)(\d+)", r"\g<1>binary \g<3>", retVal)
39+
retVal = re.sub(r"([>=]\s*)(\d+)", r"\g<1>binary \g<2>", retVal)
40+
retVal = re.sub(r"\b(0x[0-9a-f]+)", r"binary \g<1>", retVal)
41+
retVal = re.sub(r"(\s+binary)+", r"\g<1>", retVal)
42+
43+
return retVal

0 commit comments

Comments
 (0)