8
8
import java .awt .Component ;
9
9
import java .awt .event .ActionListener ;
10
10
import java .awt .event .ActionEvent ;
11
- import java .io .PrintWriter ;
12
11
13
12
public class GUI {
14
- private IBurpExtenderCallbacks mCall ;
15
- private IExtensionHelpers helpers ;
16
- private PrintWriter stdout ;
17
- private PrintWriter stderr ;
18
-
19
13
private JPanel contentPane ;
20
14
private JLabel lbHost ;
21
15
private JTextField tfHost ;
@@ -42,11 +36,7 @@ public class GUI{
42
36
"woaini520" ,"woaini" ,"100200" ,"1314520"
43
37
};
44
38
45
- public GUI (IBurpExtenderCallbacks callbacks ) {
46
- this .mCall = callbacks ;
47
- this .helpers = callbacks .getHelpers ();
48
- this .stdout = new PrintWriter (callbacks .getStdout (), true );
49
- this .stderr = new PrintWriter (callbacks .getStderr (), true );
39
+ public GUI () {
50
40
contentPane = new JPanel ();
51
41
contentPane .setBorder (new EmptyBorder (5 , 5 , 5 , 5 ));
52
42
contentPane .setLayout (new BorderLayout (0 , 0 ));
@@ -85,24 +75,24 @@ public GUI(IBurpExtenderCallbacks callbacks) {
85
75
btnConn .setToolTipText ("Test the connection phantomJS" );
86
76
btnConn .addActionListener (new ActionListener () {
87
77
public void actionPerformed (ActionEvent arg0 ) {
88
- GUI .this .testConnect ();
78
+ GUI .this .TestConnect ();
89
79
}
90
80
});
91
81
panel .add (btnConn );
92
82
93
83
lbConnectInfo = new JLabel ("IsConnect:" );
94
84
panel .add (lbConnectInfo );
95
- lbConnectStatus = new JLabel ("noknow " );
85
+ lbConnectStatus = new JLabel ("unknown " );
96
86
lbConnectStatus .setForeground (new Color (0 , 0 , 255 ));
97
87
panel .add (lbConnectStatus );
98
88
99
89
btnTest = new JButton ("Test" );
100
90
btnTest .addActionListener (new ActionListener () {
101
91
public void actionPerformed (ActionEvent arg0 ) {
102
- testConnect ();
92
+ GUI . this . TestConnect ();
103
93
if (isSucces ){
104
- GUI .this .Test ();
105
- GUI . this .stdout .println ("[+] test..." );
94
+ GUI .this .TestPayload ();
95
+ BurpExtender .stdout .println ("[+] test..." );
106
96
}else {
107
97
JOptionPane .showMessageDialog (contentPane , "Please check if you can connect phantomJS!" , "alert" , JOptionPane .ERROR_MESSAGE );
108
98
}
@@ -134,12 +124,12 @@ public void actionPerformed(ActionEvent arg0) {
134
124
ScrollPaneConstants .HORIZONTAL_SCROLLBAR_AS_NEEDED );
135
125
splitPane .setRightComponent (spResultPayload );
136
126
137
- mCall .customizeUiComponent (panel );
138
- mCall .customizeUiComponent (btnTest );
139
- mCall .customizeUiComponent (btnConn );
140
- mCall .customizeUiComponent (taTestPayload );
141
- mCall .customizeUiComponent (splitPane );
142
- mCall .customizeUiComponent (contentPane );
127
+ BurpExtender . callbacks .customizeUiComponent (panel );
128
+ BurpExtender . callbacks .customizeUiComponent (btnTest );
129
+ BurpExtender . callbacks .customizeUiComponent (btnConn );
130
+ BurpExtender . callbacks .customizeUiComponent (taTestPayload );
131
+ BurpExtender . callbacks .customizeUiComponent (splitPane );
132
+ BurpExtender . callbacks .customizeUiComponent (contentPane );
143
133
}
144
134
145
135
public Component getComponet (){
@@ -149,42 +139,40 @@ public Component getComponet(){
149
139
public Integer getTimeout (){
150
140
return Integer .valueOf (tfTimeout .getText ());
151
141
}
142
+
143
+ // 发送连接测试,确定是否能连接加密服务端
144
+ private void TestConnect (){
145
+ boolean isConn = Utils .sendTestConnect ();
146
+ if (isConn ){
147
+ BurpExtender .stdout .println ("[+] connect success!" );
148
+ lbConnectStatus .setText ("True" );
149
+ isSucces = true ;
150
+ lbConnectStatus .setForeground (new Color (0 ,255 ,0 ));
151
+ }else {
152
+ BurpExtender .stdout .println ("[-] connect fail!" );
153
+ lbConnectStatus .setText ("False" );
154
+ isSucces = false ;
155
+ lbConnectStatus .setForeground (new Color (255 ,0 ,0 ));
156
+ }
157
+ }
158
+
152
159
153
- // 测试
154
- private void Test () {
160
+ // 发送测试payload,确定是否加密成功
161
+ private void TestPayload () {
155
162
taResultPayload .setText ("" );
156
163
btnTest .setEnabled (false );
157
164
SwingUtilities .invokeLater (new Runnable () {
158
165
public void run () {
159
166
String [] payloads = taTestPayload .getText ().split ("\n \r " );
160
167
for (String payload : payloads ) {
161
- String newPayload = sendTestPaylaod (payload );
168
+ String newPayload = Utils . sendPayload (payload );
162
169
taResultPayload .append (newPayload + "\n \r " );
163
170
}
164
171
btnTest .setEnabled (true );
165
172
}
166
173
});
167
174
}
168
175
169
- // 发送测试payload
170
- private String sendTestPaylaod (String payload ) {
171
- String newPayload = null ;
172
- try {
173
- HttpClient hc = new HttpClient (this .getURL ());
174
- hc .setConnTimeout (Integer .valueOf (tfTimeout .getText ()));
175
- hc .setReadTimeout (Integer .valueOf (tfTimeout .getText ()));
176
- String data = "payload=" + payload ;
177
- hc .setData (data );
178
- hc .sendPost ();
179
- newPayload = hc .getRspData ();
180
- } catch (Exception e ) {
181
- stderr .println (e .getMessage ());
182
- newPayload = e .getMessage ();
183
- }
184
- return newPayload ;
185
- }
186
-
187
-
188
176
// 获取phantomJS
189
177
public String getURL (){
190
178
String URL ;
@@ -193,32 +181,4 @@ public String getURL(){
193
181
URL = String .format ("http://%s:%s" ,host ,port );
194
182
return URL ;
195
183
}
196
-
197
- //测试连接phantomJS
198
- private void testConnect (){
199
- try {
200
- HttpClient hc = new HttpClient (this .getURL ());
201
- hc .setReadTimeout (Integer .valueOf (tfTimeout .getText ()));
202
- hc .setConnTimeout (Integer .valueOf (tfTimeout .getText ()));
203
- hc .sendGet ();
204
- int n = helpers .indexOf (hc .getRspData ().getBytes (), "hello" .getBytes (), false , 0 , hc .getRspData ().length ());
205
- if ((hc .getStatusCode () == 200 )&&(n != -1 )){
206
- stdout .println ("[+] connect success!" );
207
- lbConnectStatus .setText ("True" );
208
- isSucces = true ;
209
- lbConnectStatus .setForeground (new Color (0 ,255 ,0 ));
210
- }else {
211
- stdout .println ("[-] connect fail!" );
212
- lbConnectStatus .setText ("False" );
213
- isSucces = false ;
214
- lbConnectStatus .setForeground (new Color (255 ,0 ,0 ));
215
- }
216
- } catch (Exception e ) {
217
- stderr .println (e .getMessage ());
218
- stdout .println ("[-] connect fail!" );
219
- lbConnectStatus .setText ("False" );
220
- isSucces = false ;
221
- lbConnectStatus .setForeground (new Color (255 ,0 ,0 ));
222
- }
223
- }
224
184
}
0 commit comments