Skip to content

Commit 04989ee

Browse files
committed
UI & Error Handling
- Fix parsing dialog window location - Add service name to tabs - Add additional checks for WSDL validity
1 parent c8e0d71 commit 04989ee

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

src/main/java/burp/Menu.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void mouseClicked(MouseEvent e) {
3838
public void mousePressed(MouseEvent e) {
3939
WSDLParser parser = new WSDLParser(helpers, tab);
4040
try {
41-
new GuiWorker(parser,invocation, tab, callbacks).execute();
41+
new Worker(parser,invocation, tab, callbacks).execute();
4242
} catch (Exception e1) {
4343
e1.printStackTrace();
4444
}
@@ -66,7 +66,7 @@ public void mouseExited(MouseEvent e) {
6666

6767
}
6868

69-
class GuiWorker extends SwingWorker<Void,Void> {
69+
class Worker extends SwingWorker<Void,Void> {
7070

7171
private JDialog dialog = new JDialog();
7272
private JProgressBar progressBar = new JProgressBar();
@@ -76,13 +76,13 @@ class GuiWorker extends SwingWorker<Void,Void> {
7676
private IBurpExtenderCallbacks callbacks;
7777
private int status;
7878

79-
public GuiWorker(WSDLParser parser, IContextMenuInvocation invocation, WSDLParserTab tab, IBurpExtenderCallbacks callbacks) {
79+
public Worker(WSDLParser parser, IContextMenuInvocation invocation, WSDLParserTab tab, IBurpExtenderCallbacks callbacks) {
8080
progressBar.setString("Parsing WSDL");
8181
progressBar.setStringPainted(true);
8282
progressBar.setIndeterminate(true);
8383
dialog.getContentPane().add(progressBar);
8484
dialog.pack();
85-
dialog.setLocationRelativeTo(dialog.getParent());
85+
dialog.setLocationRelativeTo(tab.getUiComponent().getParent());
8686
dialog.setModal(false);
8787
dialog.setVisible(true);
8888
this.parser = parser;
@@ -106,6 +106,8 @@ protected void done() {
106106

107107
} else if(status == -2){
108108
JOptionPane.showMessageDialog(tab.getUiComponent().getParent(), "Error: Not a WSDL");
109+
} else if(status == -3){
110+
JOptionPane.showMessageDialog(tab.getUiComponent().getParent(), "Error: Can't Parse WSDL");
109111
}
110112
else {
111113
final JTabbedPane parent = (JTabbedPane) tab.getUiComponent().getParent();

src/main/java/burp/WSDLParser.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
4343

4444
IResponseInfo responseInfo = helpers.analyzeResponse(response);
4545

46+
if (!responseInfo.getStatedMimeType().contains("XML")){
47+
return -2;
48+
49+
}
50+
4651
int bodyOffset = responseInfo.getBodyOffset();
4752

4853
String body = new String(response, bodyOffset, response.length - bodyOffset);
@@ -52,11 +57,26 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
5257
return -2;
5358
}
5459

55-
Wsdl parser = Wsdl.parse(temp.toURI().toString());
60+
IRequestInfo request = helpers.analyzeRequest(requestResponse);
61+
62+
String url = request.getUrl().toString();
63+
64+
String requestName = url.substring(url.lastIndexOf("/") + 1);
65+
66+
if (requestName.contains(".")){
67+
requestName = requestName.substring(0,requestName.indexOf("."));
68+
}
69+
Wsdl parser;
70+
try {
71+
parser = Wsdl.parse(temp.toURI().toString());
72+
} catch (Exception e){
73+
return -3;
74+
}
5675
if (!temp.delete()){
5776
System.out.println("Can't delete temp file");
5877
}
59-
WSDLTab wsdltab = tab.createTab();
78+
79+
WSDLTab wsdltab = tab.createTab(requestName);
6080
List<QName> bindings = parser.getBindings();
6181
SoapBuilder builder;
6282
List<SoapOperation> operations;
@@ -93,10 +113,8 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
93113
private File createTempFile(String body) {
94114
File temp = null;
95115
if (!body.contains("definitions")) {
96-
System.out.println("WSDL definition not found");
97116
return null;
98117
}
99-
100118
try {
101119
temp = File.createTempFile("temp", ".wsdl");
102120
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));

src/main/java/burp/WSDLParserTab.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public WSDLParserTab(final IBurpExtenderCallbacks callbacks) {
2222

2323
}
2424

25-
public WSDLTab createTab() {
25+
public WSDLTab createTab(String request) {
2626

27-
WSDLTab wsdltab = new WSDLTab((callbacks), tabs);
27+
WSDLTab wsdltab = new WSDLTab((callbacks), tabs, request);
2828
tabs.setSelectedIndex(tabCount - removedTabCount);
2929
tabCount++;
3030

src/main/java/burp/WSDLTab.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class WSDLTab extends AbstractTableModel implements IMessageEditorControl
1818
JSplitPane splitPane;
1919
JTabbedPane tabbedPane;
2020

21-
public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane) {
21+
public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane, String request) {
2222
this.tabbedPane = tabbedPane;
2323
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
2424
wsdlTable = new WSDLTable(WSDLTab.this);
@@ -32,7 +32,7 @@ public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane) {
3232
tabs.addTab("Request", requestViewer.getComponent());
3333
splitPane.setTopComponent(scrollPane);
3434
splitPane.setBottomComponent(tabs);
35-
tabbedPane.add(Integer.toString(WSDLParserTab.tabCount), splitPane);
35+
tabbedPane.add(request, splitPane);
3636
tabbedPane.setTabComponentAt(WSDLParserTab.tabCount - WSDLParserTab.removedTabCount, new ButtonTabComponent(tabbedPane));
3737

3838
}

0 commit comments

Comments
 (0)