class Buby

Buby is a mash-up of the commercial security testing web proxy PortSwigger Burp Suite(tm) allowing you to add scripting to Burp. Burp is driven from and tied to JRuby with a Java extension using the BurpExtender API.

The Buby class is an abstract implementation of a BurpExtender ruby handler. Included are several abstract event handlers used from the BurpExtender java implementation:

Buby also supports the newer event handlers available in Burp 1.2.09 and up:

This class also exposes several methods to access Burp functionality and user interfaces through the IBurpExtenderCallbacks interface (note, several abbreviated aliases also exist for each):

Buby also provides front-end ruby methods for the various callback methods supported by Burp. New callbacks have been cropping up in newer Burp versions frequently.

Available since Burp 1.2.09:

Available since Burp 1.2.15:

Available since Burp 1.2.17:

If you wish to access any of the IBurpExtenderCallbacks methods directly. You can use ‘#burp_callbacks’ to obtain a reference.

Credit:

Constants

ACTION_DONT_INTERCEPT
ACTION_DONT_INTERCEPT_AND_REHOOK
ACTION_DO_INTERCEPT
ACTION_DO_INTERCEPT_AND_REHOOK
ACTION_DROP
ACTION_FOLLOW_RULES
ACTION_FOLLOW_RULES_AND_REHOOK
VERSION

Public Class Methods

burp_loaded?() click to toggle source

Checks the Java namespace to see if Burp has been loaded.

# File lib/buby.rb, line 831
def self.burp_loaded?
  @burp_loaded ||= begin
    java_import 'burp.StartBurp'
    true
  rescue NameError
    false
  end
end
libpath( *args ) click to toggle source

Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join.

# File lib/buby.rb, line 846
def self.libpath( *args )
  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
end
load_burp(jar_path) click to toggle source

Attempts to load burp with require and confirm it provides the required class in the Java namespace.

Returns: true/false depending on whether the required jar provides us the required class

Raises: may raise the usual require exceptions if jar_path is bad.

# File lib/buby.rb, line 825
def self.load_burp(jar_path)
  require jar_path
  return burp_loaded?
end
new(other=nil) click to toggle source
# File lib/buby.rb, line 94
def initialize(other=nil)
  if other
    raise "arg 0 must be another kind of Buby" unless other.is_a? Buby
    @burp_extender = other.burp_extender
    @burp_callbacks = other.burp_callbacks
  end
end
path( *args ) click to toggle source

Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.

# File lib/buby.rb, line 854
def self.path( *args )
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
end
require_all_libs_relative_to( fname, dir = nil ) click to toggle source

Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.

# File lib/buby.rb, line 863
def self.require_all_libs_relative_to( fname, dir = nil )
  dir ||= ::File.basename(fname, '.*')
  search_me = ::File.expand_path(
      ::File.join(::File.dirname(fname), dir, '**', '*.rb'))

  Dir.glob(search_me).sort.each {|rb| require rb}
end
start_burp(h_class=nil, init_args=nil, args=nil) click to toggle source

Starts burp using a supplied handler class,

h_class = Buby or a derived class. instance of which will become handler.
args = arguments to Burp
init_args = arguments to the handler constructor

Returns the handler instance
# File lib/buby.rb, line 811
def self.start_burp(h_class=nil, init_args=nil, args=nil)
  h_class ||= self
  init_args ||= []
  args ||= []
  h_class.new(*init_args).start_burp(args)
end

Public Instance Methods

_check_and_callback(meth, *args) click to toggle source

This method is a __send__ callback gate for the IBurpExtenderCallbacks reference. It first checks to see if a method is available before calling with the specified arguments, and raises an exception if it is unavailable.

  • meth = string or symbol name of method

  • args = variable length array of arguments to pass to meth

# File lib/buby.rb, line 257
def _check_and_callback(meth, *args)
  cb = _check_cb
  unless cb.respond_to?(meth)
    raise "#{meth} is not available in your version of Burp"
  end
  cb.__send__ meth, *args
