Burp Suite User Forum

Create new post

Problems with availability of HashMap in doPassiveScan (noob level)

first | Last updated: Mar 06, 2016 08:10PM UTC

Hi, First of all sorry for this stupid noob question, but it has been driving me crazy for hours now. Why is "hostHashMap" null in "doPassiveScan"? How can I make hostHashMap available? Many thanks in advance! package burp; import java.awt.Component; import java.io.PrintWriter; import javax.swing.JSplitPane; import java.util.HashMap; import java.util.List; public class BurpExtender implements IBurpExtender, IScannerCheck, ITab { private IBurpExtenderCallbacks callbacks; private IExtensionHelpers helpers; public PrintWriter stdout; private HashMap<String, String> hostHashMap; private JSplitPane splitPane; private static final String VERSION = "0.1"; private static final String EXTENSION_NAME = "test"; @Override public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) { // keep a reference to our callbacks object this.callbacks = callbacks; this.helpers = callbacks.getHelpers(); // set our extension name callbacks.setExtensionName(EXTENSION_NAME); // obtain our output stream stdout = new PrintWriter(callbacks.getStdout(), true); // register ourselves as a custom scanner check callbacks.registerScannerCheck(this); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); // add the custom tab to Burp's UI callbacks.addSuiteTab(this); // write a message to our output stream callbacks.printOutput("Started " + EXTENSION_NAME + " version " + VERSION); // testing HashMap HashMap<String, String> hostHashMap = new HashMap<String, String>(); hostHashMap.put("key", "value"); } @Override public List<IScanIssue> doPassiveScan(IHttpRequestResponse baseRequestResponse) { // hostHashMap should be available here...? if (hostHashMap == null) { stdout.println("no"); } else { stdout.println("yes"); } return null; } @Override public List<IScanIssue> doActiveScan(IHttpRequestResponse baseRequestResponse, IScannerInsertionPoint insertionPoint) { return null; } @Override public String getTabCaption() { return EXTENSION_NAME; } @Override public Component getUiComponent() { return splitPane; } @Override public int consolidateDuplicateIssues(IScanIssue existingIssue, IScanIssue newIssue) { return 0; } }

PortSwigger Agent | Last updated: Mar 10, 2016 11:25AM UTC

At the point when you create your hashmap, you are assigning it to a local variable within the method, not to the class variable that you have declared. Remove HashMap<String, String> from the start of the line where you create your map.

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.