Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/tamper/bluecoat.py
2983 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
import re
9
10
from lib.core.data import kb
11
from lib.core.enums import PRIORITY
12
13
__priority__ = PRIORITY.NORMAL
14
15
def dependencies():
16
pass
17
18
def tamper(payload, **kwargs):
19
"""
20
Replaces the space following an SQL statement with a random valid blank character, then converts = to LIKE
21
22
Requirement:
23
* Blue Coat SGOS with WAF activated as documented in
24
https://kb.bluecoat.com/index?page=content&id=FAQ2147
25
26
Tested against:
27
* MySQL 5.1, SGOS
28
29
Notes:
30
* Useful to bypass Blue Coat's recommended WAF rule configuration
31
32
>>> tamper('SELECT id FROM users WHERE id = 1')
33
'SELECT%09id FROM%09users WHERE%09id LIKE 1'
34
"""
35
36
def process(match):
37
word = match.group('word')
38
if word.upper() in kb.keywords:
39
return match.group().replace(word, "%s%%09" % word)
40
else:
41
return match.group()
42
43
retVal = payload
44
45
if payload:
46
retVal = re.sub(r"\b(?P<word>[A-Z_]+)(?=[^\w(]|\Z)", process, retVal)
47
retVal = re.sub(r"\s*=\s*", " LIKE ", retVal)
48
retVal = retVal.replace("%09 ", "%09")
49
50
return retVal
51
52