1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Add inner2_loop()

This commit is contained in:
jsteube 2016-09-29 14:46:51 +02:00
parent 1cf4b2a093
commit e12abeb9de
9 changed files with 581 additions and 675 deletions

View File

@ -42,6 +42,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra);
void opencl_ctx_devices_kernel_loops (opencl_ctx_t *opencl_ctx, const user_options_extra_t *user_options_extra, const hashconfig_t *hashconfig, const hashes_t *hashes, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db);
void opencl_session_destroy (opencl_ctx_t *opencl_ctx);

View File

@ -8,7 +8,11 @@
#include <string.h>
#define INCR_DICTS 1000
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options);
void straight_ctx_destroy (straight_ctx_t *straight_ctx);
void straight_append_dict (straight_ctx_t *straight_ctx, const char *dict);
#endif // _STRAIGHT_H

View File

@ -1129,6 +1129,7 @@ typedef struct
char **induction_dictionaries;
int induction_dictionaries_cnt;
int induction_dictionaries_pos;
} induct_ctx_t;
@ -1144,19 +1145,24 @@ typedef struct
{
bool enabled;
char *dictfile;
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
char **dicts;
u32 dicts_pos;
u32 dicts_cnt;
u32 dicts_avail;
char *dict;
} straight_ctx_t;
typedef struct
{
bool enabled;
char *dictfile1;
char *dictfile2;
char *dict1;
char *dict2;
u32 combs_mode;
u32 combs_cnt;
@ -1253,13 +1259,6 @@ typedef struct
time_t cpt_start;
u64 cpt_total;
/**
* user
*/
char *dictfile;
char *dictfile2;
/**
* status, timer
*/

View File

@ -297,13 +297,17 @@ void *thread_calc (void *p)
}
else
{
char *dictfile = data.dictfile;
char *dictfile = straight_ctx->dict;
if (attack_mode == ATTACK_MODE_COMBI)
{
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
dictfile = data.dictfile2;
dictfile = combinator_ctx->dict1;
}
else
{
dictfile = combinator_ctx->dict2;
}
}
@ -322,13 +326,13 @@ void *thread_calc (void *p)
if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
const char *dictfilec = data.dictfile2;
const char *dictfilec = combinator_ctx->dict2;
FILE *combs_fp = fopen (dictfilec, "rb");
if (combs_fp == NULL)
{
log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno));
fclose (fd);
@ -339,7 +343,7 @@ void *thread_calc (void *p)
}
else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
{
const char *dictfilec = data.dictfile;
const char *dictfilec = combinator_ctx->dict1;
FILE *combs_fp = fopen (dictfilec, "rb");

File diff suppressed because it is too large Load Diff

View File

@ -2498,6 +2498,38 @@ void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_optio
}
}
void opencl_ctx_devices_kernel_loops (opencl_ctx_t *opencl_ctx, const user_options_extra_t *user_options_extra, const hashconfig_t *hashconfig, const hashes_t *hashes, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
if (device_param->kernel_loops_min < device_param->kernel_loops_max)
{
u32 innerloop_cnt = 0;
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = mask_ctx->bfs_cnt;
}
else
{
innerloop_cnt = hashes->salts_buf[0].salt_iter;
}
if ((innerloop_cnt >= device_param->kernel_loops_min) &&
(innerloop_cnt <= device_param->kernel_loops_max))
{
device_param->kernel_loops_max = innerloop_cnt;
}
}
}
}
int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db)
{
/**

View File

@ -389,7 +389,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con
{
if (user_options_extra->wordlist_mode == WL_MODE_FILE)
{
if (data.dictfile != NULL) log_info ("Input.Mode.....: File (%s)", data.dictfile);
log_info ("Input.Mode.....: File (%s)", straight_ctx->dict);
}
else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
{
@ -398,8 +398,8 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
if (data.dictfile2 != NULL) log_info ("Input.Right....: File (%s)", data.dictfile2);
log_info ("Input.Left.....: File (%s)", combinator_ctx->dict1);
log_info ("Input.Right....: File (%s)", combinator_ctx->dict2);
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
@ -452,8 +452,8 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
if (mask_ctx->mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
log_info ("Input.Left.....: File (%s)", straight_ctx->dict);
log_info ("Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL))
{
@ -467,8 +467,8 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (mask_ctx->mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
if (data.dictfile != NULL) log_info ("Input.Right....: File (%s)", data.dictfile);
log_info ("Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
log_info ("Input.Right....: File (%s)", straight_ctx->dict);
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL))
{

View File

@ -63,6 +63,13 @@ void straight_ctx_destroy (straight_ctx_t *straight_ctx)
{
if (straight_ctx->enabled == false) return;
for (u32 dict_pos = 0; dict_pos < straight_ctx->dicts_cnt; dict_pos++)
{
myfree (straight_ctx->dicts[dict_pos]);
}
myfree (straight_ctx->dicts);
myfree (straight_ctx->kernel_rules_buf);
straight_ctx->kernel_rules_buf = NULL;
@ -70,3 +77,17 @@ void straight_ctx_destroy (straight_ctx_t *straight_ctx)
myfree (straight_ctx);
}
void straight_append_dict (straight_ctx_t *straight_ctx, const char *dict)
{
if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt)
{
straight_ctx->dicts = (char **) myrealloc (straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *));
straight_ctx->dicts_avail += INCR_DICTS;
}
straight_ctx->dicts[straight_ctx->dicts_cnt] = mystrdup (dict);
straight_ctx->dicts_cnt++;
}

View File

@ -5,31 +5,11 @@
#include "common.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "logging.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "tuningdb.h"
#include "thread.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "hash_management.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "weak_hash.h"
extern hc_global_data_t data;
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
{
if (device_param == NULL)
@ -48,12 +28,6 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
device_param->kernel_params_buf32[33] = 0;
device_param->kernel_params_buf32[34] = 1;
char *dictfile_old = data.dictfile;
const char *weak_hash_check = "weak-hash-check";
data.dictfile = (char *) weak_hash_check;
uint cmd0_rule_old = straight_ctx->kernel_rules_buf[0].cmds[0];
straight_ctx->kernel_rules_buf[0].cmds[0] = 0;
@ -108,7 +82,5 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
device_param->kernel_params_buf32[33] = 0;
device_param->kernel_params_buf32[34] = 0;
data.dictfile = dictfile_old;
straight_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
}