Rich5 / pyhashcat

Python bindings for hashcat
56 stars 37 forks source link

simple_mask.py --> ImportError: ... libhashcat.so #27

Closed friluk closed 5 years ago

friluk commented 6 years ago

Hi, when I wanted to tryout pyhashcat for the first time after the installation, i got this error message:

$ python simple_mask.py Traceback (most recent call last): File "simple_mask.py", line 6, in <module> from pyhashcat import Hashcat ImportError: dlopen(/Library/Python/2.7/site-packages/pyhashcat.so, 2): Library not loaded: libhashcat.so Referenced from: /Library/Python/2.7/site-packages/pyhashcat.so Reason: unsafe use of relative rpath libhashcat.so in /Library/Python/2.7/site-packages/pyhashcat.so with restricted binary

Can someone give me hint how to solve this?

Rich5 commented 6 years ago

What OS are you using? pyhashcat has only really been tested on Ubuntu and Debian. From a little searching this error seems to come up a lot on OSX.

friluk commented 6 years ago

Yes you are right, I'm working with Mac Os High Sierra 10.13.2. Do you have an idea how to solve this problem? I read something about that relative paths aren't allowed under Mac Os and that a symbolic link from the library (which couldn't be loaded) to the "/usr/local/lib/" directory would solve the problem, but I don't know where the library is located and so I couldn't solve the problem until now.

friluk commented 6 years ago

I tried to make an symbolic link from /usr/local/lib/libhashcat.so to /usr/lib/libhashcat.so, this was at first declined, because of the SIP protection of Mac Os. After I deactivated the SIP protection, I could create the symbolic link. With the symbolic link I don't get an error when I start the simple_mask.py, the output is the following:

$ python simple_mask.py 
-------------------------------
---- Simple pyhashcat Test ----
-------------------------------
[!] Hashcat object init with id:  4512606808
[!] cb_id cracked:  1001
[!] cb_id finished:  1002
[!] cb_id any:  1003
[+] Writing to  /Users/****/outfile.txt
[+] Running hashcat
ANY- 4512606808 Initializing
STATUS:  Initializing 

There still seem to be errors, do you have an idea?

Rich5 commented 6 years ago

It appears to have loaded correctly from what I can tell. I don't see any errors in the output you posted either. Did you let the script run a little while? It might take a some time to crack the test hash. I don't have a Mac to test this on so it's hard to troubleshoot. I'll see if I can get access to one next week some time and try it out

friluk commented 6 years ago

Sorry I made an mistake. It worked because of the deactivated SIP protection. After I activated it again, the error message is back.

Rich5 commented 6 years ago

Since SIP seems to be the problem you can try installing libhashcat in a non-protected location and then build the extension with that path instead.

friluk commented 6 years ago

cool thank you I will try that

friluk commented 6 years ago

I'm sorry, I'm clearly a noob :D , but do I have to just copy the libhashcat file to another location and after that edit the paths accordingly or do I have to completely rebuild / compile hashcat and pyhashcat?

Rich5 commented 6 years ago

You will definitely have to rebuild pyhashcat. I think you can just move libhashcat though. Not 100% but try moving it and then rebuilding the python extension with the new path.