Skip to content

Commit

Permalink
给代码添加合适的注释,修改不合理方法名,升级版本号为0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
c0ny1 committed Mar 18, 2019
1 parent 27f2d1d commit b651794
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/burp/BurpExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class BurpExtender implements IBurpExtender,IHttpListener,IProxyListener
public static IBurpExtenderCallbacks callbacks;
public static IExtensionHelpers helpers;
private String extensionName = "Chunked coding converter";
private String version ="0.1";
private String version ="0.2";
public static PrintWriter stdout;
public static PrintWriter stderr;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/burp/Config.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package burp;


/**
* 配置对象类,负责对配置项进行设置与获取
*/
public class Config {
private static Integer min_chunked_len = 1;
private static Integer max_chunked_len = 3;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/burp/ConfigDlg.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
* 配置窗口类,负责显示配置窗口,处理窗口消息
*/
public class ConfigDlg extends JDialog {
private final JPanel mainPanel = new JPanel();
private final JPanel topPanel = new JPanel();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/burp/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import java.util.ArrayList;
import java.util.List;


/**
* 菜单类,负责显示菜单,处理菜单事件
*/
public class Menu implements IContextMenuFactory {

public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation) {
List<JMenuItem> menus = new ArrayList();
JMenu chunkedMenu = new JMenu("Chunked coding converter");
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/burp/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,21 @@
import java.io.UnsupportedEncodingException;
import java.util.*;

/**
* 编码解码类,负责对目标请求进行编码解码
*/
public class Transfer {
/**
* 对请求包进行chunked编码
* @param requestResponse 要处理的请求响应对象
* @param minChunkedLen 分块最短长度
* @param maxChunkedLen 分块最长长度
* @param isComment 是否添加注释
* @param minCommentLen 注释最短长度
* @param maxCommentLen 注释最长长度
* @return 编码后的请求包
* @throws UnsupportedEncodingException
*/
public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunkedLen, int maxChunkedLen, boolean isComment,int minCommentLen,int maxCommentLen) throws UnsupportedEncodingException {
byte[] request = requestResponse.getRequest();
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
Expand All @@ -27,7 +41,7 @@ public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunk
headers.add("Transfer-Encoding: chunked");

//encoding
List<String> str_list = Util.getStrList1(body,minChunkedLen,maxChunkedLen);
List<String> str_list = Util.getStrRandomLenList(body,minChunkedLen,maxChunkedLen);
String encoding_body = "";
for(String str:str_list){
if(isComment){
Expand All @@ -47,6 +61,13 @@ public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunk
return BurpExtender.helpers.buildHttpMessage(headers,encoding_body.getBytes());
}


/**
* 对编码过的请求包进行解码
* @param requestResponse 已编码过的请求响应对象
* @return 解码后的请求包
* @throws UnsupportedEncodingException
*/
public static byte[] decoding(IHttpRequestResponse requestResponse) throws UnsupportedEncodingException {
byte[] request = requestResponse.getRequest();
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
Expand Down Expand Up @@ -84,6 +105,7 @@ public static byte[] decoding(IHttpRequestResponse requestResponse) throws Unsup
return BurpExtender.helpers.buildHttpMessage(headers,decoding_body.getBytes());
}


/**
* 通过数据包头部是否存在Transfer-Encoding头,来判断其是否被编码
* @param requestResponse
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/burp/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ public static List<String> getStrList(String inputString, int length, int size)
return list;
}


public static List<String> getStrList1(String str, int minLen, int maxLen){
/**
* 把原始字符串分割成指定范围的随着长度字符串列表
* @param str 要分割的字符串
* @param minLen 随机最小长度
* @param maxLen 随机最大长度
* @return
*/
public static List<String> getStrRandomLenList(String str, int minLen, int maxLen){
List<String> list_str = new ArrayList<String>();
int sum = 0;
while (sum<str.length()){
Expand Down

0 comments on commit b651794

Please sign in to comment.