Analyze the Results for a POST-based SQL Injection
In this step, you will analyze the output from sqlmap to understand the vulnerability it discovered. After the scan from the previous step completes, sqlmap will present a summary of its findings.
The final output will look something like this:
---
Parameter: username (POST)
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: username=test' AND (SELECT 6113 FROM (SELECT(SLEEP(5)))bYjb) AND 'TEST'='TEST&password=test
---
[INFO] the back-end DBMS is 'MySQL >= 5.0.12'
web server operating system: Linux
web application technology: PHP 8.1.2
back-end DBMS: MySQL >= 5.0
[INFO] fetched data logged to text files under '/home/labex/.sqlmap/output/localhost:8000'
Let's break down this result:
- Parameter: username (POST): This confirms the vulnerability was found in the
username parameter of a POST request.
- Type: time-based blind: This is the type of SQL injection. "Blind" means the application does not return database errors in its responses. "Time-based" means
sqlmap confirmed the vulnerability by injecting commands that cause a time delay (e.g., SLEEP(5)) and measuring the server's response time.
- Payload: This shows the actual malicious input that
sqlmap used to confirm the vulnerability.
sqlmap also saves all session information, including logs and results, to a directory. The location is mentioned in the output, typically ~/.sqlmap/output/. You can inspect this directory to find detailed logs of the scan.
Let's list the contents of the results directory for our target:
ls -l ~/.sqlmap/output/localhost:8000
You will see files like log and session.sqlite. The log file contains a complete record of the scan, which is useful for detailed analysis and reporting.
total 24
-rw-r--r-- 1 labex labex 15589 Dec 6 15:30 log
-rw-r--r-- 1 labex labex 8192 Dec 6 15:30 session.sqlite
-rw-r--r-- 1 labex labex 0 Dec 6 15:29 target.txt
You have now successfully identified and confirmed a POST-based SQL injection vulnerability using sqlmap.