2013-02-14 15:32:17 +04:00
|
|
|
#!/usr/bin/env python
|
2011-07-07 22:45:07 +04:00
|
|
|
|
|
|
|
"""
|
2018-01-02 02:48:10 +03:00
|
|
|
Copyright (c) 2006-2018 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2011-07-07 22:45:07 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
import string
|
|
|
|
|
|
|
|
from lib.core.enums import PRIORITY
|
|
|
|
|
|
|
|
__priority__ = PRIORITY.LOW
|
|
|
|
|
|
|
|
def dependencies():
|
|
|
|
pass
|
|
|
|
|
2012-12-03 17:27:01 +04:00
|
|
|
def tamper(payload, **kwargs):
|
2011-07-07 22:45:07 +04:00
|
|
|
"""
|
|
|
|
Double url-encodes all characters in a given payload (not processing
|
|
|
|
already encoded)
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
* Useful to bypass some weak web application firewalls that do not
|
|
|
|
double url-decode the request before processing it through their
|
|
|
|
ruleset
|
2013-03-14 00:57:09 +04:00
|
|
|
|
|
|
|
>>> tamper('SELECT FIELD FROM%20TABLE')
|
|
|
|
'%2553%2545%254C%2545%2543%2554%2520%2546%2549%2545%254C%2544%2520%2546%2552%254F%254D%2520%2554%2541%2542%254C%2545'
|
2011-07-07 22:45:07 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
retVal = payload
|
|
|
|
|
|
|
|
if payload:
|
|
|
|
retVal = ""
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
while i < len(payload):
|
2013-01-10 16:18:44 +04:00
|
|
|
if payload[i] == '%' and (i < len(payload) - 2) and payload[i + 1:i + 2] in string.hexdigits and payload[i + 2:i + 3] in string.hexdigits:
|
2013-03-14 00:57:09 +04:00
|
|
|
retVal += '%%25%s' % payload[i + 1:i + 3]
|
2011-07-07 22:45:07 +04:00
|
|
|
i += 3
|
|
|
|
else:
|
2012-07-24 03:21:32 +04:00
|
|
|
retVal += '%%25%.2X' % ord(payload[i])
|
2011-07-07 22:45:07 +04:00
|
|
|
i += 1
|
|
|
|
|
2012-10-25 12:10:23 +04:00
|
|
|
return retVal
|