buby 1.3.3-java → 1.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.rdoc +28 -14
  2. data/Rakefile +96 -6
  3. data/VERSION.yml +5 -0
  4. data/bin/buby +2 -0
  5. data/buby.gemspec +102 -17
  6. data/{java/src → ext/buby/burp}/BurpExtender.java +189 -29
  7. data/ext/burp_interfaces/burp/IBurpExtender.java +31 -0
  8. data/ext/burp_interfaces/burp/IBurpExtenderCallbacks.java +785 -0
  9. data/ext/burp_interfaces/burp/IContextMenuFactory.java +38 -0
  10. data/ext/burp_interfaces/burp/IContextMenuInvocation.java +156 -0
  11. data/ext/burp_interfaces/burp/ICookie.java +53 -0
  12. data/ext/burp_interfaces/burp/IExtensionHelpers.java +352 -0
  13. data/ext/burp_interfaces/burp/IExtensionStateListener.java +27 -0
  14. data/ext/burp_interfaces/burp/IHttpListener.java +37 -0
  15. data/ext/burp_interfaces/burp/IHttpRequestResponse.java +102 -0
  16. data/ext/burp_interfaces/burp/IHttpRequestResponsePersisted.java +26 -0
  17. data/ext/burp_interfaces/burp/IHttpRequestResponseWithMarkers.java +44 -0
  18. data/ext/burp_interfaces/burp/IHttpService.java +39 -0
  19. data/ext/burp_interfaces/burp/IInterceptedProxyMessage.java +116 -0
  20. data/ext/burp_interfaces/burp/IIntruderAttack.java +31 -0
  21. data/ext/burp_interfaces/burp/IIntruderPayloadGenerator.java +50 -0
  22. data/ext/burp_interfaces/burp/IIntruderPayloadGeneratorFactory.java +40 -0
  23. data/ext/burp_interfaces/burp/IIntruderPayloadProcessor.java +45 -0
  24. data/{java/src → ext/burp_interfaces}/burp/IMenuItemHandler.java +36 -40
  25. data/ext/burp_interfaces/burp/IMessageEditor.java +64 -0
  26. data/ext/burp_interfaces/burp/IMessageEditorController.java +49 -0
  27. data/ext/burp_interfaces/burp/IMessageEditorTab.java +102 -0
  28. data/ext/burp_interfaces/burp/IMessageEditorTabFactory.java +38 -0
  29. data/ext/burp_interfaces/burp/IParameter.java +104 -0
  30. data/ext/burp_interfaces/burp/IProxyListener.java +37 -0
  31. data/ext/burp_interfaces/burp/IRequestInfo.java +95 -0
  32. data/ext/burp_interfaces/burp/IResponseInfo.java +54 -0
  33. data/ext/burp_interfaces/burp/IScanIssue.java +120 -0
  34. data/ext/burp_interfaces/burp/IScanQueueItem.java +80 -0
  35. data/ext/burp_interfaces/burp/IScannerCheck.java +89 -0
  36. data/ext/burp_interfaces/burp/IScannerInsertionPoint.java +156 -0
  37. data/ext/burp_interfaces/burp/IScannerInsertionPointProvider.java +38 -0
  38. data/ext/burp_interfaces/burp/IScannerListener.java +30 -0
  39. data/ext/burp_interfaces/burp/IScopeChangeListener.java +25 -0
  40. data/ext/burp_interfaces/burp/ISessionHandlingAction.java +51 -0
  41. data/ext/burp_interfaces/burp/ITab.java +38 -0
  42. data/ext/burp_interfaces/burp/ITempFile.java +33 -0
  43. data/ext/burp_interfaces/burp/ITextEditor.java +90 -0
  44. data/lib/buby/burp_extender/console_frame.rb +33 -0
  45. data/lib/buby/burp_extender/console_pane.rb +26 -0
  46. data/lib/buby/burp_extender/console_tab.rb +15 -0
  47. data/lib/buby/burp_extender/context_menu.rb +29 -0
  48. data/lib/buby/burp_extender/context_menu_factory.rb +17 -0
  49. data/lib/buby/burp_extender/context_menu_item.rb +13 -0
  50. data/lib/buby/burp_extender/jcheck_box_menu_item.rb +12 -0
  51. data/lib/buby/burp_extender/jmenu.rb +11 -0
  52. data/lib/buby/burp_extender/jmenu_item.rb +12 -0
  53. data/lib/buby/burp_extender/menu.rb +11 -0
  54. data/lib/buby/burp_extender/menu_item.rb +12 -0
  55. data/lib/buby/burp_extender.rb +339 -0
  56. data/lib/buby/context_menu_factory.rb +35 -0
  57. data/lib/buby/cookie.rb +37 -0
  58. data/lib/buby/extender.rb +156 -0
  59. data/lib/buby/http_listener.rb +29 -0
  60. data/lib/buby/{extends → implants}/buby_array_wrapper.rb +0 -0
  61. data/lib/buby/implants/context_menu_invocation.rb +113 -0
  62. data/lib/buby/implants/cookie.rb +47 -0
  63. data/lib/buby/implants/extension_helpers.rb +286 -0
  64. data/lib/buby/{extends → implants}/http_request_response.rb +8 -1
  65. data/lib/buby/implants/intercepted_proxy_message.rb +53 -0
  66. data/lib/buby/implants/intruder_attack.rb +42 -0
  67. data/lib/buby/implants/jruby.rb +64 -0
  68. data/lib/buby/implants/message_editor.rb +70 -0
  69. data/lib/buby/implants/message_editor_controller.rb +60 -0
  70. data/lib/buby/implants/parameter.rb +84 -0
  71. data/lib/buby/implants/request_info.rb +47 -0
  72. data/lib/buby/implants/response_info.rb +44 -0
  73. data/lib/buby/{extends → implants}/scan_issue.rb +1 -2
  74. data/lib/buby/implants/scan_queue_item.rb +53 -0
  75. data/lib/buby/implants/scanner_insertion_point.rb +92 -0
  76. data/lib/buby/implants/temp_file.rb +43 -0
  77. data/lib/buby/implants/text_editor.rb +63 -0
  78. data/lib/buby/implants.rb +28 -0
  79. data/lib/buby/intruder_payload_generator.rb +60 -0
  80. data/lib/buby/intruder_payload_generator_factory.rb +32 -0
  81. data/lib/buby/intruder_payload_processor.rb +38 -0
  82. data/lib/buby/message_editor_controller.rb +41 -0
  83. data/lib/buby/message_editor_tab.rb +98 -0
  84. data/lib/buby/message_editor_tab_factory.rb +28 -0
  85. data/lib/buby/parameter/base.rb +40 -0
  86. data/lib/buby/parameter/body.rb +7 -0
  87. data/lib/buby/parameter/cookie.rb +7 -0
  88. data/lib/buby/parameter/url.rb +7 -0
  89. data/lib/buby/parameter.rb +15 -0
  90. data/lib/buby/proxy_listener.rb +26 -0
  91. data/lib/buby/scan_issue.rb +112 -0
  92. data/lib/buby/scanner_check.rb +84 -0
  93. data/lib/buby/scanner_insertion_point.rb +118 -0
  94. data/lib/buby/scanner_insertion_point_provider.rb +27 -0
  95. data/lib/buby/scanner_listener.rb +22 -0
  96. data/lib/buby/scope_change_listener.rb +19 -0
  97. data/lib/buby/session_handling_action.rb +43 -0
  98. data/lib/buby/tab.rb +37 -0
  99. data/lib/buby/version.rb +9 -0
  100. data/lib/buby.rb +892 -101
  101. metadata +118 -22
  102. data/VERSION +0 -1
  103. data/java/buby.jar +0 -0
  104. data/java/src/burp/IBurpExtender.java +0 -180
  105. data/java/src/burp/IBurpExtenderCallbacks.java +0 -373
  106. data/java/src/burp/IHttpRequestResponse.java +0 -156
  107. data/java/src/burp/IScanIssue.java +0 -106
  108. data/java/src/burp/IScanQueueItem.java +0 -76
  109. data/lib/buby/extends.rb +0 -4
