burp
Interface IExtensionHelpers


public interface IExtensionHelpers

This interface contains a number of helper methods, which extensions can use to assist with various common tasks that arise for Burp extensions. Extensions can call IBurpExtenderCallbacks.getHelpers to obtain an instance of this interface.


Method Summary
 byte[] addParameter(byte[] request, IParameter parameter)
          This method adds a new parameter to an HTTP request, and if appropriate updates the Content-Length header.
 IRequestInfo analyzeRequest(byte[] request)
          This method can be used to analyze an HTTP request, and obtain various key details about it.
 IRequestInfo analyzeRequest(IHttpRequestResponse request)
          This method can be used to analyze an HTTP request, and obtain various key details about it.
 IRequestInfo analyzeRequest(IHttpService httpService, byte[] request)
          This method can be used to analyze an HTTP request, and obtain various key details about it.
 IResponseInfo analyzeResponse(byte[] response)
          This method can be used to analyze an HTTP response, and obtain various key details about it.
 IResponseKeywords analyzeResponseKeywords(java.util.List<java.lang.String> keywords, byte[]... responses)
          This method analyzes one or more responses to identify the number of occurrences of the specified keywords and returns an IResponseKeywords object that can be queried to obtain details of the number of occurrences of each keyword.
 IResponseVariations analyzeResponseVariations(byte[]... responses)
          This method analyzes one or more responses to identify variations in a number of attributes and returns an IResponseVariations object that can be queried to obtain details of the variations.
 byte[] base64Decode(byte[] data)
          This method can be used to Base64-decode the specified data.
 byte[] base64Decode(java.lang.String data)
          This method can be used to Base64-decode the specified data.
 java.lang.String base64Encode(byte[] data)
          This method can be used to Base64-encode the specified data.
 java.lang.String base64Encode(java.lang.String data)
          This method can be used to Base64-encode the specified data.
 byte[] buildHttpMessage(java.util.List<java.lang.String> headers, byte[] body)
          This method builds an HTTP message containing the specified headers and message body.
 byte[] buildHttpRequest(java.net.URL url)
          This method creates a GET request to the specified URL.
 IHttpService buildHttpService(java.lang.String host, int port, boolean useHttps)
          This method constructs an IHttpService object based on the details provided.
 IHttpService buildHttpService(java.lang.String host, int port, java.lang.String protocol)
          This method constructs an IHttpService object based on the details provided.
 IParameter buildParameter(java.lang.String name, java.lang.String value, byte type)
          This method constructs an IParameter object based on the details provided.
 java.lang.String bytesToString(byte[] data)
          This method can be used to convert data from an array of bytes into String form.
 IParameter getRequestParameter(byte[] request, java.lang.String parameterName)
          This method can be used to retrieve details of a specified parameter within an HTTP request.
 int indexOf(byte[] data, byte[] pattern, boolean caseSensitive, int from, int to)
          This method searches a piece of data for the first occurrence of a specified pattern.
 IScannerInsertionPoint makeScannerInsertionPoint(java.lang.String insertionPointName, byte[] baseRequest, int from, int to)
          This method constructs an IScannerInsertionPoint object based on the details provided.
 byte[] removeParameter(byte[] request, IParameter parameter)
          This method removes a parameter from an HTTP request, and if appropriate updates the Content-Length header.
 byte[] stringToBytes(java.lang.String data)
          This method can be used to convert data from String form into an array of bytes.
 byte[] toggleRequestMethod(byte[] request)
          This method can be used to toggle a request's method between GET and POST.
 byte[] updateParameter(byte[] request, IParameter parameter)
          This method updates the value of a parameter within an HTTP request, and if appropriate updates the Content-Length header.
 byte[] urlDecode(byte[] data)
          This method can be used to URL-decode the specified data.
 java.lang.String urlDecode(java.lang.String data)
          This method can be used to URL-decode the specified data.
 byte[] urlEncode(byte[] data)
          This method can be used to URL-encode the specified data.
 java.lang.String urlEncode(java.lang.String data)
          This method can be used to URL-encode the specified data.
 

Method Detail

analyzeRequest

IRequestInfo analyzeRequest(IHttpRequestResponse request)
This method can be used to analyze an HTTP request, and obtain various key details about it.

Parameters:
request - An IHttpRequestResponse object containing the request to be analyzed.
Returns:
An IRequestInfo object that can be queried to obtain details about the request.

analyzeRequest

IRequestInfo analyzeRequest(IHttpService httpService,
                            byte[] request)
This method can be used to analyze an HTTP request, and obtain various key details about it.

