Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
70 lines (58 loc) · 2.09 KB

File metadata and controls

70 lines (58 loc) · 2.09 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/usr/bin/env python3
"""
Extract scripts embedded within IDA Pro databases.
author: Willi Ballenthin
email: willi.ballenthin@gmail.com
"""
import argparse
import logging
import sys
import idb
import idb.netnode
logger = logging.getLogger(__name__)
def main(argv=None):
if argv is None:
argv = sys.argv[1:]
parser = argparse.ArgumentParser(
description="Extract scripts embedded within IDA Pro databases."
)
parser.add_argument("idbpath", type=str, help="Path to input idb file")
parser.add_argument(
"-v", "--verbose", action="store_true", help="Enable debug logging"
)
parser.add_argument(
"-q", "--quiet", action="store_true", help="Disable all output but errors"
)
args = parser.parse_args(args=argv)
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
logging.getLogger().setLevel(logging.DEBUG)
elif args.quiet:
logging.basicConfig(level=logging.ERROR)
logging.getLogger().setLevel(logging.ERROR)
else:
logging.basicConfig(level=logging.INFO)
logging.getLogger().setLevel(logging.INFO)
with idb.from_file(args.idbpath) as db:
try:
for script in idb.analysis.enumerate_script_snippets(db):
logger.debug("script: %s", script.name)
logger.debug("language: %s", script.language)
logger.debug("code: \n%s", script.code)
if script.language == "Python":
ext = ".py"
elif script.language == "IDC":
ext = ".idc"
else:
raise ValueError("unexpected script language: " + script.language)
filename = script.name + ext
logger.info(
"writing %s script %s to %s", script.language, script.name, filename
)
with open(filename, "wb") as f:
f.write(script.code.encode("utf-8"))
except KeyError:
logger.warning("not found script snippets")
return 0
if __name__ == "__main__":
sys.exit(main())
Morty Proxy This is a proxified and sanitized view of the page, visit original site.