1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-13 19:28:56 +00:00
hashcat/src/terminal.c

912 lines
20 KiB
C
Raw Normal View History

/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
2016-09-15 02:21:41 +00:00
#include "types.h"
#include "memory.h"
#include "event.h"
2016-10-16 17:32:43 +00:00
#include "convert.h"
#include "thread.h"
#include "timer.h"
2016-09-15 02:21:41 +00:00
#include "status.h"
#include "restore.h"
#include "shared.h"
2016-10-16 17:32:43 +00:00
#include "hwmon.h"
#include "interface.h"
#include "outfile.h"
#include "terminal.h"
#include "hashcat.h"
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
2016-10-06 18:57:29 +00:00
void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const char *version_tag)
2016-09-28 21:53:46 +00:00
{
2016-10-06 18:57:29 +00:00
user_options_t *user_options = hashcat_ctx->user_options;
2016-09-28 21:53:46 +00:00
if (user_options->quiet == true) return;
if (user_options->keyspace == true) return;
if (user_options->stdout_flag == true) return;
if (user_options->show == true) return;
if (user_options->left == true) return;
if (user_options->benchmark == true)
{
if (user_options->machine_readable == false)
{
2016-10-14 19:38:52 +00:00
event_log_info (hashcat_ctx, "%s (%s) starting in benchmark mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
2016-09-28 21:53:46 +00:00
}
else
{
event_log_info (hashcat_ctx, "# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start));
2016-09-28 21:53:46 +00:00
}
}
else if (user_options->restore == true)
{
2016-10-14 19:38:52 +00:00
event_log_info (hashcat_ctx, "%s (%s) starting in restore mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
}
else if (user_options->speed_only == true)
{
event_log_info (hashcat_ctx, "%s (%s) starting in speed-only mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
2016-09-28 21:53:46 +00:00
}
else
{
event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
2016-09-28 21:53:46 +00:00
}
}
2016-10-06 18:57:29 +00:00
void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop)
2016-09-28 21:53:46 +00:00
{
2016-10-06 18:57:29 +00:00
const user_options_t *user_options = hashcat_ctx->user_options;
2016-09-28 21:53:46 +00:00
if (user_options->quiet == true) return;
if (user_options->keyspace == true) return;
if (user_options->stdout_flag == true) return;
if (user_options->show == true) return;
if (user_options->left == true) return;
event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start));
event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop));
2016-09-28 21:53:46 +00:00
}
int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
2016-09-28 21:40:16 +00:00
{
#if defined (_WIN)
SetConsoleWindowSize (132);
if (_setmode (_fileno (stdin), _O_BINARY) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno));
2016-09-28 21:40:16 +00:00
return -1;
}
if (_setmode (_fileno (stdout), _O_BINARY) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno));
2016-09-28 21:40:16 +00:00
return -1;
}
if (_setmode (_fileno (stderr), _O_BINARY) == -1)
{
event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno));
2016-09-28 21:40:16 +00:00
return -1;
}
#endif
return 0;
}
2016-09-11 08:39:19 +00:00
void send_prompt ()
{
fprintf (stdout, "%s", PROMPT);
fflush (stdout);
}
void clear_prompt ()
{
fputc ('\r', stdout);
for (size_t i = 0; i < strlen (PROMPT); i++)
{
fputc (' ', stdout);
}
fputc ('\r', stdout);
fflush (stdout);
}
static void keypress (hashcat_ctx_t *hashcat_ctx)
2016-09-15 02:21:41 +00:00
{
2016-10-06 14:34:30 +00:00
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
// this is required, because some of the variables down there are not initialized at that point
while (status_ctx->devices_status == STATUS_INIT) hc_sleep_msec (100);
2016-09-24 23:02:44 +00:00
const bool quiet = user_options->quiet;
2016-09-15 02:21:41 +00:00
tty_break ();
2016-09-15 02:21:41 +00:00
2016-09-29 21:49:33 +00:00
while (status_ctx->shutdown_outer == false)
2016-09-15 02:21:41 +00:00
{
int ch = tty_getchar ();
2016-09-15 02:21:41 +00:00
if (ch == -1) break;
if (ch == 0) continue;
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
2016-09-29 22:04:12 +00:00
hc_thread_mutex_lock (status_ctx->mux_display);
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
switch (ch)
{
case 's':
case '\r':
case '\n':
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
status_display (hashcat_ctx);
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-09-21 14:07:49 +00:00
if (quiet == false) send_prompt ();
2016-09-15 02:21:41 +00:00
break;
case 'b':
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
bypass (hashcat_ctx);
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one");
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-09-21 14:07:49 +00:00
if (quiet == false) send_prompt ();
2016-09-15 02:21:41 +00:00
break;
case 'p':
event_log_info (hashcat_ctx, "");
SuspendThreads (hashcat_ctx);
2016-09-15 02:21:41 +00:00
if (status_ctx->devices_status == STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Paused");
}
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-09-21 14:07:49 +00:00
if (quiet == false) send_prompt ();
2016-09-15 02:21:41 +00:00
break;
case 'r':
event_log_info (hashcat_ctx, "");
ResumeThreads (hashcat_ctx);
2016-09-15 02:21:41 +00:00
if (status_ctx->devices_status == STATUS_RUNNING)
{
event_log_info (hashcat_ctx, "Resumed");
}
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-09-21 14:07:49 +00:00
if (quiet == false) send_prompt ();
2016-09-15 02:21:41 +00:00
break;
case 'c':
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-10-06 14:34:30 +00:00
stop_at_checkpoint (hashcat_ctx);
2016-09-15 02:21:41 +00:00
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-09-21 14:07:49 +00:00
if (quiet == false) send_prompt ();
2016-09-15 02:21:41 +00:00
break;
case 'q':
event_log_info (hashcat_ctx, "");
2016-09-15 02:21:41 +00:00
2016-10-16 17:32:43 +00:00
myquit (hashcat_ctx);
2016-09-15 02:21:41 +00:00
break;
}
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
2016-09-29 22:04:12 +00:00
hc_thread_mutex_unlock (status_ctx->mux_display);
2016-09-15 02:21:41 +00:00
}
tty_fix ();
}
void *thread_keypress (void *p)
{
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
keypress (hashcat_ctx);
2016-09-15 02:21:41 +00:00
return NULL;
2016-09-15 02:21:41 +00:00
}
#if defined (_WIN)
void SetConsoleWindowSize (const int x)
{
HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
if (h == INVALID_HANDLE_VALUE) return;
CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
if (!GetConsoleScreenBufferInfo (h, &bufferInfo)) return;
SMALL_RECT *sr = &bufferInfo.srWindow;
sr->Right = MAX (sr->Right, x - 1);
COORD co;
co.X = sr->Right + 1;
co.Y = 9999;
if (!SetConsoleScreenBufferSize (h, co)) return;
if (!SetConsoleWindowInfo (h, TRUE, sr)) return;
}
#endif
#if defined (__linux__)
static struct termios savemodes;
static int havemodes = 0;
int tty_break()
{
struct termios modmodes;
if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1;
havemodes = 1;
modmodes = savemodes;
modmodes.c_lflag &= ~ICANON;
modmodes.c_cc[VMIN] = 1;
modmodes.c_cc[VTIME] = 0;
return tcsetattr (fileno (stdin), TCSANOW, &modmodes);
}
int tty_getchar()
{
fd_set rfds;
FD_ZERO (&rfds);
FD_SET (fileno (stdin), &rfds);
struct timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
int retval = select (1, &rfds, NULL, NULL, &tv);
if (retval == 0) return 0;
if (retval == -1) return -1;
return getchar();
}
int tty_fix()
{
if (!havemodes) return 0;
return tcsetattr (fileno (stdin), TCSADRAIN, &savemodes);
}
#endif
#if defined(__APPLE__) || defined(__FreeBSD__)
static struct termios savemodes;
static int havemodes = 0;
int tty_break()
{
struct termios modmodes;
if (ioctl (fileno (stdin), TIOCGETA, &savemodes) < 0) return -1;
havemodes = 1;
modmodes = savemodes;
modmodes.c_lflag &= ~ICANON;
modmodes.c_cc[VMIN] = 1;
modmodes.c_cc[VTIME] = 0;
return ioctl (fileno (stdin), TIOCSETAW, &modmodes);
}
int tty_getchar()
{
fd_set rfds;
FD_ZERO (&rfds);
FD_SET (fileno (stdin), &rfds);
struct timeval tv;
tv.tv_sec = 1;
tv.tv_usec = 0;
int retval = select (1, &rfds, NULL, NULL, &tv);
if (retval == 0) return 0;
if (retval == -1) return -1;
return getchar();
}
int tty_fix()
{
if (!havemodes) return 0;
return ioctl (fileno (stdin), TIOCSETAW, &savemodes);
}
#endif
#if defined (_WIN)
static DWORD saveMode = 0;
int tty_break()
{
HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
GetConsoleMode (stdinHandle, &saveMode);
SetConsoleMode (stdinHandle, ENABLE_PROCESSED_INPUT);
return 0;
}
int tty_getchar()
{
HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
DWORD rc = WaitForSingleObject (stdinHandle, 1000);
if (rc == WAIT_TIMEOUT) return 0;
if (rc == WAIT_ABANDONED) return -1;
if (rc == WAIT_FAILED) return -1;
// The whole ReadConsoleInput () part is a workaround.
// For some unknown reason, maybe a mingw bug, a random signal
// is sent to stdin which unblocks WaitForSingleObject () and sets rc 0.
// Then it wants to read with getche () a keyboard input
// which has never been made.
INPUT_RECORD buf[100];
DWORD num = 0;
memset (buf, 0, sizeof (buf));
ReadConsoleInput (stdinHandle, buf, 100, &num);
FlushConsoleInputBuffer (stdinHandle);
for (DWORD i = 0; i < num; i++)
{
if (buf[i].EventType != KEY_EVENT) continue;
KEY_EVENT_RECORD KeyEvent = buf[i].Event.KeyEvent;
if (KeyEvent.bKeyDown != TRUE) continue;
return KeyEvent.uChar.AsciiChar;
}
return 0;
}
int tty_fix()
{
HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
SetConsoleMode (stdinHandle, saveMode);
return 0;
}
#endif
2016-10-16 17:32:43 +00:00
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
2016-10-16 17:32:43 +00:00
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
2016-10-16 17:32:43 +00:00
if (rc_status == -1)
2016-10-16 17:32:43 +00:00
{
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
return;
}
printf ("STATUS\t%u\t", hashcat_status->status_number);
2016-10-16 17:32:43 +00:00
printf ("SPEED\t");
2016-10-16 17:32:43 +00:00
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2016-10-16 17:32:43 +00:00
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
printf ("%" PRIu64 "\t", (u64) device_info->hashes_msec_dev);
// that 1\t is for backward compatibility
printf ("1\t");
2016-10-16 17:32:43 +00:00
}
printf ("EXEC_RUNTIME\t");
2016-10-16 17:32:43 +00:00
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2016-10-16 17:32:43 +00:00
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
printf ("%f\t", device_info->exec_msec_dev);
2016-10-16 17:32:43 +00:00
}
printf ("CURKU\t%" PRIu64 "\t", hashcat_status->restore_point);
2016-10-16 17:32:43 +00:00
printf ("PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip);
2016-10-16 17:32:43 +00:00
printf ("RECHASH\t%u\t%u\t", hashcat_status->digests_done, hashcat_status->digests_cnt);
2016-10-16 17:32:43 +00:00
printf ("RECSALT\t%u\t%u\t", hashcat_status->salts_done, hashcat_status->salts_cnt);
2016-10-16 17:32:43 +00:00
if (user_options->gpu_temp_disable == false)
{
printf ("TEMP\t");
2016-10-16 17:32:43 +00:00
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2016-10-16 17:32:43 +00:00
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
// ok, little cheat here...
2016-10-16 17:32:43 +00:00
const int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
2016-10-16 17:32:43 +00:00
printf ("%d\t", temp);
}
2016-10-16 17:32:43 +00:00
}
printf (EOL);
fflush (stdout);
2016-10-16 17:32:43 +00:00
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
}
void status_display (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
2016-10-16 17:32:43 +00:00
if (user_options->machine_readable == true)
2016-10-16 17:32:43 +00:00
{
status_display_machine_readable (hashcat_ctx);
2016-10-16 17:32:43 +00:00
return;
}
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
2016-10-16 17:32:43 +00:00
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
2016-10-16 17:32:43 +00:00
if (rc_status == -1)
2016-10-16 17:32:43 +00:00
{
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
return;
}
/**
* show something
*/
event_log_info (hashcat_ctx,
"Session........: %s",
hashcat_status->session);
event_log_info (hashcat_ctx,
"Status.........: %s (%u)",
hashcat_status->status_string,
hashcat_status->status_number);
event_log_info (hashcat_ctx,
"Time.Started...: %s (%s)",
hashcat_status->time_started_absolute,
hashcat_status->time_started_relative);
2016-10-16 17:32:43 +00:00
event_log_info (hashcat_ctx,
"Time.Estimated.: %s (%s)",
hashcat_status->time_estimated_absolute,
hashcat_status->time_estimated_relative);
event_log_info (hashcat_ctx,
"Hash.Type......: %s",
hashcat_status->hash_type);
event_log_info (hashcat_ctx,
"Hash.Target....: %s",
hashcat_status->hash_target);
switch (hashcat_status->input_mode)
2016-10-16 17:32:43 +00:00
{
case INPUT_MODE_STRAIGHT_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_STRAIGHT_FILE_RULES_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (%s)",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_STRAIGHT_FILE_RULES_GEN:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (Generated)");
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_STRAIGHT_STDIN:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_STRAIGHT_STDIN_RULES_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (%s)",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_STRAIGHT_STDIN_RULES_GEN:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (Generated)");
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_COMBINATOR_BASE_LEFT:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: File (%s), Right Side",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_COMBINATOR_BASE_RIGHT:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: File (%s), Left Side",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_MASK:
event_log_info (hashcat_ctx,
"Input.Mask.....: %s",
hashcat_status->input_base);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_MASK_CS:
event_log_info (hashcat_ctx,
"Input.Mask.....: %s",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_HYBRID1:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Right Side",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_HYBRID1_CS:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Right Side",
hashcat_status->input_mod);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_HYBRID2:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Left Side",
hashcat_status->input_mod);
2016-10-16 17:32:43 +00:00
break;
2016-10-16 17:32:43 +00:00
case INPUT_MODE_HYBRID2_CS:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Left Side",
hashcat_status->input_mod);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
2016-10-16 17:32:43 +00:00
break;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx,
"Candidates.#%d..: %s", device_id + 1,
device_info->input_candidates_dev);
}
switch (hashcat_status->progress_mode)
2016-10-17 14:22:32 +00:00
{
case PROGRESS_MODE_KEYSPACE_KNOWN:
event_log_info (hashcat_ctx,
"Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->progress_cur_relative_skip,
hashcat_status->progress_end_relative_skip,
hashcat_status->progress_finished_percent);
event_log_info (hashcat_ctx,
"Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->progress_rejected,
hashcat_status->progress_cur_relative_skip,
hashcat_status->progress_rejected_percent);
event_log_info (hashcat_ctx,
"Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->restore_point,
hashcat_status->restore_total,
hashcat_status->restore_percent);
2016-10-17 14:22:32 +00:00
break;
2016-10-17 14:22:32 +00:00
case PROGRESS_MODE_KEYSPACE_UNKNOWN:
event_log_info (hashcat_ctx,
"Progress.......: %" PRIu64,
hashcat_status->progress_cur_relative_skip);
event_log_info (hashcat_ctx,
"Rejected.......: %" PRIu64,
hashcat_status->progress_rejected);
event_log_info (hashcat_ctx,
"Restore.Point..: %" PRIu64,
hashcat_status->restore_point);
2016-10-17 14:22:32 +00:00
break;
}
event_log_info (hashcat_ctx,
"Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts",
hashcat_status->digests_done,
hashcat_status->digests_cnt,
hashcat_status->digests_percent,
hashcat_status->salts_done,
hashcat_status->salts_cnt,
hashcat_status->salts_percent);
2016-10-16 17:32:43 +00:00
event_log_info (hashcat_ctx,
"Recovered/Time.: %s",
hashcat_status->cpt);
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
event_log_info (hashcat_ctx,
"Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1,
device_info->speed_sec_dev,
device_info->exec_msec_dev);
2016-10-16 17:32:43 +00:00
}
if (hashcat_status->device_info_active > 1)
{
event_log_info (hashcat_ctx,
"Speed.Dev.#*...: %9sH/s",
hashcat_status->speed_sec_all);
}
2016-10-16 17:32:43 +00:00
if (user_options->gpu_temp_disable == false)
{
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
event_log_info (hashcat_ctx,
"HWMon.Dev.#%d...: %s", device_id + 1,
device_info->hwmon_dev);
2016-10-16 17:32:43 +00:00
}
}
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
}
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
2016-10-17 15:20:19 +00:00
const u32 hash_mode = hashconfig->hash_mode;
2016-10-16 17:32:43 +00:00
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
2016-10-16 17:32:43 +00:00
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
2016-10-16 17:32:43 +00:00
if (rc_status == -1)
2016-10-16 17:32:43 +00:00
{
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
return;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2016-10-16 17:32:43 +00:00
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (device_info->hashes_msec_dev_benchmark * 1000));
2016-10-16 17:32:43 +00:00
}
hcfree (hashcat_status);
}
void status_benchmark (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
2016-10-16 17:32:43 +00:00
if (user_options->machine_readable == true)
{
status_benchmark_automate (hashcat_ctx);
return;
}
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
2016-10-16 17:32:43 +00:00
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
2016-10-16 17:32:43 +00:00
if (rc_status == -1)
2016-10-16 17:32:43 +00:00
{
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
return;
2016-10-16 17:32:43 +00:00
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2016-10-16 17:32:43 +00:00
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2016-10-16 17:32:43 +00:00
if (device_info->skipped_dev == true) continue;
2016-10-16 17:32:43 +00:00
event_log_info (hashcat_ctx,
"Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1,
device_info->speed_sec_dev,
device_info->exec_msec_dev);
2016-10-16 17:32:43 +00:00
}
if (hashcat_status->device_info_active > 1)
2016-10-16 17:32:43 +00:00
{
event_log_info (hashcat_ctx,
"Speed.Dev.#*...: %9sH/s",
hashcat_status->speed_sec_all);
2016-10-16 17:32:43 +00:00
}
hcfree (hashcat_status);
2016-10-16 17:32:43 +00:00
}