-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfunction_strings.py
More file actions
74 lines (51 loc) · 1.93 KB
/
function_strings.py
File metadata and controls
74 lines (51 loc) · 1.93 KB
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
import idaapi
import idc
import sark
def show_function_strings(function):
idaapi.msg("\n\nString References in {}:0x{:08X}\n".format(function.name, function.startEA))
idaapi.msg("From To String\n")
for xref in function.xrefs_from:
if xref.type.is_code:
continue
string_type = idc.GetStringType(xref.to)
if string_type is None:
continue
string = idc.GetString(xref.to, strtype=string_type)
if not string:
continue
# Trim the string for easier display
string = string[:100]
idaapi.msg("0x{:08X} 0x{:08X} {}\n".format(xref.frm, xref.to, repr(string)))
def show_current_function_strings():
try:
function = sark.Function(idc.here())
show_function_strings(function)
except sark.exceptions.SarkNoFunction:
idaapi.msg("[FunctionStrings] No function at 0x{:08X}.\n".format(idc.here()))
def show_highlighted_function_strings():
identifier = idaapi.get_highlighted_identifier()
if not identifier:
return
try:
function = sark.Function(name=identifier)
show_function_strings(function)
except sark.exceptions.SarkNoFunction:
idaapi.msg("[FunctionStrings] {!r} is not a function.\n".format(identifier))
class FunctionStrings(idaapi.plugin_t):
flags = 0
comment = "Show Function Strings"
help = "Show all strings references by the function."
wanted_name = "FunctionStrings"
wanted_hotkey = ""
def init(self):
self.hotkeys = []
self.hotkeys.append(idaapi.add_hotkey("Alt+9", show_current_function_strings))
self.hotkeys.append(idaapi.add_hotkey("Ctrl+Alt+9", show_highlighted_function_strings))
return idaapi.PLUGIN_KEEP
def term(self):
for hotkey in self.hotkeys:
idaapi.del_hotkey(hotkey)
def run(self, arg):
pass
def PLUGIN_ENTRY():
return FunctionStrings()