From ee5bce1c3ec02c6f2ac148ec138d36356c49cc3d Mon Sep 17 00:00:00 2001 From: philsmd Date: Wed, 26 Aug 2020 12:14:26 +0200 Subject: [PATCH 1/4] fixes #2518: call clear_prompt () more often to avoid misaligned prompt --- docs/changes.txt | 1 + src/backend.c | 3 +++ src/main.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index a72ff0505..2119efbea 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -18,6 +18,7 @@ - Fixed internal access on module option attribute OPTS_TYPE_SUGGEST_KG with the result that it was unused - Fixed race condition resulting in out of memory error on startup if multiple hashcat instances are started at the same time - Fixed unexpected non-unique salts in multi-hash cracking in Bitcoin/Litecoin wallet.dat module which lead to false negatives +- Fixed rare case of misalignment of the status prompt when other user warnings are shown within the hashcat output ## ## Improvements diff --git a/src/backend.c b/src/backend.c index 894eb8746..63b040040 100644 --- a/src/backend.c +++ b/src/backend.c @@ -23,6 +23,7 @@ #include "event.h" #include "dynloader.h" #include "backend.h" +#include "terminal.h" #if defined (__linux__) static const char *dri_card0_path = "/dev/dri/card0"; @@ -6890,6 +6891,8 @@ void backend_ctx_devices_update_power (hashcat_ctx_t *hashcat_ctx) { if (user_options->quiet == false) { + clear_prompt (hashcat_ctx); + event_log_advice (hashcat_ctx, "The wordlist or mask that you are using is too small."); event_log_advice (hashcat_ctx, "This means that hashcat cannot use the full parallel power of your device(s)."); event_log_advice (hashcat_ctx, "Unless you supply more work, your cracking speed will drop."); diff --git a/src/main.c b/src/main.c index 48cf59e27..83300493d 100644 --- a/src/main.c +++ b/src/main.c @@ -239,6 +239,8 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB { event_log_info_nn (hashcat_ctx, NULL); + clear_prompt (hashcat_ctx); + send_prompt (hashcat_ctx); } } From 6587606ba40a19f0d459a7fc5ce21b14e0fe0826 Mon Sep 17 00:00:00 2001 From: philsmd Date: Wed, 26 Aug 2020 12:24:23 +0200 Subject: [PATCH 2/4] unit tests: fix packaging (-p) of tests --- docs/changes.txt | 1 + tools/test.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index d0c494452..7cfc6860e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -32,6 +32,7 @@ - Hash-Mode 13200 (AxCrypt): Changed the name to AxCrypt 1 to avoid confusion - Hash-Mode 13300 (AxCrypt in-memory SHA1): Changed the name to AxCrypt 1 in-memory SHA1 +- Unit tests: Fixed the packaging of test (-p) feature * changes v6.1.0 -> v6.1.1 diff --git a/tools/test.sh b/tools/test.sh index e64e6685c..ef3d2dd55 100755 --- a/tools/test.sh +++ b/tools/test.sh @@ -3346,6 +3346,6 @@ if [ "${PACKAGE}" -eq 1 ]; then -e "s/^\(ATTACK\)=0/\1=${ATTACK}/" \ "${OUTD}/test.sh" - "${PACKAGE_CMD}" "${OUTD}/${OUTD}.7z" "${OUTD}/" >/dev/null 2>/dev/null + ${PACKAGE_CMD} "${OUTD}/${OUTD}.7z" "${OUTD}/" >/dev/null 2>/dev/null fi From 8e6949e00d5a7f85db68071b2645ccfb90efa389 Mon Sep 17 00:00:00 2001 From: philsmd Date: Wed, 26 Aug 2020 12:41:25 +0200 Subject: [PATCH 3/4] minor: update list of perl modules for unit tests --- tools/install_modules.sh | 1 + tools/test_modules/m22911.pm | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/install_modules.sh b/tools/install_modules.sh index b8c578a3f..ace67de1e 100755 --- a/tools/install_modules.sh +++ b/tools/install_modules.sh @@ -18,6 +18,7 @@ cpan install Authen::Passphrase::LANManager \ Convert::EBCDIC \ Crypt::CBC \ Crypt::DES \ + Crypt::DES_EDE3 \ Crypt::Digest::RIPEMD160 \ Crypt::Digest::Whirlpool \ Crypt::ECB \ diff --git a/tools/test_modules/m22911.pm b/tools/test_modules/m22911.pm index 3bb086300..fd4b0b18c 100644 --- a/tools/test_modules/m22911.pm +++ b/tools/test_modules/m22911.pm @@ -9,6 +9,7 @@ use strict; use warnings; use Crypt::CBC; +use Crypt::DES_EDE3; use Digest::MD5 qw (md5); sub module_constraints { [[0, 256], [16, 16], [-1, -1], [-1, -1], [-1, -1]] } From 698d0fbbda6a3d390bf34ec6f7a9bcd8a8862c5b Mon Sep 17 00:00:00 2001 From: philsmd Date: Wed, 26 Aug 2020 12:49:54 +0200 Subject: [PATCH 4/4] tests: added Python 3 support and make it default --- docs/changes.txt | 1 + tools/install_modules.sh | 10 +++++----- tools/test_modules/m11700.pm | 5 ++--- tools/test_modules/m11750.pm | 4 ++-- tools/test_modules/m11760.pm | 4 ++-- tools/test_modules/m11800.pm | 4 ++-- tools/test_modules/m11850.pm | 4 ++-- tools/test_modules/m11860.pm | 4 ++-- tools/test_modules/m20011.pm | 36 ++++++++++++++++++------------------ tools/test_modules/m20012.pm | 36 ++++++++++++++++++------------------ tools/test_modules/m20013.pm | 36 ++++++++++++++++++------------------ 11 files changed, 72 insertions(+), 72 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index d0c494452..3be8a4d82 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -32,6 +32,7 @@ - Hash-Mode 13200 (AxCrypt): Changed the name to AxCrypt 1 to avoid confusion - Hash-Mode 13300 (AxCrypt in-memory SHA1): Changed the name to AxCrypt 1 in-memory SHA1 +- Unit tests: Added Python 3 support for all of the Python code in our test framework * changes v6.1.0 -> v6.1.1 diff --git a/tools/install_modules.sh b/tools/install_modules.sh index b8c578a3f..61d016d2c 100755 --- a/tools/install_modules.sh +++ b/tools/install_modules.sh @@ -63,13 +63,13 @@ cpan install Authen::Passphrase::LANManager \ ERRORS=$((ERRORS+$?)) -pip2 install pygost +pip install pygost -# pip2 uninstall -y pycryptoplus pycrypto pycryptodome +# pip uninstall -y pycryptoplus pycrypto pycryptodome -pip2 install pycryptoplus -pip2 uninstall -y pycryptodome -pip2 install pycrypto +pip install pycryptoplus +pip uninstall -y pycryptodome +pip install pycrypto ERRORS=$((ERRORS+$?)) diff --git a/tools/test_modules/m11700.pm b/tools/test_modules/m11700.pm index 94603d172..52e05c9b1 100644 --- a/tools/test_modules/m11700.pm +++ b/tools/test_modules/m11700.pm @@ -16,18 +16,17 @@ sub module_generate_hash # PyGOST outputs digests in little-endian order, while the kernels # expect them in big-endian; hence the digest[::-1] mirroring. - # Using sys.stdout.write instead of print to disable \n character. my $python_code = <<"END_CODE"; import binascii import sys from pygost import gost34112012256 digest = gost34112012256.new (b"$word").digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $hash = `python2 -c '$python_code'`; + my $hash = `python -c '$python_code'`; return $hash; } diff --git a/tools/test_modules/m11750.pm b/tools/test_modules/m11750.pm index 73d28cae7..8175e8b01 100644 --- a/tools/test_modules/m11750.pm +++ b/tools/test_modules/m11750.pm @@ -23,11 +23,11 @@ from pygost import gost34112012256 key = b"$word" msg = b"$salt" digest = hmac.new (key, msg, gost34112012256).digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $digest = `python2 -c '$python_code'`; + my $digest = `python -c '$python_code'`; my $hash = sprintf ("%s:%s", $digest, $salt); diff --git a/tools/test_modules/m11760.pm b/tools/test_modules/m11760.pm index e1edcbaee..badaa1504 100644 --- a/tools/test_modules/m11760.pm +++ b/tools/test_modules/m11760.pm @@ -23,11 +23,11 @@ from pygost import gost34112012256 key = b"$salt" msg = b"$word" digest = hmac.new (key, msg, gost34112012256).digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $digest = `python2 -c '$python_code'`; + my $digest = `python -c '$python_code'`; my $hash = sprintf ("%s:%s", $digest, $salt); diff --git a/tools/test_modules/m11800.pm b/tools/test_modules/m11800.pm index 7dd297847..c6b350d4f 100644 --- a/tools/test_modules/m11800.pm +++ b/tools/test_modules/m11800.pm @@ -20,11 +20,11 @@ import binascii import sys from pygost import gost34112012512 digest = gost34112012512.new (b"$word").digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $hash = `python2 -c '$python_code'`; + my $hash = `python -c '$python_code'`; return $hash; } diff --git a/tools/test_modules/m11850.pm b/tools/test_modules/m11850.pm index 21bb4dc3c..e93a31dac 100644 --- a/tools/test_modules/m11850.pm +++ b/tools/test_modules/m11850.pm @@ -24,11 +24,11 @@ from pygost import gost34112012512 key = b"$word" msg = b"$salt" digest = hmac.new (key, msg, gost34112012512).digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $digest = `python2 -c '$python_code'`; + my $digest = `python -c '$python_code'`; my $hash = sprintf ("%s:%s", $digest, $salt); diff --git a/tools/test_modules/m11860.pm b/tools/test_modules/m11860.pm index 17d78fc8c..37e9cbd8c 100644 --- a/tools/test_modules/m11860.pm +++ b/tools/test_modules/m11860.pm @@ -24,11 +24,11 @@ from pygost import gost34112012512 key = b"$salt" msg = b"$word" digest = hmac.new (key, msg, gost34112012512).digest () -sys.stdout.write (binascii.hexlify (digest[::-1])) +print (binascii.hexlify (digest[::-1]).decode (), end = "") END_CODE - my $digest = `python2 -c '$python_code'`; + my $digest = `python -c '$python_code'`; my $hash = sprintf ("%s:%s", $digest, $salt); diff --git a/tools/test_modules/m20011.pm b/tools/test_modules/m20011.pm index 2d69ffe91..18ef71468 100644 --- a/tools/test_modules/m20011.pm +++ b/tools/test_modules/m20011.pm @@ -34,11 +34,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -48,7 +48,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -77,11 +77,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -91,7 +91,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -122,11 +122,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -136,7 +136,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -165,11 +165,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -179,7 +179,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -210,11 +210,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -224,7 +224,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -253,11 +253,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -267,7 +267,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; diff --git a/tools/test_modules/m20012.pm b/tools/test_modules/m20012.pm index 0a945efd2..93ed77dca 100644 --- a/tools/test_modules/m20012.pm +++ b/tools/test_modules/m20012.pm @@ -34,11 +34,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -48,7 +48,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -77,11 +77,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -91,7 +91,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -122,11 +122,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -136,7 +136,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -165,11 +165,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -179,7 +179,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -210,11 +210,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -224,7 +224,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -253,11 +253,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -267,7 +267,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; diff --git a/tools/test_modules/m20013.pm b/tools/test_modules/m20013.pm index 5f8c08dc9..f5563f339 100644 --- a/tools/test_modules/m20013.pm +++ b/tools/test_modules/m20013.pm @@ -34,11 +34,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -48,7 +48,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -77,11 +77,11 @@ key = (key1, key2) cipher = AES.new (key, AES.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -91,7 +91,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -122,11 +122,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -136,7 +136,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -165,11 +165,11 @@ key = (key1, key2) cipher = python_Twofish.new (key, python_Twofish.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -179,7 +179,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -210,11 +210,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" encrypted = cipher.encrypt (base64.b64decode (data), sequence) -print encrypted.encode ("hex") +print (encrypted.hex ()) END_CODE @@ -224,7 +224,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g; @@ -253,11 +253,11 @@ key = (key1, key2) cipher = python_Serpent.new (key, python_Serpent.MODE_XTS) -sequence = "01".decode ("hex") +sequence = b"\x01" decrypted = cipher.decrypt (base64.b64decode (data), sequence) -print decrypted.encode ("hex") +print (decrypted.hex ()) END_CODE @@ -267,7 +267,7 @@ END_CODE $python_code =~ s/key_tweak/"$key_tweak"/; $python_code =~ s/data/"$data_base64"/; - my $output_buf = `python2 -c '$python_code'`; + my $output_buf = `python -c '$python_code'`; $output_buf =~ s/[\r\n]//g;