Skip to content

Commit ac8d118

Browse files
committed
First commit
0 parents  commit ac8d118

File tree

7 files changed

+716
-0
lines changed

7 files changed

+716
-0
lines changed

HexForge.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import idaapi
2+
import inspect
3+
4+
from hexforge_modules import crypto, encoding, misc
5+
6+
7+
CRYPTO_MODULE_PATH = "HexForge/crypto/"
8+
ENCODING_MODULE_PATH = "HexForge/encoding/"
9+
MISC_MODULE_PATH = "HexForge/misc/"
10+
11+
g_crypto_modules = [cls() for _, cls in inspect.getmembers(crypto, inspect.isclass)]
12+
g_encoding_modules = [cls() for _, cls in inspect.getmembers(encoding, inspect.isclass)]
13+
g_misc_modules = [cls() for _, cls in inspect.getmembers(misc, inspect.isclass)]
14+
15+
16+
class hexforge_plugin_t(idaapi.plugin_t):
17+
flags = idaapi.PLUGIN_KEEP
18+
comment = ""
19+
help = ""
20+
wanted_name = "HexForge"
21+
22+
def init(self):
23+
idaapi.msg("init() called!\n")
24+
self._init_actions()
25+
self._init_hooks()
26+
return idaapi.PLUGIN_KEEP
27+
28+
def run(self, arg):
29+
idaapi.msg("run() called with %d!\n" % arg)
30+
31+
def term(self):
32+
self._del_action()
33+
idaapi.msg("term() called!\n")
34+
35+
# --------------------------------------------------------------------------
36+
# Initializations
37+
# --------------------------------------------------------------------------
38+
39+
def _init_actions(self) -> None:
40+
for module in g_crypto_modules + g_encoding_modules + g_misc_modules:
41+
module.init_action()
42+
43+
def _del_action(self) -> None:
44+
for module in g_crypto_modules + g_encoding_modules + g_misc_modules:
45+
module.del_action()
46+
47+
# --------------------------------------------------------------------------
48+
# Initialize Hooks
49+
# --------------------------------------------------------------------------
50+
51+
def _init_hooks(self) -> None:
52+
"""
53+
Install plugin hooks into IDA.
54+
"""
55+
self._hooks = Hooks()
56+
self._hooks.hook()
57+
58+
59+
# Plugin Hooks
60+
61+
62+
class Hooks(idaapi.UI_Hooks):
63+
def finish_populating_widget_popup(self, widget, popup):
64+
"""
65+
A right click menu is about to be shown. (IDA 7)
66+
"""
67+
inject_actions(widget, popup, idaapi.get_widget_type(widget))
68+
return 0
69+
70+
71+
# Prefix Wrappers
72+
73+
74+
def inject_actions(form, popup, form_type) -> int:
75+
"""
76+
Inject actions to popup menu(s) based on context.
77+
"""
78+
79+
if (form_type == idaapi.BWN_DISASMS) or (form_type == idaapi.BWN_DUMP):
80+
for module in g_crypto_modules:
81+
idaapi.attach_action_to_popup(
82+
form,
83+
popup,
84+
module.ACTION_NAME,
85+
CRYPTO_MODULE_PATH,
86+
idaapi.SETMENU_APP,
87+
)
88+
89+
for module in g_misc_modules:
90+
idaapi.attach_action_to_popup(
91+
form,
92+
popup,
93+
module.ACTION_NAME,
94+
MISC_MODULE_PATH,
95+
idaapi.SETMENU_APP,
96+
)
97+
98+
for module in g_encoding_modules:
99+
idaapi.attach_action_to_popup(
100+
form,
101+
popup,
102+
module.ACTION_NAME,
103+
ENCODING_MODULE_PATH,
104+
idaapi.SETMENU_APP,
105+
)
106+
107+
return 0
108+
109+
110+
# Register IDA plugin
111+
def PLUGIN_ENTRY() -> hexforge_plugin_t:
112+
return hexforge_plugin_t()
113+
114+
115+
PLUGIN_ENTRY()

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## HexForge IDA plugin
2+
This IDA plugin extends the functionality of the assembly and hex view. With this plugin, you can conveniently decode/decrypt/alter data directly from the IDA Pro interface. The following actions include:
3+
- Copying raw hex from IDA's disassembly or hex view
4+
- Patching or nopping bytes from memory or statically
5+
- Quickly use popular crypto/encoding algorithms for decryption
6+
- AES
7+
- ChaCha20
8+
- RC4
9+
- XOR
10+
- Base64
11+
12+
13+
## How to use
14+
Select the data in IDA hex view or disassembly view and right click to get the menu
15+
16+
![image](https://github.com/user-attachments/assets/fb597d92-a12e-4755-b305-506197724014)
17+
18+
19+
### How to add a module
20+
This section will help you understand how to add new modules to the `hexforge_modules` package. By following these steps, you can create custom modules that integrate seamlessly with the Hexforge framework.
21+
22+
- Start by creating a new Python class inside the hexforge_modules package. This class will represent your module. The class should be named appropriately to reflect its purpose.
23+
- Your class must inherit from the `helper.ModuleTemplate` class.
24+
- The `_action` method is where you define the main logic of your module. This could be encryption, decryption, compression, or any other action your module is designed to perform.
25+
- If your module requires user input, you should create a GUI interface using the InputFormT class. This form will be presented to the user when your module is invoked.
26+
27+
You can follow the example provided below for XOR decryption:
28+
29+
https://github.com/elastic/HexForge/blob/984c40d24a8a2fa3ccb52264961bdeb679e0ff69/hexforge_modules/crypto.py#L202

0 commit comments

Comments
 (0)