Extracting Data

Overview

With a working oracle, we can extract data character by character.

Process:

  1. Find password length

  2. Extract each character using ASCII values

  3. Reconstruct the full value


Step 1: Finding the Length

Use LEN(string) to find password length:

# Get the target's password length
length = 0

# Loop until the value of `length` matches `LEN(password)`
while not oracle(f"LEN(password)={length}"):
    length += 1

print(f"[*] Password length = {length}")

Output


Step 2: Extracting Characters

SQL Functions Used

Function
Purpose
Example

SUBSTRING(expr, start, len)

Extract character at position

SUBSTRING(password, 1, 1)

ASCII(char)

Convert character to decimal

ASCII('A') = 65

Query Structure

Where:

  • N = character position (1-indexed)

  • C = ASCII decimal value to test


Manual Testing

Test Position 1, ASCII 0

Payload:

Response: available (False) - Character is NOT ASCII 0

Test Position 1, ASCII 57 ('9')

Payload:

Response: taken (True) - First character IS '9'!


ASCII Reference

Printable Range

Range
Characters

32-47

Space, punctuation

48-57

0-9 (digits)

65-90

A-Z (uppercase)

97-122

a-z (lowercase)

123-126

Brackets, symbols

πŸ’‘ Tip: For hashes, focus on 48-57 (0-9) and 97-102 (a-f) for hex characters.


Automated Extraction Script


Full Working Script

Output


Troubleshooting

Script Fails / Incomplete Results

Solution 1: Reset target machine and retry

Solution 2: Add delay between requests

Rate Limiting

If getting blocked, increase delay:


Performance Analysis

Password Length
ASCII Range
Max Requests

32 chars

0-127

32 Γ— 128 = 4,096

32 chars

32-126 (printable)

32 Γ— 95 = 3,040

32 chars

hex only (0-9, a-f)

32 Γ— 16 = 512

Time Estimation

At 100ms per request:

  • 4,096 requests β‰ˆ 6.8 minutes

  • 512 requests β‰ˆ 51 seconds


Optimizations Preview

Instead of linear (0,1,2...127), use binary search:

Complexity: 7 requests per character instead of ~64 average!


Next Steps


Quick Reference

Key Functions (MSSQL)

Extraction Template

Last updated