Module: Buby::Implants::MessageEditor

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

Overview

This interface is used to provide extensions with an instance of Burp’s HTTP message editor, for the extension to use in its own UI. Extensions should call Buby#createMessageEditor to obtain an instance of this interface.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implant(editor) ⇒ Object

Install ourselves into the current IMessageEditor java class

Parameters:

  • editor (IMessageEditor)


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/buby/implants/message_editor.rb', line 44

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

Instance Method Details

#getMessageString

This method is used to retrieve the currently displayed message, which may have been modified by the user.

Returns:

  • (String)

    The currently displayed HTTP message.



27
28
29
# File 'lib/buby/implants/message_editor.rb', line 27

def getMessage
  String.from_java_bytes __getMessage
end

#getSelectedDataString?

This method returns the data that is currently selected by the user.

Returns:

  • (String, nil)

    The data that is currently selected by the user, or nil if no selection is made.



36
37
38
39
# File 'lib/buby/implants/message_editor.rb', line 36

def getSelectedData
  ret = __getSelectedData
  ret ? String.from_java_bytes(ret) : ret
end

#setMessage(message, isRequest) ⇒ void

This method returns an undefined value.

This method is used to display an HTTP message in the editor.

Parameters:

  • message (Array<byte>, String)

    The HTTP message to be displayed.

  • isRequest (Boolean)

    Flags whether the message is an HTTP request or response.



16
17
18
19
20
# File 'lib/buby/implants/message_editor.rb', line 16

def setMessage(message, isRequest)
  message = message.to_java_bytes if message.respond_to? :to_java_bytes
  message = message.to_java :byte if message.kind_of? Array
  __setMessage(message, isRequest)
end