@@ -0,0 +1,118 @@
1
+ class Buby
2
+ # This interface is used to define an insertion point for use by active
3
+ # Scanner checks. Extensions can obtain instances of this interface by
4
+ # registering an +IScannerCheck+, or can create instances for use by Burp's
5
+ # own scan checks by registering an +IScannerInsertionPointProvider+.
6
+ #
7
+ # @api
8
+ # @abstract Subclass for specific insertion point flavors used.
9
+ class ScannerInsertionPoint
10
+ include Java::Burb::IScannerInsertionPoint
11
+
12
+ INS_PARAM_URL = 0x00
13
+ INS_PARAM_BODY = 0x01
14
+ INS_PARAM_COOKIE = 0x02
15
+ INS_PARAM_XML = 0x03
16
+ INS_PARAM_XML_ATTR = 0x04
17
+ INS_PARAM_MULTIPART_ATTR = 0x05
18
+ INS_PARAM_JSON = 0x06
19
+ INS_PARAM_AMF = 0x07
20
+ INS_HEADER = 0x20
21
+ INS_URL_REST = 0x21
22
+ INS_PARAM_NAME_URL = 0x22
23
+ INS_PARAM_NAME_BODY = 0x23
24
+ INS_USER_PROVIDED = 0x40
25
+ INS_EXTENSION_PROVIDED = 0x41
26
+ INS_UNKNOWN = 0x7f
27
+
28
+ # @overload initialize(name = nil, type = INS_UNKNOWN, base_value = nil, offsets = nil)
29
+ # @param [String] name
30
+ # @param [Fixnum] type
31
+ # @param [String] base_value
32
+ # @param [Array<Fixnum>] offsets
33
+ # @overload initialize(hash)
34
+ # @param [Hash] hash Hash containing instance information
35
+ #
36
+ # @abstract Subclass and override for the specific insertion point flavors
37
+ # used by the implementation.
38
+ def initialize(*args)
39
+ if args.first.kind_of? Hash
40
+ hsh = args.first
41
+ @type = hsh[:type] || hsh['type']
42
+ else
43
+ @name, @type, @base_vlaue, @offsets = args
44
+ end
45
+ end
46
+
47
+ # This method returns the name of the insertion point.
48
+ #
49
+ # @return [String] The name of the insertion point (for example, a
50
+ # description of a particular request parameter).
51
+ #
52
+ def getInsertionPointName
53
+ @name || self.class.name
54
+ end
55
+
56
+ # This method returns the base value for this insertion point.
57
+ #
58
+ # @return [String] the base value that appears in this insertion point in
59
+ # the base request being scanned, or +nil+ if there is no value in the
60
+ # base request that corresponds to this insertion point.
61
+ #
62
+ # @abstract
63
+ def getBaseValue
64
+ @base_value
65
+ end
66
+
67
+ # This method is used to build a request with the specified payload placed
68
+ # into the insertion point. Any necessary adjustments to the
69
+ # Content-Length header will be made by the Scanner itself when the
70
+ # request is issued, and there is no requirement for the insertion point
71
+ # to do this.
72
+ #
73
+ # @note Burp's built-in scan checks do not apply any payload encoding
74
+ # (such as URL-encoding) when dealing with an extension-provided
75
+ # insertion point. Custom insertion points are responsible for
76
+ # performing any data encoding that is necessary given the nature and
77
+ # location of the insertion point.
78
+ #
79
+ # @param [Array<byte>] payload The payload that should be placed into the
80
+ # insertion point.
81
+ # @return [Array<byte>] The resulting request.
82
+ #
83
+ # @todo figure out wrapping these calls (method_missing magic?)
84
+ # @abstract
85
+ # @api called by burp
86
+ def buildRequest(payload)
87
+ # ...
88
+ end
89
+
90
+ # This method is used to determine the offsets of the payload value within
91
+ # the request, when it is placed into the insertion point. Scan checks may
92
+ # invoke this method when reporting issues, so as to highlight the
93
+ # relevant part of the request within the UI.
94
+ #
95
+ # @param [Array<byte>] payload The payload that should be placed into the
96
+ # insertion point.
97
+ # @return [Array<Fixnum>] An int[2] array containing the start and end
98
+ # offsets of the payload within the request, or +nil+ if this is not
99
+ # applicable (for example, where the insertion point places a payload
100
+ # into a serialized data structure, the raw payload may not literally
101
+ # appear anywhere within the resulting request).
102
+ #
103
+ # @todo figure out wrapping these calls (method_missing magic?)
104
+ # @abstract
105
+ def getPayloadOffsets(payload)
106
+ @offsets
107
+ end
108
+
109
+ # This method returns the type of the insertion point.
110
+ #
111
+ # @return [Fixnum] The type of the insertion point. Available types are
112
+ # defined in {Buby::ScannerInsertionPoint}.
113
+ #
114
+ def getInsertionPointType
115
+ @type || INS_UNKNOWN
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,27 @@
1
+ class Buby
2
+
3
+ # Extensions can implement this interface and then call
4
+ # {Buby#registerScannerInsertionPointProvider} to register a factory for
5
+ # custom Scanner insertion points.
6
+ #
7
+ class ScannerInsertionPointProvider
8
+ include Java::Burp::IScannerInsertionPointProvider
9
+
10
+ # When a request is actively scanned, the Scanner will invoke this method,
11
+ # and the provider should provide a list of custom insertion points that
12
+ # will be used in the scan.
13
+ # @note these insertion points are used in addition to those that are
14
+ # derived from Burp Scanner's configuration, and those provided by any
15
+ # other Burp extensions.
16
+ #
17
+ # @param [IHttpRequestResponse] baseRequestResponse The base request that will be actively scanned.
18
+ # @return [Array<IScannerInsertionPoint>, nil] A list of
19
+ # +IScannerInsertionPoint+ objects that should be used in thescanning, or
20
+ # +nil+ if no custom insertion points are applicable for this request.
21
+ #
22
+ def getInsertionPoints(baseRequestResponse)
23
+ pp [:got_getInsertionPoints, baseRequestResponse] if $DEBUG
24
+ __getInsertionPoints(baseRequestResponse).tap{|x|Buby::HttpRequestResponseHelper.implant(x)}
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ class Buby
2
+ # Extensions can implement this interface and then call
3
+ # {Buby#registerScannerListener} to register a Scanner listener. The listener
4
+ # will be notified of new issues that are reported by the Scanner tool.
5
+ # Extensions can perform custom analysis or logging of Scanner issues by
6
+ # registering a Scanner listener.
7
+ #
8
+ class ScannerListener
9
+ include Java::Burp::IScannerListener
10
+ # This method is invoked when a new issue is added to Burp Scanner's
11
+ # results.
12
+ #
13
+ # @param [IScanIssue] issue An object that the extension can query to obtain
14
+ # details about the new issue.
15
+ #
16
+ # @abstract
17
+ def newScanIssue(issue)
18
+ pp [:got_newScanIssue, issue] if $DEBUG
19
+ Buby::ScanIssueHelper.implant issue
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ class Buby
2
+ # Extensions can implement this interface and then call
3
+ # {Buby#registerScopeChangeListener} to register a scope change listener. The
4
+ # listener will be notified whenever a change occurs to Burp's suite-wide
5
+ # target scope.
6
+ #
7
+ # @todo improve listener classes with 1.9 instance_exec goodness next version
8
+ class ScopeChangeListener
9
+ include Java::Burp::IScopeChangeListener
10
+
11
+ # This method is invoked whenever a change occurs to Burp's suite-wide
12
+ # target scope.
13
+ #
14
+ # @abstract
15
+ def scopeChanged
16
+ pp [:got_scopeChanged] if $DEBUG
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ class Buby
2
+ # Extensions can implement this interface and then call
3
+ # {Buby#registerSessionHandlingAction} to register a custom session handling
4
+ # action. Each registered action will be available within the session handling
5
+ # rule UI for the user to select as a rule action. Users can choose to invoke
6
+ # an action directly in its own right, or following execution of a macro.
7
+ #
8
+ class SessionHandlingAction
9
+ include Java::Burp::ISessionHandlingAction
10
+ # This method is used by Burp to obtain the name of the session handling
11
+ # action. This will be displayed as an option within the session handling
12
+ # rule editor when the user selects to execute an extension-provided action.
13
+ #
14
+ # @return [String] The name of the action.
15
+ #
16
+ def getActionName
17
+ pp [:got_getActionName] if $DEBUG
18
+ self.class.name
19
+ end
20
+
21
+ # This method is invoked when the session handling action should be
22
+ # executed. This may happen as an action in its own right, or as a
23
+ # sub-action following execution of a macro.
24
+ #
25
+ # @param [IHttpRequestResponse] currentRequest The base request that is
26
+ # currently being processed. The action can query this object to obtain
27
+ # details about the base request. It can issue additional requests of its
28
+ # own if necessary, and can use the setter methods on this object to
29
+ # update the base request.
30
+ # @param [Array<IHttpRequestResponse>] macroItems If the action is invoked
31
+ # following execution of a macro, this parameter contains the result of
32
+ # executing the macro. Otherwise, it is +nil+. Actions can use the details
33
+ # of the macro items to perform custom analysis of the macro to derive
34
+ # values of non-standard session handling tokens, etc.
35
+ # @return [void]
36
+ #
37
+ # @abstract
38
+ def performAction(currentRequest, macroItems)
39
+ pp [:got_performAction, currentRequest, macroItems] if $DEBUG
40
+ Buby::HttpRequestResponseHelper.implant(currentRequest)
41
+ end
42
+ end
43
+ end
data/lib/buby/tab.rb ADDED
@@ -0,0 +1,37 @@
1
+ class Buby
2
+ # This interface is used to provide Burp with details of a custom tab that
3
+ # will be added to Burp's UI, using a method such as {Buby#addSuiteTab}.
4
+ #
5
+ # @abstract
6
+ class Tab
7
+ include Java::Burp::ITab
8
+ attr_accessor :caption, :component
9
+
10
+ def initialize(caption = nil, component = nil)
11
+ @caption = caption || self.class.name
12
+ @component = component
13
+ end
14
+
15
+ # Burp uses this method to obtain the caption that should appear on the
16
+ # custom tab when it is displayed.
17
+ #
18
+ # @return [String] The caption that should appear on the custom tab when it
19
+ # is displayed.
20
+ #
21
+ def getTabCaption
22
+ pp [:got_getTabCaption] if $DEBUG
23
+ @caption.to_s
24
+ end
25
+
26
+ # Burp uses this method to obtain the component that should be used as the
27
+ # contents of the custom tab when it is displayed.
28
+ #
29
+ # @return [java.awt.Component] The component that should be used as the
30
+ # contents of the custom tab when it is displayed.
31
+ #
32
+ def getUiComponent
33
+ pp [:got_getUiComponent] if $DEBUG
34
+ @component
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,9 @@
1
+ class Buby
2
+ module Version
3
+ STRING = "1.5.0.pre3"
4
+ MAJOR = 1
5
+ MINOR = 5
6
+ PATCH = 0
7
+ BUILD = "pre3"
8
+ end
9
+ end
data/lib/buby.rb CHANGED
@@ -1,10 +1,13 @@
1
- include Java
2
-
3
1
  require 'pp'
4
- require "buby.jar"
5
- require 'buby/extends.rb'
6
-
7
- include_class 'BurpExtender'
2
+ require 'uri'
3
+ require 'buby/implants'
4
+
5
+ # load the Burp extender interfaces if they're not already accessible
6
+ begin
7
+ Java::Burp::IBurpExtender
8
+ rescue NameError
9
+ require 'burp_interfaces.jar'
10
+ end
8
11
 
9
12
  # Buby is a mash-up of the commercial security testing web proxy PortSwigger
10
13
  # Burp Suite(tm) allowing you to add scripting to Burp. Burp is driven from
@@ -15,9 +18,10 @@ include_class 'BurpExtender'
15
18
  # java implementation:
16
19
  # * evt_extender_init
17
20
  # * evt_proxy_message
