forked from al3xtjames/ida-efitools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
efitools.py
61 lines (45 loc) · 1.77 KB
/
efitools.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
import sys
import os
import time
import core
import tools
import idc
reload(core)
reload(tools)
from core.objects import *
from core.project import *
print "Ready to rock!"
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
load_til(os.path.join(BASE_DIR, "behemoth.til"))
start_time = time.time()
# Turn any known GUIDs found into GUID structures
print "Updating GUIDs..."
tools.update_guids(os.path.join(BASE_DIR, "guids-db.ini"))
# At one point had EFI_SYSTEM_TABLE structure created outside the argument in
# an attempt to fix some error; not sure if that was actually needed.
print "Performing initial structure updates starting at entry point..."
tools.update_structs_from_regs(idc.GetEntryOrdinal(
0), rdx=Structure("EFI_SYSTEM_TABLE"))
print "Updating structures from xrefs..."
tools.update_structs_from_xrefs()
print "Searching for EFI protocols..."
tools.update_protocols()
print "Updating structures from xrefs..."
tools.update_structs_from_xrefs()
print "Searching for EFI protocols..."
tools.update_protocols()
print "Updating structures from lvars..."
for protocol in filter(lambda x: x.interface is not None, protocols):
if isinstance(protocol.interface.storage, StructureMember):
start = protocol.introduced_at
lvar = protocol.interface.storage
struc = protocol.struc
print "Working on %s %s at 0x%X" % (struc, lvar, start)
tools.update_struct_from_lvar(start, lvar, struc)
for protocol in protocols:
print protocol.name
print " GUID : %s" % protocol.guid.as_uuid()
print " Interface : %s" % protocol.interface
print " Introduced at : 0x%X" % protocol.introduced_at
print " Class : %s" % str(protocol.__class__).split(".")[-1]
print "Finished in %f seconds" % (time.time() - start_time)