buby 1.5.0.pre2-java → 1.5.0.pre3-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/buby.gemspec +15 -4
- data/ext/buby/burp/BurpExtender.java +55 -16
- data/ext/burp_interfaces/burp/IBurpExtenderCallbacks.java +52 -53
- data/ext/burp_interfaces/burp/IContextMenuInvocation.java +26 -15
- data/ext/burp_interfaces/burp/IInterceptedProxyMessage.java +23 -3
- data/ext/burp_interfaces/burp/IProxyListener.java +1 -1
- data/lib/buby.rb +48 -30
- data/lib/buby/burp_extender.rb +339 -0
- data/lib/buby/burp_extender/console_frame.rb +33 -0
- data/lib/buby/burp_extender/console_pane.rb +26 -0
- data/lib/buby/burp_extender/console_tab.rb +15 -0
- data/lib/buby/burp_extender/context_menu.rb +29 -0
- data/lib/buby/burp_extender/context_menu_factory.rb +17 -0
- data/lib/buby/burp_extender/context_menu_item.rb +13 -0
- data/lib/buby/burp_extender/jcheck_box_menu_item.rb +12 -0
- data/lib/buby/burp_extender/jmenu.rb +11 -0
- data/lib/buby/burp_extender/jmenu_item.rb +12 -0
- data/lib/buby/burp_extender/menu.rb +11 -0
- data/lib/buby/burp_extender/menu_item.rb +12 -0
- data/lib/buby/extender.rb +156 -0
- data/lib/buby/implants/context_menu_invocation.rb +29 -2
- data/lib/buby/implants/cookie.rb +0 -1
- data/lib/buby/implants/extension_helpers.rb +0 -37
- data/lib/buby/implants/http_request_response.rb +3 -3
- data/lib/buby/implants/intercepted_proxy_message.rb +0 -1
- data/lib/buby/implants/intruder_attack.rb +0 -1
- data/lib/buby/implants/jruby.rb +19 -10
- data/lib/buby/implants/message_editor.rb +0 -1
- data/lib/buby/implants/message_editor_controller.rb +0 -1
- data/lib/buby/implants/parameter.rb +0 -1
- data/lib/buby/implants/request_info.rb +0 -1
- data/lib/buby/implants/response_info.rb +0 -1
- data/lib/buby/implants/scan_queue_item.rb +0 -1
- data/lib/buby/implants/scanner_insertion_point.rb +0 -1
- data/lib/buby/implants/temp_file.rb +0 -1
- data/lib/buby/implants/text_editor.rb +0 -1
- data/lib/buby/scanner_check.rb +1 -1
- data/lib/buby/version.rb +2 -2
- metadata +15 -4
- data/lib/buby.jar +0 -0
- data/lib/burp_interfaces.jar +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
class BurpExtender
|
2
|
+
# @api private
|
3
|
+
class ConsoleFrame < Java::JavaxSwing::JFrame
|
4
|
+
attr_accessor :burp, :pane
|
5
|
+
def initialize(burp_extender, pane, opts = {}, &block)
|
6
|
+
@burp = burp_extender
|
7
|
+
@pane = pane
|
8
|
+
|
9
|
+
blck = lambda do |event|
|
10
|
+
if event.getID == Java::JavaAwtEvent::WindowEvent::WINDOW_CLOSING
|
11
|
+
@pane.tar.shutdown
|
12
|
+
self.dispose
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
super(opts[:title] || 'JRuby IRB Console (tab will autocomplete)')
|
17
|
+
set_size(*(opts[:size] || [700, 600]))
|
18
|
+
content_pane.add(@pane)
|
19
|
+
addWindowStateListener &blck
|
20
|
+
addWindowListener &blck
|
21
|
+
|
22
|
+
if block_given?
|
23
|
+
addWindowStateListener &block
|
24
|
+
addWindowListener &block
|
25
|
+
end
|
26
|
+
|
27
|
+
@burp.callbacks.customizeUiComponent self
|
28
|
+
Java::JavaAwt::EventQueue.invoke_later {
|
29
|
+
self.visible = true
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class BurpExtender
|
2
|
+
# @api private
|
3
|
+
class ConsolePane < Java::JavaxSwing::JScrollPane
|
4
|
+
attr_accessor :text, :tar
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@text = Java::JavaxSwing::JTextPane.new
|
8
|
+
@text.font = find_font('Monospaced', Java::JavaAwt::Font::PLAIN, 14, 'Anonymous Pro', 'Anonymous', 'Monaco', 'Andale Mono')
|
9
|
+
@text.margin = Java::JavaAwt::Insets.new(8,8,8,8)
|
10
|
+
@text.caret_color = Java::JavaAwt::Color.new(0xa40000)
|
11
|
+
@text.background = Java::JavaAwt::Color.new(0xf2f2f2)
|
12
|
+
@text.foreground = Java::JavaAwt::Color.new(0xa40000)
|
13
|
+
self.viewport_view = @text
|
14
|
+
@tar = Java::OrgJrubyDemo::TextAreaReadline.new(@text, " Welcome to the Burp JRuby IRB Console [#{JRUBY_VERSION} (#{RUBY_VERSION})]\n\n")
|
15
|
+
JRuby.objectspace = true # useful for code completion
|
16
|
+
@tar.hook_into_runtime_with_streams(JRuby.runtime)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Try to find preferred font family, use otherwise -- err -- otherwise
|
20
|
+
def find_font(otherwise, style, size, *families)
|
21
|
+
avail_families = Java::JavaAwt::GraphicsEnvironment.local_graphics_environment.available_font_family_names
|
22
|
+
fontname = families.find(proc {otherwise}) { |name| avail_families.include? name }
|
23
|
+
Java::JavaAwt::Font.new(fontname, style, size)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'buby/version'
|
2
|
+
|
3
|
+
class BurpExtender
|
4
|
+
# @api private
|
5
|
+
class ConsoleTab
|
6
|
+
include Java::Burp::ITab
|
7
|
+
attr_accessor :ui_component, :tab_caption
|
8
|
+
CAPTION = "Buby v#{Buby::Version::STRING}"
|
9
|
+
|
10
|
+
def initialize component, caption = nil
|
11
|
+
@ui_component = component
|
12
|
+
@tab_caption = caption || CAPTION
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'buby/burp_extender/context_menu_item'
|
2
|
+
|
3
|
+
# @api private
|
4
|
+
class BurpExtender
|
5
|
+
# @api private
|
6
|
+
class ContextMenu < Java::JavaxSwing::JMenu
|
7
|
+
attr_accessor :burp, :invocation
|
8
|
+
def initialize burp_extender, invocation
|
9
|
+
@burp = burp_extender
|
10
|
+
@invocation = invocation
|
11
|
+
super 'Buby'
|
12
|
+
|
13
|
+
if @burp.frame
|
14
|
+
self.add(ContextMenuItem.new('Move console to tab', @burp, @invocation) do |event|
|
15
|
+
burp = event.source.burp
|
16
|
+
invocation = event.source.invocation
|
17
|
+
burp.move_to_tab
|
18
|
+
end)
|
19
|
+
else
|
20
|
+
self.add(ContextMenuItem.new('Move console to window', @burp, @invocation) do |event|
|
21
|
+
burp = event.source.burp
|
22
|
+
invocation = event.source.invocation
|
23
|
+
burp.move_to_window
|
24
|
+
end)
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'buby/burp_extender/context_menu'
|
2
|
+
|
3
|
+
class BurpExtender
|
4
|
+
# @api private
|
5
|
+
class ContextMenuFactory
|
6
|
+
attr_accessor :burp
|
7
|
+
include Java::Burp::IContextMenuFactory
|
8
|
+
def initialize burp_extender
|
9
|
+
@burp = burp_extender
|
10
|
+
end
|
11
|
+
|
12
|
+
def createMenuItems invocation
|
13
|
+
pp [:createMenuItems, invocation] if $DEBUG
|
14
|
+
[BurpExtender::ContextMenu.new(@burp, invocation)]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class BurpExtender
|
2
|
+
# @api private
|
3
|
+
class ContextMenuItem < Java::JavaxSwing::JMenuItem
|
4
|
+
attr_accessor :invocation, :burp
|
5
|
+
def initialize text, burp_extender, invocation, &block
|
6
|
+
super text
|
7
|
+
@invocation = invocation
|
8
|
+
@burp = burp_extender
|
9
|
+
|
10
|
+
addActionListener &block
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class BurpExtender
|
2
|
+
class JCheckBoxMenuItem < Java::JavaxSwing::JCheckBoxMenuItem
|
3
|
+
attr_accessor :burp
|
4
|
+
def initialize(burp_extender, *args, &block)
|
5
|
+
super *args
|
6
|
+
@burp = burp_extender
|
7
|
+
if block_given?
|
8
|
+
addActionListener &block
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
class Buby
|
2
|
+
# This is the JRuby implementation of IBurpExtender for use as a JRuby
|
3
|
+
# extension. This class handles the type conversions and other ruby sugar.
|
4
|
+
# {BurpExtender} further extends this by adding additional things during
|
5
|
+
# startup, like setting up Buby as the handler class and starting console
|
6
|
+
# tabs.
|
7
|
+
#
|
8
|
+
# @note This class, unlike the Java implementation, does not fire the
|
9
|
+
# deprecated evt_* callbacks, only the new versions.
|
10
|
+
#
|
11
|
+
# @todo move implant logic to extender interfaces
|
12
|
+
module Extender
|
13
|
+
include Java::Burp::IBurpExtender
|
14
|
+
include Java::Burp::IExtensionStateListener
|
15
|
+
include Java::Burp::IProxyListener
|
16
|
+
include Java::Burp::IHttpListener
|
17
|
+
include Java::Burp::IScannerListener
|
18
|
+
include Java::Burp::IScopeChangeListener
|
19
|
+
include Java::Burp::IContextMenuFactory
|
20
|
+
|
21
|
+
# @group Buby internals
|
22
|
+
# Internal reference to ruby handler class (usually {Buby})
|
23
|
+
@@handler = nil
|
24
|
+
|
25
|
+
# Returns the internal Ruby handler reference.
|
26
|
+
#
|
27
|
+
# The handler is the ruby class or module used for proxying BurpExtender
|
28
|
+
# events into a ruby runtime. Usually, this is Buby or a subclass.
|
29
|
+
#
|
30
|
+
def self.handler
|
31
|
+
@@handler
|
32
|
+
end
|
33
|
+
|
34
|
+
# Sets an internal reference to the ruby handler class or module to use for
|
35
|
+
# proxied BurpExtender events into a ruby runtime.
|
36
|
+
#
|
37
|
+
# Generally, this should probably be called in {#registerExtenderCallbacks}.
|
38
|
+
# However, it is also possible to set this afterwards and even swap in new
|
39
|
+
# objects during runtime.
|
40
|
+
#
|
41
|
+
def self.handler=(hndlr)
|
42
|
+
@@handler = hndlr
|
43
|
+
end
|
44
|
+
|
45
|
+
def handler
|
46
|
+
@@handler
|
47
|
+
end
|
48
|
+
|
49
|
+
def handler= hndlr
|
50
|
+
@@handler = hndlr
|
51
|
+
end
|
52
|
+
|
53
|
+
# @group Burp extender
|
54
|
+
# This callback usually fires before the handler is set.
|
55
|
+
#
|
56
|
+
def initialize *args
|
57
|
+
@@handler.extender_initialize(*args) if @@handler.respond_to? :extender_inititialize
|
58
|
+
end
|
59
|
+
|
60
|
+
# This method is invoked when the extension is loaded. It registers an
|
61
|
+
# instance of the +IBurpExtenderCallbacks+ interface, providing methods that
|
62
|
+
# may be invoked by the extension to perform various actions.
|
63
|
+
#
|
64
|
+
# @param [IBurpExtenderCallbacks] callbacks Burp's Java object for querying
|
65
|
+
# Burp's data.
|
66
|
+
# @return [void]
|
67
|
+
#
|
68
|
+
def registerExtenderCallbacks(callbacks)
|
69
|
+
@callbacks = callbacks
|
70
|
+
callbacks.issueAlert("[#{self.class}] registering JRuby handler callbacks")
|
71
|
+
callbacks.registerExtensionStateListener(self)
|
72
|
+
callbacks.registerHttpListener(self)
|
73
|
+
callbacks.registerScannerListener(self)
|
74
|
+
callbacks.registerContextMenuFactory self
|
75
|
+
callbacks.registerScopeChangeListener self
|
76
|
+
@@handler.register_callbacks(callbacks) if @@handler.respond_to? :register_callbacks
|
77
|
+
end
|
78
|
+
|
79
|
+
# @group Listeners
|
80
|
+
# This method is called when the extension is unloaded. This, in turn, calls
|
81
|
+
# {Buby#extension_unloaded} on the handler instance
|
82
|
+
#
|
83
|
+
def extensionUnloaded
|
84
|
+
@@handler.extension_unloaded if @@handler.respond_to? :extension_unloaded
|
85
|
+
end
|
86
|
+
|
87
|
+
# This method is invoked when an HTTP message is being processed by the
|
88
|
+
# Proxy and calls {Buby#process_proxy_message} on the handler.
|
89
|
+
#
|
90
|
+
# @param [Boolean] messageIsRequest Indicates whether the HTTP message is a
|
91
|
+
# request or a response.
|
92
|
+
# @param [IInterceptedProxyMessage] message An +IInterceptedProxyMessage+
|
93
|
+
# object that extensions can use to query and update details of the
|
94
|
+
# message, and control whether the message should be intercepted and
|
95
|
+
# displayed to the user for manual review or modification.
|
96
|
+
# @return [void]
|
97
|
+
#
|
98
|
+
def processProxyMessage(messageIsRequest, message)
|
99
|
+
@@handler.process_proxy_message(messageIsRequest, message) if @@handler.respond_to? :process_proxy_message
|
100
|
+
end
|
101
|
+
|
102
|
+
# This method is invoked when an HTTP request is about to be issued, and
|
103
|
+
# when an HTTP response has been received.
|
104
|
+
#
|
105
|
+
# @param [Fixnum] toolFlag A flag indicating the Burp tool that issued the
|
106
|
+
# request. Burp tool flags are defined in the +IBurpExtenderCallbacks+
|
107
|
+
# interface.
|
108
|
+
# @param [Boolean] messageIsRequest Flags whether the method is being
|
109
|
+
# invoked for a request or response.
|
110
|
+
# @param [IHttpRequestResponse] messageInfo Details of the request /
|
111
|
+
# response to be processed. Extensions can call the setter methods on this
|
112
|
+
# object to update the current message and so modify Burp's behavior.
|
113
|
+
# @return [void]
|
114
|
+
#
|
115
|
+
def processHttpMessage(toolFlag, messageIsRequest, messageInfo)
|
116
|
+
@@handler.process_http_message(toolFlag, messageIsRequest, messageInfo) if @@handler.respond_to? :process_http_message
|
117
|
+
end
|
118
|
+
|
119
|
+
# This method is invoked when a new issue is added to Burp Scanner's
|
120
|
+
# results.
|
121
|
+
#
|
122
|
+
# @param [IScanIssue] issue An +IScanIssue+ object that the extension can
|
123
|
+
# query to obtain details about the new issue.
|
124
|
+
#
|
125
|
+
def newScanIssue(issue)
|
126
|
+
@@handler.new_scan_issue(issue) if @@handler.respond_to? :new_scan_issue
|
127
|
+
end
|
128
|
+
|
129
|
+
# This method will be called by Burp when the user invokes a context menu
|
130
|
+
# anywhere within Burp. The factory can then provide any custom context menu
|
131
|
+
# items that should be displayed in the context menu, based on the details
|
132
|
+
# of the menu invocation.
|
133
|
+
#
|
134
|
+
# @param [IContextMenuInvocation] invocation An object the extension can
|
135
|
+
# query to obtain details of the context menu invocation.
|
136
|
+
# @return [Array<JMenuItem>, nil] A list of custom menu items (which may
|
137
|
+
# include sub-menus, checkbox menu items, etc.) that should be displayed.
|
138
|
+
# Extensions may return +nil+ from this method, to indicate that no menu
|
139
|
+
# items are required.
|
140
|
+
#
|
141
|
+
# @abstract
|
142
|
+
def createMenuItems invocation
|
143
|
+
@@handler.create_menu_items(invocation) if @@handler.respond_to? :create_menu_items
|
144
|
+
end
|
145
|
+
|
146
|
+
# This method is invoked whenever a change occurs to Burp's suite-wide
|
147
|
+
# target scope.
|
148
|
+
#
|
149
|
+
# @return [void]
|
150
|
+
#
|
151
|
+
# @abstract
|
152
|
+
def scopeChanged
|
153
|
+
@@handler.scope_changed if @@handler.respond_to? :scope_changed
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -41,13 +41,41 @@ class Buby
|
|
41
41
|
# Context menu is being invoked in a search results window.
|
42
42
|
CONTEXT_SEARCH_RESULTS = 10;
|
43
43
|
|
44
|
+
# This method can be used to retrieve details of the HTTP requests /
|
45
|
+
# responses that were shown or selected by the user when the context menu
|
46
|
+
# was invoked.
|
47
|
+
#
|
48
|
+
# @note For performance reasons, the objects returned from this method are
|
49
|
+
# tied to the originating context of the messages within the Burp UI.
|
50
|
+
# For example, if a context menu is invoked on the Proxy intercept
|
51
|
+
# panel, then the +IHttpRequestResponse+ returned by this method will
|
52
|
+
# reflect the current contents of the interception panel, and this will
|
53
|
+
# change when the current message has been forwarded or dropped. If your
|
54
|
+
# extension needs to store details of the message for which the context
|
55
|
+
# menu has been invoked, then you should query those details from the
|
56
|
+
# +IHttpRequestResponse+ at the time of invocation, or you should use
|
57
|
+
# +IBurpExtenderCallbacks.saveBuffersToTempFiles()+ to create a
|
58
|
+
# persistent read-only copy of the +IHttpRequestResponse+.
|
59
|
+
#
|
60
|
+
# @return [Array<IHttpRequestResponse>,nil] An array of objects
|
61
|
+
# representing the items that were shown or selected by the user when
|
62
|
+
# the context menu was invoked. This method returns +nil+ if no messages
|
63
|
+
# are applicable to the invocation.
|
64
|
+
#
|
44
65
|
def getSelectedMessages
|
45
66
|
pp [:got_get_selected_messages] if $DEBUG
|
46
67
|
hrrl = __getSelectedMessages
|
47
68
|
HttpRequestResponseHelper.implant(hrrl.first)
|
48
69
|
hrrl
|
49
70
|
end
|
50
|
-
|
71
|
+
|
72
|
+
# This method can be used to retrieve details of the Scanner issues that
|
73
|
+
# were selected by the user when the context menu was invoked.
|
74
|
+
#
|
75
|
+
# @return [Array<IScanIssue>,nil] The issues that were selected by the
|
76
|
+
# user when the context menu was invoked. This method returns +nil+ if
|
77
|
+
# no Scanner issues are applicable to the invocation.
|
78
|
+
#
|
51
79
|
def getSelectedIssues
|
52
80
|
pp [:got_get_selected_issues] if $DEBUG
|
53
81
|
sil = __getSelectedIssues
|
@@ -58,7 +86,6 @@ class Buby
|
|
58
86
|
# Install ourselves into the current +IContextMenuInvocation+ java class
|
59
87
|
# @param [IContextMenuInvocation] invocation
|
60
88
|
#
|
61
|
-
# @todo __persistent__?
|
62
89
|
def self.implant(invocation)
|
63
90
|
unless invocation.implanted? || invocation.nil?
|
64
91
|
pp [:implanting, invocation, invocation.class] if $DEBUG
|
data/lib/buby/implants/cookie.rb
CHANGED
@@ -18,7 +18,6 @@ class Buby
|
|
18
18
|
# Install ourselves into the current +ICookie+ java class
|
19
19
|
# @param [ICookie] cookie instance
|
20
20
|
#
|
21
|
-
# @todo __persistent__?
|
22
21
|
def self.implant(cookie)
|
23
22
|
unless cookie.implanted? || cookie.nil?
|
24
23
|
pp [:implanting, cookie, cookie.class] if $DEBUG
|
@@ -245,46 +245,9 @@ class Buby
|
|
245
245
|
Buby::Implants::ScannerInsertionPoint.implant(__makeScannerInsertionPoint(insertion_point_name, base_request, from, to))
|
246
246
|
end
|
247
247
|
|
248
|
-
def self.extend_proxy(arg)
|
249
|
-
pp [self, arg, arg.class]
|
250
|
-
a_methods = %w{
|
251
|
-
analyzeRequest
|
252
|
-
analyzeResponse
|
253
|
-
getRequestParameter
|
254
|
-
indexOf
|
255
|
-
buildHttpMessage
|
256
|
-
buildHttpRequest
|
257
|
-
addParameter
|
258
|
-
removeParameter
|
259
|
-
updateParameter
|
260
|
-
toggleRequestMethod
|
261
|
-
buildHttpService
|
262
|
-
buildParameter
|
263
|
-
makeScannerInsertionPoint
|
264
|
-
}
|
265
|
-
a_methods.each do |meth|
|
266
|
-
pp ["__" + meth, self] if $DEBUG
|
267
|
-
arg.class_exec(meth) do |meth|
|
268
|
-
alias_method "__"+meth.to_s, meth
|
269
|
-
end
|
270
|
-
end
|
271
|
-
a_methods.each do |meth|
|
272
|
-
pp [meth, self] if $DEBUG
|
273
|
-
arg.java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
|
274
|
-
pp [ruby_meth, meth, self] if $DEBUG
|
275
|
-
arg.class_exec(ruby_meth, meth, instance_method(meth)) do |ruby_meth, meth_name, meth|
|
276
|
-
define_method meth_name, meth
|
277
|
-
# alias_method ruby_meth, "__"+meth unless ruby_meth == meth
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
include Buby::Implants::Proxy
|
282
|
-
end
|
283
|
-
|
284
248
|
# Install ourselves into the current +IExtensionHelpers+ java class
|
285
249
|
# @param [IExtensionHelpers] helpers
|
286
250
|
#
|
287
|
-
# @todo __persistent__?
|
288
251
|
def self.implant(helpers)
|
289
252
|
unless helpers.implanted? || helpers.nil?
|
290
253
|
pp [:implanting, helpers, helpers.class] if $DEBUG
|