mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Cleanup some macro values
This commit is contained in:
parent
d9073296e4
commit
6aee697112
@ -28,7 +28,9 @@
|
||||
#define SPEED_CACHE 128
|
||||
#define SPEED_MAXAGE 4096
|
||||
|
||||
#define HCBUFSIZ 0x50000 // general large space buffer size in case the size is unknown at compile-time
|
||||
// general buffer size in case the size is unknown at compile-time
|
||||
#define HCBUFSIZ_TINY 0x100
|
||||
#define HCBUFSIZ_LARGE 0x50000
|
||||
|
||||
#define BLOCK_SIZE 64
|
||||
|
||||
@ -39,7 +41,7 @@
|
||||
|
||||
#define DEVICES_MAX 128
|
||||
|
||||
#define PARAMCNT 64
|
||||
|
||||
|
||||
|
||||
#define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define PARAMCNT 64
|
||||
|
||||
static const char CL_VENDOR_AMD[] = "Advanced Micro Devices, Inc.";
|
||||
static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel";
|
||||
static const char CL_VENDOR_APPLE[] = "Apple";
|
||||
|
@ -12,13 +12,13 @@ uint count_lines (FILE *fd)
|
||||
{
|
||||
uint cnt = 0;
|
||||
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ + 1);
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE + 1);
|
||||
|
||||
char prev = '\n';
|
||||
|
||||
while (!feof (fd))
|
||||
{
|
||||
size_t nread = fread (buf, sizeof (char), HCBUFSIZ, fd);
|
||||
size_t nread = fread (buf, sizeof (char), HCBUFSIZ_LARGE, fd);
|
||||
|
||||
if (nread < 1) continue;
|
||||
|
||||
@ -51,7 +51,7 @@ int fgetl (FILE *fp, char *line_buf)
|
||||
|
||||
line_len++;
|
||||
|
||||
if (line_len == HCBUFSIZ) line_len--;
|
||||
if (line_len == HCBUFSIZ_LARGE) line_len--;
|
||||
|
||||
if (c == '\n') break;
|
||||
}
|
||||
|
@ -711,7 +711,7 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
|
||||
|
||||
// hash
|
||||
|
||||
char out_buf[HCBUFSIZ] = { 0 };
|
||||
char out_buf[HCBUFSIZ_LARGE] = { 0 };
|
||||
|
||||
const u32 salt_pos = plain->salt_pos;
|
||||
const u32 digest_pos = plain->digest_pos; // relative
|
||||
@ -1424,7 +1424,7 @@ static void save_hash ()
|
||||
fputc (separator, fp);
|
||||
}
|
||||
|
||||
char out_buf[HCBUFSIZ]; // scratch buffer
|
||||
char out_buf[HCBUFSIZ_LARGE]; // scratch buffer
|
||||
|
||||
out_buf[0] = 0;
|
||||
|
||||
@ -2483,7 +2483,7 @@ static int autotune (hc_device_param_t *device_param)
|
||||
|
||||
static int run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
|
||||
{
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
// init speed timer
|
||||
|
||||
@ -3642,11 +3642,11 @@ static void *thread_outfile_remove (void *p)
|
||||
|
||||
fseek (fp, out_info[j].seek, SEEK_SET);
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
char *ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
|
||||
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, fp);
|
||||
|
||||
if (ptr == NULL) break;
|
||||
|
||||
@ -3996,7 +3996,7 @@ static void *thread_calc_stdin (void *p)
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
const uint attack_kern = data.attack_kern;
|
||||
|
||||
@ -4015,7 +4015,7 @@ static void *thread_calc_stdin (void *p)
|
||||
|
||||
while (words_cur < device_param->kernel_power)
|
||||
{
|
||||
char *line_buf = fgets (buf, HCBUFSIZ - 1, stdin);
|
||||
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin);
|
||||
|
||||
if (line_buf == NULL) break;
|
||||
|
||||
@ -4923,7 +4923,7 @@ static uint hlfmt_detect (FILE *fp, uint max_check)
|
||||
|
||||
uint num_check = 0;
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
@ -10882,7 +10882,7 @@ int main (int argc, char **argv)
|
||||
|
||||
uint line_num = 0;
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (pot_fp))
|
||||
{
|
||||
@ -11547,7 +11547,7 @@ int main (int argc, char **argv)
|
||||
|
||||
uint line_num = 0;
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
@ -12298,17 +12298,17 @@ int main (int argc, char **argv)
|
||||
|
||||
if (fp != NULL)
|
||||
{
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
// to be safe work with a copy (because of line_len loop, i etc)
|
||||
// moved up here because it's easier to handle continue case
|
||||
// it's just 64kb
|
||||
|
||||
char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
char *ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
|
||||
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, fp);
|
||||
|
||||
if (ptr == NULL) break;
|
||||
|
||||
@ -12348,7 +12348,7 @@ int main (int argc, char **argv)
|
||||
// here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
|
||||
// manipulate salt_buf
|
||||
|
||||
memset (line_buf_cpy, 0, HCBUFSIZ);
|
||||
memset (line_buf_cpy, 0, HCBUFSIZ_LARGE);
|
||||
memcpy (line_buf_cpy, line_buf, i);
|
||||
|
||||
char *mac2_pos = strrchr (line_buf_cpy, ':');
|
||||
@ -12852,7 +12852,7 @@ int main (int argc, char **argv)
|
||||
all_kernel_rules_buf = (kernel_rule_t **) mycalloc (rp_files_cnt, sizeof (kernel_rule_t *));
|
||||
}
|
||||
|
||||
char *rule_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *rule_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
int rule_len = 0;
|
||||
|
||||
@ -12882,7 +12882,7 @@ int main (int argc, char **argv)
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
memset (rule_buf, 0, HCBUFSIZ);
|
||||
memset (rule_buf, 0, HCBUFSIZ_LARGE);
|
||||
|
||||
rule_len = fgetl (fp, rule_buf);
|
||||
|
||||
@ -13001,7 +13001,7 @@ int main (int argc, char **argv)
|
||||
kernel_rules_avail += INCR_RULES;
|
||||
}
|
||||
|
||||
memset (rule_buf, 0, HCBUFSIZ);
|
||||
memset (rule_buf, 0, HCBUFSIZ_LARGE);
|
||||
|
||||
rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
|
||||
|
||||
@ -13176,7 +13176,7 @@ int main (int argc, char **argv)
|
||||
|
||||
cl_platform_id platform = platforms[platform_id];
|
||||
|
||||
char platform_vendor[INFOSZ] = { 0 };
|
||||
char platform_vendor[HCBUFSIZ_TINY] = { 0 };
|
||||
|
||||
CL_err = hc_clGetPlatformInfo (data.ocl, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL);
|
||||
|
||||
@ -13766,19 +13766,19 @@ int main (int argc, char **argv)
|
||||
|
||||
// device_name_chksum
|
||||
|
||||
char *device_name_chksum = (char *) mymalloc (INFOSZ);
|
||||
char *device_name_chksum = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
|
||||
#if defined (__x86_64__)
|
||||
snprintf (device_name_chksum, INFOSZ - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME);
|
||||
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 64, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME);
|
||||
#else
|
||||
snprintf (device_name_chksum, INFOSZ - 1, "%u-%u-%u-%s-%s-%s-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME);
|
||||
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%u-%u-%u-%s-%s-%s-%u", 32, device_param->platform_vendor_id, device_param->vector_width, device_param->device_name, device_param->device_version, device_param->driver_version, COMPTIME);
|
||||
#endif
|
||||
|
||||
uint device_name_digest[4] = { 0 };
|
||||
|
||||
md5_64 ((uint *) device_name_chksum, device_name_digest);
|
||||
|
||||
snprintf (device_name_chksum, INFOSZ - 1, "%08x", device_name_digest[0]);
|
||||
snprintf (device_name_chksum, HCBUFSIZ_TINY - 1, "%08x", device_name_digest[0]);
|
||||
|
||||
device_param->device_name_chksum = device_name_chksum;
|
||||
|
||||
@ -16965,11 +16965,11 @@ int main (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (mask_fp))
|
||||
{
|
||||
memset (line_buf, 0, HCBUFSIZ);
|
||||
memset (line_buf, 0, HCBUFSIZ_LARGE);
|
||||
|
||||
int line_len = fgetl (mask_fp, line_buf);
|
||||
|
||||
@ -17106,13 +17106,13 @@ int main (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
uint masks_avail = 1;
|
||||
|
||||
while (!feof (mask_fp))
|
||||
{
|
||||
memset (line_buf, 0, HCBUFSIZ);
|
||||
memset (line_buf, 0, HCBUFSIZ_LARGE);
|
||||
|
||||
int line_len = fgetl (mask_fp, line_buf);
|
||||
|
||||
@ -17285,13 +17285,13 @@ int main (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
uint masks_avail = 1;
|
||||
|
||||
while (!feof (mask_fp))
|
||||
{
|
||||
memset (line_buf, 0, HCBUFSIZ);
|
||||
memset (line_buf, 0, HCBUFSIZ_LARGE);
|
||||
|
||||
int line_len = fgetl (mask_fp, line_buf);
|
||||
|
||||
|
@ -24,10 +24,10 @@
|
||||
#include "thread.h"
|
||||
#include "data.h"
|
||||
|
||||
#if defined (HAVE_HWMON)
|
||||
|
||||
hc_thread_mutex_t mux_hwmon;
|
||||
|
||||
#if defined (HAVE_HWMON)
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
int get_adapters_num_adl (void *adl, int *iNumberAdapters)
|
||||
|
@ -82,18 +82,18 @@ restore_data_t *init_restore (int argc, char **argv)
|
||||
|
||||
if (rd->pid)
|
||||
{
|
||||
char *pidbin = (char *) mymalloc (HCBUFSIZ);
|
||||
char *pidbin = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
int pidbin_len = -1;
|
||||
|
||||
#if defined (_POSIX)
|
||||
snprintf (pidbin, HCBUFSIZ - 1, "/proc/%d/cmdline", rd->pid);
|
||||
snprintf (pidbin, HCBUFSIZ_LARGE - 1, "/proc/%d/cmdline", rd->pid);
|
||||
|
||||
FILE *fd = fopen (pidbin, "rb");
|
||||
|
||||
if (fd)
|
||||
{
|
||||
pidbin_len = fread (pidbin, 1, HCBUFSIZ, fd);
|
||||
pidbin_len = fread (pidbin, 1, HCBUFSIZ_LARGE, fd);
|
||||
|
||||
pidbin[pidbin_len] = 0;
|
||||
|
||||
@ -118,12 +118,12 @@ restore_data_t *init_restore (int argc, char **argv)
|
||||
#elif defined (_WIN)
|
||||
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
|
||||
|
||||
char *pidbin2 = (char *) mymalloc (HCBUFSIZ);
|
||||
char *pidbin2 = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
int pidbin2_len = -1;
|
||||
|
||||
pidbin_len = GetModuleFileName (NULL, pidbin, HCBUFSIZ);
|
||||
pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, HCBUFSIZ);
|
||||
pidbin_len = GetModuleFileName (NULL, pidbin, HCBUFSIZ_LARGE);
|
||||
pidbin2_len = GetModuleFileNameEx (hProcess, NULL, pidbin2, HCBUFSIZ_LARGE);
|
||||
|
||||
pidbin[pidbin_len] = 0;
|
||||
pidbin2[pidbin2_len] = 0;
|
||||
@ -197,11 +197,11 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
|
||||
|
||||
rd->argv = (char **) mycalloc (rd->argc, sizeof (char *));
|
||||
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
for (uint i = 0; i < rd->argc; i++)
|
||||
{
|
||||
if (fgets (buf, HCBUFSIZ - 1, fp) == NULL)
|
||||
if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL)
|
||||
{
|
||||
log_error ("ERROR: Can't read %s", eff_restore_file);
|
||||
|
||||
|
@ -395,7 +395,7 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
|
||||
{
|
||||
uint rule_cnt;
|
||||
uint rule_pos;
|
||||
uint rule_len = HCBUFSIZ - 1; // maximum possible len
|
||||
uint rule_len = HCBUFSIZ_LARGE - 1; // maximum possible len
|
||||
|
||||
char rule_cmd;
|
||||
|
||||
|
@ -527,7 +527,7 @@ void status_display ()
|
||||
}
|
||||
else
|
||||
{
|
||||
char out_buf[HCBUFSIZ] = { 0 };
|
||||
char out_buf[HCBUFSIZ_LARGE] = { 0 };
|
||||
|
||||
ascii_digest (out_buf, 0, 0);
|
||||
|
||||
|
@ -107,11 +107,11 @@ tuning_db_t *tuning_db_init (const char *tuning_db_file)
|
||||
|
||||
int line_num = 0;
|
||||
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ);
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
while (!feof (fp))
|
||||
{
|
||||
char *line_buf = fgets (buf, HCBUFSIZ - 1, fp);
|
||||
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, fp);
|
||||
|
||||
if (line_buf == NULL) break;
|
||||
|
||||
|
@ -57,9 +57,9 @@ int main (int argc, char **argv)
|
||||
{
|
||||
FILE *fp = stdin;
|
||||
|
||||
char *rule_buf = (char *) malloc (HCBUFSIZ);
|
||||
char *rule_buf = (char *) malloc (HCBUFSIZ_LARGE);
|
||||
|
||||
char *line_buf = (char *) malloc (HCBUFSIZ);
|
||||
char *line_buf = (char *) malloc (HCBUFSIZ_LARGE);
|
||||
|
||||
int rp_gen_func_min = RP_GEN_FUNC_MIN;
|
||||
int rp_gen_func_max = RP_GEN_FUNC_MAX;
|
||||
@ -72,7 +72,7 @@ int main (int argc, char **argv)
|
||||
|
||||
if (feof (fp)) break;
|
||||
|
||||
char *line_ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
|
||||
char *line_ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, fp);
|
||||
|
||||
if (line_ptr == NULL) continue;
|
||||
|
||||
@ -114,7 +114,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy (rule_buf, argv[1], HCBUFSIZ - 1);
|
||||
strncpy (rule_buf, argv[1], HCBUFSIZ_LARGE - 1);
|
||||
|
||||
rule_len = strlen (rule_buf);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user