18
- # * evt_command_line_args
21
+ # * evt_command_line_args (removed in 1.5.01)
19
22
  # * evt_register_callbacks
20
- # * evt_application_closing
23
+ # * evt_application_closing (deprecated)
24
+ # * evt_extension_unloaded
21
25
  #
22
26
  # Buby also supports the newer event handlers available in Burp 1.2.09 and up:
23
27
  # * evt_http_message
@@ -79,21 +83,48 @@ include_class 'BurpExtender'
79
83
  # to type and say out-loud. Mike Tracy gets full credit as official
80
84
  # Buby-namer.
81
85
  #
86
+ # @todo move more to Java side
82
87
  class Buby
83
-
84
- VERSION =
85
- if File.file?(f=::File.expand_path(File.join(::File.dirname(__FILE__), "../VERSION")))
86
- File.read(f).chomp
87
- end
88
+ autoload :ContextMenuFactory, 'buby/context_menu_factory'
89
+ autoload :Cookie, 'buby/cookie'
90
+ autoload :HttpListener, 'buby/http_listener'
91
+ autoload :IntruderPayloadGenerator, 'buby/intruder_payload_generator'
92
+ autoload :IntruderPayloadGeneratorFactory, 'buby/intruder_payload_generator_factory'
93
+ autoload :IntruderPayloadProcessor, 'buby/intruder_payload_processor'
94
+ autoload :MessageEditorController, 'buby/message_editor_controller'
95
+ autoload :MessageEditorTab, 'buby/message_editor_tab'
96
+ autoload :MessageEditorTabFactory, 'buby/message_editor_tab_factory'
97
+ autoload :Parameter, 'buby/parameter'
98
+ autoload :ProxyListener, 'buby/proxy_listener'
99
+ autoload :ScanIssue, 'buby/scan_issue'
100
+ autoload :ScannerCheck, 'buby/scanner_check'
101
+ autoload :ScannerInsertionPoint, 'buby/scanner_insertion_point'
102
+ autoload :ScannerInsertionPointProvider, 'buby/scanner_insertion_point_provider'
103
+ autoload :ScannerListener, 'buby/scanner_listener'
104
+ autoload :ScopeChangeListener, 'buby/scope_change_listener'
105
+ autoload :SessionHandlingAction, 'buby/session_handling_action'
106
+ autoload :Tab, 'buby/tab'
107
+ autoload :Version, 'buby/version'
108
+
109
+ # @deprecated moving to proper version module
110
+ VERSION = Buby::Version::STRING
111
+
112
+ # latest tested version of burp
113
+ COMPAT_VERSION = '1.5.05'
88
114
 
89
115
  # :stopdoc:
116
+ # @deprecated to be removed next version
117
+ # @api private
90
118
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
119
+
120
+ # @deprecated to be removed next version
121
+ # @api private
91
122
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
92
123
  # :startdoc:
93
124
 
94
125
  def initialize(other=nil)
95
126
  if other
96
- raise "arg 0 must be another kind of Buby" unless other.is_a? Buby
127
+ raise TypeError, "argument must be another kind of Buby, got #{other.class}" unless other.is_a? Buby
97
128
  @burp_extender = other.burp_extender
98
129
  @burp_callbacks = other.burp_callbacks
99
130
  end
@@ -101,8 +132,9 @@ class Buby
101
132
 
102
133
  # Makes this handler the active Ruby handler object for the BurpExtender
103
134
  # Java runtime. (there can be only one!)
104
- def activate!
105
- BurpExtender.set_handler(self)
135
+ # @param extender Buby's BurpExtender interface
136
+ def activate!(extender)
137
+ extender.handler = self
106
138
  end
107
139
 
108
140
  # Returns the internal reference to the BurpExtender instance. This
@@ -121,20 +153,72 @@ class Buby
121
153
  @burp_callbacks or raise "Burp callbacks have not been set"
122
154
  end
123
155
 
124
- # Send an HTTP request to the Burp Scanner tool to perform an active
125
- # vulnerability scan.
126
- # * host = The hostname of the remote HTTP server.
127
- # * port = The port of the remote HTTP server.
128
- # * https = Flags whether the protocol is HTTPS or HTTP.
129
- # * req = The full HTTP request. (String or Java bytes[])
130
- # * ip_off = A list of index pairs representing the
131
- # * positions of the insertion points that should be scanned. Each item in
132
- # * the list must be an int[2] array containing the start and end offsets
133
- # * for the insertion point. *1.4+* only
134
-
135
- def doActiveScan(host, port, https, req, ip_off)
136
- req = req.to_java_bytes if req.is_a? String
137
- getBurpVersion ? _check_cb.doActiveScan(host, port, https, req, ip_off) : _check_cb.doActiveScan(host, port, https, req)
156
+ # This method can be used to send an HTTP request to the Burp Scanner tool
157
+ # to perform an active vulnerability scan. If the request is not within the
158
+ # current active scanning scope, the user will be asked if they wish to
159
+ # proceed with the scan.
160
+ #
161
+ # @overload doActiveScan(host, port, useHttps, request, insertionPointOffsets = nil)
162
+ # @param [String] host The hostname of the remote HTTP server.
163
+ # @param [Fixnum] port The port of the remote HTTP server.
164
+ # @param [Boolean] useHttps Flags whether the protocol is HTTPS or HTTP.
165
+ # @param [String, Array<byte>] request The full HTTP request.
166
+ # @param [Array<Array<Fixnum>>] insertionPointOffsets A list of index pairs
167
+ # representing the positions of the insertion points that should be
168
+ # scanned. Each item in the list must be an +int\[2]+ array containing the
169
+ # start and end offsets for the insertion point.
170
+ # @overload doActiveScan(request, insertionPointOffsets = nil)
171
+ # @param [IHttpRequestResponse] request Request object containing details
172
+ # about the request to scan.
173
+ # @param [Array<Array<Fixnum>>] insertionPointOffsets A list of index pairs
174
+ # representing the positions of the insertion points that should be
175
+ # scanned. Each item in the list must be an +int\[2]+ array containing the
176
+ # start and end offsets for the insertion point.
177
+ # @overload doActiveScan(url, insertionPointOffsets = nil)
178
+ # @param [String, URI, java.net.URL] url Build a +GET+ request and scan url.
179
+ # @param [Array<Array<Fixnum>>] insertionPointOffsets A list of index pairs
180
+ # representing the positions of the insertion points that should be
181
+ # scanned. Each item in the list must be an +int\[2]+ array containing the
182
+ # start and end offsets for the insertion point.
183
+ # @return [IScanQueueItem] The resulting scan queue item.
184
+ #
185
+ def doActiveScan(*args)
186
+ host, port, https, req, ip_off = args
187
+ case args.size
188
+ when 1,2
189
+ req = args.first
190
+ ip_off = args[1]
191
+ if req.kind_of? Java::Burp::IHttpRequestResponse
192
+ serv = req.getHttpService
193
+ https = serv.getProtocol == "https"
194
+ host = serv.getHost
195
+ port = serv.getPort
196
+ req = req.request
197
+ else
198
+ url = (req.kind_of?(URI) || req.kind_of?(Java::JavaNet::URL)) ? req : Java::JavaNet::URL.new(req.to_s)
199
+ req = getHelpers.buildHttpRequest req
200
+ host = url.host
201
+ port = url.port
202
+ if url.scheme.downcase == "https"
203
+ https = true
204
+ port = 443 if port == -1
205
+ else
206
+ https = false
207
+ port = 80 if port == -1
208
+ end
209
+ end
210
+ when 4,5
211
+ host, port, https, req, ip_off = args
212
+ else
213
+ raise ArgumentError
214
+ end
215
+ req = req.to_java_bytes if req.respond_to? :to_java_bytes
216
+ scanq = if getBurpVersion
217
+ _check_cb.doActiveScan(host, port, https, req, ip_off)
218
+ else
219
+ _check_cb.doActiveScan(host, port, https, req)
220
+ end
221
+ Buby::Implants::ScanQueueItem.implant scanq
138
222
  end
139
223
  alias do_active_scan doActiveScan
140
224
  alias active_scan doActiveScan
@@ -157,7 +241,7 @@ class Buby
157
241
  # Exclude the specified URL from the Suite-wide scope.
158
242
  # * url = The URL to exclude from the Suite-wide scope.
159
243
  def excludeFromScope(url)
160
- url = java.net.URL.new(url) if url.is_a? String
244
+ url = Java::JavaNet::URL.new(url) if url.is_a? String
161
245
  _check_cb.excludeFromScope(url)
162
246
  end
163
247
  alias exclude_from_scope excludeFromScope
@@ -166,7 +250,7 @@ class Buby
166
250
  # Include the specified URL in the Suite-wide scope.
167
251
  # * url = The URL to exclude in the Suite-wide scope.
168
252
  def includeInScope(url)
169
- url = java.net.URL.new(url) if url.is_a? String
253
+ url = Java::JavaNet::URL.new(url) if url.is_a? String
170
254
  _check_cb.includeInScope(url)
171
255
  end
172
256
  alias include_in_scope includeInScope
@@ -177,7 +261,7 @@ class Buby
177
261
  #
178
262
  # Returns: true / false
179
263
  def isInScope(url)
180
- url = java.net.URL.new(url) if url.is_a? String
264
+ url = Java::JavaNet::URL.new(url) if url.is_a? String
181
265
  _check_cb.isInScope(url)
182
266
  end
183
267
  alias is_in_scope isInScope
@@ -197,10 +281,25 @@ class Buby
197
281
  # * https = Flags whether the protocol is HTTPS or HTTP.
198
282
  # * req = The full HTTP request. (String or Java bytes[])
199
283
  #
