Skip to content

Commit 2642e45

Browse files
committed
New tamper script
1 parent 537f39e commit 2642e45

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tamper/commalessmid.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2015 sqlmap developers (http://sqlmap.org/)
5+
See the file 'doc/COPYING' for copying permission
6+
"""
7+
8+
import re
9+
10+
from lib.core.enums import PRIORITY
11+
12+
__priority__ = PRIORITY.HIGH
13+
14+
def dependencies():
15+
pass
16+
17+
def tamper(payload, **kwargs):
18+
"""
19+
Replaces instances like 'MID(A, B, C)' with 'MID(A FROM B FOR C)'
20+
21+
Requirement:
22+
* MySQL
23+
24+
Tested against:
25+
* MySQL 5.0 and 5.5
26+
27+
>>> tamper('MID(VERSION(), 1, 1)')
28+
'MID(VERSION() FROM 1 FOR 1)'
29+
"""
30+
31+
retVal = payload
32+
33+
match = re.search(r"(?i)MID\(([^,]+?)\s*,\s*(\d+)\s*\,\s*(\d+)\s*\)", payload or "")
34+
if match:
35+
retVal = retVal.replace(match.group(0), "MID(%s FROM %s FOR %s)" % (match.group(1), match.group(2), match.group(3)))
36+
37+
return retVal

0 commit comments

Comments
 (0)