7
7
import org .xml .sax .SAXException ;
8
8
9
9
import javax .swing .*;
10
- import javax .swing .ScrollPaneConstants ;
11
10
import javax .wsdl .WSDLException ;
12
11
import javax .xml .namespace .QName ;
13
12
import javax .xml .parsers .ParserConfigurationException ;
14
13
import java .awt .*;
15
- import java .io .BufferedWriter ;
16
- import java .io .File ;
17
- import java .io .FileWriter ;
18
14
import java .io .IOException ;
19
- import java .net .URL ;
20
- import java .net .URLConnection ;
15
+ import java .util .ArrayList ;
21
16
import java .util .Iterator ;
22
17
import java .util .List ;
23
18
import java .util .concurrent .ExecutionException ;
@@ -26,6 +21,7 @@ public class WSDLParser {
26
21
27
22
private IExtensionHelpers helpers ;
28
23
private WSDLParserTab tab ;
24
+ public static List <String > headers ;
29
25
30
26
public WSDLParser (IExtensionHelpers helpers , WSDLParserTab tab ) {
31
27
this .helpers = helpers ;
@@ -55,17 +51,8 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
55
51
56
52
}
57
53
58
- int bodyOffset = responseInfo .getBodyOffset ();
59
-
60
- String body = new String (response , bodyOffset , response .length - bodyOffset );
61
-
62
- File temp = createTempFile (body );
63
- if (temp == null ) {
64
- JOptionPane .showMessageDialog (tab .getUiComponent ().getParent (), "Not a WSDL" , "Error" , JOptionPane .ERROR_MESSAGE );
65
- return -2 ;
66
- }
67
-
68
54
IRequestInfo request = helpers .analyzeRequest (requestResponse );
55
+ headers = request .getHeaders ();
69
56
70
57
String url = request .getUrl ().toString ();
71
58
@@ -79,8 +66,7 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
79
66
}
80
67
Wsdl parser ;
81
68
try {
82
- URLConnection a = new URL (url .toString ()).openConnection ();
83
- parser = Wsdl .parse (url .toString ());
69
+ parser = Wsdl .parse (url );
84
70
} catch (Exception e ){
85
71
StringBuilder sb = new StringBuilder ();
86
72
sb .append (e .getMessage ());
@@ -103,9 +89,6 @@ public Dimension getPreferredSize() {
103
89
tab .getUiComponent ().getParent (), jsp , "Error" , JOptionPane .ERROR_MESSAGE );
104
90
return -3 ;
105
91
}
106
- if (!temp .delete ()){
107
- System .out .println ("Can't delete temp file" );
108
- }
109
92
110
93
WSDLTab wsdltab = tab .createTab (requestName );
111
94
List <QName > bindings ;
@@ -158,30 +141,12 @@ public Dimension getPreferredSize() {
158
141
return 0 ;
159
142
}
160
143
161
- private File createTempFile (String body ) {
162
- File temp = null ;
163
- if (!body .contains ("definitions" )) {
164
- return null ;
165
- }
166
- try {
167
- temp = File .createTempFile ("temp" , ".wsdl" );
168
- BufferedWriter bw = new BufferedWriter (new FileWriter (temp ));
169
-
170
- bw .write (body );
171
- bw .close ();
172
- } catch (Exception e ) {
173
- e .printStackTrace ();
174
- }
175
- return temp ;
176
- }
177
-
178
144
private byte [] createRequest (IHttpRequestResponse requestResponse , SoapBuilder builder , SoapOperation operation ) {
179
145
SoapContext context = SoapContext .builder ()
180
146
.alwaysBuildHeaders (true ).exampleContent (true ).typeComments (true ).buildOptional (true ).build ();
181
147
String message = builder .buildInputMessage (operation , context );
182
148
String host = getHost (builder .getServiceUrls ().get (0 ));
183
149
String endpointURL = getEndPoint (builder .getServiceUrls ().get (0 ), host );
184
-
185
150
List <String > headers ;
186
151
187
152
headers = helpers .analyzeRequest (requestResponse ).getHeaders ();
@@ -199,9 +164,11 @@ private byte[] createRequest(IHttpRequestResponse requestResponse, SoapBuilder b
199
164
iter .remove ();
200
165
}
201
166
}
167
+ headers .add ("SOAPAction: " + operation .getOperationName ());
202
168
headers .add ("Content-Type: text/xml;charset=UTF-8" );
203
169
headers .add ("Host: " + host );
204
170
171
+
205
172
return helpers .buildHttpMessage (headers , message .getBytes ());
206
173
}
207
174
0 commit comments