200
- # Returns: The full response retrieved from the remote server.
201
- def makeHttpRequest(host, port, https, req)
202
- req = req.to_java_bytes if req.is_a? String
203
- String.from_java_bytes( _check_cb.makeHttpRequest(host, port, https, req) )
284
+ # also may be called with new IHttpService as an argument
285
+ # * service = IHttpService object with host, port, etc.
286
+ # * request = request string
287
+ # @return The full response retrieved from the remote server.
288
+ #
289
+ def makeHttpRequest(*args)
290
+ ret = case args.size
291
+ when 2
292
+ service, req = args
293
+ req = req.to_java_bytes if req.is_a? String
294
+ _check_and_callback(:makeHttpRequst, service, req)
295
+ when 4
296
+ host, port, https, req = args
297
+ req = req.to_java_bytes if req.is_a? String
298
+ _check_cb.makeHttpRequest(host, port, https, req)
299
+ else
300
+ raise ArgumentError
301
+ end
302
+ String.from_java_bytes(ret)
204
303
  end
205
304
  alias make_http_request makeHttpRequest
206
305
  alias make_request makeHttpRequest
@@ -242,7 +341,7 @@ class Buby
242
341
  # Send a seed URL to the Burp Spider tool.
243
342
  # * url = The new seed URL to begin spidering from.
244
343
  def sendToSpider(url)
245
- url = java.net.URL.new(url) if url.is_a? String
344
+ url = Java::JavaNet::URL.new(url) if url.is_a? String
246
345
  _check_cb.sendToSpider(url)
247
346
  end
248
347
  alias send_to_spider sendToSpider
@@ -254,17 +353,18 @@ class Buby
254
353
  #
255
354
  # * meth = string or symbol name of method
256
355
  # * args = variable length array of arguments to pass to meth
257
- def _check_and_callback(meth, *args)
356
+ def _check_and_callback(meth, *args, &block)
258
357
  cb = _check_cb
259
358
  unless cb.respond_to?(meth)
260
359
  raise "#{meth} is not available in your version of Burp"
261
360
  end
262
- cb.__send__ meth, *args
361
+ cb.__send__ meth, *args, &block
263
362
  end
264
363
 
265
364
 
266
365
  # Returns a Java array of IHttpRequestResponse objects pulled directly from
267
366
  # the Burp proxy history.
367
+ # @todo Bring IHttpRequestResponse helper up to date
268
368
  def getProxyHistory
269
369
  HttpRequestResponseList.new(_check_and_callback(:getProxyHistory))
270
370
  end
@@ -275,6 +375,7 @@ class Buby
275
375
  # Returns a Java array of IHttpRequestResponse objects pulled directly from
276
376
  # the Burp site map for all urls matching the specified literal prefix.
277
377
  # The prefix can be nil to return all objects.
378
+ # @todo Bring IHttpRequestResponse helper up to date
278
379
  def getSiteMap(urlprefix=nil)
279
380
  HttpRequestResponseList.new(_check_and_callback(:getSiteMap, urlprefix))
280
381
  end
@@ -300,7 +401,7 @@ class Buby
300
401
  #
301
402
  # * filename = path and filename of the file to restore from
302
403
  def restoreState(filename)
303
- _check_and_callback(:restoreState, java.io.File.new(filename))
404
+ _check_and_callback(:restoreState, Java::JavaIo::File.new(filename))
304
405
  end
305
406
  alias restore_state restoreState
306
407
 
@@ -311,7 +412,7 @@ class Buby
311
412
  #
312
413
  # * filename = path and filename of the file to save to
313
414
  def saveState(filename)
314
- _check_and_callback(:saveState, java.io.File.new(filename))
415
+ _check_and_callback(:saveState, Java::JavaIo::File.new(filename))
315
416
  end
316
417
  alias save_state saveState
317
418
 
@@ -320,12 +421,20 @@ class Buby
320
421
  # containing parameters as they are structured in the 'Parameters' tab in the
321
422
  # Burp request UI.
322
423
  #
323
- # IMPORTANT: This method is only available with Burp 1.2.09 and higher.
424
+ # IMPORTANT: This method is only available with Burp 1.2.09+ and deprecated in 1.5.01
324
425
  #
325
- # req = raw request (String or Java bytes[])
326
- def getParameters(req)
327
- req = req.to_java_bytes if req.is_a? String
328
- _check_and_callback(:getParameters, req)
426
+ # This method parses the specified request and returns details of each
427
+ # request parameter.
428
+ #
429
+ # @param request The request to be parsed.
430
+ # @return An array of:
431
+ # <code>String[] { name, value, type }</code> containing details of the
432
+ # parameters contained within the request.
433
+ # @deprecated Use +IExtensionHelpers.analyzeRequest()+ instead.
434
+ #
435
+ def getParameters(request)
436
+ request = request.to_java_bytes if request.is_a? String
437
+ _check_and_callback(:getParameters, request)
329
438
  end
330
439
  alias parameters getParameters
331
440
  alias get_parameters getParameters
@@ -335,12 +444,20 @@ class Buby
335
444
  # array containing the headers as they are structured in the 'Headers' tab
336
445
  # in the Burp request/response viewer UI.
337
446
  #
338
- # IMPORTANT: This method is only available with Burp 1.2.09 and higher.
447
+ # IMPORTANT: This method is only available with Burp 1.2.09+ and is deprecated in 1.5.01
448
+ #
449
+ # This method parses the specified request and returns details of each HTTP
450
+ # header.
451
+ #
452
+ # @param message The request to be parsed.
453
+ # @return An array of HTTP headers.
454
+ # @deprecated Use
455
+ # <code>IExtensionHelpers.analyzeRequest()</code> or
456
+ # <code>IExtensionHelpers.analyzeResponse()</code> instead.
339
457
  #
340
- # msg = raw request/response (String or Java bytes[])
341
- def getHeaders(msg)
342
- msg = msg.to_java_bytes if msg.is_a? String
343
- _check_and_callback(:getHeaders, msg)
458
+ def getHeaders(message)
459
+ message = message.to_java_bytes if message.is_a? String
460
+ _check_and_callback(:getHeaders, message)
344
461
  end
345
462
  alias headers getHeaders
346
463
  alias get_headers getHeaders
@@ -353,18 +470,25 @@ class Buby
353
470
  alias exit_suite exitSuite
354
471
  alias close exitSuite
355
472
 
356
- # This method can be used to register a new menu item which will appear
357
- # on the various context menus that are used throughout Burp Suite to
358
- # handle user-driven actions.
359
- #
473
+ # This method can be used to register a new menu item which will appear on
474
+ # the various context menus that are used throughout Burp Suite to handle
475
+ # user-driven actions.
476
+ #
360
477
  # @param menuItemCaption The caption to be displayed on the menu item.
361
- # @param menuItemHandler The handler to be invoked when the user clicks
362
- # on the menu item.
363
- #
364
- # This method is only available with Burp 1.3.07 and higher.
365
- def registerMenuItem(menuItemCaption, menuItemHandler)
366
- _check_and_callback(:registerMenuItem, menuItemCaption, menuItemHandler)
478
+ # @param menuItemHandler The handler to be invoked when the user clicks on
479
+ # the menu item.
480
+ # @deprecated Use {#registerContextMenuFactory} instead.
481
+ #
482
+ # This method is only available with Burp 1.3.07+ and is deprecated in 1.5.01.
483
+ #
484
+ def registerMenuItem(menuItemCaption, menuItemHandler = nil, &block)
485
+ ret = if block_given?
486
+ _check_and_callback(:registerMenuItem, menuItemCaption, &block)
487
+ else
488
+ _check_and_callback(:registerMenuItem, menuItemCaption, menuItemHandler)
489
+ end
367
490
  issueAlert("Handler #{menuItemHandler} registered for \"#{menuItemCaption}\"")
491
+ ret
368
492
  end
369
493
  alias register_menu_item registerMenuItem
370
494
 
@@ -407,8 +531,8 @@ class Buby
407
531
  # configuration.
408
532
  #
409
533
  # This method is only available with Burp 1.3.09+
410
- def loadConfig(conf)
411
- _check_and_callback(:loadConfig, conf)
534
+ def loadConfig(config)
535
+ _check_and_callback(:loadConfig, config)
412
536
  end
413
537
  alias load_config loadConfig
414
538
  alias config= loadConfig
@@ -437,8 +561,498 @@ class Buby
437
561
  end
438
562
  end
439
563
  alias burp_version getBurpVersion
