如何捕获该服务器无法在burp扩展?

时间:2017-01-22 04:49:59

标签: java burp

我正在开发一个burp扩展程序。 我使用callbacks.makeHttpRequest(host,port,bool,request)方法。 当burp可以到达服务器时,一切正常,但如果服务器无法将错误抛给stderr。

这是代码

protected static final String HOST = "127.0.0.1";
protected static final int PORT = 1337;
private IBurpExtenderCallbacks callbacks;

private class MyThread implements Runnable {

    private IHttpRequestResponse request;

    MyThread(IHttpRequestResponse inputRequest) {
        request = inputRequest;
    }

    @Override
    public void run() {
        String host = "http://" + HOST + ":" + PORT + "/";
        host = host + "?" + "host=" + request.getHttpService().getHost() + "&port=" +
                request.getHttpService().getPort();
        try {
            URL url = new URL(host);
            byte[] hostrequest = helpers.buildHttpRequest(url);
            try {
                byte[] response = callbacks.makeHttpRequest(HOST, PORT, false, hostrequest);
                if (response != null) {
                    IResponseInfo responseinfo = helpers.analyzeResponse(response);
                    if (responseinfo.getStatusCode() == 200) {
                        callbacks.makeHttpRequest(HOST, PORT, false, request.getRequest());
                    }
                }
            } catch (Exception e) {
                stdout.println("Server is unable");
            }

        } catch (MalformedURLException e) {
            stdout.println("URL CREATING ERROR");
        }
    }
}

因此,如果HOST无法,则byte [] response = callbacks.makeHttpRequest(HOST,PORT,false,hostrequest);  抛出错误:

java.lang.UnsupportedOperationException: Request has not yet been issued
   at burp.cfc.makeHttpRequest(Unknown Source)
   at burp.BurpExtender$MyThread.run(BurpExtender.java:77)
   at java.lang.Thread.run(Thread.java:745)

我需要自己抓住它

0 个答案:

没有答案