π‘οΈ Defense Detection: Systematic identification of input filters, blacklisted characters, and WAF protection mechanisms
Overview
Even when developers attempt to secure web applications against injections, implementations may still be exploitable if not properly coded. Common mitigation techniques include:
Blacklisted characters and words on the back-end
Input validation filters at the application level
Web Application Firewalls (WAFs) with broader detection scope
Pattern-based detection systems
This section demonstrates how to identify what is being blocked and develop systematic bypass strategies.
Focus: Methodical filter detection and characterization to develop targeted bypass techniques.
Filter/WAF Detection
Initial Detection Signs
Scenario: Enhanced Host Checker application with security mitigations
Previous Working Payload:
127.0.0.1;whoami
Current Response:
Detection Indicators:
Application-Level Filtering:
Error message appears in normal application output
Standard web application styling maintained
Response includes original form structure
Error displayed where command output would appear
WAF-Level Filtering:
Different error page format
May include IP address and request details
Generic security-focused error message
Response may lack application-specific styling
Response Analysis
Application Filter Response:
WAF Response (Example):
Blacklisted Characters
Common Implementation
Typical PHP Blacklist Filter:
Filter Characteristics:
String-based detection - Searches for exact character matches
Case-sensitive or case-insensitive matching
Partial matches - Any occurrence triggers block
Word boundaries - May or may not respect word boundaries
Filter Logic Variations
Simple Character Blacklist:
Regex-Based Filtering:
Word-Based Filtering:
Combined Filtering:
Systematic Filter Identification
Step-by-Step Testing Methodology
Step 1: Baseline Verification
Step 2: Individual Character Testing
Test each injection operator separately:
Semicolon Test:
Expected Result:Invalid input (β Blocked)
AND Operator Test:
Expected Result:Invalid input (β Blocked)
OR Operator Test:
Expected Result:Invalid input (β Blocked)
Pipe Test:
Expected Result:Invalid input (β Blocked)
Background Test:
Expected Result:Invalid input (β Blocked)
New Line Test:
Expected Result: Normal ping output (β Not blocked!)
Character-by-Character Analysis
Isolate each special character:
HTB Academy Lab Results
Question: Which of (new-line, &, |) is not blacklisted by the web application?
Testing Process:
New Line Test:
Ampersand Test:
Pipe Test:
Answer:new-line (\n / %0a) is not blacklisted by the web application.
Advanced Filter Detection
Testing Alternative Characters
Extended Character Set:
Unicode Alternatives:
Command Detection Testing
After identifying allowed separators, test commands:
This systematic approach to filter identification provides the foundation for developing effective bypass techniques and ensures comprehensive understanding of the target application's security mechanisms.
# Using newline separator
ip=127.0.0.1%0awhoami
ip=127.0.0.1%0aid
ip=127.0.0.1%0alstp=127.0.0.1%0acat
# If basic commands are blocked, try alternatives
whoami β w β /usr/bin/whoami
id β /usr/bin/id
ls β dir (Windows) β /bin/ls
cat β type (Windows) β more β less