564
+ alias get_burp_version getBurpVersion
565
+
566
+ # This method is used to set the display name for the current extension,
567
+ # which will be displayed within the user interface for the Extender tool.
568
+ #
569
+ # @param [String] name The extension name.
570
+ # @return [void]
571
+ #
572
+ def setExtensionName(name)
573
+ _check_and_callback(:setExtensionName, name)
574
+ end
575
+ alias extension_name= setExtensionName
576
+ alias set_extension_name setExtensionName
577
+
578
+ # This method is used to obtain an
579
+ # <code>IExtensionHelpers</code> object, which can be used by the extension
580
+ # to perform numerous useful tasks.
581
+ #
582
+ # @return An object containing numerous helper methods, for tasks such as
583
+ # building and analyzing HTTP requests.
584
+ #
585
+ def getHelpers
586
+ @helpers ||= Buby::Implants::ExtensionHelpers.implant(_check_and_callback(:getHelpers))
587
+ end
588
+ alias helpers getHelpers
589
+ alias get_helpers getHelpers
590
+
591
+ # This method is used to obtain the current extension's standard output
592
+ # stream. Extensions should write all output to this stream, allowing the
593
+ # Burp user to configure how that output is handled from within the UI.
594
+ #
595
+ # @return [OutputStream] The extension's standard output stream.
596
+ #
597
+ # @todo double check
598
+ def getStdout
599
+ @stdout ||= _check_and_callback(:getStdout)
600
+ end
601
+ alias stdout getStdout
602
+ alias get_stdout getStdout
603
+
604
+ # This method is used to obtain the current extension's standard error
605
+ # stream. Extensions should write all error messages to this stream,
606
+ # allowing the Burp user to configure how that output is handled from
607
+ # within the UI.
608
+ #
609
+ # @return [OutputStream] The extension's standard error stream.
610
+ #
611
+ def getStderr
612
+ @stderr ||= _check_and_callback(:getStderr)
613
+ end
614
+ alias stderr getStderr
615
+ alias get_stderr getStderr
616
+
617
+ # This method is used to register a listener which will be notified of
618
+ # changes to the extension's state. <b>Note:</b> Any extensions that start
619
+ # background threads or open system resources (such as files or database
620
+ # connections) should register a listener and terminate threads / close
621
+ # resources when the extension is unloaded.
622
+ #
623
+ # @overload registerExtensionStateListener(listener)
624
+ # @param [IExtensionStateListener] listener A listener for extension
625
+ # state events
626
+ # @overload registerExtensionStateListener(&block)
627
+ # @param [Proc] &block A listener for extension state events
628
+ # (Isn't JRuby fun?)
629
+ #
630
+ def registerExtensionStateListener(listener = nil, &block)
631
+ if block_given?
632
+ _check_and_callback(:registerExtensionStateListener, &block)
633
+ else
634
+ _check_and_callback(:registerExtensionStateListener, listener)
635
+ end
636
+ end
637
+ alias register_extension_state_listener registerExtensionStateListener
638
+
639
+ # This method is used to register a listener which will be notified of
640
+ # requests and responses made by any Burp tool. Extensions can perform
641
+ # custom analysis or modification of these messages by registering an HTTP
642
+ # listener.
643
+ #
644
+ # @overload registerHttpListener(listener)
645
+ # @param [IHttpListener] listener A listener for http events
646
+ # @overload registerHttpListener(&block)
647
+ # @param [Proc] &block A listener for http events
648
+ # (Isn't JRuby fun?)
649
+ #
650
+ def registerHttpListener(listener = nil, &block)
651
+ if block_given?
652
+ _check_and_callback(:registerHttpListener, &block)
653
+ else
654
+ _check_and_callback(:registerHttpListener, listener)
655
+ end
656
+ end
657
+ alias register_http_listener registerHttpListener
658
+
659
+ # This method is used to register a listener which will be notified of
660
+ # requests and responses being processed by the Proxy tool. Extensions can
661
+ # perform custom analysis or modification of these messages, and control
662
+ # in-UI message interception, by registering a proxy listener.
663
+ #
664
+ # @overload registerProxyListener(listener)
665
+ # @param [IProxyListener] listener A listener for proxy events
666
+ # @overload registerHttpListener(&block)
667
+ # @param [Proc] &block A listener for proxy events
668
+ # (Isn't JRuby fun?)
669
+ #
670
+ def registerProxyListener(listener = nil, &block)
671
+ if block_given?
672
+ _check_and_callback(:registerProxyListener, &block)
673
+ else
674
+ _check_and_callback(:registerProxyListener, listener)
675
+ end
676
+ end
677
+ alias register_proxy_listener registerProxyListener
678
+
679
+ # This method is used to register a listener which will be notified of new
680
+ # issues that are reported by the Scanner tool. Extensions can perform
681
+ # custom analysis or logging of Scanner issues by registering a Scanner
682
+ # listener.
683
+ #
684
+ # @overload registerScannerListener(listener)
685
+ # @param [IScannerListener] listener A listener for scanner events
686
+ # @overload registerScannerListener(&block)
687
+ # @param [Proc] &block A listener for scanner events
688
+ # (Isn't JRuby fun?)
689
+ #
690
+ def registerScannerListener(listener = nil, &block)
691
+ if block_given?
692
+ _check_and_callback(:registerScannerListener, &block)
693
+ else
694
+ _check_and_callback(:registerScannerListener, listener)
695
+ end
696
+ end
697
+ alias register_scanner_listener registerScannerListener
698
+
699
+ # This method is used to register a listener which will be notified of
700
+ # changes to Burp's suite-wide target scope.
701
+ #
702
+ # @overload registerScopeChangeListener(listener)
703
+ # @param [IScopeChangeListener] listener A listener for scope change events
704
+ # @overload registerScopeChangeListener(&block)
705
+ # @param [Proc] &block A listener for scope change events
706
+ # (Isn't JRuby fun?)
707
+ #
708
+ def registerScopeChangeListener(listener = nil, &block)
709
+ if block_given?
710
+ _check_and_callback(:registerScopeChangeListener, &block)
711
+ else
712
+ _check_and_callback(:registerScopeChangeListener, listener)
713
+ end
714
+ end
715
+
716
+ # This method is used to register a factory for custom context menu items.
717
+ # When the user invokes a context menu anywhere within Burp, the factory
718
+ # will be passed details of the invocation event, and asked to provide any
719
+ # custom context menu items that should be shown.
720
+ #
721
+ # @overload registerContextMenuFactory(factory)
722
+ # @param [IContextMenuFactory] factory A listener for context
723
+ # menu invocation events
724
+ # @overload registerContextMenuFactory(&block)
725
+ # @param [Proc] &block A listener for context menu invocation events
726
+ # (Isn't JRuby fun?)
727
+ # @note It is probably better to use the more explicit +factory+ argument
728
+ # version to ensure the +IContextMenuInvocation+ Java classes have been
729
+ # wrapped properly.
730
+ #
731
+ def registerContextMenuFactory(factory = nil, &block)
732
+ if block_given?
733
+ _check_and_callback(:registerContextMenuFactory, &block)
734
+ else
735
+ _check_and_callback(:registerContextMenuFactory, factory)
736
+ end
737
+ end
738
+ alias register_context_menu_factory registerContextMenuFactory
739
+
740
+ # This method is used to register a factory for custom message editor tabs.
741
+ # For each message editor that already exists, or is subsequently created,
742
+ # within Burp, the factory will be asked to provide a new instance of an
743
+ # <code>IMessageEditorTab</code> object, which can provide custom rendering
744
+ # or editing of HTTP messages.
745
+ #
746
+ # @overload registerMessageEditorTabFactory(factory)
747
+ # @param [IMessageEditorTabFactory] factory A listener for message editor
748
+ # tab events
749
+ # @overload registerMessageEditorTabFactory(&block)
750
+ # @param [Proc] &block A listener for message editor tab events
751
+ # (Isn't JRuby fun?)
752
+ # @note It is probably better to use the more explicit +factory+ argument
753
+ # version to ensure the +IMessageEditorController+ Java classes have been
754
+ # wrapped properly.
755
+ #
756
+ def registerMessageEditorTabFactory(factory = nil, &block)
757
+ if block_given?
758
+ _check_and_callback(:registerMessageEditorTabFactory, &block)
759
+ else
760
+ _check_and_callback(:registerMessageEditorTabFactory, factory)
761
+ end
762
+ end
763
+ alias register_message_editor_tab_factory registerMessageEditorTabFactory
764
+
765
+ # This method is used to register a provider of Scanner insertion points.
766
+ # For each base request that is actively scanned, Burp will ask the
767
+ # provider to provide any custom scanner insertion points that are
768
+ # appropriate for the request.
769
+ #
770
+ # @overload registerScannerInsertionPointProvider(provider)
771
+ # @param [IScannerInsertionPointProvider] provider A provider of scanner
772
+ # insertion points
773
+ # @overload registerScannerInsertionPointProvider(&block)
774
+ # @param [Proc] &block A provider of scanner insertion points
775
+ # (Isn't JRuby fun?)
776
+ #
777
+ def registerScannerInsertionPointProvider(provider = nil, &block)
778
+ if block_given?
779
+ _check_and_callback(:registerScannerInsertionPointProvider, &block)
780
+ else
781
+ _check_and_callback(:registerScannerInsertionPointProvider, provider)
782
+ end
783
+ end
784
+ alias register_scanner_insertion_point_provider registerScannerInsertionPointProvider
785
+
786
+ # This method is used to register a custom Scanner check. When performing
787
+ # scanning, Burp will ask the check to perform active or passive scanning
788
+ # on the base request, and report any Scanner issues that are identified.
789
+ #
790
+ # @param [IScannerCheck] check An object that performs a given check.
791
+ #
792
+ def registerScannerCheck(check = nil, &block)
793
+ if block_given?
794
+ _check_and_callback(:registerScannerCheck, &block)
795
+ else
796
+ _check_and_callback(:registerScannerCheck, check)
797
+ end
798
+ end
799
+ alias register_scanner_check registerScannerCheck
800
+
801
+ # This method is used to register a factory for Intruder payloads. Each
802
+ # registered factory will be available within the Intruder UI for the user
803
+ # to select as the payload source for an attack. When this is selected, the
804
+ # factory will be asked to provide a new instance of an
805
+ # +IIntruderPayloadGenerator+ object, which will be used to generate payloads
806
+ # for the attack.
807
+ #
808
+ # @param [IIntruderPayloadGeneratorFactory] factory An object to be used for
809
+ # generating intruder payloads.
810
+ #
811
+ # @todo Test - block version may work here
812
+ def registerIntruderPayloadGeneratorFactory(factory = nil, &block)
813
+ if block_given?
814
+ _check_and_callback(:registerIntruderPayloadGeneratorFactory, &block)
815
+ else
816
+ _check_and_callback(:registerIntruderPayloadGeneratorFactory, factory)
817
+ end
818
+ end
819
+ alias register_intruder_payload_generator_factory registerIntruderPayloadGeneratorFactory
820
+
821
+ # This method is used to register a custom Intruder payload processor. Each
822
+ # registered processor will be available within the Intruder UI for the
823
+ # user to select as the action for a payload processing rule.
824
+ #
825
+ # @param [IIntruderPayloadProcessor] processor An object used for processing
826
+ # Intruder payloads
827
+ #
828
+ # @todo Test - block version may work here
829
+ def registerIntruderPayloadProcessor(processor)
830
+ if block_given?
831
+ _check_and_callback(:registerIntruderPayloadProcessor, &block)
832
+ else
833
+ _check_and_callback(:registerIntruderPayloadProcessor, processor)
834
+ end
835
+ end
836
+ alias register_intruder_payload_processor registerIntruderPayloadProcessor
837
+
838
+ # This method is used to register a custom session handling action. Each
839
+ # registered action will be available within the session handling rule UI
840
+ # for the user to select as a rule action. Users can choose to invoke an
841
+ # action directly in its own right, or following execution of a macro.
842
+ #
843
+ # @param [ISessionHandlingAction] action An object used to perform a given session action.
844
+ #
845
+ # @todo Test - block version may work here
846
+ def registerSessionHandlingAction(action)
847
+ if block_given?
848
+ _check_and_callback(:registerSessionHandlingAction, &block)
849
+ else
850
+ _check_and_callback(:registerSessionHandlingAction, action)
851
+ end
852
+ end
853
+ alias register_session_handling_action registerSessionHandlingAction
854
+
855
+ # This method is used to add a custom tab to the main Burp Suite window.
856
+ #
857
+ # @param [ITab] tab A tab to be added to the suite's user interface.
858
+ #
859
+ def addSuiteTab(tab)
860
+ _check_and_callback(:addSuiteTab, tab)
861
+ end
862
+ alias add_suite_tab addSuiteTab
863
+
864
+ # This method is used to remove a previously-added tab from the main Burp
865
+ # Suite window.
866
+ #
867
+ # @param [ITab] tab The tab to be removed from the suite's user interface.
868
+ #
869
+ def removeSuiteTab(tab)
870
+ _check_and_callback(:removeSuiteTab, tab)
871
+ end
872
+ alias remove_suite_tab removeSuiteTab
873
+
874
+ # This method is used to customize UI components in line with Burp's UI
875
+ # style, including font size, colors, table line spacing, etc.
876
+ #
877
+ # @param [Component] component The UI component to be customized.
878
+ #
879
+ def customizeUiComponent(component)
880
+ _check_and_callback(:customizeUiComponent, component)
881
+ end
882
+ alias customize_ui_component customizeUiComponent
883
+
884
+ # This method is used to create a new instance of Burp's HTTP message
885
+ # editor, for the extension to use in its own UI.
886
+ #
887
+ # @param controller An object created by the extension that implements the
888
+ # +IMessageEditorController+ interface. This parameter is optional and
889
+ # defaults to +nil+. If it is provided, then the message editor will query
890
+ # the controller when required to obtain details about the currently
891
+ # displayed message, including the +IHttpService+ for the message, and the
892
+ # associated request or response message. If a controller is not provided,
893
+ # then the message editor will not support context menu actions, such as
894
+ # sending requests to other Burp tools.
895
+ # @param [Boolean] editable Indicates whether the editor created should be
896
+ # editable, or used only for message viewing.
897
+ # @return [IMessageEditor] An object which the extension can use in
898
+ # its own UI.
899
+ #
900
+ def createMessageEditor(controller = nil, editable = true)
901
+ Buby::Implants::MessageEditor.implant _check_and_callback(:createMessageEditor, controller, editable)
902
+ end
903
+ alias create_message_editor createMessageEditor
904
+
905
+ # This method is used to save configuration settings for the extension in a
906
+ # persistent way that survives reloads of the extension and of Burp Suite.
907
+ # Saved settings can be retrieved using the method {#loadExtensionSetting}.
908
+ #
909
+ # @param [String] name The name of the setting.
910
+ # @param [String] value The value of the setting. If this value is +nil+ then
911
+ # any existing setting with the specified name will be removed.
912
+ #
913
+ def saveExtensionSetting(name, value)
914
+ _check_and_callback(:saveExtensionSetting, name, value)
915
+ end
916
+ alias save_extension_setting saveExtensionSetting
917
+
918
+ # This method is used to load configuration settings for the extension that
919
+ # were saved using the method
920
+ # <code>saveExtensionSetting()</code>.
921
+ #
922
+ # @param [String] name The name of the setting.
923
+ # @return [String] The value of the setting, or +nil+ if no value is set.
924
+ #
925
+ def loadExtensionSetting(name)
926
+ _check_and_callback(:loadExtensionSetting, name)
927
+ end
928
+ alias load_extension_setting loadExtensionSetting
929
+
930
+ # This method is used to create a new instance of Burp's plain text editor,
931
+ # for the extension to use in its own UI.
932
+ #
933
+ # @return [ITextEditor] A new text editor the extension can use in its own UI.
934
+ #
935
+ def createTextEditor()
936
+ _check_and_callback(:createTextEditor)
937
+ end
938
+ alias create_text_editor createTextEditor
939
+
940
+ # This method is used to retrieve the contents of Burp's session handling
941
+ # cookie jar. Extensions that provide an +ISessionHandlingAction+ can query
942
+ # and update the cookie jar in order to handle unusual session handling
943
+ # mechanisms.
944
+ #
945
+ # @return [Array<ICookie>] An array of the cookies representing the contents
946
+ # of Burp's session handling cookie jar.
947
+ #
948
+ def getCookieJarContents
949
+ _check_and_callback(:getCookieJarContents).tap{|arr| Buby::Implants::Cookie.implant(arr.first)}
950
+ end
951
+ alias get_cookie_jar_contents getCookieJarContents
952
+ alias cookie_jar_contents getCookieJarContents
953
+
954
+ # This method is used to update the contents of Burp's session handling
955
+ # cookie jar. Extensions that provide an
956
+ # <code>ISessionHandlingAction</code> can query and update the cookie jar
957
+ # in order to handle unusual session handling mechanisms.
958
+ #
959
+ # @param [ICookie] cookie An object containing details of the cookie to be
960
+ # updated. If the cookie jar already contains a cookie that matches the
961
+ # specified domain and name, then that cookie will be updated with the new
962
+ # value and expiration, unless the new value is +nil+, in which case the
963
+ # cookie will be removed. If the cookie jar does not already contain a
964
+ # cookie that matches the specified domain and name, then the cookie will
965
+ # be added.
966
+ #
967
+ # @see Buby::Cookie
968
+ def updateCookieJar(cookie)
969
+ _check_and_callback(:updateCookieJar, cookie)
970
+ end
971
+ alias update_cookie_jar updateCookieJar
972
+
973
+ # This method is used to create a temporary file on disk containing the
974
+ # provided data. Extensions can use temporary files for long-term storage
975
+ # of runtime data, avoiding the need to retain that data in memory.
976
+ # Not strictly needed in JRuby (use Tempfile class in stdlib instead) but might see use.
977
+ #
978
+ # @param [String, Array<byte>] buffer The data to be saved to a temporary file.
979
+ # @return [ITempFile] A reference to the temp file.
980
+ #
981
+ def saveToTempFile(buffer)
982
+ buffer = buffer.to_java_bytes if buffer.respond_to? :to_java_bytes
983
+ Buby::Implants::TempFile.implant(_check_and_callback(:saveToTempFile, buffer))
984
+ end
985
+ alias save_to_temp_file saveToTempFile
986
+
987
+ # This method is used to save the request and response of an
988
+ # +IHttpRequestResponse+ object to temporary files, so that they are no longer
989
+ # held in memory. Extensions can used this method to convert
990
+ # +IHttpRequestResponse+ objects into a form suitable for long-term storage.
991
+ #
992
+ # @param [IHttpRequestResponse] httpRequestResponse The request and response
993
+ # messages to be saved to temporary files.
994
+ # @return [IHttpRequestResponsePersisted] A reference to the saved temp file.
995
+ #
996
+ # @todo move HttpRequestResponse to new Implants method...
997
+ def saveBuffersToTempFiles(httpRequestResponse)
998
+ _check_and_callback(:saveBuffersToTempFiles, httpRequestResponse).tap{|obj| Buby::HttpRequestResponseHelper.implant(obj)}
999
+ end
1000
+ alias save_buffers_to_temp_files saveBuffersToTempFiles
1001
+
1002
+ # This method is used to apply markers to an HTTP request or response, at
1003
+ # offsets into the message that are relevant for some particular purpose.
1004
+ # Markers are used in various situations, such as specifying Intruder
1005
+ # payload positions, Scanner insertion points, and highlights in Scanner
1006
+ # issues.
1007
+ #
1008
+ # @param [IHttpRequestResponse] httpRequestResponse The object to which the
1009
+ # markers should be applied.
1010
+ # @param [Array<Array<Fixnum>>] requestMarkers A list of index pairs
1011
+ # representing the offsets of markers to be applied to the request message.
1012
+ # Each item in the list must be an +int[2]+ array containing the start and
1013
+ # end offsets for the marker. This parameter is optional and may be +nil+ if
1014
+ # no request markers are required.
1015
+ # @param [Array<Array<Fixnum>>] responseMarkers A list of index pairs
1016
+ # representing the offsets of markers to be applied to the response message.
1017
+ # Each item in the list must be an +int[2]+ array containing the start and
1018
+ # end offsets for the marker. This parameter is optional and may be +nil+ if
1019
+ # no response markers are required.
1020
+ # @return [IHttpRequestResponseWithMarkers] A marked request/response pair.
1021
+ #
1022
+ # @todo Bring IHttpRequestResponse helper up to date
1023
+ def applyMarkers(httpRequestResponse, requestMarkers, responseMarkers)
1024
+ _check_and_callback(:applyMarkers, httpRequestResponse, requestMarkers, responseMarkers).tap{|obj| Buby::HttpRequestResponseHelper.implant(obj)}
1025
+ end
1026
+ alias apply_markers applyMarkers
1027
+
1028
+ # This method is used to obtain the descriptive name for the Burp tool
1029
+ # identified by the tool flag provided.
1030
+ #
1031
+ # @param [Fixnum] toolFlag A flag identifying a Burp tool (+TOOL_PROXY+, +TOOL_SCANNER+, etc.). Tool flags are defined within this interface.
1032
+ # @return [String] The descriptive name for the specified tool.
1033
+ #
1034
+ def getToolName(toolFlag)
1035
+ _check_and_callback(:getToolName, toolFlag)
1036
+ end
1037
+ alias get_tool_name getToolName
1038
+
1039
+ # This method is used to register a new Scanner issue.
1040
+ # @note Wherever possible, extensions should implement custom Scanner checks
1041
+ # using +IScannerCheck+ and report issues via those checks, so as to
1042
+ # integrate with Burp's user-driven workflow, and ensure proper
1043
+ # consolidation of duplicate reported issues. This method is only designed
1044
+ # for tasks outside of the normal testing workflow, such as importing
1045
+ # results from other scanning tools.
1046
+ #
1047
+ # @param [IScanIssue] issue An issue to be added to the scan results.
1048
+ #
1049
+ def addScanIssue(issue)
1050
+ _check_and_callback(:addScanIssue, issue)
1051
+ end
1052
+ alias add_scan_issue addScanIssue
440
1053
 
