JPaulMora/Pyrit

undefined symbol: aesni_key

akumagiri opened this issue · 19 comments

followed all instructions. after install I get this...
pyrit -h
Traceback (most recent call last):
File "/usr/local/bin/pyrit", line 4, in
import pyrit_cli
File "/usr/local/lib/python2.7/dist-packages/pyrit_cli.py", line 32, in
import cpyrit.cpyrit
File "/usr/local/lib/python2.7/dist-packages/cpyrit/cpyrit.py", line 42, in
import util
File "/usr/local/lib/python2.7/dist-packages/cpyrit/util.py", line 54, in
import _cpyrit_cpu
ImportError: /usr/local/lib/python2.7/dist-packages/cpyrit/_cpyrit_cpu.so: undefined symbol: aesni_key

i was able to get around this problem with one small preprocessor definition change. this is related to a C compiler intrinsic function that does AES, but i'm assuming people like me who ended up getting this error are more interested in cuda/opencl anyway, so let's get rid of these CPU intrinsics.
edit Pyrit/cpyrit/cpufeatures.h and comment out the line "#define COMPILE_AESNI". then run the clean, build, and install on pyrit's setup.py and on the opencl or cuda module you want in the modules folder. assuming you did the configuration to enable it, the GPU acceleration should now work.

The same trouble, line commenting did not help.

I have same trouble...

Been trying to figure out a fix for this too, and finally got it working (maybe), @nicholas-long had the right idea, but perhaps meant to provide more info on editing.

To get it working on my end I had to completely disable the AESNI functions. Following Nicolas' instructions by commenting out the "define COMPILE_AESNI", or the whole block/lines in cpufeatures.h (Not completely sure if this is required), and heading over to "Pyrit/cpyrit/_cpyrit_cpu.c" and commenting out lines 1080 - 1142, or where COMPILE_AESNI starts to its end.

P.S: This is on a fresh install, and assuming it's breaking when you barely even run pyrit. I was able to at minimum start a benchmark after this so hopefully it'll fix it for anyone else too while we wait for Pyrit(2)? to update to Py3 :)

Estuve tratando de encontrar una solución para esto también, y finalmente lo hice funcionar (tal vez), @ nicholas-long tuvo la idea correcta, pero tal vez pretendía brindar más información sobre la edición.

Para que funcione, tuve que desactivar completamente las funciones de AESNI. Siguiendo las instrucciones de Nicolas comentando "define COMPILE_AESNI", o todo el bloque / líneas en cpufeatures.h (No estoy completamente seguro de si esto es necesario), y dirigiéndose a "Pyrit / cpyrit / _cpyrit_cpu.c" y comentando las líneas 1080-1142, o donde COMPILE_AESNI comienza hasta el final.

PD: Esto es una instalación nueva, y asumiendo que se está rompiendo cuando apenas ejecutas pyrit. Pude, como mínimo, iniciar un punto de referencia después de esto, así que espero que lo solucione para cualquier otra persona también mientras esperamos Pyrit (2). para actualizar a Py3 :)

Muchas gracias por el dato, acabó de resolver el problema :)

this is still an issue as of today

yep

voje commented

Got the same issue trying to install on Ubuntu Focal. Switching to Debian resolved the issue.

Working Dockerfile:

FROM debian:stable

RUN apt-get update

RUN apt-get install -y git vim curl

RUN apt-get install -y python2
RUN ln -s /usr/bin/python2 /usr/bin/python

WORKDIR /opt/pip2
RUN curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py
RUN python2 ./get-pip.py
RUN pip install \
    psycopg2-binary \
    scapy==2.3.2

RUN apt-get install -y \
        gcc \
        python2-dev \
        libssl-dev \
        zlib1g-dev \
        libpcap-dev

WORKDIR /root/git/
RUN git clone https://github.com/JPaulMora/Pyrit.git

WORKDIR /root/git/Pyrit
RUN git checkout f0f1913c645b445dd391fb047b812b5ba511782c
RUN ./setup.py clean
RUN ./setup.py build
RUN ./setup.py install

