Support Center

Burp Community

See what our users are saying about Burp Suite:

How do I?

New Post View All

Feature Requests

New Post View All

Burp Extensions

New Post View All

Bug Reports

New Post View All
Documentation

Burp Suite Documentation

Take a look at our Documentation section for full details about every Burp Suite tool, function and configuration option.

Full Documentation Contents Burp Projects
Suite Functions Burp Tools
Options Using Burp Suite
Extensibility

Burp Extender

Burp Extender lets you extend the functionality of Burp Suite in numerous ways.

Extensions can be written in Java, Python or Ruby.

API documentation Writing your first Burp Suite extension
Sample extensions View community discussions about Extensibility
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Extension resource loading

Mehrdad Sep 10, 2017 04:35AM UTC

I've embedded some static files inside the extension, in the folder named `assets`.
Trying to access them fails, using following code:

InputStream in = DataUtils.class.getClassLoader().getResourceAsStream("/assets/" + filename);

Maybe it fails because "/" refers to root of `burp.jar`, not my `ext.jar`.
How can I access the assets?


Mehrdad Sep 12, 2017 04:16AM UTC
This code works for me, assuming assets are not loaded in classpath:

public static String readAsset(String filename) throws IOException {
URL url = new URL("jar:file:/"+BurpExtender.getInstance().getCallbacks().getExtensionFilename()+"!/assets/"+ filename);
InputStream in = url.openStream();
StringWriter writer = new StringWriter();
IOUtils.copy(in, writer, StandardCharsets.UTF_8);
return writer.toString();
}

Paul Johnston Sep 13, 2017 11:34AM UTC Support Center agent

Hi Mehrdad,

Thanks for your message. I presume DataUtils is within your extension? DataUtils.class.getClassLoader should return the loader for your extension. You can check this with:

    URLClassLoader ucl = (URLClassLoader) DataUtils.class.getClassLoader();
    for(URL url : ucl.getURLs()) {
       callbacks.printOutput(url.toString());
    }

I just did some testing, and I think you need to remove the leading / from your file name. Also, use “jar -tf” to double check your assets location within your jar file.

Please let us know if you need any further assistance.


Post Your public answer

Your name
Your email address
Answer