Skip to content

Commit

Permalink
UI & Error Handling
Browse files Browse the repository at this point in the history
- Fix parsing dialog window location
- Add service name to tabs
- Add additional checks for WSDL validity
  • Loading branch information
egru committed May 6, 2015
1 parent c8e0d71 commit 04989ee
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
10 changes: 6 additions & 4 deletions src/main/java/burp/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void mouseClicked(MouseEvent e) {
public void mousePressed(MouseEvent e) {
WSDLParser parser = new WSDLParser(helpers, tab);
try {
new GuiWorker(parser,invocation, tab, callbacks).execute();
new Worker(parser,invocation, tab, callbacks).execute();
} catch (Exception e1) {
e1.printStackTrace();
}
Expand Down Expand Up @@ -66,7 +66,7 @@ public void mouseExited(MouseEvent e) {

}

class GuiWorker extends SwingWorker<Void,Void> {
class Worker extends SwingWorker<Void,Void> {

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

public GuiWorker(WSDLParser parser, IContextMenuInvocation invocation, WSDLParserTab tab, IBurpExtenderCallbacks callbacks) {
public Worker(WSDLParser parser, IContextMenuInvocation invocation, WSDLParserTab tab, IBurpExtenderCallbacks callbacks) {
progressBar.setString("Parsing WSDL");
progressBar.setStringPainted(true);
progressBar.setIndeterminate(true);
dialog.getContentPane().add(progressBar);
dialog.pack();
dialog.setLocationRelativeTo(dialog.getParent());
dialog.setLocationRelativeTo(tab.getUiComponent().getParent());
dialog.setModal(false);
dialog.setVisible(true);
this.parser = parser;
Expand All @@ -106,6 +106,8 @@ protected void done() {

} else if(status == -2){
JOptionPane.showMessageDialog(tab.getUiComponent().getParent(), "Error: Not a WSDL");
} else if(status == -3){
JOptionPane.showMessageDialog(tab.getUiComponent().getParent(), "Error: Can't Parse WSDL");
}
else {
final JTabbedPane parent = (JTabbedPane) tab.getUiComponent().getParent();
Expand Down
26 changes: 22 additions & 4 deletions src/main/java/burp/WSDLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback

IResponseInfo responseInfo = helpers.analyzeResponse(response);

if (!responseInfo.getStatedMimeType().contains("XML")){
return -2;

}

int bodyOffset = responseInfo.getBodyOffset();

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

Wsdl parser = Wsdl.parse(temp.toURI().toString());
IRequestInfo request = helpers.analyzeRequest(requestResponse);

String url = request.getUrl().toString();

String requestName = url.substring(url.lastIndexOf("/") + 1);

if (requestName.contains(".")){
requestName = requestName.substring(0,requestName.indexOf("."));
}
Wsdl parser;
try {
parser = Wsdl.parse(temp.toURI().toString());
} catch (Exception e){
return -3;
}
if (!temp.delete()){
System.out.println("Can't delete temp file");
}
WSDLTab wsdltab = tab.createTab();

WSDLTab wsdltab = tab.createTab(requestName);
List<QName> bindings = parser.getBindings();
SoapBuilder builder;
List<SoapOperation> operations;
Expand Down Expand Up @@ -93,10 +113,8 @@ public int parseWSDL(IHttpRequestResponse requestResponse, IBurpExtenderCallback
private File createTempFile(String body) {
File temp = null;
if (!body.contains("definitions")) {
System.out.println("WSDL definition not found");
return null;
}

try {
temp = File.createTempFile("temp", ".wsdl");
BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/burp/WSDLParserTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public WSDLParserTab(final IBurpExtenderCallbacks callbacks) {

}

public WSDLTab createTab() {
public WSDLTab createTab(String request) {

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/burp/WSDLTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class WSDLTab extends AbstractTableModel implements IMessageEditorControl
JSplitPane splitPane;
JTabbedPane tabbedPane;

public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane) {
public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane, String request) {
this.tabbedPane = tabbedPane;
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
wsdlTable = new WSDLTable(WSDLTab.this);
Expand All @@ -32,7 +32,7 @@ public WSDLTab(final IBurpExtenderCallbacks callbacks, JTabbedPane tabbedPane) {
tabs.addTab("Request", requestViewer.getComponent());
splitPane.setTopComponent(scrollPane);
splitPane.setBottomComponent(tabs);
tabbedPane.add(Integer.toString(WSDLParserTab.tabCount), splitPane);
tabbedPane.add(request, splitPane);
tabbedPane.setTabComponentAt(WSDLParserTab.tabCount - WSDLParserTab.removedTabCount, new ButtonTabComponent(tabbedPane));

}
Expand Down

0 comments on commit 04989ee

Please sign in to comment.