Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/tamper/percentage.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 os
9
import string
10
11
from lib.core.common import singleTimeWarnMessage
12
from lib.core.enums import PRIORITY
13
14
__priority__ = PRIORITY.LOW
15
16
def dependencies():
17
singleTimeWarnMessage("tamper script '%s' is only meant to be run against ASP web applications" % os.path.basename(__file__).split(".")[0])
18
19
def tamper(payload, **kwargs):
20
"""
21
Adds a percentage sign ('%') infront of each character (e.g. SELECT -> %S%E%L%E%C%T)
22
23
Requirement:
24
* ASP
25
26
Tested against:
27
* Microsoft SQL Server 2000, 2005
28
* MySQL 5.1.56, 5.5.11
29
* PostgreSQL 9.0
30
31
Notes:
32
* Useful to bypass weak and bespoke web application firewalls
33
34
>>> tamper('SELECT FIELD FROM TABLE')
35
'%S%E%L%E%C%T %F%I%E%L%D %F%R%O%M %T%A%B%L%E'
36
"""
37
38
if payload:
39
retVal = ""
40
i = 0
41
42
while i < len(payload):
43
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:
44
retVal += payload[i:i + 3]
45
i += 3
46
elif payload[i] != ' ':
47
retVal += '%%%s' % payload[i]
48
i += 1
49
else:
50
retVal += payload[i]
51
i += 1
52
53
return retVal
54
55