PortSwigger / burp-extensions-montoya-api

Burp Extensions Api
Other
125 stars 3 forks source link

NullPointerException on audit.addRequest() #61

Closed 423locked closed 1 year ago

423locked commented 1 year ago

Hello! I've been trying to run a scan in my extension.

The code was: @Override public void initialize(MontoyaApi api) { Audit audit = api.scanner().startAudit(AuditConfiguration.auditConfiguration(BuiltInAuditConfiguration.LEGACY_ACTIVE_AUDIT_CHECKS)); audit.addRequest(HttpRequest.httpRequest(new String("http://testphp.vulnweb.com/"))); }

I've also tried with HttpRequest.httpRequestFromUrl("https://testphp.vulnweb.com") but got the same nullpointer exception. Could you please point out the problem?

Hannah-PortSwigger commented 1 year ago

Hi

I've tested using HttpRequest.httpRequestFromUrl(), and that should work for you.

When providing a String argument to HttpRequest.httpRequest(), you will need to provide the request itself, rather than the URL of the site. For example:

"GET / HTTP/1.1\r\nHost: testphp.vulnweb.com\r\n\r\n"

In addition, you will also need to provide it with a valid HttpService.

You should find that the following code works for your purposes:

Audit audit = api.scanner().startAudit(AuditConfiguration.auditConfiguration(BuiltInAuditConfiguration.LEGACY_ACTIVE_AUDIT_CHECKS));
audit.addRequest(HttpRequest.httpRequestFromUrl("http://testphp.vulnweb.com/"));
423locked commented 1 year ago

Thanks! httpRequestFromUrl works well.