-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic.py
More file actions
25 lines (22 loc) · 828 Bytes
/
Copy patharithmetic.py
File metadata and controls
25 lines (22 loc) · 828 Bytes
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
from pwn import *
context.log_level = "error" #get rid of annoying connect disconnect prints
add_code = b"\x00\x00\x11\x42"
crashing_code = b"\x00\x00\x11\x74"
def attempt(shellcode):
with remote("localhost", 5000) as r:
r.recvuntil(b"(0 to use the builtin): ")
r.sendline(f"{len(shellcode)}".encode())
r.recvuntil(b"bytes of shellcode: ")
r.send(shellcode)
return r.clean(timeout=0.5)
def add(dst, r1,r2):
add_val = 0x40000000 #decoded and masked value that means 32-bit add
#or registers into instruction
add_val |= dst
add_val |= r1 << 0x10
add_val |= r2 << 0x15
return p32(add_val) #encode
if __name__ == "__main__":
add_val = add(21,22,23) #add: a5=t8+t9
sc = add_val + crashing_code # modified addition + crash
print(attempt(sc).decode())