I am practicing Buffer Overflow exploits, and I am following this website. My code looks like this:
# Run the program, waits until it sees ':' (end of prompt), send our format strings, then prints
# the output. The last line ensures that we don't kill the process
#!/usr/bin/env python
from pwn import *
io = process('./00')
print(io.recvregex(b':')) # read untill we get the prompt
io.sendline(b'%p,%p,%p')
io.recvline()
print(io.recvline())
io.sendline(cyclic(50)) # pwntools cyclic generates a 50 char pattern to send as input
io.wait()
core = io.corefile # pwntools pulls core dump to extract needed values
stack = core.rsp
info('rsp = %#x', stack)
pattern = core.read(stack, 4)
rip_offset = cyclic_find(pattern)
info('rip offset is %d', rip_offsett)
io.interactive() # interactive() lets us communicate with the program through keyboard
Unfortunatley, I am unable to run it. This is the output I get:
m@m-VirtualBox:~/Documents$ ./pwn.py
from: can't read /var/mail/pwn
./pwn.py: line 7: syntax error near unexpected token `('
./pwn.py: line 7: `io = process('./00')'
I have tried looking at this question for answers, but adding more quotation marks did not solve it, neither did adding the line #!/usr/bin/env python
at the top of the .py-file (like they suggested here and here) How do I fix this?