Course contentsShow
← Security
Lesson 583 of 3,05213. Web Security - Injection AttacksFree lesson

Advanced Data Exfiltration Methods

Using substring functions, concatenation, and encoding to extract data efficiently in constrained scenarios.

Advanced Data Exfiltration Methods

What you'll learn: How to efficiently extract data from databases through SQL injection using substring extraction, concatenation, and encoding when direct retrieval is blocked or limited.

When you've successfully exploited SQL injection but face constraints—like limited output space, no visible errors, or restrictive filtering—you need advanced techniques to piece together stolen data bit by bit.

Why Basic Extraction Fails

Sometimes you can't simply dump an entire database column. The application might truncate output, filter certain characters, or only show single results. You need surgical precision to extract data in small, controlled chunks.

Substring Extraction

The SUBSTRING() function (or SUBSTR() in some databases) lets you extract specific character ranges from data:

' UNION SELECT SUBSTRING(password, 1, 1) FROM users--

This grabs just the first character of a password. You then repeat for positions 2, 3, 4, and so on—reconstructing the full value character by character through multiple requests.

Concatenation for Assembly

Use CONCAT() or the || operator to combine multiple pieces of data into one output field:

' UNION SELECT CONCAT(username, ':', password) FROM users--

This merges username and password into a single extractable string, maximizing what you get per query.

Encoding for Evasion

When filters block certain characters or data types, encoding bypasses restrictions. Converting to hexadecimal, ASCII values, or base64 lets you extract data that would otherwise trigger filters:

' UNION SELECT HEX(password) FROM users--

The hex-encoded output looks like 68656c6c6f instead of hello—you decode it offline.

Key Takeaway: Advanced data exfiltration uses substring functions to extract data piece-by-piece, concatenation to combine multiple fields efficiently, and encoding to bypass filters—essential when direct extraction methods are constrained or blocked.