Closed dmiller423 closed 2 years ago
Hi, Ropper only shows that message if z3 cannot be imported. Are the z3 python bindings installed? Can you import z3 in the python console?
looks like I tried to install the z3 module and it failed, and then built z3 and installed and failed to install python module again... thx
Even with it built and modules installed, it blows up when using semantics
`` [ERROR] Please report this error on https://github.com/sashs/ropper [ERROR] Traceback (most recent call last): File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/semantic.py", line 66, in analyse irsb = pyvex.IRSB(bytes(gadget.bytes), gadget.address+thumb, gadget.arch.info, bytes_offset=thumb, num_bytes=len(gadget.bytes), opt_level=0) NameError: name 'pyvex' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/console.py", line 62, in cmd func(self, text) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/console.py", line 1079, in do_semantic self.__rs.analyseGadgets(self.currentFile) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/service.py", line 612, in analyseGadgets g.info = analyser.analyse(g) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/semantic.py", line 73, in analyse except pyvex.PyVEXError as e: NameError: name 'pyvex' is not defined ``
Did you install pyvex as pointed out in the README as necessary dependendy for semantic search?
yes
Could you please check if it is installed correctly?
The error message says NameError: name 'pyvex' is not defined
which should be only the case if it could not be imported.
Python 3.10.7 (main, Sep 8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvex
>>>
Still the same error? Which command do you use to start ropper?
something like
./Ropper.py --file ../x86_kernel_4.03.bin.elf --semantic "r13 = r14"
It worked one time when i reinstalled the z3 python module, and then i changed the registers and it just started throwing exceptions
This shows I am using the same python interpreter, and that pyvex is not only installed that calling it does work (left out args so it blows up on purpose / simply testing it is indeed available)
null@rygar:/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel$ python3 ropper/Ropper.py --file ./x86_kernel_4.03.bin.elf --semantic "r13 = r14" [INFO] Load gadgets from cache [LOAD] loading... 100% [LOAD] removing double gadgets... 100% [ERROR] Please report this error on https://github.com/sashs/ropper [ERROR] Traceback (most recent call last): File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/semantic.py", line 66, in analyse irsb = pyvex.IRSB(bytes(gadget.bytes), gadget.address+thumb, gadget.arch.info, bytes_offset=thumb, num_bytes=len(gadget.bytes), opt_level=0) NameError: name 'pyvex' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/console.py", line 62, in cmd func(self, text) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/console.py", line 1079, in do_semantic self.__rs.analyseGadgets(self.currentFile) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/service.py", line 612, in analyseGadgets g.info = analyser.analyse(g) File "/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel/ropper/ropper/semantic.py", line 73, in analyse except pyvex.PyVEXError as e: NameError: name 'pyvex' is not defined
null@rygar:/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel$ python3
Python 3.10.7 (main, Sep 8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvex
>>> pyvex.IRSB()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: IRSB.__init__() missing 3 required positional arguments: 'data', 'mem_addr', and 'arch'
>>>
I still think that this is an issue of your environment, because of the name error which says that pyvex is not known.
Could you please execute in your bash
/usr/bin/env python
and there try to import pyvex.
Afterwards you could try to execute ropper with your python interpreter
python Ropper.py
I've just created a docker container, and installed everything (ropper, pyvex, z3) and it works fine.
I can import pyvex fine when I do that, but both the git version and the version imported via pip both give the same exception that pyvex is not defined. /shrug
Can you import
import z3
import pyvex
import archinfo
null@rygar:/media/null/TEMP/_RE/FS_dumps/4.03_x86_kernel$ /usr/bin/env python
Python 3.10.7 (main, Sep 8 2022, 14:34:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import z3
>>> import pyvex
>>> import archinfo
>>>
Still same behaviour if you use this python Ropper.py
Which OS do you use?
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.10
Release: 22.10
Codename: kinetic
Have you tried it with python Ropper.py
?
Sorry for the inconvenience, but I need to find out what the issue is. I tried it in gentoo and in a docker container with ubuntu 22.04.1 and everything works fine.
I will try it tomorrow on ubuntu 22.10.
https://github.com/sashs/Ropper/issues/164#issuecomment-1298887445
^ using same python for both, and using python-is-python3
I tried it with a fresh docker container with ubuntu 22.10 installed I installed
apt install python-is-python3 z3 python3-pip python3-z3
pip install pyvex
pip install ropper
Afterwards I tried
ropper -f /bin/ls --semantic "rax==rbx"
works without issues.
I assume there is something wrong with your environment
Any update?
I don't have time to debug the problem further, so I've just written it off as a non-functional feature. I tested every possible scenario I can think of and I couldn't tell you why it somehow doesn't see a package that's clearly installed and can be imported and used without trouble. There are no alternate environments except one made in pycharm and z3 / pyvex work in that venv as they do at global scope. Git repo and the version installed via pip both do the exact same thing / there is no difference that could be explained away by local conflict in one. I simply don't have any answers for you, but I'm sure the issue will come back up again at some point: they always do.
Ok. Nevertheless, many thanks for your support. Since I cannot reproduce the issue, even on the same operating system and python version, I will close this issue.
@dmiller423, If you encounter such an error, it's possible that you installed the 'z3' package instead of 'z3-solver', as both packages exist in Python with similar names. To resolve this, check your installed packages using 'pip list'. If 'z3' is installed but not 'z3-solver', first uninstall 'z3' with 'pip uninstall z3', and then install 'z3-solver' using 'pip install z3-solver'.
Z3 was successfully installed. ; [ERROR] z3 has to be installed in order to use semantic search