Skip to content

Commit fc99129

Browse files
committed
adds a try catch surrounding calls to the HAM engine to gracefully handle potential errors
1 parent a0f3ede commit fc99129

File tree

1 file changed

+58
-52
lines changed

1 file changed

+58
-52
lines changed

burp/src/main/java/burp/custombutton/EndpointsButton.java

Lines changed: 58 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -71,71 +71,77 @@ public void actionPerformed(java.awt.event.ActionEvent e)
7171
{
7272
if (BurpPropertiesManager.getBurpPropertiesManager().getConfigFile() != null )
7373
callbacks.loadConfigFromJson(getBurpConfigAsString());
74-
75-
EndpointDecorator[] endpoints = getEndpoints(view);
76-
EndpointDecorator[] comparePoints = null;
77-
if(BurpPropertiesManager.getBurpPropertiesManager().getOldSourceFolder()!= null && !BurpPropertiesManager.getBurpPropertiesManager().getOldSourceFolder().trim().isEmpty())
78-
comparePoints = getComparePoints(view);
79-
if (endpoints.length == 0)
80-
JOptionPane.showMessageDialog(view, getNoEndpointsMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
81-
else
74+
try
8275
{
83-
if (comparePoints != null && comparePoints.length != 0)
84-
endpoints = compareEndpoints(endpoints, comparePoints, view);
85-
86-
fillEndpointsToTable(endpoints);
87-
for (EndpointDecorator decorator : endpoints)
76+
EndpointDecorator[] endpoints = getEndpoints(view);
77+
EndpointDecorator[] comparePoints = null;
78+
if(BurpPropertiesManager.getBurpPropertiesManager().getOldSourceFolder()!= null && !BurpPropertiesManager.getBurpPropertiesManager().getOldSourceFolder().trim().isEmpty())
79+
comparePoints = getComparePoints(view);
80+
if (endpoints.length == 0)
81+
JOptionPane.showMessageDialog(view, getNoEndpointsMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
82+
else
8883
{
89-
if (decorator != null)
90-
{
91-
Endpoint.Info endpoint = decorator.getEndpoint();
92-
String endpointPath = endpoint.getUrlPath();
93-
if (endpointPath.startsWith("/"))
94-
endpointPath = endpointPath.substring(1);
84+
if (comparePoints != null && comparePoints.length != 0)
85+
endpoints = compareEndpoints(endpoints, comparePoints, view);
9586

96-
endpointPath = endpointPath.replaceAll(GENERIC_INT_SEGMENT, "1");
97-
nodes.add(endpointPath);
98-
for(Map.Entry<String, RouteParameter> parameter : endpoint.getParameters().entrySet())
99-
nodes.add(endpointPath + "?" + parameter.getKey() + "=" + parameter.getValue());
100-
}
101-
}
102-
String url = UrlDialog.show(view);
103-
if (url != null)
104-
{
105-
try
87+
fillEndpointsToTable(endpoints);
88+
for (EndpointDecorator decorator : endpoints)
10689
{
107-
if (!url.substring(url.length() - 1).equals("/"))
108-
url = url+"/";
109-
110-
for (String node: nodes)
90+
if (decorator != null)
11191
{
112-
URL nodeUrl = new URL(url + node);
113-
callbacks.includeInScope(nodeUrl);
114-
if(BurpPropertiesManager.getBurpPropertiesManager().getAutoSpider())
115-
callbacks.sendToSpider(nodeUrl);
92+
Endpoint.Info endpoint = decorator.getEndpoint();
93+
String endpointPath = endpoint.getUrlPath();
94+
if (endpointPath.startsWith("/"))
95+
endpointPath = endpointPath.substring(1);
96+
97+
endpointPath = endpointPath.replaceAll(GENERIC_INT_SEGMENT, "1");
98+
nodes.add(endpointPath);
99+
for(Map.Entry<String, RouteParameter> parameter : endpoint.getParameters().entrySet())
100+
nodes.add(endpointPath + "?" + parameter.getKey() + "=" + parameter.getValue());
116101
}
117-
buildRequests(view, callbacks, endpoints, url);
118-
completed = true;
119102
}
120-
catch (MalformedURLException e1)
103+
String url = UrlDialog.show(view);
104+
if (url != null)
121105
{
122-
JOptionPane.showMessageDialog(view, "Invalid URL.",
123-
"Warning", JOptionPane.WARNING_MESSAGE);
106+
try
107+
{
108+
if (!url.substring(url.length() - 1).equals("/"))
109+
url = url+"/";
110+
111+
for (String node: nodes)
112+
{
113+
URL nodeUrl = new URL(url + node);
114+
callbacks.includeInScope(nodeUrl);
115+
if(BurpPropertiesManager.getBurpPropertiesManager().getAutoSpider())
116+
callbacks.sendToSpider(nodeUrl);
117+
}
118+
buildRequests(view, callbacks, endpoints, url);
119+
completed = true;
120+
}
121+
catch (MalformedURLException e1)
122+
{
123+
JOptionPane.showMessageDialog(view, "Invalid URL.",
124+
"Warning", JOptionPane.WARNING_MESSAGE);
125+
}
126+
127+
if (completed)
128+
JOptionPane.showMessageDialog(view, getCompletedMessage());
124129
}
130+
else
131+
makeReqs = false;
132+
}
125133

126-
if (completed)
127-
JOptionPane.showMessageDialog(view, getCompletedMessage());
134+
if(makeReqs)
135+
{
136+
if (BurpPropertiesManager.getBurpPropertiesManager().getAutoScan())
137+
sendToScanner(callbacks, UrlDialog.show(view));
138+
RequestMakerThread rmt = new RequestMakerThread(callbacks, view);
139+
new Thread(rmt).start();
128140
}
129-
else
130-
makeReqs = false;
131141
}
132-
133-
if(makeReqs)
142+
catch(Exception ex)
134143
{
135-
if (BurpPropertiesManager.getBurpPropertiesManager().getAutoScan())
136-
sendToScanner(callbacks, UrlDialog.show(view));
137-
RequestMakerThread rmt = new RequestMakerThread(callbacks, view);
138-
new Thread(rmt).start();
144+
JOptionPane.showMessageDialog(view, "An error occurred processing input. Please check input");
139145
}
140146
}
141147
else

0 commit comments

Comments
 (0)