Module: Buby::Implants::ContextMenuInvocation

Defined in:
lib/buby/implants/context_menu_invocation.rb

Overview

This interface is used when Burp calls into an extension-provided IContextMenuFactory with details of a context menu invocation. The custom context menu factory can query this interface to obtain details of the invocation event, in order to determine what menu items should be displayed. This module is used to extend the JRuby proxy class returned by Burp.

Constant Summary collapse

CONTEXT_MESSAGE_EDITOR_REQUEST =

Context menu is being invoked in a request editor.

0
CONTEXT_MESSAGE_EDITOR_RESPONSE =

Context menu is being invoked in a response editor.

1
CONTEXT_MESSAGE_VIEWER_REQUEST =

Context menu is being invoked in a non-editable request viewer.

2
CONTEXT_MESSAGE_VIEWER_RESPONSE =

Context menu is being invoked in a non-editable response viewer.

3
CONTEXT_TARGET_SITE_MAP_TREE =

Context menu is being invoked in the Target site map tree.

4
CONTEXT_TARGET_SITE_MAP_TABLE =

Context menu is being invoked in the Target site map table.

5
CONTEXT_PROXY_HISTORY =

Context menu is being invoked in the Proxy history.

6
CONTEXT_SCANNER_RESULTS =

Context menu is being invoked in the Scanner results.

7
CONTEXT_INTRUDER_PAYLOAD_POSITIONS =

Context menu is being invoked in the Intruder payload positions editor.

8
CONTEXT_INTRUDER_ATTACK_RESULTS =

Context menu is being invoked in an Intruder attack results.

9
CONTEXT_SEARCH_RESULTS =

Context menu is being invoked in a search results window.

10
CONTEXTS =
{
  CONTEXT_MESSAGE_EDITOR_REQUEST             => "message_editor_request",
  CONTEXT_MESSAGE_EDITOR_RESPONSE    => "message_editor_response",
  CONTEXT_MESSAGE_VIEWER_REQUEST     => "message_viewer_request",
  CONTEXT_MESSAGE_VIEWER_RESPONSE    => "message_viewer_response",
  CONTEXT_TARGET_SITE_MAP_TREE       => "target_site_map_tree",
  CONTEXT_TARGET_SITE_MAP_TABLE      => "target_site_map_table",
  CONTEXT_PROXY_HISTORY              => "proxy_history",
  CONTEXT_SCANNER_RESULTS            => "scanner_results",
  CONTEXT_INTRUDER_PAYLOAD_POSITIONS => "intruder_payload_positions",
  CONTEXT_INTRUDER_ATTACK_RESULTS    => "intruder_attack_results",
  CONTEXT_SEARCH_RESULTS             => "search_results"
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implant(invocation) ⇒ Object

Install ourselves into the current IContextMenuInvocation java class

Parameters:

  • invocation (IContextMenuInvocation)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/buby/implants/context_menu_invocation.rb', line 113

def self.implant(invocation)
  unless invocation.implanted? || invocation.nil?
    pp [:implanting, invocation, invocation.class] if $DEBUG
    invocation.class.class_exec(invocation) do |invocation|
      a_methods = %w{
        getSelectedMessages
        getSelectedIssues
      }
      a_methods.each do |meth|
        alias_method "__"+meth.to_s, meth
      end
      include Buby::Implants::ContextMenuInvocation
      a_methods.each do |meth|
        java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
          define_method ruby_meth, Buby::Implants::ContextMenuInvocation.instance_method(meth)
        end
      end
      include Buby::Implants::Proxy
    end
  end
  invocation
end

Instance Method Details

#context_nameString

This method can be used to retrieve the context within which the menu was invoked.

Returns:

  • (String)

    Context name



106
107
108
# File 'lib/buby/implants/context_menu_invocation.rb', line 106

def context_name
  CONTEXTS[getInvocationContext]
end

#getSelectedIssuesScanIssuesList?

This method can be used to retrieve details of the Scanner issues that were selected by the user when the context menu was invoked.

Returns:

  • (ScanIssuesList, nil)

    The issues that were selected by the user when the context menu was invoked. This method returns nil if no Scanner issues are applicable to the invocation.



92
93
94
95
# File 'lib/buby/implants/context_menu_invocation.rb', line 92

def getSelectedIssues
  pp [:got_get_selected_issues] if $DEBUG
  ScanIssuesList.new(__getSelectedIssues)
end

#getSelectedMessagesHttpRequestResponseList?

Note:

For performance reasons, the objects returned from this method are tied to the originating context of the messages within the Burp UI. For example, if a context menu is invoked on the Proxy intercept panel, then the IHttpRequestResponse returned by this method will reflect the current contents of the interception panel, and this will change when the current message has been forwarded or dropped. If your extension needs to store details of the message for which the context menu has been invoked, then you should query those details from the IHttpRequestResponse at the time of invocation, or you should use IBurpExtenderCallbacks.saveBuffersToTempFiles() to create a persistent read-only copy of the IHttpRequestResponse.

This method can be used to retrieve details of the HTTP requests / responses that were shown or selected by the user when the context menu was invoked.

Returns:

  • (HttpRequestResponseList, nil)

    An array of objects representing the items that were shown or selected by the user when the context menu was invoked. This method returns nil if no messages are applicable to the invocation.



80
81
82
83
# File 'lib/buby/implants/context_menu_invocation.rb', line 80

def getSelectedMessages
  pp [:got_get_selected_messages] if $DEBUG
  HttpRequestResponseList.new(__getSelectedMessages)
end

#tool_nameString

Get the name of the tool invoking a context menu

Returns:

  • (String)

    Tool name



99
100
101
# File 'lib/buby/implants/context_menu_invocation.rb', line 99

def tool_name
  $burp.getToolName getToolFlag
end