GithubHelp home page GithubHelp logo

pyhashcat's People

Contributors

hops avatar jauler avatar rich5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyhashcat's Issues

Port to Python 3

Once the Python 2 bindings are finished need to port to Python 3. This is a placeholder issue.

Benchmark

How is it possible to benchmark using pyHashcat?
I tried with:

from pyhashcat import Hashcat
from time import sleep

hc = Hashcat()
hc.benchmark = True
hc.hash_mode = 0
hc.hashcat_session_execute()
sleep(5)

except that I got

$ python benchmark.py 
Traceback (most recent call last):
  File "benchmark.py", line 8, in <module>
    sleep(5)
RuntimeError: Hash source not set

Build without root

Hello,
How can I build it without root permissions?
Even compiling hashcat and installing libhashcat in HOME, and installing pyhashcat with --user flag, I've got a RuntimeError: /usr/local/share/hashcat/OpenCL/: No such file or directory when running python test.py

Add event_disconnect feature

User defined callbacks can be connected to events from libhashcat, but can not be removed. Need a event_disconnect function that removes the pointer from the array and realigns the entries.

test.py SystemError

Running test.py with hc.benchmark = False results in error output below.
Running with hc.benchmark = True never exits. Stuck with several lines of incoming seqnr wraps around. Full output below.

Thanks.

pyhashcat version: VERSION: 2.0b2

$ python --version
Python 2.7.12
$ python ./test.py 
-------------------------------
---- Simple pyhashcat Test ----
-------------------------------
[!] Hashcat object init with id:  140282505598432
[!] cb_id cracked:  1001
[!] cb_id finished:  1002
[!] cb_id benchmark_status:  1003
[+] Running hashcat
140282505598432 EVENT_CRACKER_HASH_CRACKED
140282505598432 EVENT_CRACKER_FINISHED
HashType:  MD5
Device  0 :	4958708.71482
Device  1 :	4737036.60512
Device  2 :	5293956.73817
Device  3 :	4849355.66241
Traceback (most recent call last):
  File "./test.py", line 74, in <module>
    sleep(2)
SystemError: ../Python/getargs.c:1444: bad argument to internal function
$ python ./test.py 
-------------------------------
---- Simple pyhashcat Test ----
-------------------------------
[!] Hashcat object init with id:  139913512453600
[!] cb_id cracked:  1001
[!] cb_id finished:  1002
[!] cb_id benchmark_status:  1003
[!] Starting Benchmark Mode
[+] Running hashcat
 EVENT_CRACKER_FINISHED
HashType:  MD4
:evice  46791844.931
1 :ice  46414015.0428
46772277.6694	-
Device  3 :	45973634.76
139913512453600 EVENT_CRACKER_FINISHED
HashType:  MD5
Device  0 :	25868310.3016
Device  1 :	25510858.3593
Device  2 :	25720091.9822
Device  3 :	25299277.6898

<...snip...>

139913512453600 EVENT_CRACKER_FINISHED
HashType:  JKS Java Key Store Private Keys (SHA1)
Device  0 :	8209537.46407
Device  1 :	8139933.04546
Device  2 :	8213657.10369
Device  3 :	8077036.32381
EVENT_CRACKER_FINISHED
HashType:  Ethereum Wallet, PBKDF2-HMAC-SHA256
0 :ice  4.76240316915
Device  1 :	4.73325260293
 :vice  4.77918779341
Device  3 :	4.6979248746
-39913512453600 EVENT_CRACKER_FINISHED/
HashType:  ArubaOS
Device  0 :	6951549.02733
1 :ice  6865637.87776
Device  2 :	6919010.22765
Device  3 :	6796247.26566
139913512453600 EVENT_CRACKER_FINISHED
HashType:  ChaCha20
Device  0 :	4643312.29935
Device  1 :	4630241.20991
Device  2 :	4662345.1764
Device  3 :	4549198.33512
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
incoming seqnr wraps around
^CTraceback (most recent call last):
  File "./test.py", line 70, in <module>
    sys.stdout.flush()
KeyboardInterrupt


SystemError: Python/getargs.c:1461: bad argument to internal function