end
_check_cb() click to toggle source

Internal method to check for the existence of the #burp_callbacks reference before doing anything with it.

# File lib/buby.rb, line 120
def _check_cb
  @burp_callbacks or raise "Burp callbacks have not been set"
end
activate!() click to toggle source

Makes this handler the active Ruby handler object for the BurpExtender Java runtime. (there can be only one!)

# File lib/buby.rb, line 104
def activate!
  BurpExtender.set_handler(self)
end
active_scan(host, port, https, req, ip_off) click to toggle source
Alias for: doActiveScan
addToSiteMap(item) click to toggle source

This method can be used to add an item to Burp’s site map with the specified request/response details. This will overwrite the details of any existing matching item in the site map.

@param item Details of the item to be added to the site map

This method is only available with Burp 1.3.09+

# File lib/buby.rb, line 380
def addToSiteMap(item)
  _check_and_callback(:addToSiteMap, item)
end
Also aliased as: add_to_site_map
add_to_site_map(item) click to toggle source
Alias for: addToSiteMap
alert(msg) click to toggle source
Alias for: issueAlert
burp_callbacks() click to toggle source

Returns the internal reference to the IBupExtenderCallbacks instance. This reference gets set from Java through the #evt_register_callbacks method. It is exposed to allow you to access the IBurpExtenderCallbacks instance directly if you so choose.

# File lib/buby.rb, line 116
def burp_callbacks; @burp_callbacks; end
burp_extender() click to toggle source

Returns the internal reference to the BurpExtender instance. This reference gets set from Java through the #evt_extender_init method.

# File lib/buby.rb, line 110
def burp_extender; @burp_extender; end
burp_version() click to toggle source
Alias for: getBurpVersion
close(prompt_user=false) click to toggle source
Alias for: exitSuite
config() click to toggle source
Alias for: saveConfig
config=(conf) click to toggle source
Alias for: loadConfig
doActiveScan(host, port, https, req, ip_off) click to toggle source

Send an HTTP request to the Burp Scanner tool to perform an active vulnerability scan.

* host = The hostname of the remote HTTP server.
* port = The port of the remote HTTP server.
* https = Flags whether the protocol is HTTPS or HTTP.
* req  = The full HTTP request. (String or Java bytes[])
* ip_off = A list of index pairs representing the
* positions of the insertion points that should be scanned. Each item in
* the list must be an int[2] array containing the start and end offsets
* for the insertion point. *1.4+* only
# File lib/buby.rb, line 135
def doActiveScan(host, port, https, req, ip_off)
  req = req.to_java_bytes if req.is_a? String
  getBurpVersion ? _check_cb.doActiveScan(host, port, https, req, ip_off) : _check_cb.doActiveScan(host, port, https, req)
end
Also aliased as: do_active_scan, active_scan
doPassiveScan(host, port, https, req, rsp) click to toggle source

Send an HTTP request and response to the Burp Scanner tool to perform a passive vulnerability scan.

* host = The hostname of the remote HTTP server.
* port = The port of the remote HTTP server.
* https = Flags whether the protocol is HTTPS or HTTP.
* req  = The full HTTP request. (String or Java bytes[])
* rsp  = The full HTTP response. (String or Java bytes[])
# File lib/buby.rb, line 149
def doPassiveScan(host, port, https, req, rsp)
  req = req.to_java_bytes if req.is_a? String
  rsp = rsp.to_java_bytes if rsp.is_a? String
  _check_cb.doPassiveScan(host, port, https, req, rsp)
end
Also aliased as: do_passive_scan, passive_scan
do_active_scan(host, port, https, req, ip_off) click to toggle source
Alias for: doActiveScan
do_passive_scan(host, port, https, req, rsp) click to toggle source
Alias for: doPassiveScan
evt_application_closing() click to toggle source

This method is called by BurpExtender right before closing the application. Implementations can use this method to perform cleanup tasks such as closing files or databases before exit.

