-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcontext_menu_pure.rb
65 lines (52 loc) · 2.26 KB
/
context_menu_pure.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
# KING SABRI | @KINGSABRI
# BurpSuite Extension | Pure context menu implementation
#
# Ruby requires
require 'java'
# Java imports
java_import javax.swing.JMenu # Right-click Section menu
java_import javax.swing.JMenuItem # Right-click Regular menu
# Burp Suite API imports
java_import 'burp.IBurpExtender'
java_import 'burp.IBurpExtenderCallbacks'
java_import 'burp.IContextMenuFactory'
#
# BurpExtender, the main Extender API ِِclass to register all extensions and interfaces
#
class BurpExtender
include IBurpExtender
include IContextMenuFactory
attr_reader :callbacks
# IBurpExtender::registerExtenderCallbacks(IBurpExtenderCallbacks callbacks);
def registerExtenderCallbacks(callbacks)
@callbacks = callbacks
@helper = callbacks.getHelpers
@context = nil
@callbacks.setExtensionName('Right-click Menu') # Set Extension name
@callbacks.registerContextMenuFactory(self) # register a factory for custom context menu items.
end
# createMenuItems(IContextMenuInvocation invocation)
# This method will be called by Burp when the user invokes a context menu anywhere within Burp.
#
# @param invocation
# An object that implements the IMessageEditorTabFactory interface,
#
# @return Array
def createMenuItems(invocation)
menu_list = [] # Array of menus datastore
menuItem = JMenuItem.new('<html><b>Ruby | Menu</b></html>') # Create a regular menuitem
menuItem.addActionListener { puts 'An action has been performed' } # addActionLinstener takes a block of actions
# Create Section menu (contains sub-menus)
sectionsMenu = JMenu.new('<html><b>Ruby | Menu with sub-menus (Sections Menu)</b></html>')
menuItem1 = JMenuItem.new('Sub-menuItem 1') # Create a regular menuitem
menuItem1.addActionListener { puts 'Yup, menuItem 1 clicked!' } # Add an action
sectionsMenu.add(menuItem1) # Add it to it's parent, the section menu
menuItem2 = JMenuItem.new('Sub-menuItem 2')
menuItem2.addActionListener { puts 'Yup, menuItem 2 clicked!' }
sectionsMenu.add(menuItem2)
# All menus has to be added to the array
menu_list << menuItem
menu_list << sectionsMenu
end
end