Skip to content

Commit b651794

Browse files
committed
给代码添加合适的注释,修改不合理方法名,升级版本号为0.2
1 parent 27f2d1d commit b651794

File tree

6 files changed

+41
-8
lines changed

6 files changed

+41
-8
lines changed

src/main/java/burp/BurpExtender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class BurpExtender implements IBurpExtender,IHttpListener,IProxyListener
66
public static IBurpExtenderCallbacks callbacks;
77
public static IExtensionHelpers helpers;
88
private String extensionName = "Chunked coding converter";
9-
private String version ="0.1";
9+
private String version ="0.2";
1010
public static PrintWriter stdout;
1111
public static PrintWriter stderr;
1212

src/main/java/burp/Config.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package burp;
22

3-
3+
/**
4+
* 配置对象类,负责对配置项进行设置与获取
5+
*/
46
public class Config {
57
private static Integer min_chunked_len = 1;
68
private static Integer max_chunked_len = 3;

src/main/java/burp/ConfigDlg.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.awt.event.ActionEvent;
66
import java.awt.event.ActionListener;
77

8-
8+
/**
9+
* 配置窗口类,负责显示配置窗口,处理窗口消息
10+
*/
911
public class ConfigDlg extends JDialog {
1012
private final JPanel mainPanel = new JPanel();
1113
private final JPanel topPanel = new JPanel();

src/main/java/burp/Menu.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
import java.util.ArrayList;
77
import java.util.List;
88

9-
9+
/**
10+
* 菜单类,负责显示菜单,处理菜单事件
11+
*/
1012
public class Menu implements IContextMenuFactory {
11-
1213
public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation) {
1314
List<JMenuItem> menus = new ArrayList();
1415
JMenu chunkedMenu = new JMenu("Chunked coding converter");

src/main/java/burp/Transfer.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
import java.io.UnsupportedEncodingException;
44
import java.util.*;
55

6+
/**
7+
* 编码解码类,负责对目标请求进行编码解码
8+
*/
69
public 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

src/main/java/burp/Util.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,14 @@ public static List<String> getStrList(String inputString, int length, int size)
3838
return list;
3939
}
4040

41-
42-
public static List<String> getStrList1(String str, int minLen, int maxLen){
41+
/**
42+
* 把原始字符串分割成指定范围的随着长度字符串列表
43+
* @param str 要分割的字符串
44+
* @param minLen 随机最小长度
45+
* @param maxLen 随机最大长度
46+
* @return
47+
*/
48+
public static List<String> getStrRandomLenList(String str, int minLen, int maxLen){
4349
List<String> list_str = new ArrayList<String>();
4450
int sum = 0;
4551
while (sum<str.length()){

0 commit comments

Comments
 (0)