RUN pyrit -h

I have same trouble.

Traceback (most recent call last):
File "/usr/local/bin/pyrit", line 4, in
import pyrit_cli
File "/usr/local/lib/python2.7/dist-packages/pyrit_cli.py", line 32, in
import cpyrit.cpyrit
File "/usr/local/lib/python2.7/dist-packages/cpyrit/cpyrit.py", line 42, in
import util
File "/usr/local/lib/python2.7/dist-packages/cpyrit/util.py", line 54, in
import _cpyrit_cpu
ImportError: /usr/local/lib/python2.7/dist-packages/cpyrit/_cpyrit_cpu.so: undefined symbol: aesni_key

I was able to work around this by fudging the code as suggested by @RootSrc. I made a script that will install it on Kali Rolling, but if you're on a different distro, the specific command to fudge the code before building is

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

I was able to work around this by fudging the code as suggested by @RootSrc. I made a script that will install it on Kali Rolling, but if you're on a different distro, the specific command to fudge the code before building is

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

Only posted 4 hours ago and just in time for when I needed it. THIS is the fix.

Wow just adding an X to that line really did it. lol

I was able to work around this by fudging the code as suggested by @RootSrc. I made a script that will install it on Kali Rolling, but if you're on a different distro, the specific command to fudge the code before building is

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

This worked

Hello, I tried all the methods but it still does not work, the last one I tried is this:

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

it compiles it and installs it but when I execute any command this happens:──(root💀kali)-[/home/tuvi/Pyrit]
└─# pyrit --help
Traceback (most recent call last):
File "/usr/local/bin/pyrit", line 6, in
pyrit_cli.Pyrit_CLI().initFromArgv()
File "/usr/local/lib/python2.7/dist-packages/pyrit_cli.py", line 62, in initFromArgv
('all-handshakes', 'aes'))
File "/usr/lib/python2.7/getopt.py", line 88, in getopt
opts, args = do_longs(opts, args[0][2:], longopts, args[1:])
File "/usr/lib/python2.7/getopt.py", line 152, in do_longs
has_arg, opt = long_has_args(opt, longopts)
File "/usr/lib/python2.7/getopt.py", line 169, in long_has_args
raise GetoptError('option --%s not recognized' % opt, opt)
getopt.GetoptError: option --help not recognized

someone who can help me?

I was able to work around this by fudging the code as suggested by @RootSrc. I made a script that will install it on Kali Rolling, but if you're on a different distro, the specific command to fudge the code before building is

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

@Grezzo Your script worked beautifully for Parrot also. Thank you

It's work. Thks

Having this issue in June 2022 on Linux Mint 20. Going to try solutions mentioned in this thread.

Hello, I tried all the methods but it still does not work, the last one I tried is this:

sed -i "s/COMPILE_AESNI/COMPILE_AESNIX/" Pyrit/cpyrit/_cpyrit_cpu.c

it compiles it and installs it but when I execute any command this happens:
──(rootskullkali)-[/home/tuvi/Pyrit] └─# pyrit --help Traceback (most recent call last): File "/usr/local/bin/pyrit", line 6, in pyrit_cli.Pyrit_CLI().initFromArgv() File "/usr/local/lib/python2.7/dist-packages/pyrit_cli.py", line 62, in initFromArgv ('all-handshakes', 'aes')) File "/usr/lib/python2.7/getopt.py", line 88, in getopt opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) File "/usr/lib/python2.7/getopt.py", line 152, in do_longs has_arg, opt = long_has_args(opt, longopts) File "/usr/lib/python2.7/getopt.py", line 169, in long_has_args raise GetoptError('option --%s not recognized' % opt, opt) getopt.GetoptError: option --help not recognized

someone who can help me?

I'm having the same exact issue compiling Pyrit. I'll try to see what's going on.

Julian and everyone else who was getting that getopt error, I figured out how to fix it.
Instead of running pyrit --help, try running pyrit help. You're good.