title: inject code onto command line input using python27
body: <p>I have written a simple c program with a bufferoveflow. It is basically a game to guess 4 digits number but starts by asking players to enter their name and this is where buffer overflow happens...I have written an exploit to basically inject shellcode when the &quot;Please enter your name&quot; When I run it without program attached to the immunity debugger it works fine but when I attach the exe file to the immunity debugger python script does noting as it is not something that is running on the debugger.....so basically nothing happens when I execute the code. Python code is below:</p>
  <p>import sys, struct, os
  import subprocess
  import time
  from subprocess import Popen, PIPE</p>
  <p>location ='C:\Users\ZEIT8042\Desktop\Guessthenumber\guess.exe</p>
  <p>p= Popen([location],stdin=PIPE,stdout=PIPE,stderr=PIPE)
  time.sleep(15) #tried this to make the program stall for 15 seconds so that it can be attached to immunity debugger.
  junk='A'*40
  o,e= p.communicate(input=junk)
  print(o)</p>
  <p>What I am trying to do is  check if the program is running...if it is running then inject the shellcode when the exe asks for the name.....any help would be appreciated...</p>