441
1054
  ### Event Handlers ###
1055
+ # @todo move basic event handler logic to extender side
442
1056
 
443
1057
  # This method is called by the BurpExtender java implementation upon
444
1058
  # initialization of the BurpExtender instance for Burp. The args parameter
@@ -446,11 +1060,24 @@ class Buby
446
1060
  # so that implementations can access and extend its public interfaces.
447
1061
  #
448
1062
  # The return value is ignored.
1063
+ # @deprecated
449
1064
  def evt_extender_init ext
450
1065
  @burp_extender = ext
451
1066
  pp([:got_extender, ext]) if $DEBUG
452
1067
  end
453
1068
 
1069
+ # This method is called by the BurpExtender implementations upon
1070
+ # initialization of the BurpExtender instance for Burp. The args parameter
1071
+ # is passed with a instance of the newly initialized BurpExtender instance
1072
+ # so that implementations can access and extend its public interfaces.
1073
+ #
1074
+ # @param [IBurpExtender] ext
1075
+ # @return [void]
1076
+ def extender_initialize ext
1077
+ @burp_extender = ext
1078
+ pp([:got_extender, ext]) if $DEBUG
1079
+ end
1080
+
454
1081
  # This method is called by the BurpExtender implementation Burp startup.
455
1082
  # The args parameter contains main()'s argv command-line arguments array.
