-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy-strings.py
executable file
·66 lines (51 loc) · 1.98 KB
/
copy-strings.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
import ida_kernwin
from PyQt5.Qt import QApplication
class copy_only_string(ida_kernwin.action_handler_t):
ACTION_NAME = "copy only string"
ACTION_LABEL = "Copy only string(s)"
ACTION_SHORTCUT = "Ctrl+C"
def __init__(self):
ida_kernwin.action_handler_t.__init__(self)
def activate(self, ctx):
data = []
for idx in ctx.chooser_selection:
_, _, _, s = ida_kernwin.get_chooser_data(ctx.widget_title, idx)
data.append(s)
QApplication.clipboard().setText(", ".join(data))
return 0
def update(self, ctx):
if ctx.widget_type == ida_kernwin.BWN_STRINGS:
return ida_kernwin.AST_ENABLE_FOR_WIDGET
return ida_kernwin.AST_DISABLE_FOR_WIDGET
class print_string(ida_kernwin.action_handler_t):
ACTION_NAME = "print_string"
ACTION_LABEL = "Print string(s)"
ACTION_SHORTCUT = "Ctrl+P"
def __init__(self):
ida_kernwin.action_handler_t.__init__(self)
def activate(self, ctx):
for idx in ctx.chooser_selection:
addr, _, _, s = ida_kernwin.get_chooser_data(ctx.widget_title, idx)
print("%s: '%s'" % (addr, s))
return 0
def update(self, ctx):
if ctx.widget_type == ida_kernwin.BWN_STRINGS:
return ida_kernwin.AST_ENABLE_FOR_WIDGET
return ida_kernwin.AST_DISABLE_FOR_WIDGET
klasses = [copy_only_string, print_string]
sw = ida_kernwin.find_widget("Strings window")
if not sw:
sw = ida_kernwin.open_strings_window(ida_idaapi.BADADDR)
for klass in klasses:
ida_kernwin.unregister_action(klass.ACTION_NAME)
if ida_kernwin.register_action(
ida_kernwin.action_desc_t(
klass.ACTION_NAME, klass.ACTION_LABEL, klass(), klass.ACTION_SHORTCUT
)
):
if sw:
ida_kernwin.attach_action_to_popup(sw, None, klass.ACTION_NAME)
print(
"Permanently added '%s' action to 'String window's popup"
% klass.ACTION_LABEL
)