Skip to content

Commit 27f2d1d

Browse files
committed
删除多余变量精简代码,添加贡献者
1 parent 7b180bd commit 27f2d1d

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

src/main/java/burp/BurpExtender.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
1515
this.callbacks = callbacks;
1616
this.helpers = callbacks.getHelpers();
1717
callbacks.setExtensionName(String.format("%s %s",extensionName,version));
18-
callbacks.registerContextMenuFactory(new Menu(callbacks));
18+
callbacks.registerContextMenuFactory(new Menu());
1919
callbacks.registerHttpListener(this);
2020
callbacks.registerProxyListener(this);
2121
stdout = new PrintWriter(callbacks.getStdout(),true);
@@ -32,7 +32,7 @@ public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequ
3232

3333
if(reqInfo.getMethod().equals("POST")){
3434
try {
35-
byte[] request = Transfer.encoding(helpers, messageInfo, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
35+
byte[] request = Transfer.encoding(messageInfo, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
3636
if (request != null) {
3737
messageInfo.setRequest(request);
3838
}
@@ -52,7 +52,7 @@ public void processProxyMessage(final boolean messageIsRequest, final IIntercept
5252

5353
if(reqInfo.getMethod().equals("POST")){
5454
try {
55-
byte[] request = Transfer.encoding(helpers, messageInfo, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
55+
byte[] request = Transfer.encoding(messageInfo, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
5656
if (request != null) {
5757
messageInfo.setRequest(request);
5858
}
@@ -63,7 +63,11 @@ public void processProxyMessage(final boolean messageIsRequest, final IIntercept
6363
}
6464
}
6565

66-
66+
/**
67+
* 插件是否作用于该套件
68+
* @param toolFlag
69+
* @return
70+
*/
6771
private boolean isValidTool(int toolFlag){
6872
return (Config.isAct_on_all_tools() ||
6973
(Config.isAct_on_proxy() && toolFlag== IBurpExtenderCallbacks.TOOL_PROXY) ||
@@ -88,6 +92,7 @@ public String getBanner(){
8892
+ "[+] " + extensionName + " v" + version +"\n"
8993
+ "[+] anthor: c0ny1\n"
9094
+ "[+] email: [email protected]\n"
95+
+ "[+] contributor: phith0n\n"
9196
+ "[+] github: http://github.com/c0ny1/chunked-coding-converter\n"
9297
+ "[+] ##############################################";
9398
return bannerInfo;

src/main/java/burp/Menu.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,11 @@
33
import javax.swing.*;
44
import java.awt.event.ActionEvent;
55
import java.awt.event.ActionListener;
6-
import java.io.PrintWriter;
76
import java.util.ArrayList;
87
import java.util.List;
98

109

1110
public class Menu implements IContextMenuFactory {
12-
private IBurpExtenderCallbacks callbacks;
13-
private final IExtensionHelpers m_helpers;
14-
private PrintWriter stdout;
15-
private PrintWriter stderr;
16-
17-
18-
public Menu(IBurpExtenderCallbacks callbacks) {
19-
this.callbacks = callbacks;
20-
this.m_helpers = callbacks.getHelpers();
21-
this.stdout = new PrintWriter(callbacks.getStdout(),true);
22-
this.stderr = new PrintWriter(callbacks.getStderr(),true);
23-
}
24-
2511

2612
public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation) {
2713
List<JMenuItem> menus = new ArrayList();
@@ -44,7 +30,7 @@ public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation)
4430

4531
public void actionPerformed(ActionEvent arg0) {
4632
IHttpRequestResponse iReqResp = invocation.getSelectedMessages()[0];
47-
IRequestInfo reqInfo = m_helpers.analyzeRequest(iReqResp.getRequest());
33+
IRequestInfo reqInfo = BurpExtender.helpers.analyzeRequest(iReqResp.getRequest());
4834
// 不对GET请求进行编码
4935
if(!reqInfo.getMethod().equals("POST")){
5036
JOptionPane.showConfirmDialog(null,"GET requests cannot be chunked encoded!","Warning",JOptionPane.CLOSED_OPTION,JOptionPane.WARNING_MESSAGE);
@@ -58,12 +44,12 @@ public void actionPerformed(ActionEvent arg0) {
5844
}
5945

6046
try {
61-
byte[] request = Transfer.encoding(m_helpers, iReqResp, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
47+
byte[] request = Transfer.encoding(iReqResp, Config.getMin_chunked_len(),Config.getMax_chunked_len(),Config.isAddComment(),Config.getMin_comment_len(),Config.getMax_comment_len());
6248
if (request != null) {
6349
iReqResp.setRequest(request);
6450
}
6551
} catch (Exception e) {
66-
stderr.println(e.getMessage());
52+
BurpExtender.stderr.println(e.getMessage());
6753
}
6854
}
6955
});
@@ -80,12 +66,12 @@ public void actionPerformed(ActionEvent arg0) {
8066
}
8167

8268
try {
83-
byte[] request = Transfer.decoding(m_helpers,iReqResp);
69+
byte[] request = Transfer.decoding(iReqResp);
8470
if (request != null) {
8571
iReqResp.setRequest(request);
8672
}
8773
} catch (Exception e) {
88-
stderr.println(e.getMessage());
74+
BurpExtender.stderr.println(e.getMessage());
8975
}
9076
}
9177
});
@@ -95,10 +81,10 @@ public void actionPerformed(ActionEvent arg0) {
9581
public void actionPerformed(ActionEvent arg0) {
9682
try {
9783
ConfigDlg dlg = new ConfigDlg();
98-
callbacks.customizeUiComponent(dlg);
84+
BurpExtender.callbacks.customizeUiComponent(dlg);
9985
dlg.setVisible(true);
10086
}catch (Exception e){
101-
e.printStackTrace(stderr);
87+
e.printStackTrace(BurpExtender.stderr);
10288
}
10389
}
10490
});

src/main/java/burp/Transfer.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import java.util.*;
55

66
public class Transfer {
7-
public static byte[] encoding(IExtensionHelpers helpers, IHttpRequestResponse requestResponse,int minChunkedLen, int maxChunkedLen, boolean isComment,int minCommentLen,int maxCommentLen) throws UnsupportedEncodingException {
7+
public static byte[] encoding(IHttpRequestResponse requestResponse,int minChunkedLen, int maxChunkedLen, boolean isComment,int minCommentLen,int maxCommentLen) throws UnsupportedEncodingException {
88
byte[] request = requestResponse.getRequest();
9-
IRequestInfo requestInfo = helpers.analyzeRequest(request);
9+
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
1010
int bodyOffset = requestInfo.getBodyOffset();
1111
int body_length = request.length - bodyOffset;
1212
String body = new String(request, bodyOffset, body_length, "UTF-8");
@@ -15,7 +15,7 @@ public static byte[] encoding(IExtensionHelpers helpers, IHttpRequestResponse r
1515
return request;
1616
}
1717

18-
List<String> headers = helpers.analyzeRequest(request).getHeaders();
18+
List<String> headers = BurpExtender.helpers.analyzeRequest(request).getHeaders();
1919
Iterator<String> iter = headers.iterator();
2020
while (iter.hasNext()) {
2121
//不对请求包重复编码
@@ -44,17 +44,17 @@ public static byte[] encoding(IExtensionHelpers helpers, IHttpRequestResponse r
4444

4545

4646

47-
return helpers.buildHttpMessage(headers,encoding_body.getBytes());
47+
return BurpExtender.helpers.buildHttpMessage(headers,encoding_body.getBytes());
4848
}
4949

50-
public static byte[] decoding(IExtensionHelpers helpers, IHttpRequestResponse requestResponse) throws UnsupportedEncodingException {
50+
public static byte[] decoding(IHttpRequestResponse requestResponse) throws UnsupportedEncodingException {
5151
byte[] request = requestResponse.getRequest();
52-
IRequestInfo requestInfo = helpers.analyzeRequest(request);
52+
IRequestInfo requestInfo = BurpExtender.helpers.analyzeRequest(request);
5353
int bodyOffset = requestInfo.getBodyOffset();
5454
String body = new String(request, bodyOffset, request.length - bodyOffset, "UTF-8");
5555

5656
// Delete Transfer-Encoding header
57-
List<String> headers = helpers.analyzeRequest(request).getHeaders();
57+
List<String> headers = BurpExtender.helpers.analyzeRequest(request).getHeaders();
5858
Iterator<String> iter = headers.iterator();
5959
Boolean isChunked = false;//是否被分块编码过
6060
while (iter.hasNext()) {
@@ -81,7 +81,7 @@ public static byte[] decoding(IExtensionHelpers helpers, IHttpRequestResponse re
8181
}
8282
}
8383

84-
return helpers.buildHttpMessage(headers,decoding_body.getBytes());
84+
return BurpExtender.helpers.buildHttpMessage(headers,decoding_body.getBytes());
8585
}
8686

8787
/**

0 commit comments

Comments
 (0)