# File lib/buby.rb, line 695
def evt_application_closing 
  pp([:got_app_close]) if $DEBUG
end
evt_command_line_args(args) click to toggle source

This method is called by the BurpExtender implementation Burp startup. The args parameter contains main()‘s argv command-line arguments array.

Note: This maps to the ‘setCommandLineArgs’ method in the java implementation of BurpExtender.

The return value is ignored.

# File lib/buby.rb, line 461
def evt_command_line_args args
  pp([:got_args, args]) if $DEBUG
end
evt_extender_init(ext) click to toggle source

This method is called by the BurpExtender java implementation upon initialization of the BurpExtender instance for Burp. The args parameter is passed with a instance of the newly initialized BurpExtender instance so that implementations can access and extend its public interfaces.

The return value is ignored.

# File lib/buby.rb, line 449
def evt_extender_init ext
  @burp_extender = ext
  pp([:got_extender, ext]) if $DEBUG
end
evt_http_message(tool_name, is_request, message_info) click to toggle source

This method is invoked whenever any of Burp’s tools makes an HTTP request or receives a response. This is effectively a generalised version of the pre-existing #evt_proxy_message method, and can be used to intercept and modify the HTTP traffic of all Burp tools.

IMPORTANT: This event handler is only used in Burp version 1.2.09 and higher.

Note: this method maps to the processHttpMessage BurpExtender Java method.

This method should be overridden if you wish to implement functionality relating to generalized requests and responses from any BurpSuite tool.

You may want to use #evt_proxy_message if you only intend to work on proxied messages. Note, however, the IHttpRequestResponse Java object is not used in #evt_proxy_message and gives #evt_http_message a somewhat nicer interface to work with.

Parameters:

  • tool_name = a string name of the tool that generated the message

  • is_request = boolean true = request / false = response

  • message_info = an instance of the IHttpRequestResponse Java class with methods for accessing and manipulating various attributes of the message.

# File lib/buby.rb, line 670
def evt_http_message(tool_name, is_request, message_info)
  HttpRequestResponseHelper.implant(message_info)
  pp([:got_http_message, tool_name, is_request, message_info]) if $DEBUG
end
evt_proxy_message(msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action) click to toggle source

This method is called by BurpExtender while proxying HTTP messages and before passing them through the Burp proxy. Implementations can use this method to implement arbitrary processing upon HTTP requests and responses such as interception, logging, modification, and so on.

The ‘is_req’ parameter indicates whether it is a response or request.

Note: This method maps to the ‘processProxyMessage’ method in the java implementation of BurpExtender.

See also, #evt_proxy_message_raw which is actually called before this in the BurpExtender processProxyMessage handler.

Below are the parameters descriptions based on the IBurpExtender javadoc. Where applicable, decriptions have been modified for local parameter naming and other ruby-specific details added.

  • msg_ref: An identifier which is unique to a single request/response pair. This can be used to correlate details of requests and responses and perform processing on the response message accordingly. This number also corresponds to the Burp UI’s proxy “history” # column.

  • is_req: (true/false) Flags whether the message is a client request or a server response.

  • rhost: The hostname of the remote HTTP server.

  • rport: The port of the remote HTTP server.

  • is_https: Flags whether the protocol is HTTPS or HTTP.

  • http_meth: The method verb used in the client request.

  • url: The requested URL. Set in both the request and response.

  • resourceType: The filetype of the requested resource, or nil if the resource has no filetype.

  • status: The HTTP status code returned by the server. This value is nil for request messages.

  • req_content_type: The content-type string returned by the server. This value is nil for request messages.

  • message: The full HTTP message.

    **Ruby note:

    For convenience, the message is received and returned as a ruby 
    String object. Internally within Burp it is handled as a java byte[] 
    array. See also the notes about the return object below.
  • action: An array containing a single integer, allowing the implementation to communicate back to Burp Proxy a non-default interception action for the message. The default value is ACTION_FOLLOW_RULES (or 0). Possible values include:

    ACTION_FOLLOW_RULES = 0
    ACTION_DO_INTERCEPT = 1
    ACTION_DONT_INTERCEPT = 2
    ACTION_DROP = 3

    Refer to the BurpExtender.java source comments for more details.

