Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving performance of --show #2 #3990

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
##

- DEScrypt Kernel (1500): Improved performance from 950MH/s to 2200MH/s (RX6900XT) on HIP backend by workaround invalid compile time optimizer
- Added a redundant signature check to modules 01711, 02100, 07500, 13100, 13400, 18200, 19600, 19700, 19800, 19900, 20200, 20300, 20400, 28800, 28900, and 29700 to improve potfile reading performance

##
## Bugs
Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_01711.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

/**
* Checking the signature for performance optimization
*/

if (line_len < 64) return (PARSER_SALT_LENGTH);

if (strncmp(line_buf, SIGNATURE_SHA512B64S, strlen (SIGNATURE_SHA512B64S))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 2;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_02100.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

/**
* Checking the signature for performance optimization
*/

if (line_len < 41) return (PARSER_SALT_LENGTH);

if (strncmp(line_buf, SIGNATURE_DCC2, strlen (SIGNATURE_DCC2))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 4;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_07500.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5PA, strlen (SIGNATURE_KRB5PA))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 6;
Expand Down
12 changes: 10 additions & 2 deletions src/modules/module_13100.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5TGS, strlen (SIGNATURE_KRB5TGS))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -123,8 +133,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* format 3: $krb5tgs$spn:checksum$edata2
*/

if (line_len < (int) strlen (SIGNATURE_KRB5TGS)) return (PARSER_SALT_LENGTH);

memset (krb5tgs, 0, sizeof (krb5tgs_t));

token.token_cnt = 4;
Expand Down
8 changes: 8 additions & 0 deletions src/modules/module_13400.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

if (line_len < 128) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KEEPASS, strlen (SIGNATURE_KEEPASS))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

if ((line_buf[line_len - (64 + 1 + 2 + 1 + 2)] == '*')
&& (line_buf[line_len - (64 + 1 + 2 + 1 + 1)] == '1')
&& (line_buf[line_len - (64 + 1 + 2 + 1 + 0)] == '*')) is_keyfile_present = true;
Expand Down
12 changes: 10 additions & 2 deletions src/modules/module_18200.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5ASREP, strlen (SIGNATURE_KRB5ASREP))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -121,8 +131,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* format 2: $krb5asrep$user_principal_name:checksum$edata2
*/

if (line_len < (int) strlen (SIGNATURE_KRB5ASREP)) return (PARSER_SALT_LENGTH);

memset (krb5asrep, 0, sizeof (krb5asrep_t));

size_t parse_off = 0;
Expand Down
13 changes: 10 additions & 3 deletions src/modules/module_19600.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5TGS, strlen (SIGNATURE_KRB5TGS))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -103,9 +113,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* $krb5tgs$17$*user*realm*spn*$checksum$edata2
*/

// assume no signature found
if (line_len < 12) return (PARSER_SALT_LENGTH);

char *spn_info_start = strchr (line_buf + 12 + 1, '*');

int is_spn_provided = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_19700.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5TGS, strlen (SIGNATURE_KRB5TGS))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand Down
14 changes: 11 additions & 3 deletions src/modules/module_19800.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* Author......: See docs/credits.txt
* License.....: MIT
Expand Down Expand Up @@ -89,6 +90,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5PA, strlen (SIGNATURE_KRB5PA))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -102,9 +113,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* $krb5pa$17$*user*realm*$enc_timestamp+checksum
*/

// assume no signature found
if (line_len < 11) return (PARSER_SALT_LENGTH);

// assume $krb5pa$17$user$realm$enc_timestamp+checksum
token.token_cnt = 4;

Expand Down
13 changes: 10 additions & 3 deletions src/modules/module_19900.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 46) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5PA, strlen (SIGNATURE_KRB5PA))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -102,9 +112,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* $krb5pa$18$*user*realm*$enc_timestamp+checksum
*/

// assume no signature found
if (line_len < 11) return (PARSER_SALT_LENGTH);

// assume $krb5pa$18$user$realm$enc_timestamp+checksum
token.token_cnt = 4;

Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_20200.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

/**
* Checking the signature for performance optimization
*/

if (line_len < 52) return (PARSER_SALT_LENGTH);

if (strncmp(line_buf, SIGNATURE_PASSLIB_PBKDF2_SHA512, strlen (SIGNATURE_PASSLIB_PBKDF2_SHA512))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 5;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/module_20300.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

/**
* Checking the signature for performance optimization
*/

if (line_len < 52) return (PARSER_SALT_LENGTH);

if (strncmp(line_buf, SIGNATURE_PASSLIB_PBKDF2_SHA256, strlen (SIGNATURE_PASSLIB_PBKDF2_SHA256))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 5;
Expand Down
9 changes: 9 additions & 0 deletions src/modules/module_20400.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

/**
* Checking the signature for performance optimization
*/
if (line_len < 52) return (PARSER_SALT_LENGTH);

if (strncmp(line_buf, SIGNATURE_PASSLIB_PBKDF2_SHA1, strlen (SIGNATURE_PASSLIB_PBKDF2_SHA1))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.token_cnt = 5;
Expand Down
13 changes: 10 additions & 3 deletions src/modules/module_28800.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 11) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5DB, strlen (SIGNATURE_KRB5DB))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -113,9 +123,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* $krb5db$17$user$realm$*spn*$hash
*/

// assume no signature found
if (line_len < 11) return (PARSER_SALT_LENGTH);

char *spn_info_start = strchr (line_buf + 11 + 1, '*');

int is_spn_provided = 0;
Expand Down
13 changes: 10 additions & 3 deletions src/modules/module_28900.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

hc_token_t token;

if (line_len < 11) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KRB5DB, strlen (SIGNATURE_KRB5DB))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

memset (&token, 0, sizeof (hc_token_t));

token.signatures_cnt = 1;
Expand All @@ -113,9 +123,6 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
* $krb5db$18$user$realm$*spn*$hash
*/

// assume no signature found
if (line_len < 11) return (PARSER_SALT_LENGTH);

char *spn_info_start = strchr (line_buf + 11 + 1, '*');

int is_spn_provided = 0;
Expand Down
8 changes: 8 additions & 0 deletions src/modules/module_29700.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE

if (line_len < 128) return (PARSER_SALT_LENGTH);

/**
* Checking the signature for performance optimization
*/

if (strncmp(line_buf, SIGNATURE_KEEPASS, strlen (SIGNATURE_KEEPASS))) {
return (PARSER_SIGNATURE_UNMATCHED);
}

if ((line_buf[line_len - (64 + 1 + 2 + 1 + 2)] == '*')
&& (line_buf[line_len - (64 + 1 + 2 + 1 + 1)] == '1')
&& (line_buf[line_len - (64 + 1 + 2 + 1 + 0)] == '*')) is_keyfile_present = true;
Expand Down
Loading