456
1083
  #
@@ -458,30 +1085,74 @@ class Buby
458
1085
  # implementation of BurpExtender.
459
1086
  #
460
1087
  # The return value is ignored.
1088
+ # @deprecated - nothing calls this anymore
461
1089
  def evt_command_line_args args
462
1090
  pp([:got_args, args]) if $DEBUG
463
1091
  end
464
1092
 
465
- # This method is called by BurpExtender on startup to register Burp's
1093
+ # This method is called by BurpExtender on startup to register Burp's
466
1094
  # IBurpExtenderCallbacks interface object.
467
1095
  #
468
- # This maps to the 'registerExtenderCallbacks' method in the Java
1096
+ # This maps to the 'registerExtenderCallbacks' method in the Java
469
1097
  # implementation of BurpExtender.
470
1098
  #
471
1099
  # The return value is ignored.
472
- def evt_register_callbacks cb
1100
+ # @deprecated
1101
+ # @param cb [IBurpExtenderCallbacks] callbacks presented by burp
1102
+ # @param alert [Boolean]
1103
+ # @return [IBurpExtenderCallbacks] cb
1104
+ def evt_register_callbacks cb, alert = true
1105
+ cb.issueAlert("[JRuby::#{self.class}] registered callback") if alert
1106
+ pp([:got_evt_register_callbacks, cb]) if $DEBUG
473
1107
  @burp_callbacks = cb
474
- cb.issueAlert("[JRuby::#{self.class}] registered callback")
475
- pp([:got_callbacks, cb]) if $DEBUG
476
1108
  end
477
1109
 
478
- ACTION_FOLLOW_RULES = BurpExtender::ACTION_FOLLOW_RULES
479
- ACTION_DO_INTERCEPT = BurpExtender::ACTION_DO_INTERCEPT
480
- ACTION_DONT_INTERCEPT = BurpExtender::ACTION_DONT_INTERCEPT
481
- ACTION_DROP = BurpExtender::ACTION_DROP
482
- ACTION_FOLLOW_RULES_AND_REHOOK = BurpExtender::ACTION_FOLLOW_RULES_AND_REHOOK
483
- ACTION_DO_INTERCEPT_AND_REHOOK = BurpExtender::ACTION_DO_INTERCEPT_AND_REHOOK
484
- ACTION_DONT_INTERCEPT_AND_REHOOK = BurpExtender::ACTION_DONT_INTERCEPT_AND_REHOOK
1110
+ # This method is called by BurpExtender on startup to register Burp's
1111
+ # IBurpExtenderCallbacks interface object.
1112
+ #
1113
+ # This maps to the 'registerExtenderCallbacks' method in the Java
1114
+ # implementation of BurpExtender.
1115
+ #
1116
+ # @param callbacks [IBurpExtenderCallbacks] callbacks presented by burp
1117
+ # @param alert [Boolean]
1118
+ # @return [IBurpExtenderCallbacks] cb
1119
+ def register_callbacks callbacks, alert = true
1120
+ callbacks.issueAlert("[JRuby::#{self.class}] registered callback") if alert
1121
+ pp([:got_register_callbacks, callbacks]) if $DEBUG
1122
+ evt_register_callbacks(callbacks, false) if respond_to? :evt_register_callbacks
1123
+ @burp_callbacks = callbacks
1124
+ end
1125
+
1126
+
1127
+ ACTION_FOLLOW_RULES = Java::Burp::IInterceptedProxyMessage::ACTION_FOLLOW_RULES
1128
+ ACTION_DO_INTERCEPT = Java::Burp::IInterceptedProxyMessage::ACTION_DO_INTERCEPT
1129
+ ACTION_DONT_INTERCEPT = Java::Burp::IInterceptedProxyMessage::ACTION_DONT_INTERCEPT
1130
+ ACTION_DROP = Java::Burp::IInterceptedProxyMessage::ACTION_DROP
1131
+ ACTION_FOLLOW_RULES_AND_REHOOK = Java::Burp::IInterceptedProxyMessage::ACTION_FOLLOW_RULES_AND_REHOOK
1132
+ ACTION_DO_INTERCEPT_AND_REHOOK = Java::Burp::IInterceptedProxyMessage::ACTION_DO_INTERCEPT_AND_REHOOK
1133
+ ACTION_DONT_INTERCEPT_AND_REHOOK = Java::Burp::IInterceptedProxyMessage::ACTION_DONT_INTERCEPT_AND_REHOOK
1134
+ # Flag used to identify Burp Suite as a whole.
1135
+ TOOL_SUITE = Java::Burp::IBurpExtenderCallbacks::TOOL_SUITE
1136
+ # Flag used to identify the Burp Target tool.
1137
+ TOOL_TARGET = Java::Burp::IBurpExtenderCallbacks::TOOL_TARGET
1138
+ # Flag used to identify the Burp Proxy tool.
1139
+ TOOL_PROXY = Java::Burp::IBurpExtenderCallbacks::TOOL_PROXY
1140
+ # Flag used to identify the Burp Spider tool.
1141
+ TOOL_SPIDER = Java::Burp::IBurpExtenderCallbacks::TOOL_SPIDER
1142
+ # Flag used to identify the Burp Scanner tool.
1143
+ TOOL_SCANNER = Java::Burp::IBurpExtenderCallbacks::TOOL_SCANNER
1144
+ # Flag used to identify the Burp Intruder tool.
1145
+ TOOL_INTRUDER = Java::Burp::IBurpExtenderCallbacks::TOOL_INTRUDER
1146
+ # Flag used to identify the Burp Repeater tool.
1147
+ TOOL_REPEATER = Java::Burp::IBurpExtenderCallbacks::TOOL_REPEATER
1148
+ # Flag used to identify the Burp Sequencer tool.
1149
+ TOOL_SEQUENCER = Java::Burp::IBurpExtenderCallbacks::TOOL_SEQUENCER
1150
+ # Flag used to identify the Burp Decoder tool.
1151
+ TOOL_DECODER = Java::Burp::IBurpExtenderCallbacks::TOOL_DECODER
1152
+ # Flag used to identify the Burp Comparer tool.
1153
+ TOOL_COMPARER = Java::Burp::IBurpExtenderCallbacks::TOOL_COMPARER
1154
+ # Flag used to identify the Burp Extender tool.
1155
+ TOOL_EXTENDER = Java::Burp::IBurpExtenderCallbacks::TOOL_EXTENDER
485
1156
 
486
1157
  # Seems we need to specifically render our 'message' to a string here in
487
1158
  # ruby. Otherwise there's flakiness when converting certain binary non-ascii
@@ -622,6 +1293,8 @@ class Buby
622
1293
  # message[0..4] = "HEAD "
623
1294
  # return message.dup
624
1295
  #
1296
+ # @deprecated Legacy - Use {Buby#process_proxy_message} or
1297
+ # {Buby::ProxyListener}
625
1298
  def evt_proxy_message msg_ref, is_req, rhost, rport, is_https, http_meth, url, resourceType, status, req_content_type, message, action
