forked from NetSPI/JavaSerialKiller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChildTab.java
More file actions
197 lines (148 loc) · 7.27 KB
/
ChildTab.java
File metadata and controls
197 lines (148 loc) · 7.27 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package burp;
import com.google.common.primitives.Bytes;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
public class ChildTab implements IMessageEditorController, ActionListener {
private final IMessageEditor requestViewer;
private final IMessageEditor responseViewer;
private final IBurpExtenderCallbacks callbacks;
private final IExtensionHelpers helpers;
private final IHttpService httpService;
private byte[] request;
private byte[] response;
public static byte[] selectedMessage;
private final JPanel panel;
public static boolean isEncoded;
JButton goButton;
JCheckBox base64CheckBox;
private final JComboBox<String> payloadComboBox;
private final JTextField commandTextField;
private final JLabel status;
public ChildTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane, String title, byte[] request, IHttpService httpService) {
this.callbacks = callbacks;
this.helpers = callbacks.getHelpers();
this.httpService = httpService;
this.request = request;
panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
requestViewer = callbacks.createMessageEditor(this, true);
responseViewer = callbacks.createMessageEditor(this, false);
requestViewer.setMessage(request, true);
JPanel leftSplitPanePanel = new JPanel();
leftSplitPanePanel.setLayout(new BorderLayout());
leftSplitPanePanel.add(requestViewer.getComponent());
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setAlignmentX(Component.CENTER_ALIGNMENT);
splitPane.setResizeWeight(0.5);
splitPane.setLeftComponent(leftSplitPanePanel);
splitPane.setRightComponent(responseViewer.getComponent());
JPanel topButtonPanel = new JPanel();
topButtonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
goButton = new JButton("Go");
goButton.setActionCommand("go");
goButton.addActionListener(ChildTab.this);
JButton serializeButton = new JButton("Serialize");
serializeButton.setActionCommand("serialize");
serializeButton.addActionListener(ChildTab.this);
base64CheckBox = new JCheckBox("Base64 Encode");
String[] typeStrings = { "BeanShell1","CommonsBeanutilsCollectionsLogging1", "CommonsCollections1", "CommonsCollections2", "CommonsCollections3", "CommonsCollections4","Groovy1","Jdk7u21","Spring1"};
payloadComboBox = new JComboBox<>(typeStrings);
JButton helpButton = new JButton("?");
helpButton.setActionCommand("?");
helpButton.addActionListener(ChildTab.this);
topButtonPanel.add(goButton);
topButtonPanel.add(serializeButton);
topButtonPanel.add(base64CheckBox);
topButtonPanel.add(payloadComboBox);
topButtonPanel.add(helpButton);
JPanel commandPanel = new JPanel();
commandPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
JLabel commandLabel = new JLabel("Command: ");
commandTextField = new JTextField(50);
commandTextField.setMaximumSize(new Dimension(Integer.MAX_VALUE, commandTextField.getPreferredSize().height));
commandPanel.add(commandLabel);
commandPanel.add(commandTextField);
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
status = new JLabel("Done");
bottomPanel.add(status);
panel.add(topButtonPanel);
panel.add(commandPanel);
panel.add(splitPane);
panel.add(bottomPanel);
tabbedPane.add(title, panel);
tabbedPane.setTabComponentAt(JavaSerialKillerTab.tabCount - JavaSerialKillerTab.removedTabCount, new ButtonTabComponent(tabbedPane));
}
private void sendRequest() {
Thread thread = new Thread() {
public void run() {
IRequestInfo iRequestInfo = helpers.analyzeRequest(requestViewer.getMessage());
byte[] requestMessage = requestViewer.getMessage();
java.util.List<String> headers = iRequestInfo.getHeaders();
int bodyOffset = iRequestInfo.getBodyOffset();
byte[] newBody = new byte[requestMessage.length - bodyOffset];
System.arraycopy(requestMessage, bodyOffset, newBody, 0, requestMessage.length - bodyOffset);
byte[] requestHTTPMessage = helpers.buildHttpMessage(headers, newBody);
responseViewer.setMessage(new byte[0], false);
status.setText("Waiting");
goButton.setEnabled(false);
IHttpRequestResponse httpMessage = callbacks.makeHttpRequest(httpService, requestHTTPMessage);
status.setText("Done");
responseViewer.setMessage(httpMessage.getResponse(), false);
response = httpMessage.getResponse();
goButton.setEnabled(true);
}
};
thread.start();
}
private void serializeRequest() {
byte[] message = requestViewer.getMessage();
byte[] selectedMessage = requestViewer.getSelectedData();
// String[] command = Utilities.formatCommand(commandTextField.getText());
boolean isEncoded = base64CheckBox.isSelected();
String command = commandTextField.getText();
String payloadType = payloadComboBox.getSelectedItem().toString();
byte[] httpMessage = Utilities.serializeRequest(message,selectedMessage,isEncoded,command,helpers,payloadType);
requestViewer.setMessage(httpMessage, true);
request = httpMessage;
}
private void questionDialog(){
JOptionPane.showMessageDialog(this.panel,"BeanShell1 [org.beanshell:bsh:2.0b5]\n" +
"CommonsBeanutilsCollectionsLogging1 [commons-beanutils:commons-beanutils:1.9.2, commons-collections:commons-collections:3.1, commons-logging:commons-logging:1.2]\n" +
"CommonsCollections1 [commons-collections:commons-collections:3.1]\n" +
"CommonsCollections2 [org.apache.commons:commons-collections4:4.0]\n" +
"CommonsCollections3 [commons-collections:commons-collections:3.1]\n" +
"CommonsCollections4 [org.apache.commons:commons-collections4:4.0]\n" +
"Groovy1 [org.codehaus.groovy:groovy:2.3.9]\n" +
"Jdk7u21 []\n" +
"Spring1 [org.springframework:spring-core:4.1.4.RELEASE, org.springframework:spring-beans:4.1.4.RELEASE]",
"ysoserial Payload Options",
JOptionPane.PLAIN_MESSAGE);
}
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
switch (command) {
case "go":
sendRequest();
break;
case "serialize":
serializeRequest();
break;
case "?":
questionDialog();
break;
}
}
public IHttpService getHttpService() {
return httpService;
}
public byte[] getRequest() {
return request;
}
public byte[] getResponse() {
return response;
}
}