
x01 功能设计
我们先来看看插件要实现的功能
-
在Burp Repeater套件上可对数据包进行快速chunked解码编码
-
自动化对Burp的Proxy,scanner,spider等套件的数据包进行编码
-
可设置分块长度,是否开启注释
0x02 编写代码
限于边幅,我只说明核心函数,并通过注释的方式解释代码的相关功能。
2.1 编码函数
这是我们的核心函数,对各个套件数据HTTP数据进行chunked编码
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
public static byte[] encoding(IExtensionHelpers helpers, IHttpRequestResponse requestResponse, int split_len, boolean isComment) throws UnsupportedEncodingException { byte[] request = requestResponse.getRequest(); IRequestInfo requestInfo = helpers.analyzeRequest(request); int bodyOffset = requestInfo.getBodyOffset(); int body_length = request.length - bodyOffset; String body = new String(request, bodyOffset, body_length, "UTF-8"); // 对长度大于10000的数据包,不处理 if (request.length - bodyOffset > 10000){ return request; } //对数据包进行编码处理 List<String> str_list = Util.getStrList(body,Config.splite_len); String encoding_body = ""; for(String str:str_list){ if(Config.isComment){ encoding_body += String.format("%s;%s",Util.decimalToHex(str.length()),Util.getRandomString(10)); }else{ encoding_body += Util.decimalToHex(str.length()); } encoding_body += "\r\n"; encoding_body += str; encoding_body += "\r\n"; } encoding_body += "0\r\n\r\n"; //在数据包中添加Transfer-Encoding: chunked头 List<String> headers = helpers.analyzeRequest(request).getHeaders(); Iterator<String> iter = headers.iterator(); while (iter.hasNext()) { if (((String)iter.next()).contains("Transfer-Encoding")) { iter.remove(); } } headers.add("Transfer-Encoding: chunked"); return helpers.buildHttpMessage(headers,encoding_body.getBytes());} |
自动编码其他模块的数据包,我们可以通过实现Burp的IHttpListener,IProxyListener这两个接口,分别实现processHttpMessage(),processProxyMessage()这两个方法。
这里注意一个问题,Burp的所有模块的HTTP流量都会经过IHttpListener.processHttpMessage()这个方法,但是如果在这里处理数据包的话,Burp Proxy模块的数据包被修改之后,不会在Proxy套件UI界面显示修改后的流量,故Proxy模块流量处理单独使用IProxyListener.processProxyMessage()。
2.2 自动编码Proxy套件的流量
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
@Overridepublic void processProxyMessage(final boolean messageIsRequest, final IInterceptedProxyMessage proxyMessage) { if(messageIsRequest && isValidTool(IBurpExtenderCallbacks.TOOL_PROXY)){ IHttpRequestResponse messageInfo = proxyMessage.getMessageInfo(); IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo.getRequest()); //只对Content-Typt头为application/x-www-form-urlencode的POST包进行编码 if(reqInfo.getMethod().equals("POST") && reqInfo.getContentType() == IRequestInfo.CONTENT_TYPE_URL_ENCODED){ try { //使用encoding方法对原请求包进行chunked编码 byte[] request = Transfer.encoding(helpers, messageInfo, Config.splite_len,Config.isComment); if (request != null) { //将原HTTP请求包替换为chunked编码后的请求包 messageInfo.setRequest(request); } } catch (Exception e) { stderr.println(e.getMessage()); } } }} |
完整的代码
chunked-coding-converter-master.zip
插件编译
|
1
|
mvn package |
插件使用


演示效果
3.1 演示一:快速编码解码
在Burp repeater套件可以快速对请求内容进行chunked编码解码,来对WAF进行测试。

快速编码解码对WAF进行测试
3.2 演示二:搭配sqlmap进行sql注入
sqlmap代理到Burp中,插件对Proxy套件的流量进行编码处理,来绕过waf。