Parameters:
httpService - The HTTP service associated with the request. This is optional and may be null, in which case the resulting IRequestInfo object will not include the full request URL.
request - The request to be analyzed.
Returns:
An IRequestInfo object that can be queried to obtain details about the request.

analyzeRequest

IRequestInfo analyzeRequest(byte[] request)
This method can be used to analyze an HTTP request, and obtain various key details about it. The resulting IRequestInfo object will not include the full request URL. To obtain the full URL, use one of the other overloaded analyzeRequest() methods.

Parameters:
request - The request to be analyzed.
Returns:
An IRequestInfo object that can be queried to obtain details about the request.

analyzeResponse

IResponseInfo analyzeResponse(byte[] response)
This method can be used to analyze an HTTP response, and obtain various key details about it.

Parameters:
response - The response to be analyzed.
Returns:
An IResponseInfo object that can be queried to obtain details about the response.

getRequestParameter

IParameter getRequestParameter(byte[] request,
                               java.lang.String parameterName)
This method can be used to retrieve details of a specified parameter within an HTTP request. Note: Use analyzeRequest() to obtain details of all parameters within the request.

Parameters:
request - The request to be inspected for the specified parameter.
parameterName - The name of the parameter to retrieve.
Returns:
An IParameter object that can be queried to obtain details about the parameter, or null if the parameter was not found.

urlDecode

java.lang.String urlDecode(java.lang.String data)
This method can be used to URL-decode the specified data.

Parameters:
data - The data to be decoded.
Returns:
The decoded data.

urlEncode

java.lang.String urlEncode(java.lang.String data)
This method can be used to URL-encode the specified data. Any characters that do not need to be encoded within HTTP requests are not encoded.

Parameters:
data - The data to be encoded.
Returns:
The encoded data.

urlDecode

byte[] urlDecode(byte[] data)
This method can be used to URL-decode the specified data.

Parameters:
data - The data to be decoded.
Returns:
The decoded data.

urlEncode

byte[] urlEncode(byte[] data)
This method can be used to URL-encode the specified data. Any characters that do not need to be encoded within HTTP requests are not encoded.

Parameters:
data - The data to be encoded.
Returns:
The encoded data.

base64Decode

byte[] base64Decode(java.lang.String data)
This method can be used to Base64-decode the specified data.

Parameters:
data - The data to be decoded.
Returns:
The decoded data.

base64Decode

byte[] base64Decode(byte[] data)
This method can be used to Base64-decode the specified data.

Parameters:
data - The data to be decoded.
Returns:
The decoded data.

base64Encode

java.lang.String base64Encode(java.lang.String data)
This method can be used to Base64-encode the specified data.

Parameters:
data - The data to be encoded.
Returns:
The encoded data.

base64Encode

java.lang.String base64Encode(byte[] data)
This method can be used to Base64-encode the specified data.

Parameters:
data - The data to be encoded.
Returns:
The encoded data.

stringToBytes

byte[] stringToBytes(java.lang.String data)
This method can be used to convert data from String form into an array of bytes. The conversion does not reflect any particular character set, and a character with the hex representation 0xWXYZ will always be converted into a byte with the representation 0xYZ. It performs the opposite conversion to the method bytesToString(), and byte-based data that is converted to a String and back again using these two methods is guaranteed to retain its integrity (which may not be the case with conversions that reflect a given character set).

Parameters:
data - The data to be converted.
Returns:
The converted data.

bytesToString

java.lang.String bytesToString(byte[] data)
This method can be used to convert data from an array of bytes into String form. The conversion does not reflect any particular character set, and a byte with the representation 0xYZ will always be converted into a character with the hex representation 0x00YZ. It performs the opposite conversion to the method stringToBytes(), and byte-based data that is converted to a String and back again using these two methods is guaranteed to retain its integrity (which may not be the case with conversions that reflect a given character set).

Parameters:
data - The data to be converted.
Returns:
The converted data.

indexOf

int indexOf(byte[] data,
            byte[] pattern,
            boolean caseSensitive,
            int from,
            int to)
This method searches a piece of data for the first occurrence of a specified pattern. It works on byte-based data in a way that is similar to the way the native Java method String.indexOf() works on String-based data.

Parameters:
data - The data to be searched.
pattern - The pattern to be searched for.
caseSensitive - Flags whether or not the search is case-sensitive.
from - The offset within data where the search should begin.
to - The offset within data where the search should end.
Returns:
The offset of the first occurrence of the pattern within the specified bounds, or -1 if no match is found.

buildHttpMessage

byte[] buildHttpMessage(java.util.List<java.lang.String> headers,
                        byte[] body)
This method builds an HTTP message containing the specified headers and message body. If applicable, the Content-Length header will be added or updated, based on the length of the body.

