Filter Identification

πŸ›‘οΈ 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:

  1. Blacklisted characters and words on the back-end

  2. Input validation filters at the application level

  3. Web Application Firewalls (WAFs) with broader detection scope

  4. 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:

Basic Commands:

Alternative Commands:

Payload Structure Analysis

Test different payload positions:

Prefix Injection:

Suffix Injection:

Middle Injection:

Multiple Commands:


Filter Bypass Strategy Development

Systematic Approach

Phase 1: Character Mapping

Phase 2: Command Testing

Phase 3: Payload Optimization

Documentation Template

Filter Analysis Report:


Common Filter Patterns

Application-Level Filters

Simple Blacklist:

  • Blocks common injection characters

  • Case-sensitive string matching

  • No context awareness

  • Easy to bypass with alternatives

Advanced Application Filters:

  • Regex pattern matching

  • Command word detection

  • Context-aware filtering

  • Parameter validation

WAF-Level Filters

Signature-Based:

  • Known attack pattern detection

  • Multi-parameter correlation

  • HTTP header analysis

  • Rate limiting integration

Behavioral Analysis:

  • Anomaly detection

  • Machine learning models

  • Statistical analysis

  • Dynamic rule adaptation

Hybrid Approaches

Multi-Layer Defense:

  1. Client-side validation (easily bypassed)

  2. Application input filters (character/command blocking)

  3. WAF protection (pattern-based detection)

  4. System-level controls (sandboxing, permissions)


Testing Automation

Systematic Character Testing Script

Python Filter Detector:

Command Testing Automation

Command Enumeration:


Key Takeaways

Filter Identification Best Practices

1. Systematic Testing:

  • Start with individual characters

  • Test all injection operators

  • Document allowed/blocked patterns

  • Build comprehensive filter map

2. Incremental Complexity:

  • Begin with simple payloads

  • Gradually increase complexity

  • Test command combinations

  • Validate bypass techniques

3. Documentation:

  • Maintain detailed filter analysis

  • Track working payloads

  • Note environmental constraints

  • Plan bypass strategies

Success Indicators

βœ… Effective Filter Mapping:

  • Clear allowed/blocked character list

  • Working injection operator identified

  • Command execution confirmed

  • Bypass strategy developed

πŸ” Further Investigation Needed:

  • Mixed/inconsistent responses

  • Partial command execution

  • Timing-based differences

  • Context-dependent filtering

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.

Last updated