-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.py
32 lines (24 loc) · 938 Bytes
/
example.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
import sys
from vtil import Vtil
from utils import to_string
def main():
vtil = Vtil.from_file(sys.argv[1])
entrypoint = vtil.entrypoint.entry_vip
print(f"===> Entrypoint: {entrypoint}")
for basic_block in vtil.explored_blocks.basic_blocks:
vip = basic_block.entry_vip
instructions = basic_block.instructions
print(f"\n===> Block VIP: {vip}")
for instruction in instructions:
code = ""
code += instruction.name + " "
for operand in instruction.operands:
operand = operand.operand
if isinstance(operand, Vtil.RegisterDesc):
code += to_string(operand.flags, operand.bit_offset, operand.bit_count, operand.combined_id)
code += " "
else:
code += hex(operand.imm) + " "
print(code)
if __name__ == "__main__":
main()