BurpSuite获取req和resp数据
package burp;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BurpExtender implements IBurpExtender, IHttpListener,
IProxyListener, IScannerListener, IExtensionStateListener
{
private IBurpExtenderCallbacks callbacks;
private PrintWriter stdout;
private IExtensionHelpers helpers;
//
// implement IBurpExtender
//
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
{
// keep a reference to our callbacks object
this.callbacks = callbacks;
helpers = callbacks.getHelpers();
// set our extension name
callbacks.setExtensionName("VulnScan(20181121001)");
// obtain our output stream
stdout = new PrintWriter(callbacks.getStdout(), true);
// register ourselves as an HTTP listener
callbacks.registerHttpListener(this);
// register ourselves as a Proxy listener
// callbacks.registerProxyListener(this);
// register ourselves as a Scanner listener
// callbacks.registerScannerListener(this);
// register ourselves as an extension state listener
// callbacks.registerExtensionStateListener(this);
}
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)
{
if (messageIsRequest){
//此时response为空.
IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
List<String> headers = reqInfo.getHeaders();
String hostname = messageInfo.getHttpService().getHost();
int port = messageInfo.getHttpService().getPort();
byte[] body = Arrays.copyOfRange(
messageInfo.getRequest(),
reqInfo.getBodyOffset(),
messageInfo.getRequest().length);
String s = new String(body);
// stdout.println("requests----------");
// stdout.println(reqInfo.getUrl());
// stdout.println(reqInfo.getMethod());
// stdout.println("hostname:" + hostname);
// stdout.println("headers:" + headers);
// stdout.println("body:" + s);
}else{
//response
byte[] responseBytes = messageInfo.getResponse();
IResponseInfo respInfo = helpers.analyzeResponse(responseBytes);
List<String> headers = respInfo.getHeaders();
IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
String hostname = messageInfo.getHttpService().getHost();
String myurl = reqInfo.getUrl().toString();
stdout.println(reqInfo.getUrl());
if (!hostname.equals("clients4.google.com") && myurl.indexOf("")){
stdout.println("response----------");
stdout.println(reqInfo.getUrl());
stdout.println(hostname);
String s = new String(responseBytes);
stdout.println(s);
byte[] body = Arrays.copyOfRange(
messageInfo.getResponse(),
respInfo.getBodyOffset(),
messageInfo.getResponse().length);
String ss = new String(body);
stdout.println("body:" + ss);
}
// stdout.println("headers:" + headers);
// header or something
//stdout.println(messageInfo.getResponse());
}
// stdout.println(messageInfo.getRequest());
// stdout.println(messageInfo.getResponse());
// stdout.println(messageInfo.getHttpService());
// stdout.println(
// (messageIsRequest ? "HTTP request to " : "HTTP response from ") +
// messageInfo.getHttpService() +
// " [" + callbacks.getToolName(toolFlag) + "]");
}
//
// implement IProxyListener
//
@Override
public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessage message)
{
stdout.println(
(messageIsRequest ? "Proxy request to " : "Proxy response from ") +
message.getMessageInfo().getHttpService());
}
//
// implement IScannerListener
//
@Override
public void newScanIssue(IScanIssue issue)
{
stdout.println("New scan issue: " + issue.getIssueName());
}
//
// implement IExtensionStateListener
//
@Override
public void extensionUnloaded()
{
stdout.println("Extension was unloaded");
}
}
BurpSuite获取req和resp数据
package burp;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BurpExtender implements IBurpExtender, IHttpListener,
IProxyListener, IScannerListener, IExtensionStateListener
{
private IBurpExtenderCallbacks callbacks;
private PrintWriter stdout;
private IExtensionHelpers helpers;
//
// implement IBurpExtender
//
@Override
public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
{
// keep a reference to our callbacks object
this.callbacks = callbacks;
helpers = callbacks.getHelpers();
// set our extension name
callbacks.setExtensionName("VulnScan(20181121001)");
// obtain our output stream
stdout = new PrintWriter(callbacks.getStdout(), true);
// register ourselves as an HTTP listener
callbacks.registerHttpListener(this);
// register ourselves as a Proxy listener
// callbacks.registerProxyListener(this);
// register ourselves as a Scanner listener
// callbacks.registerScannerListener(this);
// register ourselves as an extension state listener
// callbacks.registerExtensionStateListener(this);
}
@Override
public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)
{
if (messageIsRequest){
//此时response为空.
IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
List<String> headers = reqInfo.getHeaders();
String hostname = messageInfo.getHttpService().getHost();
int port = messageInfo.getHttpService().getPort();
byte[] body = Arrays.copyOfRange(
messageInfo.getRequest(),
reqInfo.getBodyOffset(),
messageInfo.getRequest().length);
String s = new String(body);
// stdout.println("requests----------");
// stdout.println(reqInfo.getUrl());
// stdout.println(reqInfo.getMethod());
// stdout.println("hostname:" + hostname);
// stdout.println("headers:" + headers);
// stdout.println("body:" + s);
}else{
//response
byte[] responseBytes = messageInfo.getResponse();
IResponseInfo respInfo = helpers.analyzeResponse(responseBytes);
List<String> headers = respInfo.getHeaders();
IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
String hostname = messageInfo.getHttpService().getHost();
String myurl = reqInfo.getUrl().toString();
stdout.println(reqInfo.getUrl());
if (!hostname.equals("clients4.google.com") && myurl.indexOf("")){
stdout.println("response----------");
stdout.println(reqInfo.getUrl());
stdout.println(hostname);
String s = new String(responseBytes);
stdout.println(s);
byte[] body = Arrays.copyOfRange(
messageInfo.getResponse(),
respInfo.getBodyOffset(),
messageInfo.getResponse().length);
String ss = new String(body);
stdout.println("body:" + ss);
}
// stdout.println("headers:" + headers);
// header or something
//stdout.println(messageInfo.getResponse());
}
// stdout.println(messageInfo.getRequest());
// stdout.println(messageInfo.getResponse());
// stdout.println(messageInfo.getHttpService());
// stdout.println(
// (messageIsRequest ? "HTTP request to " : "HTTP response from ") +
// messageInfo.getHttpService() +
// " [" + callbacks.getToolName(toolFlag) + "]");
}
//
// implement IProxyListener
//
@Override
public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessage message)
{
stdout.println(
(messageIsRequest ? "Proxy request to " : "Proxy response from ") +
message.getMessageInfo().getHttpService());
}
//
// implement IScannerListener
//
@Override
public void newScanIssue(IScanIssue issue)
{
stdout.println("New scan issue: " + issue.getIssueName());
}
//
// implement IExtensionStateListener
//
@Override
public void extensionUnloaded()
{
stdout.println("Extension was unloaded");
}
}
参考代码