BurpSuite获取req和resp数据

  1. package burp;
  2. import java.io.PrintWriter;
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. public class BurpExtender implements IBurpExtender, IHttpListener,
  7. IProxyListener, IScannerListener, IExtensionStateListener
  8. {
  9. private IBurpExtenderCallbacks callbacks;
  10. private PrintWriter stdout;
  11. private IExtensionHelpers helpers;
  12. //
  13. // implement IBurpExtender
  14. //
  15. @Override
  16. public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
  17. {
  18. // keep a reference to our callbacks object
  19. this.callbacks = callbacks;
  20. helpers = callbacks.getHelpers();
  21. // set our extension name
  22. callbacks.setExtensionName("VulnScan(20181121001)");
  23. // obtain our output stream
  24. stdout = new PrintWriter(callbacks.getStdout(), true);
  25. // register ourselves as an HTTP listener
  26. callbacks.registerHttpListener(this);
  27. // register ourselves as a Proxy listener
  28. // callbacks.registerProxyListener(this);
  29. // register ourselves as a Scanner listener
  30. // callbacks.registerScannerListener(this);
  31. // register ourselves as an extension state listener
  32. // callbacks.registerExtensionStateListener(this);
  33. }
  34. @Override
  35. public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)
  36. {
  37. if (messageIsRequest){
  38. //此时response为空.
  39. IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
  40. List<String> headers = reqInfo.getHeaders();
  41. String hostname = messageInfo.getHttpService().getHost();
  42. int port = messageInfo.getHttpService().getPort();
  43. byte[] body = Arrays.copyOfRange(
  44. messageInfo.getRequest(),
  45. reqInfo.getBodyOffset(),
  46. messageInfo.getRequest().length);
  47. String s = new String(body);
  48. // stdout.println("requests----------");
  49. // stdout.println(reqInfo.getUrl());
  50. // stdout.println(reqInfo.getMethod());
  51. // stdout.println("hostname:" + hostname);
  52. // stdout.println("headers:" + headers);
  53. // stdout.println("body:" + s);
  54. }else{
  55. //response
  56. byte[] responseBytes = messageInfo.getResponse();
  57. IResponseInfo respInfo = helpers.analyzeResponse(responseBytes);
  58. List<String> headers = respInfo.getHeaders();
  59. IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
  60. String hostname = messageInfo.getHttpService().getHost();
  61. String myurl = reqInfo.getUrl().toString();
  62. stdout.println(reqInfo.getUrl());
  63. if (!hostname.equals("clients4.google.com") && myurl.indexOf("")){
  64. stdout.println("response----------");
  65. stdout.println(reqInfo.getUrl());
  66. stdout.println(hostname);
  67. String s = new String(responseBytes);
  68. stdout.println(s);
  69. byte[] body = Arrays.copyOfRange(
  70. messageInfo.getResponse(),
  71. respInfo.getBodyOffset(),
  72. messageInfo.getResponse().length);
  73. String ss = new String(body);
  74. stdout.println("body:" + ss);
  75. }
  76. // stdout.println("headers:" + headers);
  77. // header or something
  78. //stdout.println(messageInfo.getResponse());
  79. }
  80. // stdout.println(messageInfo.getRequest());
  81. // stdout.println(messageInfo.getResponse());
  82. // stdout.println(messageInfo.getHttpService());
  83. // stdout.println(
  84. // (messageIsRequest ? "HTTP request to " : "HTTP response from ") +
  85. // messageInfo.getHttpService() +
  86. // " [" + callbacks.getToolName(toolFlag) + "]");
  87. }
  88. //
  89. // implement IProxyListener
  90. //
  91. @Override
  92. public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessage message)
  93. {
  94. stdout.println(
  95. (messageIsRequest ? "Proxy request to " : "Proxy response from ") +
  96. message.getMessageInfo().getHttpService());
  97. }
  98. //
  99. // implement IScannerListener
  100. //
  101. @Override
  102. public void newScanIssue(IScanIssue issue)
  103. {
  104. stdout.println("New scan issue: " + issue.getIssueName());
  105. }
  106. //
  107. // implement IExtensionStateListener
  108. //
  109. @Override
  110. public void extensionUnloaded()
  111. {
  112. stdout.println("Extension was unloaded");
  113. }
  114. }
  1. BurpSuite获取reqresp数据
  2. package burp;
  3. import java.io.PrintWriter;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6. import java.util.List;
  7. public class BurpExtender implements IBurpExtender, IHttpListener,
  8. IProxyListener, IScannerListener, IExtensionStateListener
  9. {
  10. private IBurpExtenderCallbacks callbacks;
  11. private PrintWriter stdout;
  12. private IExtensionHelpers helpers;
  13. //
  14. // implement IBurpExtender
  15. //
  16. @Override
  17. public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks)
  18. {
  19. // keep a reference to our callbacks object
  20. this.callbacks = callbacks;
  21. helpers = callbacks.getHelpers();
  22. // set our extension name
  23. callbacks.setExtensionName("VulnScan(20181121001)");
  24. // obtain our output stream
  25. stdout = new PrintWriter(callbacks.getStdout(), true);
  26. // register ourselves as an HTTP listener
  27. callbacks.registerHttpListener(this);
  28. // register ourselves as a Proxy listener
  29. // callbacks.registerProxyListener(this);
  30. // register ourselves as a Scanner listener
  31. // callbacks.registerScannerListener(this);
  32. // register ourselves as an extension state listener
  33. // callbacks.registerExtensionStateListener(this);
  34. }
  35. @Override
  36. public void processHttpMessage(int toolFlag, boolean messageIsRequest, IHttpRequestResponse messageInfo)
  37. {
  38. if (messageIsRequest){
  39. //此时response为空.
  40. IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
  41. List<String> headers = reqInfo.getHeaders();
  42. String hostname = messageInfo.getHttpService().getHost();
  43. int port = messageInfo.getHttpService().getPort();
  44. byte[] body = Arrays.copyOfRange(
  45. messageInfo.getRequest(),
  46. reqInfo.getBodyOffset(),
  47. messageInfo.getRequest().length);
  48. String s = new String(body);
  49. // stdout.println("requests----------");
  50. // stdout.println(reqInfo.getUrl());
  51. // stdout.println(reqInfo.getMethod());
  52. // stdout.println("hostname:" + hostname);
  53. // stdout.println("headers:" + headers);
  54. // stdout.println("body:" + s);
  55. }else{
  56. //response
  57. byte[] responseBytes = messageInfo.getResponse();
  58. IResponseInfo respInfo = helpers.analyzeResponse(responseBytes);
  59. List<String> headers = respInfo.getHeaders();
  60. IRequestInfo reqInfo = helpers.analyzeRequest(messageInfo);
  61. String hostname = messageInfo.getHttpService().getHost();
  62. String myurl = reqInfo.getUrl().toString();
  63. stdout.println(reqInfo.getUrl());
  64. if (!hostname.equals("clients4.google.com") && myurl.indexOf("")){
  65. stdout.println("response----------");
  66. stdout.println(reqInfo.getUrl());
  67. stdout.println(hostname);
  68. String s = new String(responseBytes);
  69. stdout.println(s);
  70. byte[] body = Arrays.copyOfRange(
  71. messageInfo.getResponse(),
  72. respInfo.getBodyOffset(),
  73. messageInfo.getResponse().length);
  74. String ss = new String(body);
  75. stdout.println("body:" + ss);
  76. }
  77. // stdout.println("headers:" + headers);
  78. // header or something
  79. //stdout.println(messageInfo.getResponse());
  80. }
  81. // stdout.println(messageInfo.getRequest());
  82. // stdout.println(messageInfo.getResponse());
  83. // stdout.println(messageInfo.getHttpService());
  84. // stdout.println(
  85. // (messageIsRequest ? "HTTP request to " : "HTTP response from ") +
  86. // messageInfo.getHttpService() +
  87. // " [" + callbacks.getToolName(toolFlag) + "]");
  88. }
  89. //
  90. // implement IProxyListener
  91. //
  92. @Override
  93. public void processProxyMessage(boolean messageIsRequest, IInterceptedProxyMessage message)
  94. {
  95. stdout.println(
  96. (messageIsRequest ? "Proxy request to " : "Proxy response from ") +
  97. message.getMessageInfo().getHttpService());
  98. }
  99. //
  100. // implement IScannerListener
  101. //
  102. @Override
  103. public void newScanIssue(IScanIssue issue)
  104. {
  105. stdout.println("New scan issue: " + issue.getIssueName());
  106. }
  107. //
  108. // implement IExtensionStateListener
  109. //
  110. @Override
  111. public void extensionUnloaded()
  112. {
  113. stdout.println("Extension was unloaded");
  114. }
  115. }

参考代码