mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-25 07:58:19 +00:00
Merge pull request #1331 from philsmd/master
use an overflow check instead of a hard coded max. value for ETA
This commit is contained in:
commit
a697ad87ae
@ -25,6 +25,7 @@
|
|||||||
- Fixed a memory problem that occured when the OpenCL folder was not found and e.g. the shared and session folder were the same
|
- Fixed a memory problem that occured when the OpenCL folder was not found and e.g. the shared and session folder were the same
|
||||||
- Fixed the version number used in the restore file header
|
- Fixed the version number used in the restore file header
|
||||||
- Fixed the parsing of command line options. It doesn't show two times the same error about an invalid option anymore.
|
- Fixed the parsing of command line options. It doesn't show two times the same error about an invalid option anymore.
|
||||||
|
- Fixed the estimated time value whenever the value is very large and overflows
|
||||||
|
|
||||||
##
|
##
|
||||||
## Improvements
|
## Improvements
|
||||||
|
@ -62,4 +62,8 @@ void hc_string_trim_leading (char *s);
|
|||||||
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
|
size_t hc_fread (void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||||
|
|
||||||
|
void hc_time (hc_time_t *t);
|
||||||
|
struct tm *hc_gmtime (hc_time_t *t);
|
||||||
|
char *hc_ctime (hc_time_t *t, char *buf, MAYBE_UNUSED size_t buf_size);
|
||||||
|
|
||||||
#endif // _SHARED_H
|
#endif // _SHARED_H
|
||||||
|
@ -47,6 +47,7 @@ double status_get_msec_paused (const hashcat_ctx_t *hashcat_
|
|||||||
double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx);
|
double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx);
|
||||||
char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx);
|
char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx);
|
||||||
char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx);
|
char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx);
|
||||||
|
hc_time_t status_get_sec_etc (const hashcat_ctx_t *hashcat_ctx);
|
||||||
char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx);
|
char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx);
|
||||||
char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx);
|
char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx);
|
||||||
u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx);
|
u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx);
|
||||||
|
@ -43,6 +43,14 @@ typedef uint16_t u16;
|
|||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint64_t u64;
|
typedef uint64_t u64;
|
||||||
|
|
||||||
|
// time
|
||||||
|
|
||||||
|
#if defined (_WIN)
|
||||||
|
typedef __time64_t hc_time_t;
|
||||||
|
#else
|
||||||
|
typedef time_t hc_time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
// timer
|
// timer
|
||||||
|
|
||||||
#if defined (_WIN)
|
#if defined (_WIN)
|
||||||
|
37
src/shared.c
37
src/shared.c
@ -441,3 +441,40 @@ void hc_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
|||||||
|
|
||||||
if (rc == 0) rc = 0;
|
if (rc == 0) rc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void hc_time (hc_time_t *t)
|
||||||
|
{
|
||||||
|
#if defined (_WIN)
|
||||||
|
_time64 (t);
|
||||||
|
#else
|
||||||
|
time (t);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tm *hc_gmtime (hc_time_t *t)
|
||||||
|
{
|
||||||
|
#if defined (_WIN)
|
||||||
|
return _gmtime64 (t);
|
||||||
|
#else
|
||||||
|
return gmtime (t);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
char *hc_ctime (hc_time_t *t, char *buf, MAYBE_UNUSED size_t buf_size)
|
||||||
|
{
|
||||||
|
char *etc = NULL;
|
||||||
|
|
||||||
|
#if defined (_WIN)
|
||||||
|
etc = _ctime64 (t);
|
||||||
|
|
||||||
|
if (etc != NULL)
|
||||||
|
{
|
||||||
|
snprintf (buf, buf_size, "%s", etc);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
etc = ctime_r (t, buf); // buf should have room for at least 26 bytes
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return etc;
|
||||||
|
}
|
||||||
|
119
src/status.c
119
src/status.c
@ -18,6 +18,7 @@
|
|||||||
#include "mpsp.h"
|
#include "mpsp.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "status.h"
|
#include "status.h"
|
||||||
|
#include "shared.h"
|
||||||
|
|
||||||
static const char ST_0000[] = "Initializing";
|
static const char ST_0000[] = "Initializing";
|
||||||
static const char ST_0001[] = "Autotuning";
|
static const char ST_0001[] = "Autotuning";
|
||||||
@ -36,6 +37,9 @@ static const char ST_9999[] = "Unknown! Bug!";
|
|||||||
|
|
||||||
static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' };
|
static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' };
|
||||||
|
|
||||||
|
static const char ETA_ABSOLUTE_MAX_EXCEEDED[] = "Next Big Bang"; // in honor of ighashgpu
|
||||||
|
static const char ETA_RELATIVE_MAX_EXCEEDED[] = "> 10 years";
|
||||||
|
|
||||||
static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx)
|
static char *status_get_rules_file (const hashcat_ctx_t *hashcat_ctx)
|
||||||
{
|
{
|
||||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
@ -981,16 +985,12 @@ char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx)
|
|||||||
return display_run;
|
return display_run;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx)
|
hc_time_t status_get_sec_etc (const hashcat_ctx_t *hashcat_ctx)
|
||||||
{
|
{
|
||||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||||
|
|
||||||
#if defined (_WIN)
|
hc_time_t sec_etc = 0;
|
||||||
__time64_t sec_etc = 0;
|
|
||||||
#else
|
|
||||||
time_t sec_etc = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||||
{
|
{
|
||||||
@ -1014,21 +1014,33 @@ char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need this check to avoid integer overflow
|
return sec_etc;
|
||||||
if (sec_etc > 100000000)
|
}
|
||||||
{
|
|
||||||
sec_etc = 100000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t now;
|
char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx)
|
||||||
|
{
|
||||||
|
hc_time_t sec_etc = status_get_sec_etc (hashcat_ctx);
|
||||||
|
|
||||||
time (&now);
|
hc_time_t now;
|
||||||
|
hc_time (&now);
|
||||||
|
|
||||||
now += sec_etc;
|
|
||||||
|
|
||||||
char buf[32] = { 0 };
|
char buf[32] = { 0 };
|
||||||
|
|
||||||
char *etc = ctime_r (&now, buf);
|
char *etc;
|
||||||
|
|
||||||
|
if (overflow_check_u64_add (now, sec_etc) == false)
|
||||||
|
{
|
||||||
|
etc = (char *) ETA_ABSOLUTE_MAX_EXCEEDED;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hc_time_t end = now + sec_etc;
|
||||||
|
|
||||||
|
etc = hc_ctime (&end, buf, sizeof (buf));
|
||||||
|
|
||||||
|
if (etc == NULL) etc = (char *) ETA_ABSOLUTE_MAX_EXCEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
const size_t etc_len = strlen (etc);
|
const size_t etc_len = strlen (etc);
|
||||||
|
|
||||||
@ -1040,59 +1052,22 @@ char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
|
char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
|
||||||
{
|
{
|
||||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
|
||||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
|
||||||
|
|
||||||
#if defined (_WIN)
|
|
||||||
__time64_t sec_etc = 0;
|
|
||||||
#else
|
|
||||||
time_t sec_etc = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
|
||||||
{
|
|
||||||
if (status_ctx->devices_status != STATUS_CRACKED)
|
|
||||||
{
|
|
||||||
const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx);
|
|
||||||
const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx);
|
|
||||||
|
|
||||||
const u64 progress_ignore = status_get_progress_ignore (hashcat_ctx);
|
|
||||||
|
|
||||||
const double hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx);
|
|
||||||
|
|
||||||
if (hashes_msec_all > 0)
|
|
||||||
{
|
|
||||||
const u64 progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
|
|
||||||
|
|
||||||
u64 msec_left = (u64) ((progress_left_relative_skip - progress_ignore) / hashes_msec_all);
|
|
||||||
|
|
||||||
sec_etc = msec_left / 1000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need this check to avoid integer overflow
|
|
||||||
#if defined (_WIN)
|
|
||||||
if (sec_etc > 100000000)
|
|
||||||
{
|
|
||||||
sec_etc = 100000000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tm *tmp;
|
|
||||||
|
|
||||||
#if defined (_WIN)
|
|
||||||
tmp = _gmtime64 (&sec_etc);
|
|
||||||
#else
|
|
||||||
struct tm tm;
|
|
||||||
|
|
||||||
tmp = gmtime_r (&sec_etc, &tm);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *display = (char *) malloc (HCBUFSIZ_TINY);
|
char *display = (char *) malloc (HCBUFSIZ_TINY);
|
||||||
|
|
||||||
format_timer_display (tmp, display, HCBUFSIZ_TINY);
|
hc_time_t sec_etc = status_get_sec_etc (hashcat_ctx);
|
||||||
|
|
||||||
|
struct tm *tmp = hc_gmtime (&sec_etc);
|
||||||
|
|
||||||
|
if (tmp == NULL)
|
||||||
|
{
|
||||||
|
snprintf (display, HCBUFSIZ_TINY, "%s", ETA_RELATIVE_MAX_EXCEEDED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
format_timer_display (tmp, display, HCBUFSIZ_TINY);
|
||||||
|
}
|
||||||
|
|
||||||
if (user_options->runtime > 0)
|
if (user_options->runtime > 0)
|
||||||
{
|
{
|
||||||
@ -1102,21 +1077,11 @@ char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx)
|
|||||||
|
|
||||||
if (runtime_left > 0)
|
if (runtime_left > 0)
|
||||||
{
|
{
|
||||||
#if defined (_WIN)
|
hc_time_t sec_left = runtime_left;
|
||||||
__time64_t sec_left = runtime_left;
|
|
||||||
#else
|
|
||||||
time_t sec_left = runtime_left;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tm *tmp_left;
|
struct tm *tmp_left;
|
||||||
|
|
||||||
#if defined (_WIN)
|
tmp_left = hc_gmtime (&sec_left);
|
||||||
tmp_left = _gmtime64 (&sec_left);
|
|
||||||
#else
|
|
||||||
struct tm tm_left;
|
|
||||||
|
|
||||||
tmp_left = gmtime_r (&sec_left, &tm_left);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *display_left = (char *) malloc (HCBUFSIZ_TINY);
|
char *display_left = (char *) malloc (HCBUFSIZ_TINY);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user