626
1299
  pp([ (is_req)? :got_proxy_request : :got_proxy_response,
627
1300
  [:msg_ref, msg_ref],
@@ -640,6 +1313,21 @@ class Buby
640
1313
  return message
641
1314
  end
642
1315
 
1316
+ # This method is invoked when an HTTP message is being processed by the Proxy.
1317
+ #
1318
+ # @param [Boolean] messageIsRequest Indicates whether the HTTP message is a
1319
+ # request or a response.
1320
+ # @param [IInterceptedProxyMessage] message An +IInterceptedProxyMessage+
1321
+ # object that extensions can use to query and update details of the
1322
+ # message, and control whether the message should be intercepted and
1323
+ # displayed to the user for manual review or modification.
1324
+ # @return [void]
1325
+ #
1326
+ # @see Buby::ProxyListener
1327
+ def process_proxy_message(messageIsRequest, message)
1328
+ pp [:got_processProxyMessage] if $debug
1329
+ Buby::Implants::InterceptedProxyMessage.implant message
1330
+ end
643
1331
 
644
1332
  # This method is invoked whenever any of Burp's tools makes an HTTP request
645
1333
  # or receives a response. This is effectively a generalised version of the
@@ -667,9 +1355,33 @@ class Buby
667
1355
  # * message_info = an instance of the IHttpRequestResponse Java class with
668
1356
  # methods for accessing and manipulating various attributes of the message.
669
1357
  #
1358
+ # @todo Bring IHttpRequestResponse helper up to date
1359
+ # @note Changed in Burp 1.5.01+
1360
+ # @deprecated This is the called by the legacy interface, use
1361
+ # {#process_http_message} instead
670
1362
  def evt_http_message(tool_name, is_request, message_info)
671
1363
  HttpRequestResponseHelper.implant(message_info)
672
- pp([:got_http_message, tool_name, is_request, message_info]) if $DEBUG
1364
+ pp([:got_evt_http_message, tool_name, is_request, message_info]) if $DEBUG
1365
+ end
1366
+
1367
+
1368
+ # This method is invoked when an HTTP request is about to be issued, and
1369
+ # when an HTTP response has been received.
1370
+ #
1371
+ # @param [Fixnum] toolFlag A flag indicating the Burp tool that issued the
1372
+ # request. Burp tool flags are defined in the +IBurpExtenderCallbacks+
1373
+ # interface.
1374
+ # @param [Boolean] messageIsRequest Flags whether the method is being invoked
1375
+ # for a request or response.
1376
+ # @param [IHttpRequestResponse] messageInfo Details of the request / response
1377
+ # to be processed. Extensions can call the setter methods on this object to
1378
+ # update the current message and so modify Burp's behavior.
1379
+ # @return [void]
1380
+ # @note This is the 1.5.01+ version of this callback
1381
+ #
1382
+ def process_http_message(toolFlag, messageIsRequest, messageInfo)
1383
+ HttpRequestResponseHelper.implant(messageInfo)
1384
+ pp([:got_process_http_message, toolFlag, messageIsRequest, messageInfo]) if $DEBUG
673
1385
  end
674
1386
 
675
1387
  # This method is invoked whenever Burp Scanner discovers a new, unique
@@ -684,18 +1396,70 @@ class Buby
684
1396
  # Parameters:
685
1397
  # * issue = an instance of the IScanIssue Java class with methods for viewing
686
1398
  # information on the scan issue that was generated.
1399
+ # @todo move implant to new way...
1400
+ # @deprecated
687
1401
  def evt_scan_issue(issue)
688
1402
  ScanIssueHelper.implant(issue)
689
1403
  pp([:got_scan_issue, issue]) if $DEBUG
690
1404
  end
691
1405
 
1406
+
1407
+ # This method is invoked when a new issue is added to Burp Scanner's
1408
+ # results.
1409
+ #
1410
+ # @param [IScanIssue] issue An +IScanIssue+ object that the extension can
1411
+ # query to obtain details about the new issue.
1412
+ #
1413
+ # @return [void]
1414
+ #
1415
+ # @abstract
1416
+ # @note This maps to the newScanIssue callback in IScannerListener implemented
1417
+ # by the BurpExtender side.
1418
+ def new_scan_issue(issue)
1419
+ pp [:got_newScanIssue, issue] if $DEBUG
1420
+ ScanIssueHelper.implant issue
1421
+ end
1422
+
692
1423
  # This method is called by BurpExtender right before closing the
693
1424
  # application. Implementations can use this method to perform cleanup
694
1425
  # tasks such as closing files or databases before exit.
1426
+ # @deprecated
695
1427
  def evt_application_closing
696
1428
  pp([:got_app_close]) if $DEBUG
697
1429
  end
698
1430
 
1431
+ # This method is called by BurpExtender right before closing the
1432
+ # application. Implementations can use this method to perform cleanup
1433
+ # tasks such as closing files or databases before exit.
1434
+ def application_closing
1435
+ pp([:got_app_close]) if $DEBUG
1436
+ end
1437
+
1438
+ # This method is called by BurpExtender right before unloading the
1439
+ # extension. Implementations can use this method to perform cleanup
1440
+ # tasks such as closing files or databases before exit.
1441
+ def extension_unloaded
1442
+ pp([:got_extension_unloaded]) if $DEBUG
1443
+ end
1444
+
1445
+ # This method is used to unload the extension from Burp Suite.
1446
+ #
1447
+ def unloadExtension
1448
+ _check_and_callback(:unloadExtension)
1449
+ end
1450
+ alias unload_extension unloadExtension
1451
+
1452
+ # This method returns the command line arguments that were passed to Burp
1453
+ # on startup.
1454
+ #
1455
+ # @return [Array<String>] The command line arguments that were passed to Burp on startup.
1456
+ #
1457
+ def getCommandLineArguments
1458
+ _check_and_callback(:getCommandLineArguments)
1459
+ end
1460
+ alias get_command_line_arguments getCommandLineArguments
1461
+ alias command_line_arguments getCommandLineArguments
1462
+
699
1463
  ### Sugar/Convenience methods
700
1464
 
701
1465
  # This is a convenience wrapper which can load a given burp state file and
@@ -783,10 +1547,10 @@ class Buby
783
1547
  def harvest_cookies_from_history(cookie=nil, urlrx=nil, statefile=nil)
784
1548
  ret = []
785
1549
  search_proxy_history(statefile, urlrx) do |hrr|
786
- if heads=hrr.rsp_headers
787
- ret += heads.select do |h|
788
- h[0].downcase == 'set-cookie' and (not block_given? or yield(h[1]))
789
- end.map{|h| h[1]}
1550
+ if (resp = hrr.response)
1551
+ ret += helpers.analyzeResponse(resp).getCookies.select do |c|
1552
+ (cookie.nil? or c.match(cookie)) && (not block_given? or yield(c))
1553
+ end
790
1554
  end
791
1555
  end
792
1556
  return ret
@@ -796,23 +1560,38 @@ class Buby
796
1560
 
797
1561
  # Prepares the java BurpExtender implementation with a reference
798
1562
  # to self as the module handler and launches burp suite.
799
- def start_burp(args=[])
800
- activate!()
801
- Java::Burp::StartBurp.main(args.to_java(:string))
1563
+ # @param extender Buby exender interface
1564
+ def start(extender = nil, args = [])
1565
+ # so we don't get error when this file is loaded
1566
+ extender ||= legacy_mode? ? Java.burp.BurpExtender : Object.const_get(:BurpExtender)
1567
+ activate!(extender)
1568
+ Java.burp.StartBurp.main(args.to_java(:string)) if legacy_mode?
802
1569
  return self
803
1570
  end
804
1571
 
805
- # Starts burp using a supplied handler class,
806
- # h_class = Buby or a derived class. instance of which will become handler.
807
- # args = arguments to Burp
808
- # init_args = arguments to the handler constructor
1572
+ # @deprecated Use Buby#start instead
1573
+ alias start_burp start
1574
+
1575
+ # Starts burp using a supplied handler class
1576
+ #
1577
+ # @param extender Buby BurpExtender to use for callbacks
1578
+ # @param [Class] h_class Buby or a derived class. instance of which will
1579
+ # become handler.
1580
+ # @param [Array<String>] args arguments to Burp
1581
+ # @param init_args arguments to the handler constructor
809
1582
  #
810
- # Returns the handler instance
811
- def self.start_burp(h_class=nil, init_args=nil, args=nil)
1583
+ # @return Buby handler instance
1584
+ def self.start(extender = nil, h_class=nil, init_args=nil, args=nil)
812
1585
  h_class ||= self
813
1586
  init_args ||= []
814
1587
  args ||= []
815
- h_class.new(*init_args).start_burp(args)
1588
+ h_class.new(*init_args).start_burp(extender, args)
1589
+ end
1590
+
1591
+ # @see Buby.start
1592
+ # @deprecated Use Buby.start instead
1593
+ def self.start_burp(extender = nil, h_class = nil, init_args = nil, args = nil)
1594
+ self.start(extender, h_class, init_args, args)
816
1595
  end
817
1596
 
818
1597
  # Attempts to load burp with require and confirm it provides the required
@@ -830,19 +1609,36 @@ class Buby
830
1609
  # Checks the Java namespace to see if Burp has been loaded.
831
1610
  def self.burp_loaded?
832
1611
  @burp_loaded ||= begin
833
- java_import 'burp.StartBurp'
1612
+ Java.burp.StartBurp
834
1613
  true
835
1614
  rescue NameError
836
1615
  false
837
1616
  end
838
1617
  end
839
1618
 
1619
+ # determines if we're running in legacy mode
1620
+ # @return [Class, nil]
1621
+ def self.legacy_mode?
1622
+ @legacy ||= begin
1623
+ Java.burp.BurpExtender
1624
+ rescue NameError
1625
+ false
1626
+ end
1627
+ @legacy
1628
+ end
1629
+
1630
+ def legacy_mode?
1631
+ self.class.legacy_mode?
1632
+ end
1633
+
840
1634
  ### Extra cruft added by Mr Bones:
841
1635
 
842
1636
  # Returns the library path for the module. If any arguments are given,
843
1637
  # they will be joined to the end of the libray path using
844
1638
  # <tt>File.join</tt>.
845
1639
  #
1640
+ # @deprecated
1641
+ # @api private
846
1642
  def self.libpath( *args )
847
1643
  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
848
1644
  end
@@ -851,6 +1647,8 @@ class Buby
851
1647
  # they will be joined to the end of the path using
852
1648
  # <tt>File.join</tt>.
853
1649
  #
1650
+ # @deprecated
1651
+ # @api private
854
1652
  def self.path( *args )
855
1653
  args.empty? ? PATH : ::File.join(PATH, args.flatten)
856
1654
  end
@@ -860,6 +1658,8 @@ class Buby
860
1658
  # in. Optionally, a specific _directory_ name can be passed in such that
861
1659
  # the _filename_ does not have to be equivalent to the directory.
862
1660
  #
1661
+ # @deprecated
1662
+ # @api private
863
1663
  def self.require_all_libs_relative_to( fname, dir = nil )
864
1664
  dir ||= ::File.basename(fname, '.*')
865
1665
  search_me = ::File.expand_path(
@@ -869,12 +1669,3 @@ class Buby
869
1669
  end
870
1670
 
871
1671
  end # Buby
872
-
873
-
874
- # Try requiring 'burp.jar' from the Ruby lib-path
875
- unless Buby.burp_loaded?
876
- begin require "burp.jar"
877
- rescue LoadError
878
- end
879
- end
880
-