pythonimporterrornameerrorpwntools

How to specify the process in python pwntools?


Cant set the process in Python 2.7.17 pwntools.

Source code:

from pwn import *
s=process('/root/Dokumente/Scripts/example_program')

I tried from pwn import *:

root@bitpc:~# python pwn.py 
Traceback (most recent call last):
  File "pwn.py", line 1, in <module>
    from pwn import *
  File "/root/pwn.py", line 2, in <module>
    s=process('/root/Dokumente/Scripts/example_program')
NameError: name 'process' is not defined

That was not working. Then i imported process directly:

root@bitpc:~# python pwn.py 
Traceback (most recent call last):
  File "pwn.py", line 1, in <module>
    from pwn import process
  File "/root/pwn.py", line 1, in <module>
    from pwn import process
ImportError: cannot import name process

I got an import error. How to fix this?


Solution

  • It seems that your exploit script's name is pwn.py. rename it to some other name such as exp.py. otherwise python will try to import things in your pwn.py instead of importing things from pwntools.