Return Value:

Implementations should return either (a) the same object received
in the message paramater, or (b) a different object containing a 
modified message.

**IMPORTANT RUBY NOTE: Always be sure to return a new object if making modifications to messages.

Explanation: The (a) and (b) convention above is followed rather literally during type conversion on the return value back into the java BurpExtender.

When determining whether a change has been made in the message or not, the decision is made based on whether the object returned is the same as the object submitted in the call to evt_proxy_message.

So, for example, using in-place modification of the message using range substring assignments or destructive method variations like String.sub!() and String.gsub! alone won’t work because the same object gets returned to BurpExtender.

In short, this means that if you want modifications to be made, be sure to return a different String than the one you got in your handler.

So for example this code won’t do anything at all:

...
message.sub!(/^GET /, "HEAD ")
return message

Nor this:

message[0..4] = "HEAD "
return message

But this will

...
return message.sub(/^GET /, "HEAD ")

And so will this

...
message[0..4] = "HEAD "
return message.dup
# File lib/buby.rb, line 625
def evt_proxy_message msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action
  pp([ (is_req)? :got_proxy_request : :got_proxy_response,
       [:msg_ref, msg_ref], 
       [:is_req, is_req], 
       [:rhost, rhost], 
       [:rport, rport], 
       [:is_https, is_https], 
       [:http_meth, http_meth], 
       [:url, url], 
       [:resourceType, resourceType], 
       [:status, status], 
       [:req_content_type, req_content_type], 
       [:message, message], 
       [:action, action[0]] ]) if $DEBUG
  
  return message
end
evt_proxy_message_raw(msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action) click to toggle source

Seems we need to specifically render our ‘message’ to a string here in ruby. Otherwise there’s flakiness when converting certain binary non-ascii sequences. As long as we do it here, it should be fine.

Note: This method maps to the ‘processProxyMessage’ method in the java implementation of BurpExtender.

This method just handles the conversion to and from #evt_proxy_message which expects a message string

# File lib/buby.rb, line 495
def evt_proxy_message_raw msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action
  pp [:evt_proxy_message_raw_hit, msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action ] if $DEBUG

  str_msg = String.from_java_bytes(message)
  ret = evt_proxy_message(msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, str_msg, action)

  message = ret.to_java_bytes if ret.object_id != str_msg.object_id
  return message
end
evt_register_callbacks(cb) click to toggle source

This method is called by BurpExtender on startup to register Burp’s IBurpExtenderCallbacks interface object.

This maps to the ‘registerExtenderCallbacks’ method in the Java implementation of BurpExtender.

The return value is ignored.

# File lib/buby.rb, line 472
def evt_register_callbacks cb
  @burp_callbacks = cb
  cb.issueAlert("[JRuby::#{self.class}] registered callback")
  pp([:got_callbacks, cb]) if $DEBUG
end
evt_scan_issue(issue) click to toggle source

This method is invoked whenever Burp Scanner discovers a new, unique issue, and can be used to perform customised reporting or logging of detected issues.

IMPORTANT: This event handler is only used in Burp version 1.2.09 and higher.

Note: this method maps to the BurpExtender Java method.

Parameters:

  • issue = an instance of the IScanIssue Java class with methods for viewing information on the scan issue that was generated.

# File lib/buby.rb, line 687
def evt_scan_issue(issue)
  ScanIssueHelper.implant(issue)
  pp([:got_scan_issue, issue]) if $DEBUG
end
excludeFromScope(url) click to toggle source

Exclude the specified URL from the Suite-wide scope.

* url = The URL to exclude from the Suite-wide scope.
# File lib/buby.rb, line 159
def excludeFromScope(url)
  url = java.net.URL.new(url) if url.is_a? String
  _check_cb.excludeFromScope(url)
