pub fn whitespace_padding(input: &str) -> StringExpand description
Adds random whitespace padding to bypass simple filters.
Inserts 1-3 spaces after random alphanumeric characters with approximately 33% probability. This breaks up words and patterns while maintaining readability, useful for evading filters that match exact strings.
§Use Cases
- WAF Bypass: Evade filters that match continuous patterns
- SQL Injection: Add spaces to bypass detection (
SELECT * FROM→S E L E C T * F R O M) - XSS Testing: Break up script tags (
<script>→< s c r i p t >) - Blue Team: Test whitespace normalization in parsers
§Examples
use redstr::whitespace_padding;
let result = whitespace_padding("test");
// Example output: "t e s t" or "te s t" or "t e st" (varies each run)
assert!(result.len() >= 4);
// SQL injection with whitespace
let sql = whitespace_padding("SELECT * FROM users");
// Example: "S E L E C T * F R O M u s e r s"
// XSS payload with whitespace
let xss = whitespace_padding("<script>alert(1)</script>");
// Example: "< s c r i p t > a l e r t ( 1 ) < / s c r i p t >"