Parameters:
headers - A list of headers to include in the message.
body - The body of the message, of null if the message has an empty body.
Returns:
The resulting full HTTP message.

buildHttpRequest

byte[] buildHttpRequest(java.net.URL url)
This method creates a GET request to the specified URL. The headers used in the request are determined by the Request headers settings as configured in Burp Spider's options.

Parameters:
url - The URL to which the request should be made.
Returns:
A request to the specified URL.

addParameter

byte[] addParameter(byte[] request,
                    IParameter parameter)
This method adds a new parameter to an HTTP request, and if appropriate updates the Content-Length header.

Parameters:
request - The request to which the parameter should be added.
parameter - An IParameter object containing details of the parameter to be added. Supported parameter types are: PARAM_URL, PARAM_BODY and PARAM_COOKIE.
Returns:
A new HTTP request with the new parameter added.

removeParameter

byte[] removeParameter(byte[] request,
                       IParameter parameter)
This method removes a parameter from an HTTP request, and if appropriate updates the Content-Length header.

Parameters:
request - The request from which the parameter should be removed.
parameter - An IParameter object containing details of the parameter to be removed. Supported parameter types are: PARAM_URL, PARAM_BODY and PARAM_COOKIE.
Returns:
A new HTTP request with the parameter removed.

updateParameter

byte[] updateParameter(byte[] request,
                       IParameter parameter)
This method updates the value of a parameter within an HTTP request, and if appropriate updates the Content-Length header. Note: This method can only be used to update the value of an existing parameter of a specified type. If you need to change the type of an existing parameter, you should first call removeParameter() to remove the parameter with the old type, and then call addParameter() to add a parameter with the new type.

Parameters:
request - The request containing the parameter to be updated.
parameter - An IParameter object containing details of the parameter to be updated. Supported parameter types are: PARAM_URL, PARAM_BODY and PARAM_COOKIE.
Returns:
A new HTTP request with the parameter updated.

toggleRequestMethod

byte[] toggleRequestMethod(byte[] request)
This method can be used to toggle a request's method between GET and POST. Parameters are relocated between the URL query string and message body as required, and the Content-Length header is created or removed as applicable.

Parameters:
request - The HTTP request whose method should be toggled.
Returns:
A new HTTP request using the toggled method.

buildHttpService

IHttpService buildHttpService(java.lang.String host,
                              int port,
                              java.lang.String protocol)
This method constructs an IHttpService object based on the details provided.

Parameters:
host - The HTTP service host.
port - The HTTP service port.
protocol - The HTTP service protocol.
Returns:
An IHttpService object based on the details provided.

buildHttpService

IHttpService buildHttpService(java.lang.String host,
                              int port,
                              boolean useHttps)
This method constructs an IHttpService object based on the details provided.

Parameters:
host - The HTTP service host.
port - The HTTP service port.
useHttps - Flags whether the HTTP service protocol is HTTPS or HTTP.
Returns:
An IHttpService object based on the details provided.

buildParameter

IParameter buildParameter(java.lang.String name,
                          java.lang.String value,
                          byte type)
This method constructs an IParameter object based on the details provided.

Parameters:
name - The parameter name.
value - The parameter value.
type - The parameter type, as defined in the IParameter interface.
Returns:
An IParameter object based on the details provided.

makeScannerInsertionPoint

IScannerInsertionPoint makeScannerInsertionPoint(java.lang.String insertionPointName,
                                                 byte[] baseRequest,
                                                 int from,
                                                 int to)
This method constructs an IScannerInsertionPoint object based on the details provided. It can be used to quickly create a simple insertion point based on a fixed payload location within a base request.

Parameters:
insertionPointName - The name of the insertion point.
baseRequest - The request from which to build scan requests.
from - The offset of the start of the payload location.
to - The offset of the end of the payload location.
Returns:
An IScannerInsertionPoint object based on the details provided.

analyzeResponseVariations

IResponseVariations analyzeResponseVariations(byte[]... responses)
This method analyzes one or more responses to identify variations in a number of attributes and returns an IResponseVariations object that can be queried to obtain details of the variations.

Parameters:
responses - The responses to analyze.
Returns:
An IResponseVariations object representing the variations in the responses.

analyzeResponseKeywords

IResponseKeywords analyzeResponseKeywords(java.util.List<java.lang.String> keywords,
                                          byte[]... responses)
This method analyzes one or more responses to identify the number of occurrences of the specified keywords and returns an IResponseKeywords object that can be queried to obtain details of the number of occurrences of each keyword.

Parameters:
keywords - The keywords to look for.
responses - The responses to analyze.
Returns:
An IResponseKeywords object representing the counts of the keywords appearing in the responses.