Skip to content

Commit 70eb8de

Browse files
author
bb
committed
feat(tamper): add space2tab tamper script for WAF bypass via tab substitution
Adds a new tamper script that replaces space characters with tab characters (tab / %09). Useful against WAFs that block %20 (URL-encoded space) but allow %09 (URL-encoded tab), which is valid SQL whitespace across MySQL, MSSQL, PostgreSQL, Oracle, and SQLite.
1 parent f43dba3 commit 70eb8de

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

tamper/space2tab.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
5+
See the file 'LICENSE' for copying permission
6+
"""
7+
8+
from lib.core.compat import xrange
9+
from lib.core.enums import PRIORITY
10+
11+
__priority__ = PRIORITY.LOW
12+
13+
def dependencies():
14+
pass
15+
16+
def tamper(payload, **kwargs):
17+
"""
18+
Replaces space character (' ') with a tab character ('\t')
19+
20+
Tested against:
21+
* Microsoft SQL Server 2005, 2019
22+
* MySQL 4, 5.0 and 5.5
23+
* Oracle 10g
24+
* PostgreSQL 8.3, 9.0
25+
* SQLite 3
26+
27+
Notes:
28+
* Useful to bypass WAFs that block %20 (URL-encoded space)
29+
but allow %09 (URL-encoded tab), which is valid whitespace
30+
in most SQL engines
31+
* This tamper script should work against all (?) databases
32+
33+
>>> tamper('SELECT id FROM users')
34+
'SELECT\tid\tFROM\tusers'
35+
>>> tamper('1 AND 1=1')
36+
'1\tAND\t1=1'
37+
>>> tamper("SELECT * FROM users WHERE id='1 2'")
38+
"SELECT\t*\tFROM\tusers\tWHERE\tid='1 2'"
39+
"""
40+
41+
if not payload:
42+
return payload
43+
44+
if not payload:
45+
return payload
46+
47+
retVal = ""
48+
49+
if payload:
50+
quote, doublequote = False, False
51+
52+
for i in xrange(len(payload)):
53+
if payload[i] == '\'' and (i == 0 or payload[i - 1] != '\\'):
54+
quote = not quote
55+
elif payload[i] == '"' and (i == 0 or payload[i - 1] != '\\'):
56+
doublequote = not doublequote
57+
58+
if not quote and not doublequote and payload[i] == ' ':
59+
retVal += '\t'
60+
else:
61+
retVal += payload[i]
62+
63+
return retVal

0 commit comments

Comments
 (0)