end
Also aliased as: exclude_from_scope, exclude_scope
exclude_from_scope(url) click to toggle source
Alias for: excludeFromScope
exclude_scope(url) click to toggle source
Alias for: excludeFromScope
exitSuite(prompt_user=false) click to toggle source

Shuts down Burp programatically. If the method returns the user cancelled the shutdown prompt.

# File lib/buby.rb, line 350
def exitSuite(prompt_user=false)
  _check_and_callback(:exitSuite, prompt_user ? true : false)
end
Also aliased as: exit_suite, close
exit_suite(prompt_user=false) click to toggle source
Alias for: exitSuite
getBurpVersion() click to toggle source

This method can be used to determine the version of the loaded burp at runtime. This is included in the Javadoc for the extension interfaces but not the supplied interface files. @return String array containing the product name, major version, and minor version.

# File lib/buby.rb, line 432
def getBurpVersion
  begin
    _check_and_callback(:getBurpVersion)
  rescue
    nil
  end
end
Also aliased as: burp_version
getHeaders(msg) click to toggle source

Parses a raw HTTP message (request or response ) and returns an associative array containing the headers as they are structured in the ‘Headers’ tab in the Burp request/response viewer UI.

IMPORTANT: This method is only available with Burp 1.2.09 and higher.

msg = raw request/response (String or Java bytes[])

# File lib/buby.rb, line 341
def getHeaders(msg)
  msg = msg.to_java_bytes if msg.is_a? String
  _check_and_callback(:getHeaders, msg)
end
Also aliased as: headers, get_headers
getParameters(req) click to toggle source

Parses a raw HTTP request message and returns an associative array containing parameters as they are structured in the ‘Parameters’ tab in the Burp request UI.

IMPORTANT: This method is only available with Burp 1.2.09 and higher.

req = raw request (String or Java bytes[])

# File lib/buby.rb, line 326
def getParameters(req)
  req = req.to_java_bytes if req.is_a? String
  _check_and_callback(:getParameters, req)
end
Also aliased as: parameters, get_parameters
getProxyHistory() click to toggle source

Returns a Java array of IHttpRequestResponse objects pulled directly from the Burp proxy history.

# File lib/buby.rb, line 268
def getProxyHistory
  HttpRequestResponseList.new(_check_and_callback(:getProxyHistory))
end
Also aliased as: proxy_history, get_proxy_history
getScanIssues(urlprefix=nil) click to toggle source

This method returns all of the current scan issues for URLs matching the specified literal prefix. The prefix can be nil to match all issues.

IMPORTANT: This method is only available with Burp 1.2.15 and higher.

# File lib/buby.rb, line 289
def getScanIssues(urlprefix=nil)
  ScanIssuesList.new( _check_and_callback(:getScanIssues, urlprefix) )
end
Also aliased as: scan_issues, get_scan_issues
getSiteMap(urlprefix=nil) click to toggle source

Returns a Java array of IHttpRequestResponse objects pulled directly from the Burp site map for all urls matching the specified literal prefix. The prefix can be nil to return all objects.

# File lib/buby.rb, line 278
def getSiteMap(urlprefix=nil)
  HttpRequestResponseList.new(_check_and_callback(:getSiteMap, urlprefix))
end
Also aliased as: site_map, get_site_map
get_headers(msg) click to toggle source
Alias for: getHeaders
get_parameters(req) click to toggle source
Alias for: getParameters
get_proxy_history() click to toggle source
Alias for: getProxyHistory
get_scan_issues(urlprefix=nil) click to toggle source
Alias for: getScanIssues
get_site_map(urlprefix=nil) click to toggle source
Alias for: getSiteMap
harvest_cookies_from_history(cookie=nil, urlrx=nil, statefile=nil) { |h| ... } click to toggle source

Harvest cookies from a session’s proxy history.

Params:

