-
Notifications
You must be signed in to change notification settings - Fork 85
/
heap_viewer.py
executable file
·79 lines (64 loc) · 2.32 KB
/
heap_viewer.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
# coding: utf-8
#
# HeapViewer - by @danigargu
#
import os
import sys
import idaapi
from heap_viewer import PLUGNAME, plugin_gui
from heap_viewer.misc import is_process_suspended, log
# -----------------------------------------------------------------------
class HeapViewPlugin(idaapi.plugin_t):
flags = 0
comment = ""
help = ""
wanted_name = PLUGNAME
wanted_hotkey = "Ctrl-H"
def init(self):
self.icon_id = 0
self.add_menus()
return idaapi.PLUGIN_KEEP
def run(self, arg=0):
try:
if "ELF" not in idaapi.get_file_type_name():
raise Exception("Executable must be ELF fomat")
if not idaapi.is_debugger_on() or not is_process_suspended():
raise Exception("The debugger must be active and suspended before using this plugin")
f = plugin_gui.HeapPluginForm()
f.Show()
except Exception as e:
idaapi.warning("[%s] %s" % (PLUGNAME, str(e)))
def add_menus(self):
# To avoid creating multiple plugin_t instances
this = self
class StartHandler(idaapi.action_handler_t):
def __init__(self):
idaapi.action_handler_t.__init__(self)
def activate(self, ctx):
this.run()
return 1
def update(self, ctx):
return idaapi.AST_ENABLE_ALWAYS
act_name = '%s:start' % PLUGNAME
act_desc = idaapi.action_desc_t(
act_name, # The action name. Must be unique
PLUGNAME, # Action Text
StartHandler(), # Action handler
None, # Optional shortcut
'Start plugin', # Action tooltip
122 # Icon
)
idaapi.register_action(act_desc)
idaapi.attach_action_to_menu(
'Debugger/Debugger windows/',
act_name,
idaapi.SETMENU_APP
)
def term(self):
idaapi.msg("[%s] terminated" % (PLUGNAME))
# -----------------------------------------------------------------------
def PLUGIN_ENTRY():
return HeapViewPlugin()
# -----------------------------------------------------------------------
log("Plugin loaded")