forked from OpenRCE/paimei
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pida_dump.py
81 lines (64 loc) · 2.72 KB
/
pida_dump.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
80
81
#
# IDA Python PIDA Database Generation Script
# Dumps the current IDB into a .PIDA file.
#
# Copyright (C) 2006 Pedram Amini <[email protected]>
#
# $Id: pida_dump.py 194 2007-04-05 15:31:53Z cameron $
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
'''
@author: Pedram Amini
@license: GNU General Public License 2.0 or later
@contact: [email protected]
@organization: www.openrce.org
'''
import time
import pida
depth = None
analysis = pida.ANALYSIS_NONE
while not depth:
depth = AskStr("full", "Depth to analyze? (full, functions|func, basic blocks|bb)")
if depth:
depth = depth.lower()
if depth in ["full"]: depth = pida.DEPTH_FULL
elif depth in ["functions", "func"]: depth = pida.DEPTH_FUNCTIONS
elif depth in ["basic blocks", "bb"]: depth = pida.DEPTH_BASIC_BLOCKS
else:
Warning("Unsupported depth: %s\n\nValid options include:\n\t- full\n\t- functions\n\t- basic blocks" % depth)
depth = None
choice = AskYN(1, "Propogate nodes and edges for API calls (imports)?")
if choice == 1:
analysis |= pida.ANALYSIS_IMPORTS
choice = AskYN(1, "Enumerate RPC interfaces and dispatch routines?")
if choice == 1:
analysis |= pida.ANALYSIS_RPC
output_file = AskFile(1, GetInputFile() + ".pida", "Save PIDA file to?")
if not output_file:
Warning("Cancelled.")
else:
print "Analyzing IDB..."
start = time.time()
try:
signature = pida.signature(GetInputFilePath())
except:
print "PIDA.DUMP> Could not calculate signature for %s, perhaps the file was moved?" % GetInputFilePath()
signature = ""
module = pida.module(GetInputFile(), signature, depth, analysis)
print "Done. Completed in %f seconds.\n" % round(time.time() - start, 3)
print "Saving to file...",
start = time.time()
pida.dump(output_file, module, progress_bar="ascii")
print "Done. Completed in %f seconds." % round(time.time() - start, 3)
# clean up memory.
# XXX - this is not working...
del(module)