cookie    = optional: name of cookie to harvest
urlrx     = optional: regular expression to match urls against
statefile = optional: filename for a burp session file to temporarily load
            and harvest from.

Takes an optional block as additional ‘select’ criteria for cookies. The block return value of true/false will determine whether a cookie string is selected.

# File lib/buby.rb, line 783
def harvest_cookies_from_history(cookie=nil, urlrx=nil, statefile=nil)
  ret = []
  search_proxy_history(statefile, urlrx) do |hrr|
    if heads=hrr.rsp_headers
      ret += heads.select do |h| 
        h[0].downcase == 'set-cookie' and (not block_given? or yield(h[1]))
      end.map{|h| h[1]}
    end
  end
  return ret
end
headers(msg) click to toggle source
Alias for: getHeaders
in_scope?(url) click to toggle source
Alias for: isInScope
includeInScope(url) click to toggle source

Include the specified URL in the Suite-wide scope.

* url = The URL to exclude in the Suite-wide scope.
# File lib/buby.rb, line 168
def includeInScope(url)
  url = java.net.URL.new(url) if url.is_a? String
  _check_cb.includeInScope(url)
end
Also aliased as: include_in_scope, include_scope
include_in_scope(url) click to toggle source
Alias for: includeInScope
include_scope(url) click to toggle source
Alias for: includeInScope
intruder(host, port, https, req, ip_off) click to toggle source
Alias for: sendToIntruder
isInScope(url) click to toggle source

Query whether a specified URL is within the current Suite-wide scope.

* url = The URL to query

Returns: true / false

# File lib/buby.rb, line 179
def isInScope(url)
  url = java.net.URL.new(url) if url.is_a? String
  _check_cb.isInScope(url)
end
Also aliased as: is_in_scope, in_scope?
is_in_scope(url) click to toggle source
Alias for: isInScope
issueAlert(msg) click to toggle source

Display a message in the Burp Suite alerts tab.

* msg =  The alert message to display.
# File lib/buby.rb, line 188
def issueAlert(msg)
  _check_cb.issueAlert(msg.to_s)
end
Also aliased as: issue_alert, alert
issue_alert(msg) click to toggle source
Alias for: issueAlert
loadConfig(conf) click to toggle source

This method causes Burp to load a new configuration from the Map of name/value Strings provided. Any settings not specified in the Map will be restored to their default values. To selectively update only some settings and leave the rest unchanged, you should first call saveConfig to obtain Burp’s current configuration, modify the relevant items in the Map, and then call loadConfig with the same Map.

@param config A map of name/value Strings to use as Burp’s new configuration.

This method is only available with Burp 1.3.09+

# File lib/buby.rb, line 410
def loadConfig(conf)
  _check_and_callback(:loadConfig, conf)
end
Also aliased as: load_config, config=
load_config(conf) click to toggle source
Alias for: loadConfig
makeHttpRequest(host, port, https, req) click to toggle source

Issue an arbitrary HTTP request and retrieve its response

* host  = The hostname of the remote HTTP server.
* port  = The port of the remote HTTP server.
* https = Flags whether the protocol is HTTPS or HTTP.
* req   = The full HTTP request. (String or Java bytes[])

Returns: The full response retrieved from the remote server.

# File lib/buby.rb, line 201
def makeHttpRequest(host, port, https, req)
  req = req.to_java_bytes if req.is_a? String
  String.from_java_bytes( _check_cb.makeHttpRequest(host, port, https, req) )
end
Also aliased as: make_http_request, make_request
make_http_request(host, port, https, req) click to toggle source
Alias for: makeHttpRequest
make_request(host, port, https, req) click to toggle source
Alias for: makeHttpRequest
parameters(req) click to toggle source
Alias for: getParameters
passive_scan(host, port, https, req, rsp) click to toggle source
Alias for: doPassiveScan
proxy_history() click to toggle source
Alias for: getProxyHistory
proxy_interception=(enabled) click to toggle source
proxy_interception_enabled(enabled) click to toggle source
registerMenuItem(menuItemCaption, menuItemHandler) click to toggle source

