How to specify the process in python pwntools? - python

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?

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.

Related

Where can I find WidgetRedirector in with Python3?

I was using a tkform(https://github.com/boscoh/tkform) with Python2 and it was working perfectly.
After switching to Python3, Im unable to run it, specifically the part:
from idlelib.WidgetRedirector import WidgetRedirector
It seems that WidgetRedirecor.py not even in the library (idellib) anymore...
Traceback (most recent call last):
File "/Users/igor/opt/cymorph3/runCyMorphGUI.py", line 7, in <module>
import tkform
File "gui/tkform.py", line 22, in <module>
from idlelib import WidgetRedirector
ImportError: cannot import name 'WidgetRedirector' from 'idlelib' (/Users/igor/opt/anaconda3/envs/cyMorph3/lib/python3.9/idlelib/__init__.py)
Can I fix it somehow?
Use:
from idlelib.redirector import WidgetRedirector

I need help using ctypes on jython

I want to use libxmp.
I used:
import sys
sys.path.append('/usr/local/lib/python3.8/dist-packages')
which directly locate to libxmp
from libxmp import XMPFiles, consts
from libxmp.utils import file_to_dict
upper code box is the import part
I faced this problem:
Traceback (most recent call last):
File "/home/webprime/jython/jython/jython.py", line 5, in <module>
from libxmp import XMPFiles, consts
File "/usr/local/lib/python3.8/dist-packages/libxmp/__init__.py", line 37, in <module>
from ctypes import util
ImportError: cannot import name util
it works on Python 3.

I am not able to use re module, my interpreter showing me error

My code is:
import re
s="An apple in a day."
print(re.search("in",s))
Error:
C:\Users\DELL\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/DELL/AppData/Local/Programs/Python/Python38-32/Lib/encodings/re.py
Traceback (most recent call last):
File "C:/Users/DELL/AppData/Local/Programs/Python/Python38-32/Lib/encodings/re.py", line 1, in <module>
import re
File "C:\Users\DELL\AppData\Local\Programs\Python\Python38-32\Lib\encodings\re.py", line 3, in <module>
re.search("is",s)
AttributeError: partially initialized module 're' has no attribute 'search' (most likely due to a circular import)
Process finished with exit code 1
You name your file re.py so python confused which one to use when you call import re: your file or regexp library.
Try to rename your file to something else and not to choose other library names.

Unbable to import function

I have tried following
when I tried to import the class from the file named plyparser.py of pycparser(https://github.com/eliben/pycparser/blob/master/pycparser/plyparser.py)
using the following statement
from pycparser.plyparser import Coord
But, I am unable to import function parameterized from plyparser of pycparser using the following statement
from pycparser.plyparser import parameterized
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name parameterized
How to resolve this issue.

How to solve ImportError: cannot import name 'ProcessPoolExecutor'

I'm getting this error when trying to using polyglot library for the first time.
from polyglot.text import Text, Word
word = Text("Preprocessing is an essential step.").words[0]
print(word.morphemes)
here is the full error message.
Traceback (most recent call last):
File "/home/adeesha/PycharmProjects/theme_recomend/plyglot.py", line 2, in <module>
from polyglot.text import Text, Word
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/__init__.py", line 12, in <module>
from .base import Sequence, TokenSequence
File "/usr/local/lib/python3.5/dist-packages/polyglot-16.7.4-py3.5.egg/polyglot/base.py", line 9, in <module>
from concurrent.futures import ProcessPoolExecutor, as_completed
ImportError: cannot import name 'ProcessPoolExecutor'
the version of Python 3.5.2
how I gonna solve this problem?

Categories