1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-06-25 09:22:36 +00:00

minor code style fixes

This commit is contained in:
philsmd 2022-03-31 19:19:16 +02:00
parent 8e532e6162
commit a24d723d66
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF
18 changed files with 160 additions and 137 deletions

View File

@ -81,7 +81,8 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
#endif #endif
// color stuff pre // color stuff pre
if (is_stdout_terminal()) { if (is_stdout_terminal ())
{
#if defined (_WIN) #if defined (_WIN)
switch (loglevel) switch (loglevel)
{ {
@ -111,7 +112,8 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
fwrite (msg_buf, msg_len, 1, fp); fwrite (msg_buf, msg_len, 1, fp);
// color stuff post // color stuff post
if (is_stdout_terminal()) { if (is_stdout_terminal ())
{
#if defined (_WIN) #if defined (_WIN)
switch (loglevel) switch (loglevel)
{ {

View File

@ -496,7 +496,11 @@ int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig,
pdf_t *pdf = (pdf_t *) hashes->esalts_buf; pdf_t *pdf = (pdf_t *) hashes->esalts_buf;
// if the password in tmp->out is equal to the padding, then we recovered just the owner-password // if the password in tmp->out is equal to the padding, then we recovered just the owner-password
if(pdf_tmp->out[0]==padding[0] && pdf_tmp->out[1]==padding[1] && pdf_tmp->out[2]==padding[2] && pdf_tmp->out[3]==padding[3])
if (pdf_tmp->out[0] == padding[0] &&
pdf_tmp->out[1] == padding[1] &&
pdf_tmp->out[2] == padding[2] &&
pdf_tmp->out[3] == padding[3])
{ {
return snprintf ((char *) dst_buf, dst_sz, "%s (user password not set)", (char *) src_buf); return snprintf ((char *) dst_buf, dst_sz, "%s (user password not set)", (char *) src_buf);
} }
@ -513,6 +517,7 @@ int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig,
bool remove_padding = false; bool remove_padding = false;
int i_padding = 0; int i_padding = 0;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
if (u8OutBufPtr[i] == u8OutPadPtr[i_padding] || remove_padding) if (u8OutBufPtr[i] == u8OutPadPtr[i_padding] || remove_padding)
@ -527,7 +532,11 @@ int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig,
// TODO would be better to actually also verify the u-value whether we've retrieved the correct user-password, // TODO would be better to actually also verify the u-value whether we've retrieved the correct user-password,
// however, we'd need to include a lot of code/complexity here to do so (or call into 10500 kernel). // however, we'd need to include a lot of code/complexity here to do so (or call into 10500 kernel).
// this seems relevant: run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 0, 1, false, 0) // this seems relevant: run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 0, 1, false, 0)
if(pdf_tmp->out[0]==src_buf[0] && pdf_tmp->out[1]==src_buf[1] && pdf_tmp->out[2]==src_buf[2] && pdf_tmp->out[3]==src_buf[3])
if (pdf_tmp->out[0] == src_buf[0] &&
pdf_tmp->out[1] == src_buf[1] &&
pdf_tmp->out[2] == src_buf[2] &&
pdf_tmp->out[3] == src_buf[3])
{ {
if (pdf->u_pass_len == 0) if (pdf->u_pass_len == 0)
{ {

View File

@ -944,8 +944,7 @@ void hash_info (hashcat_ctx_t *hashcat_ctx)
{ {
char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY); char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY);
if (user_options->machine_readable == true) if (user_options->machine_readable == true) printf ("{ ");
printf("{ ");
for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++) for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++)
{ {
@ -970,8 +969,7 @@ void hash_info (hashcat_ctx_t *hashcat_ctx)
} }
} }
if (user_options->machine_readable == true) if (user_options->machine_readable == true) printf (" }");
printf(" }");
hcfree (modulefile); hcfree (modulefile);
} }
@ -1789,17 +1787,28 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx)
printf ("{ \"session\": \"%s\",", hashcat_status->session); printf ("{ \"session\": \"%s\",", hashcat_status->session);
printf (" \"guess\": {"); printf (" \"guess\": {");
if (hashcat_status->guess_base) if (hashcat_status->guess_base)
{
printf (" \"guess_base\": \"%s\",", hashcat_status->guess_base); printf (" \"guess_base\": \"%s\",", hashcat_status->guess_base);
}
else else
{
printf (" \"guess_base\": null,"); printf (" \"guess_base\": null,");
}
printf (" \"guess_base_count\": %u,", hashcat_status->guess_base_count); printf (" \"guess_base_count\": %u,", hashcat_status->guess_base_count);
printf (" \"guess_base_offset\": %u,", hashcat_status->guess_base_offset); printf (" \"guess_base_offset\": %u,", hashcat_status->guess_base_offset);
printf (" \"guess_base_percent\": %.02f,", hashcat_status->guess_base_percent); printf (" \"guess_base_percent\": %.02f,", hashcat_status->guess_base_percent);
printf (" \"guess_mask_length\": %u,", hashcat_status->guess_mask_length); printf (" \"guess_mask_length\": %u,", hashcat_status->guess_mask_length);
if (hashcat_status->guess_mod) if (hashcat_status->guess_mod)
{
printf (" \"guess_mod\": \"%s\",", hashcat_status->guess_mod); printf (" \"guess_mod\": \"%s\",", hashcat_status->guess_mod);
}
else else
{
printf (" \"guess_mod\": null,"); printf (" \"guess_mod\": null,");
}
printf (" \"guess_mod_count\": %u,", hashcat_status->guess_mod_count); printf (" \"guess_mod_count\": %u,", hashcat_status->guess_mod_count);
printf (" \"guess_mod_offset\": %u,", hashcat_status->guess_mod_offset); printf (" \"guess_mod_offset\": %u,", hashcat_status->guess_mod_offset);
printf (" \"guess_mod_percent\": %.02f,", hashcat_status->guess_mod_percent); printf (" \"guess_mod_percent\": %.02f,", hashcat_status->guess_mod_percent);

View File

@ -613,7 +613,8 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{ {
if ((user_options->separator[0] == '0') && (user_options->separator[1] == 'x')) if ((user_options->separator[0] == '0') && (user_options->separator[1] == 'x'))
{ {
if (is_valid_hex_string((u8 * )(&(user_options->separator[2])),2)){ if (is_valid_hex_string ((u8 * ) (&(user_options->separator[2])), 2))
{
u8 sep = hex_to_u8 ((u8 * ) (&(user_options->separator[2]))); u8 sep = hex_to_u8 ((u8 * ) (&(user_options->separator[2])));
user_options->separator[0] = sep; user_options->separator[0] = sep;
user_options->separator[1] = 0; user_options->separator[1] = 0;
@ -627,7 +628,9 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
error = true; error = true;
} }
} }
if (error){
if (error)
{
event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte (single char or hex format e.g. 0x09 for TAB)"); event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte (single char or hex format e.g. 0x09 for TAB)");
return -1; return -1;