Exfiltrating Database Content via SQLi
Once SQL injection is confirmed and you have query execution, the goal shifts to extracting and preserving high-value data efficiently. This page covers targeted extraction of credentials, schema mapping for scope awareness, and bulk export techniques. Run this after establishing injection type through SQL injection exploitation.
Map the Database Schema First
Before pulling data, understand what exists to prioritize targets. Pull all schemas and tables in one pass:
webapp.users,webapp.sessions,webapp.orders,webapp.api_keys
Prioritize tables with obvious high-value names before dumping everything. users, sessions, api_keys, tokens, and credentials come first. orders and logs are secondary unless credential material is expected there.
Extract Credentials and Hashes
Pull usernames, passwords, and roles from the users table in one query:
admin:5f4dcc3b5aa765d61d8327deb882cf99:administrator editor:8d3533d75ae2c3966d7e0d4fcc69216b:editor user1:d8578edf8458ce06fbc5bb76a58c5ca4:user
Crack the extracted hashes immediately. MD5 hashes use hashcat mode 0, bcrypt uses mode 3200, SHA1 uses mode 100:
5f4dcc3b5aa765d61d8327deb882cf99:password 8d3533d75ae2c3966d7e0d4fcc69216b:iloveyou
Extract API Keys and Tokens
Application tokens and API keys in the database often provide direct access to other services:
1:sk-prod-xK2aB1cD3eF4gH5iJ6kL7mN8oP9 2:sk-prod-qR1sT2uV3wX4yZ5aB6cD7eF8gH9
Bulk Dump with sqlmap
For full database dumps when manual extraction is too slow, sqlmap handles the complete extraction including all tables:
Important
sqlmap is not allowed on OSCP. Use manual extraction queries above for exam environments.
File System Read via SQLi
When FILE privilege is confirmed, read sensitive files directly through the SQL injection vector without needing LFI:
root:x:0:0:root:/root:/bin/bash
DB_PASSWORD=SuperSecret123! APP_KEY=base64:abc123...
Stage and Save Extracted Data
Organize extracted data into files on Kali for reporting and follow-on use:
Saved 3 hashes
References
-
Automated SQL injection data extraction with dump and output options
-
Hashcat — Mode Referencehashcat.net/wiki/doku.php?id=hashcat (opens in new tab)
Hash mode reference for MD5, SHA1, bcrypt and other common password hash formats
Was this helpful?
Your feedback helps improve this page.