(Possible dup of #23, but I decided to open a new bug report because of other discussions in that one).
I get really weird errors when trying to use this module. My best guess is that some value that shouldn't be modified is overwritten in the interpreter.

$ python2 -c "import sys; print(sys.version)"
2.7.14 (default, Sep 20 2017, 01:25:59)
[GCC 7.2.0]

$ ./benchmark.py
Using default hash
(140114650899832, 'EVENT_CRACKER_FINISHED')
(140114650899832, 'EVENT_CRACKER_FINISHED')
(140114650899832, 'EVENT_CRACKER_FINISHED')
(140114650899832, 'EVENT_CRACKER_HASH_CRACKED')
Traceback (most recent call last):
File "./benchmark.py", line 76, in
for line in f.readlines():
SystemError: Python/getargs.c:1461: bad argument to internal function

benchmark.py can be found here: https://pastebin.com/raw/4nDqm9de
The odd thing is, whenever I modify the file (change the printing of the results, switch the Lock to a sleep(30), etc.), the error "happens" somewhere else.

Also, sometimes I get a segfault after the error, which might be related.

[1] 13861 segmentation fault (core dumped) ./benchmark.py

IndexError when no plains to report

if len(fields) == 0 and len(results) > 0 or len(fields) != len(results[0])

If no plains exist, therefore len(results) == 0, then len(results[0]) can still be executed because the length of results is unchecked on the right side of the or statement.

Fixed:
if len(fields) == 0 and len(results) > 0 or len(results) > 0 and len(fields) != len(results[0])

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

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?

get_hashes gobbles all whitespace at the end of cracked plains

Offending line: results = [record.rstrip().rsplit(sep) for record in output_file.readlines()]
The rstrip() removes the spaces at the end of plains.

e.g.: "test" is different than "test " but, when cracked, both are returned as "test"

Suggested fix:
results = [record.rstrip('\n').rsplit(sep) for record in output_file.readlines()]

Would just do it and make a pull request but due to mitigating circumstances, this was easier.
Thanks.

Create test cases for hashcat API calls

We need a comprehensive list of tests to make sure all the features of hashcat have been implemented in into pyhashcat bindings.

  • Test all attack modes
  • Test outputs

test.py RuntimeError

i tried to use your test.py but this error occurred, I dont what is wrong about sleep(5)

-------------------------------
---- Simple pyhashcat Test ----
-------------------------------
[!] Hashcat object init with id:  140440595707256
[!] cb_id cracked:  1001
[!] cb_id finished:  1002
[!] cb_id benchmark_status:  1003
[+] Running hashcat
STATUS:  Initializing
Traceback (most recent call last):
  File "test.py", line 93, in <module>
    sleep(5)
RuntimeError

Rules not implemented?

when I set "hc.rules" it has no affect. Printing out "hc.status_get_guess_mod" returns None and the guess mode never progesses past "1". Any ideas? Thank you.

Interested in taking over repo

Hi Rich,

First, thanks for all the work you've put in over the years for this project. I really appreciate it.

Second, I have ported the C bindings to the latest version hashcat version (v5.1) and have built it successfully. All seems to be working good.

If you are still looking for maintainers, I am interested. I am currently writing a distributed cracking API and will be actively using this project as a core part of the agent code that will be accepting commands from the UI.

Again, great work and thank you for your awesome work!

Parsing output and then pushing input

I'm trying to get the output, check when the gpu temperature is a certain level, and then send a pause command to oclhashcat. As far as I can tell this doesn't really help for input right?

Clear or reset function

Need a function to reset the variables to defaults. Something like

hc.clear()
or
hc.reset()

OS X Issues

Hey Rich,

Out of curiosity, what platform are you using? I've been trying to get this to work on OS X but running into issues running the test.py script.

-------------------------------
---- Simple pyhashcat Test ----
-------------------------------
[+] Running hashcat
STATUS:  Initializing
Traceback (most recent call last):
  File "test.py", line 68, in <module>
    sleep(5)
RuntimeError: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/OpenCL/: m

It looks like there is some automagical path calculation when looking for the kernels/OpenCL files where it's using the executable path instead of /usr/local/share/hashcat in https://github.com/Rich5/pyHashcat/blob/master/pyhashcat/pyhashcat.c#L546 (which does exist locally). This doesn't seem to be an issue on Linux though.

Add hashcat events

hashcat now uses an eventing system to notify of state changes. These events need to be incorporated into pyhashcat. A list of events can be found here: https://github.com/hashcat/hashcat/blob/1f266fb0f2ecfb4e1b94494f8f9b70acd020faf9/include/types.h#L82

One event has been implemented internally to trigger on a cracked hash here as an example https://github.com/Rich5/pyHashcat/blob/bindings/pyhashcat/pyhashcat.c#L61

Developers should be able to subscribe to any event and write their own callbacks as necessary. Maybe something like this

def show_cracked(hc):
	print hc.status_get_status_string()
	# print out cracked hashes


hc = hashcat()
hc.dispatcher_connect(show_cracked, signal=hc.events['EVENT_CRACKER_HASH_CRACKED'])
...

Interpreter not available when libhashcat is running (Threading)

When libhashcat is executing the Python interpreter is locked up until the function returns. We need a solution for this issue. One option is to start a new thread in the extension code, and the other is to try and use Python's builtin threading library to call the function. Either way I think we'll need to make sure we're not allowing users to corrupt shared memory.

I'm open to any design suggestions.

Add shebangs to the python files

Can we have the shebangs at the start of the python files so we can just run the python files in the one true way rather than have to supply the interpreter.

(i.e. add:
#!/usr/bin/env python
At the start of all python files)

build errors

Firstly i want to felicitate you, Good Game. I have some problems in the installation of your tool.
when i want to build the pyhashcat i have the errors messages :

I have the Ubuntu 18.04 OS.

running build_ext
building 'pyhashcat' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-3hk45v/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Ihashcat/include -Ihashcat/deps/OpenCL-Headers -Ihashcat/OpenCL -Ihashcat -I/usr/include/python2.7 -c pyhashcat.c -o build/temp.linux-x86_64-2.7/pyhashcat.o -std=c99
pyhashcat.c: In function ‘hashcat_event_connect’:
pyhashcat.c:136:14: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
   int _hid = NULL;
              ^~~~
pyhashcat.c: In function ‘hashcat_getgpu_temp_abort’:
pyhashcat.c:2461:50: error: ‘user_options_t {aka struct user_options}’ has no member named ‘gpu_temp_abort’; did you mean ‘hwmon_temp_abort’?
   return Py_BuildValue ("i", self->user_options->gpu_temp_abort);
                                                  ^~~~~~~~~~~~~~
                                                  hwmon_temp_abort
pyhashcat.c: In function ‘hashcat_setgpu_temp_abort’:
pyhashcat.c:2484:23: error: ‘user_options_t {aka struct user_options}’ has no member named ‘gpu_temp_abort’; did you mean ‘hwmon_temp_abort’?
   self->user_options->gpu_temp_abort = PyInt_AsLong (value);
                       ^~~~~~~~~~~~~~
                       hwmon_temp_abort
pyhashcat.c: In function ‘hashcat_getgpu_temp_disable’:
pyhashcat.c:2497:47: error: ‘user_options_t {aka struct user_options}’ has no member named ‘gpu_temp_disable’; did you mean ‘self_test_disable’?
   return PyBool_FromLong (self->user_options->gpu_temp_disable);
                                               ^~~~~~~~~~~~~~~~
                                               self_test_disable
pyhashcat.c: In function ‘hashcat_setgpu_temp_disable’:
pyhashcat.c:2523:25: error: ‘user_options_t {aka struct user_options}’ has no member named ‘gpu_temp_disable’; did you mean ‘self_test_disable’?
     self->user_options->gpu_temp_disable = 1;
                         ^~~~~~~~~~~~~~~~
                         self_test_disable
pyhashcat.c:2530:25: error: ‘user_options_t {aka struct user_options}’ has no member named ‘gpu_temp_disable’; did you mean ‘self_test_disable’?
     self->user_options->gpu_temp_disable = 0;
                         ^~~~~~~~~~~~~~~~
                         self_test_disable
pyhashcat.c: In function ‘hashcat_getmarkov_hcstat’:
pyhashcat.c:3420:27: error: ‘user_options_t {aka struct user_options}’ has no member named ‘markov_hcstat’; did you mean ‘markov_hcstat2’?
   if (self->user_options->markov_hcstat == NULL)
                           ^~~~~~~~~~~~~
                           markov_hcstat2
pyhashcat.c:3426:50: error: ‘user_options_t {aka struct user_options}’ has no member named ‘markov_hcstat’; did you mean ‘markov_hcstat2’?
   return Py_BuildValue ("s", self->user_options->markov_hcstat);
                                                  ^~~~~~~~~~~~~
                                                  markov_hcstat2
pyhashcat.c: In function ‘hashcat_setmarkov_hcstat’:
pyhashcat.c:3449:23: error: ‘user_options_t {aka struct user_options}’ has no member named ‘markov_hcstat’; did you mean ‘markov_hcstat2’?
   self->user_options->markov_hcstat = PyString_AsString (value);
                       ^~~~~~~~~~~~~
                       markov_hcstat2
pyhashcat.c: In function ‘hashcat_getnvidia_spin_damp’:
pyhashcat.c:3498:50: error: ‘user_options_t {aka struct user_options}’ has no member named ‘nvidia_spin_damp’; did you mean ‘spin_damp’?
   return Py_BuildValue ("i", self->user_options->nvidia_spin_damp);
                                                  ^~~~~~~~~~~~~~~~
                                                  spin_damp
pyhashcat.c: In function ‘hashcat_setnvidia_spin_damp’:
pyhashcat.c:3521:23: error: ‘user_options_t {aka struct user_options}’ has no member named ‘nvidia_spin_damp’; did you mean ‘spin_damp’?
   self->user_options->nvidia_spin_damp = PyInt_AsLong (value);
                       ^~~~~~~~~~~~~~~~
                       spin_damp
pyhashcat.c: In function ‘hashcat_getnvidia_spin_damp’:
pyhashcat.c:3500:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
pyhashcat.c: In function ‘hashcat_getmarkov_hcstat’:
pyhashcat.c:3428:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
pyhashcat.c: In function ‘hashcat_getgpu_temp_disable’:
pyhashcat.c:2499:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
pyhashcat.c: In function ‘hashcat_getgpu_temp_abort’:
pyhashcat.c:2463:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Add docstrings

Place holder docstrings have been used in the pyhashcat.c code. These strings need to be replaced with useful information. This will allow the extension to be self documenting.

Ref: https://www.python.org/dev/peps/pep-0257/

A common method for C extensions is to declare static variables above the function and then include the variable in the method array

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.