This method can be used to register a new menu item which will appear on the various context menus that are used throughout Burp Suite to handle user-driven actions.

@param menuItemCaption The caption to be displayed on the menu item. @param menuItemHandler The handler to be invoked when the user clicks on the menu item.

This method is only available with Burp 1.3.07 and higher.

# File lib/buby.rb, line 365
def registerMenuItem(menuItemCaption, menuItemHandler)
  _check_and_callback(:registerMenuItem, menuItemCaption, menuItemHandler)
  issueAlert("Handler #{menuItemHandler} registered for \"#{menuItemCaption}\"")
end
Also aliased as: register_menu_item
register_menu_item(menuItemCaption, menuItemHandler) click to toggle source
Alias for: registerMenuItem
repeater(host, port, https, req, tab=nil) click to toggle source
Alias for: sendToRepeater
restoreState(filename) click to toggle source

Restores Burp session state from a previously saved state file. See also: saveState

IMPORTANT: This method is only available with Burp 1.2.09 and higher.

  • filename = path and filename of the file to restore from

# File lib/buby.rb, line 302
def restoreState(filename)
  _check_and_callback(:restoreState, java.io.File.new(filename))
end
Also aliased as: restore_state
restore_state(filename) click to toggle source
Alias for: restoreState
saveConfig() click to toggle source

This method causes Burp to save all of its current configuration as a Map of name/value Strings.

@return A Map of name/value Strings reflecting Burp’s current configuration.

This method is only available with Burp 1.3.09+

# File lib/buby.rb, line 392
def saveConfig
  _check_and_callback(:saveConfig).to_hash
end
Also aliased as: save_config, config
saveState(filename) click to toggle source

Saves the current Burp session to a state file. See also restoreState.

IMPORTANT: This method is only available with Burp 1.2.09 and higher.

  • filename = path and filename of the file to save to

# File lib/buby.rb, line 313
def saveState(filename)
  _check_and_callback(:saveState, java.io.File.new(filename))
end
Also aliased as: save_state
save_config() click to toggle source
Alias for: saveConfig
save_state(filename) click to toggle source
Alias for: saveState
scan_issues(urlprefix=nil) click to toggle source
Alias for: getScanIssues
search_proxy_history(statefile=nil, urlrx=nil) { |r| ... } click to toggle source

Searches the proxy history for the url’s matched by the specified regular expression (returns them all if urlrx is nil).

A statefile to search in can optionally be specified or the existing state will be used if statefile is nil.

This method also accepts an optional block which is passed each of the matched history members.

# File lib/buby.rb, line 762
def search_proxy_history(statefile=nil, urlrx=nil)
  ret = []
  with_proxy_history(statefile) do |r|
    if (not urlrx) or r.url.to_s =~ urlrx
      ret << r if (not block_given?) or yield(r)
    end
  end
  return ret
end
sendToIntruder(host, port, https, req, ip_off) click to toggle source

Send an HTTP request to the Burp Intruder tool

* host  = The hostname of the remote HTTP server.
* port  = The port of the remote HTTP server.
* https = Flags whether the protocol is HTTPS or HTTP.
* req   = The full HTTP request.  (String or Java bytes[])
* ip_off = A list of index pairs representing the
* positions of the insertion points that should be scanned. Each item in
* the list must be an int[2] array containing the start and end offsets
* for the insertion point. *1.4.04+* only
*
# File lib/buby.rb, line 218
def sendToIntruder(host, port, https, req, ip_off)
  req = req.to_java_bytes if req.is_a? String
  if self.getBurpVersion.to_a[1..-1].join(".") < "1.4.04"
    _check_cb.sendToIntruder(host, port, https, req)
  else
    _check_cb.sendToIntruder(host, port, https, req, ip_off)
  end
end
Also aliased as: send_to_intruder, intruder
sendToRepeater(host, port, https, req, tab=nil) click to toggle source

