我正在开发一个 Burp Suite 扩展。
我有一个 BurpExtender 类,它有公共静态字段。
public class BurpExtender implements IBurpExtender, IContextMenuFactory{
private IBurpExtenderCallbacks callbacks;
public static PrintWriter stdout;
public static IExtensionHelpers helpers;
...
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
this.callbacks = callbacks;
this.helpers = callbacks.getHelpers();
PrintWriter stdout = new PrintWriter(callbacks.getStdout(), true);
callbacks.setExtensionName("REQUESTSENDER");
callbacks.registerContextMenuFactory(BurpExtender.this);
stdout.println("Registered");
}
public List<JMenuItem> createMenuItems(final IContextMenuInvocation invocation) {
List<JMenuItem> menuItemList = new ArrayList<JMenuItem>();
JMenuItem item = new JMenuItem(new MyAction());
menuItemList.add(item);
return menuItemList;
}
在这个文件中我有另一个类 MyAction:
private class MyAction extends AbstractAction{
public MyAction(){
super("Name");
}
public void actionPerformed(ActionEvent e) {
//Here i want to use BurpExtender.helpers, but i cant figure out, how to.
//BurpExtender.stdout doesnt work here. Dunno why, NullPoinerException.
}
}
我有另一个解决方案,当我尝试像 JMenuItem item = new JMenuItem(new AbstractAction("123") {...} 那样做时,结果是一样的