33import java .io .UnsupportedEncodingException ;
44import java .util .*;
55
6+ /**
7+ * 编码解码类,负责对目标请求进行编码解码
8+ */
69public class Transfer {
10+ /**
11+ * 对请求包进行chunked编码
12+ * @param requestResponse 要处理的请求响应对象
13+ * @param minChunkedLen 分块最短长度
14+ * @param maxChunkedLen 分块最长长度
15+ * @param isComment 是否添加注释
16+ * @param minCommentLen 注释最短长度
17+ * @param maxCommentLen 注释最长长度
18+ * @return 编码后的请求包
19+ * @throws UnsupportedEncodingException
20+ */
721 public static byte [] encoding (IHttpRequestResponse requestResponse ,int minChunkedLen , int maxChunkedLen , boolean isComment ,int minCommentLen ,int maxCommentLen ) throws UnsupportedEncodingException {
822 byte [] request = requestResponse .getRequest ();
923 IRequestInfo requestInfo = BurpExtender .helpers .analyzeRequest (request );
@@ -27,7 +41,7 @@ public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunk
2741 headers .add ("Transfer-Encoding: chunked" );
2842
2943 //encoding
30- List <String > str_list = Util .getStrList1 (body ,minChunkedLen ,maxChunkedLen );
44+ List <String > str_list = Util .getStrRandomLenList (body ,minChunkedLen ,maxChunkedLen );
3145 String encoding_body = "" ;
3246 for (String str :str_list ){
3347 if (isComment ){
@@ -47,6 +61,13 @@ public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunk
4761 return BurpExtender .helpers .buildHttpMessage (headers ,encoding_body .getBytes ());
4862 }
4963
64+
65+ /**
66+ * 对编码过的请求包进行解码
67+ * @param requestResponse 已编码过的请求响应对象
68+ * @return 解码后的请求包
69+ * @throws UnsupportedEncodingException
70+ */
5071 public static byte [] decoding (IHttpRequestResponse requestResponse ) throws UnsupportedEncodingException {
5172 byte [] request = requestResponse .getRequest ();
5273 IRequestInfo requestInfo = BurpExtender .helpers .analyzeRequest (request );
@@ -84,6 +105,7 @@ public static byte[] decoding(IHttpRequestResponse requestResponse) throws Unsup
84105 return BurpExtender .helpers .buildHttpMessage (headers ,decoding_body .getBytes ());
85106 }
86107
108+
87109 /**
88110 * 通过数据包头部是否存在Transfer-Encoding头,来判断其是否被编码
89111 * @param requestResponse
0 commit comments