Send an HTTP request to the Burp Repeater tool.

* host  = The hostname of the remote HTTP server.
* port  = The port of the remote HTTP server.
* https = Flags whether the protocol is HTTPS or HTTP.
* req   = The full HTTP request. (String or Java bytes[])
* tab   = The tab caption displayed in Repeater. (default: auto-generated)
# File lib/buby.rb, line 235
def sendToRepeater(host, port, https, req, tab=nil)
  req = req.to_java_bytes if req.is_a? String
  _check_cb.sendToRepeater(host, port, https, req, tab)
end
Also aliased as: send_to_repeater, repeater
sendToSpider(url) click to toggle source

Send a seed URL to the Burp Spider tool.

* url = The new seed URL to begin spidering from.
# File lib/buby.rb, line 244
def sendToSpider(url)
  url = java.net.URL.new(url) if url.is_a? String
  _check_cb.sendToSpider(url)
end
Also aliased as: send_to_spider, spider
send_to_intruder(host, port, https, req, ip_off) click to toggle source
Alias for: sendToIntruder
send_to_repeater(host, port, https, req, tab=nil) click to toggle source
Alias for: sendToRepeater
send_to_spider(url) click to toggle source
Alias for: sendToSpider
setProxyInterceptionEnabled(enabled) click to toggle source

This method sets the interception mode for Burp Proxy.

@param enabled Indicates whether interception of proxy messages should be enabled.

# File lib/buby.rb, line 423
def setProxyInterceptionEnabled(enabled)
  _check_and_callback(:setProxyInterceptionEnabled, enabled)
end
site_map(urlprefix=nil) click to toggle source
Alias for: getSiteMap
spider(url) click to toggle source
Alias for: sendToSpider
start_burp(args=[]) click to toggle source

Prepares the java BurpExtender implementation with a reference to self as the module handler and launches burp suite.

# File lib/buby.rb, line 799
def start_burp(args=[])
  activate!()
  Java::Burp::StartBurp.main(args.to_java(:string))
  return self
end
with_proxy_history(statefile=nil) { |h| ... } click to toggle source

This is a convenience wrapper which can load a given burp state file and lets its caller to perform actions inside of a block on the proxy history contained in the loaded session.

If a statefile argument isn’t specified current burp session state is used.

Yields each entry in the proxy history to a block.

# File lib/buby.rb, line 721
def with_proxy_history(statefile=nil)
  with_statefile(statefile) do |this|
    this.proxy_history.each {|h| yield h }
  end
end
with_site_map(urlprefix=nil, statefile=nil) { |h| ... } click to toggle source

This is a convenience wrapper which can load a given burp state file and lets its caller to perform actions inside of a block on the site map contained in the loaded session.

If a statefile argument isn’t specified current burp session state is used.

Yields each entry in the site map to a block.

# File lib/buby.rb, line 708
def with_site_map(urlprefix=nil, statefile=nil)
  with_statefile(statefile) do |this|
    this.site_map(urlprefix).each {|h| yield h }
  end
end
with_statefile(statefile=nil) { |self| ... } click to toggle source

This is a convenience wrapper which loads a given burp statefile and lets its caller perform actions via burp while its loaded on it inside of a block. The old state is restored after the block completes.

It can safely be run with a nil statefile argument in which the current burp session state is used.

# File lib/buby.rb, line 733
def with_statefile(statefile=nil)
  if statefile
    # save current state:
    old_state=".#{$$}.#{Time.now.to_i}.state.bak"
    self.alert "Saving current state to temp statefile: #{old_state}"
    self.save_state(old_state)
    self.alert "Restoring state: #{statefile}"
    self.restore_state(statefile)
  end

  yield self

  if statefile
    # restore original state
    self.alert "Restoring temp statefile: #{old_state}"
    self.restore_state old_state
    self.alert "Deleting temp state file: #{old_state}"
    File.unlink old_state
  end
end