-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathamd64.py
43 lines (31 loc) · 829 Bytes
/
amd64.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
import unicorn
import capstone
import utils
bits = 64
regs = [
"rax", "rcx", "rdx", "rbx",
"rsp", "rbp", "rsi", "rdi",
"r8" , "r9" , "r10", "r11",
"r12", "r13", "r14", "r15",
"rip"
]
unicorn_arch = unicorn.UC_ARCH_X86
unicorn_mode = unicorn.UC_MODE_64
capstone_arch = capstone.CS_ARCH_X86
capstone_mode = capstone.CS_MODE_64
unicorn_regs = {}
capstone_regs = {}
for reg in regs:
unicorn_regs[reg] = getattr(unicorn.x86_const, "UC_X86_REG_" + reg.upper())
capstone_regs[reg] = getattr(capstone.x86_const, "X86_REG_" + reg.upper())
instruction_pointer = "rip"
stack_pointer = "rsp"
ip = instruction_pointer
sp = stack_pointer
address_mask = 0x0000007fffffffff
page_mask = 0x0000007ffffff000
page_size = 0x1000
return_instructions = ["\xc3"]
alignment = 1
pack = utils.p64
unpack = utils.u64