FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(tamper): add space2tab tamper script for WAF bypass via tab substitution by Char0n1507 · Pull Request #6088 · sqlmapproject/sqlmap · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
63 changes: 63 additions & 0 deletions tamper/space2tab.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env python

"""
Copyright (c) 2006-2026 sqlmap developers (https://sqlmap.org)
See the file 'LICENSE' for copying permission
"""

from lib.core.compat import xrange
from lib.core.enums import PRIORITY

__priority__ = PRIORITY.LOW

def dependencies():
pass

def tamper(payload, **kwargs):
"""
Replaces space character (' ') with a tab character ('\t')

Tested against:
* Microsoft SQL Server 2005, 2019
* MySQL 4, 5.0 and 5.5
* Oracle 10g
* PostgreSQL 8.3, 9.0
* SQLite 3

Notes:
* Useful to bypass WAFs that block %20 (URL-encoded space)
but allow %09 (URL-encoded tab), which is valid whitespace
in most SQL engines
* This tamper script should work against all (?) databases

>>> tamper('SELECT id FROM users')
'SELECT\tid\tFROM\tusers'
>>> tamper('1 AND 1=1')
'1\tAND\t1=1'
>>> tamper("SELECT * FROM users WHERE id='1 2'")
"SELECT\t*\tFROM\tusers\tWHERE\tid='1 2'"
"""

if not payload:
return payload

if not payload:
return payload

retVal = ""

if payload:
quote, doublequote = False, False

for i in xrange(len(payload)):
if payload[i] == '\'' and (i == 0 or payload[i - 1] != '\\'):
quote = not quote
elif payload[i] == '"' and (i == 0 or payload[i - 1] != '\\'):
doublequote = not doublequote

if not quote and not doublequote and payload[i] == ' ':
retVal += '\t'
else:
retVal += payload[i]

return retVal

Back | FazBrowse Home | New Git URL