1 /**
2 * Author......: See docs/credits.txt
3 * License.....: MIT
4 */
5
6 #include "common.h"
7 #include "types.h"
8 #include "memory.h"
9 #include "event.h"
10 #include "convert.h"
11 #include "thread.h"
12 #include "status.h"
13 #include "shared.h"
14 #include "hwmon.h"
15 #include "interface.h"
16 #include "hashcat.h"
17 #include "timer.h"
18 #include "terminal.h"
19
20 static const size_t TERMINAL_LINE_LENGTH = 79;
21
22 static const char *const PROMPT_ACTIVE = "[s]tatus [p]ause [b]ypass [c]heckpoint [f]inish [q]uit => ";
23 static const char *const PROMPT_PAUSED = "[s]tatus [r]esume [b]ypass [c]heckpoint [f]inish [q]uit => ";
24
welcome_screen(hashcat_ctx_t * hashcat_ctx,const char * version_tag)25 void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag)
26 {
27 const user_options_t *user_options = hashcat_ctx->user_options;
28
29 if (user_options->quiet == true) return;
30 if (user_options->keyspace == true) return;
31 if (user_options->stdout_flag == true) return;
32 if (user_options->show == true) return;
33 if (user_options->left == true) return;
34 if (user_options->identify == true) return;
35
36 if (user_options->usage == true)
37 {
38 event_log_info (hashcat_ctx, "%s (%s) starting in help mode", PROGNAME, version_tag);
39 event_log_info (hashcat_ctx, NULL);
40 }
41 else if (user_options->benchmark == true)
42 {
43 if (user_options->machine_readable == false)
44 {
45 event_log_info (hashcat_ctx, "%s (%s) starting in benchmark mode", PROGNAME, version_tag);
46
47 event_log_info (hashcat_ctx, NULL);
48
49 if (user_options->workload_profile_chgd == false)
50 {
51 event_log_advice (hashcat_ctx, "Benchmarking uses hand-optimized kernel code by default.");
52 event_log_advice (hashcat_ctx, "You can use it in your cracking session by setting the -O option.");
53 event_log_advice (hashcat_ctx, "Note: Using optimized kernel code limits the maximum supported password length.");
54 event_log_advice (hashcat_ctx, "To disable the optimized kernel code in benchmark mode, use the -w option.");
55 event_log_advice (hashcat_ctx, NULL);
56 }
57 }
58 else
59 {
60 event_log_info (hashcat_ctx, "# version: %s", version_tag);
61 }
62 }
63 else if (user_options->restore == true)
64 {
65 event_log_info (hashcat_ctx, "%s (%s) starting in restore mode", PROGNAME, version_tag);
66 event_log_info (hashcat_ctx, NULL);
67 }
68 else if (user_options->speed_only == true)
69 {
70 event_log_info (hashcat_ctx, "%s (%s) starting in speed-only mode", PROGNAME, version_tag);
71 event_log_info (hashcat_ctx, NULL);
72 }
73 else if (user_options->progress_only == true)
74 {
75 event_log_info (hashcat_ctx, "%s (%s) starting in progress-only mode", PROGNAME, version_tag);
76 event_log_info (hashcat_ctx, NULL);
77 }
78 else if (user_options->backend_info == true)
79 {
80 event_log_info (hashcat_ctx, "%s (%s) starting in backend information mode", PROGNAME, version_tag);
81 event_log_info (hashcat_ctx, NULL);
82 }
83 else if (user_options->hash_mode_chgd == false)
84 {
85 event_log_info (hashcat_ctx, "%s (%s) starting in autodetect mode", PROGNAME, version_tag);
86 event_log_info (hashcat_ctx, NULL);
87 }
88 else if (user_options->hash_info == true)
89 {
90 event_log_info (hashcat_ctx, "%s (%s) starting in hash-info mode", PROGNAME, version_tag);
91 event_log_info (hashcat_ctx, NULL);
92 }
93 else
94 {
95 event_log_info (hashcat_ctx, "%s (%s) starting", PROGNAME, version_tag);
96 event_log_info (hashcat_ctx, NULL);
97 }
98
99 if (user_options->force == true)
100 {
101 event_log_warning (hashcat_ctx, "You have enabled --force to bypass dangerous warnings and errors!");
102 event_log_warning (hashcat_ctx, "This can hide serious problems and should only be done when debugging.");
103 event_log_warning (hashcat_ctx, "Do not report hashcat issues encountered when using --force.");
104 event_log_warning (hashcat_ctx, NULL);
105 }
106 }
107
goodbye_screen(hashcat_ctx_t * hashcat_ctx,const time_t proc_start,const time_t proc_stop)108 void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop)
109 {
110 const user_options_t *user_options = hashcat_ctx->user_options;
111
112 if (user_options->quiet == true) return;
113 if (user_options->keyspace == true) return;
114 if (user_options->stdout_flag == true) return;
115 if (user_options->show == true) return;
116 if (user_options->left == true) return;
117 if (user_options->identify == true) return;
118
119 char start_buf[32]; memset (start_buf, 0, sizeof (start_buf));
120 char stop_buf[32]; memset (stop_buf, 0, sizeof (stop_buf));
121
122 event_log_info_nn (hashcat_ctx, "Started: %s", ctime_r (&proc_start, start_buf));
123 event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime_r (&proc_stop, stop_buf));
124 }
125
setup_console()126 int setup_console ()
127 {
128 #if defined (_WIN)
129 SetConsoleWindowSize (132);
130
131 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
132 {
133 __mingw_fprintf (stderr, "%s: %m", "stdin");
134
135 return -1;
136 }
137
138 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
139 {
140 __mingw_fprintf (stderr, "%s: %m", "stdin"); // stdout ?
141
142 return -1;
143 }
144
145 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
146 {
147 __mingw_fprintf (stderr, "%s: %m", "stdin"); // stderr ?
148
149 return -1;
150 }
151 #endif
152
153 return 0;
154 }
155
send_prompt(hashcat_ctx_t * hashcat_ctx)156 void send_prompt (hashcat_ctx_t *hashcat_ctx)
157 {
158 const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
159
160 if (status_ctx->devices_status == STATUS_PAUSED)
161 {
162 fprintf (stdout, "%s", PROMPT_PAUSED);
163 }
164 else
165 {
166 fprintf (stdout, "%s", PROMPT_ACTIVE);
167 }
168
169 fflush (stdout);
170 }
171
clear_prompt(hashcat_ctx_t * hashcat_ctx)172 void clear_prompt (hashcat_ctx_t *hashcat_ctx)
173 {
174 const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
175
176 size_t prompt_sz = 0;
177
178 if (status_ctx->devices_status == STATUS_PAUSED)
179 {
180 prompt_sz = strlen (PROMPT_PAUSED);
181 }
182 else
183 {
184 prompt_sz = strlen (PROMPT_ACTIVE);
185 }
186
187 fputc ('\r', stdout);
188
189 for (size_t i = 0; i < prompt_sz; i++)
190 {
191 fputc (' ', stdout);
192 }
193
194 fputc ('\r', stdout);
195
196 fflush (stdout);
197 }
198
keypress(hashcat_ctx_t * hashcat_ctx)199 static void keypress (hashcat_ctx_t *hashcat_ctx)
200 {
201 status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
202 user_options_t *user_options = hashcat_ctx->user_options;
203
204 // this is required, because some of the variables down there are not initialized at that point
205 while (status_ctx->devices_status == STATUS_INIT) usleep (100000);
206
207 const bool quiet = user_options->quiet;
208
209 tty_break ();
210
211 while (status_ctx->shutdown_outer == false)
212 {
213 int ch = tty_getchar ();
214
215 if (ch == -1) break;
216
217 if (ch == 0) continue;
218
219 //https://github.com/hashcat/hashcat/issues/302
220 //#if defined (_POSIX)
221 //if (ch != '\n')
222 //#endif
223
224 hc_thread_mutex_lock (status_ctx->mux_display);
225
226 event_log_info (hashcat_ctx, NULL);
227
228 switch (ch)
229 {
230 case 's':
231 case '\r':
232 case '\n':
233
234 event_log_info (hashcat_ctx, NULL);
235
236 status_display (hashcat_ctx);
237
238 event_log_info (hashcat_ctx, NULL);
239
240 if (quiet == false) send_prompt (hashcat_ctx);
241
242 break;
243
244 case 'b':
245
246 event_log_info (hashcat_ctx, NULL);
247
248 bypass (hashcat_ctx);
249
250 event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected. Bypassing current one.");
251
252 event_log_info (hashcat_ctx, NULL);
253
254 if (quiet == false) send_prompt (hashcat_ctx);
255
256 break;
257
258 case 'p':
259
260 if (status_ctx->devices_status != STATUS_PAUSED)
261 {
262 event_log_info (hashcat_ctx, NULL);
263
264 time_t now;
265
266 time (&now);
267
268 SuspendThreads (hashcat_ctx);
269
270 if (status_ctx->devices_status == STATUS_PAUSED)
271 {
272 char buf[32] = { 0 };
273
274 char *pause_time = ctime_r (&now, buf);
275
276 const size_t pause_time_len = strlen (pause_time);
277
278 if (pause_time[pause_time_len - 1] == '\n') pause_time[pause_time_len - 1] = 0;
279 if (pause_time[pause_time_len - 2] == '\r') pause_time[pause_time_len - 2] = 0;
280
281 event_log_info (hashcat_ctx, "Paused at %s", pause_time);
282 }
283
284 event_log_info (hashcat_ctx, NULL);
285 }
286
287 if (quiet == false) send_prompt (hashcat_ctx);
288
289 break;
290
291 case 'r':
292
293 if (status_ctx->devices_status == STATUS_PAUSED)
294 {
295 event_log_info (hashcat_ctx, NULL);
296
297 time_t now;
298
299 time (&now);
300
301 const double msec_paused = hc_timer_get (status_ctx->timer_paused);
302
303 ResumeThreads (hashcat_ctx);
304
305 if (status_ctx->devices_status != STATUS_PAUSED)
306 {
307 char buf[32] = { 0 };
308
309 char *resume_time = ctime_r (&now, buf);
310
311 const size_t resume_time_len = strlen (resume_time);
312
313 if (resume_time[resume_time_len - 1] == '\n') resume_time[resume_time_len - 1] = 0;
314 if (resume_time[resume_time_len - 2] == '\r') resume_time[resume_time_len - 2] = 0;
315
316 struct tm *tmp;
317 struct tm tm;
318
319 time_t sec_run = msec_paused / 1000;
320
321 tmp = gmtime_r (&sec_run, &tm);
322
323 char *display_pause = (char *) hcmalloc (HCBUFSIZ_TINY);
324
325 format_timer_display (tmp, display_pause, HCBUFSIZ_TINY);
326
327 event_log_info (hashcat_ctx, "Resumed at %s (paused for %s)", resume_time, display_pause);
328
329 hcfree (display_pause);
330 }
331
332 event_log_info (hashcat_ctx, NULL);
333 }
334
335 if (quiet == false) send_prompt (hashcat_ctx);
336
337 break;
338
339 case 'c':
340
341 event_log_info (hashcat_ctx, NULL);
342
343 stop_at_checkpoint (hashcat_ctx);
344
345 if (status_ctx->checkpoint_shutdown == true)
346 {
347 event_log_info (hashcat_ctx, "Checkpoint enabled. Will quit at next restore-point update.");
348 }
349 else
350 {
351 event_log_info (hashcat_ctx, "Checkpoint disabled. Restore-point updates will no longer be monitored.");
352 }
353
354 event_log_info (hashcat_ctx, NULL);
355
356 if (quiet == false) send_prompt (hashcat_ctx);
357
358 break;
359
360 case 'f':
361
362 event_log_info (hashcat_ctx, NULL);
363
364 finish_after_attack (hashcat_ctx);
365
366 if (status_ctx->finish_shutdown == true)
367 {
368 event_log_info (hashcat_ctx, "Finish enabled. Will quit after this attack.");
369 }
370 else
371 {
372 event_log_info (hashcat_ctx, "Finish disabled. Will continue after this attack.");
373 }
374
375 event_log_info (hashcat_ctx, NULL);
376
377 if (quiet == false) send_prompt (hashcat_ctx);
378
379 break;
380
381 case 'q':
382
383 event_log_info (hashcat_ctx, NULL);
384
385 myquit (hashcat_ctx);
386
387 break;
388
389 default:
390
391 if (quiet == false) send_prompt (hashcat_ctx);
392
393 break;
394 }
395
396 //https://github.com/hashcat/hashcat/issues/302
397 //#if defined (_POSIX)
398 //if (ch != '\n')
399 //#endif
400
401 hc_thread_mutex_unlock (status_ctx->mux_display);
402 }
403
404 tty_fix ();
405 }
406
thread_keypress(void * p)407 HC_API_CALL void *thread_keypress (void *p)
408 {
409 hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
410
411 keypress (hashcat_ctx);
412
413 return NULL;
414 }
415
416 #if defined (_WIN)
SetConsoleWindowSize(const int x)417 void SetConsoleWindowSize (const int x)
418 {
419 HANDLE h = GetStdHandle (STD_OUTPUT_HANDLE);
420
421 if (h == INVALID_HANDLE_VALUE) return;
422
423 CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
424
425 if (!GetConsoleScreenBufferInfo (h, &bufferInfo)) return;
426
427 SMALL_RECT *sr = &bufferInfo.srWindow;
428
429 sr->Right = MAX (sr->Right, x - 1);
430
431 COORD co;
432
433 co.X = sr->Right + 1;
434 co.Y = 9999;
435
436 if (!SetConsoleScreenBufferSize (h, co)) return;
437
438 if (!SetConsoleWindowInfo (h, TRUE, sr)) return;
439 }
440 #endif
441
442 #if defined (__linux__) || defined (__CYGWIN__)
443 static struct termios savemodes;
444 static int havemodes = 0;
445
tty_break()446 int tty_break ()
447 {
448 struct termios modmodes;
449
450 if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1;
451
452 havemodes = 1;
453
454 modmodes = savemodes;
455 modmodes.c_lflag &= ~ICANON;
456 modmodes.c_cc[VMIN] = 1;
457 modmodes.c_cc[VTIME] = 0;
458
459 return tcsetattr (fileno (stdin), TCSANOW, &modmodes);
460 }
461
tty_getchar()462 int tty_getchar ()
463 {
464 fd_set rfds;
465
466 FD_ZERO (&rfds);
467
468 FD_SET (fileno (stdin), &rfds);
469
470 struct timeval tv;
471
472 tv.tv_sec = 1;
473 tv.tv_usec = 0;
474
475 int retval = select (1, &rfds, NULL, NULL, &tv);
476
477 if (retval == 0) return 0;
478 if (retval == -1) return -1;
479
480 return getchar();
481 }
482
tty_fix()483 int tty_fix ()
484 {
485 if (!havemodes) return 0;
486
487 return tcsetattr (fileno (stdin), TCSADRAIN, &savemodes);
488 }
489 #endif
490
491 #if defined (__APPLE__) || defined (__FreeBSD__) || defined(__DragonFly__)
492 static struct termios savemodes;
493 static int havemodes = 0;
494
tty_break()495 int tty_break ()
496 {
497 struct termios modmodes;
498
499 if (ioctl (fileno (stdin), TIOCGETA, &savemodes) < 0) return -1;
500
501 havemodes = 1;
502
503 modmodes = savemodes;
504 modmodes.c_lflag &= ~ICANON;
505 modmodes.c_cc[VMIN] = 1;
506 modmodes.c_cc[VTIME] = 0;
507
508 return ioctl (fileno (stdin), TIOCSETAW, &modmodes);
509 }
510
tty_getchar()511 int tty_getchar ()
512 {
513 fd_set rfds;
514
515 FD_ZERO (&rfds);
516
517 FD_SET (fileno (stdin), &rfds);
518
519 struct timeval tv;
520
521 tv.tv_sec = 1;
522 tv.tv_usec = 0;
523
524 int retval = select (1, &rfds, NULL, NULL, &tv);
525
526 if (retval == 0) return 0;
527 if (retval == -1) return -1;
528
529 return getchar();
530 }
531
tty_fix()532 int tty_fix ()
533 {
534 if (!havemodes) return 0;
535
536 return ioctl (fileno (stdin), TIOCSETAW, &savemodes);
537 }
538 #endif
539
540 #if defined (_WIN)
541 static DWORD saveMode = 0;
542
tty_break()543 int tty_break ()
544 {
545 HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
546
547 GetConsoleMode (stdinHandle, &saveMode);
548 SetConsoleMode (stdinHandle, ENABLE_PROCESSED_INPUT);
549
550 return 0;
551 }
552
tty_getchar()553 int tty_getchar ()
554 {
555 HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
556
557 DWORD rc = WaitForSingleObject (stdinHandle, 1000);
558
559 if (rc == WAIT_TIMEOUT) return 0;
560 if (rc == WAIT_ABANDONED) return -1;
561 if (rc == WAIT_FAILED) return -1;
562
563 // The whole ReadConsoleInput () part is a workaround.
564 // For some unknown reason, maybe a mingw bug, a random signal
565 // is sent to stdin which unblocks WaitForSingleObject () and sets rc 0.
566 // Then it wants to read with getche () a keyboard input
567 // which has never been made.
568
569 INPUT_RECORD buf[100];
570
571 DWORD num = 0;
572
573 memset (buf, 0, sizeof (buf));
574
575 ReadConsoleInput (stdinHandle, buf, 100, &num);
576
577 FlushConsoleInputBuffer (stdinHandle);
578
579 for (DWORD i = 0; i < num; i++)
580 {
581 if (buf[i].EventType != KEY_EVENT) continue;
582
583 KEY_EVENT_RECORD KeyEvent = buf[i].Event.KeyEvent;
584
585 if (KeyEvent.bKeyDown != TRUE) continue;
586
587 return KeyEvent.uChar.AsciiChar;
588 }
589
590 return 0;
591 }
592
tty_fix()593 int tty_fix ()
594 {
595 HANDLE stdinHandle = GetStdHandle (STD_INPUT_HANDLE);
596
597 SetConsoleMode (stdinHandle, saveMode);
598
599 return 0;
600 }
601 #endif
602
compress_terminal_line_length(char * out_buf,const size_t keep_from_beginning,const size_t keep_from_end)603 void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginning, const size_t keep_from_end)
604 {
605 const size_t target_len = TERMINAL_LINE_LENGTH - keep_from_beginning;
606
607 const size_t out_len = strlen (out_buf);
608
609 if (out_len < target_len) return;
610
611 char *ptr1 = out_buf + target_len - 3 - keep_from_end;
612 char *ptr2 = out_buf + out_len - keep_from_end;
613
614 *ptr1++ = '.';
615 *ptr1++ = '.';
616 *ptr1++ = '.';
617
618 for (size_t i = 0; i < keep_from_end; i++)
619 {
620 *ptr1++ = *ptr2++;
621 }
622
623 *ptr1 = 0;
624 }
625
hash_info_single(hashcat_ctx_t * hashcat_ctx,user_options_extra_t * user_options_extra)626 void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra)
627 {
628 if (hashconfig_init (hashcat_ctx) == 0)
629 {
630 hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
631
632 event_log_info (hashcat_ctx, "Hash mode #%u", hashconfig->hash_mode);
633 event_log_info (hashcat_ctx, " Name................: %s", hashconfig->hash_name);
634 event_log_info (hashcat_ctx, " Category............: %s", strhashcategory (hashconfig->hash_category));
635 event_log_info (hashcat_ctx, " Slow.Hash...........: %s", (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) ? "No" : "Yes");
636
637 event_log_info (hashcat_ctx, " Password.Len.Min....: %d", hashconfig->pw_min);
638 event_log_info (hashcat_ctx, " Password.Len.Max....: %d", hashconfig->pw_max);
639
640 if (hashconfig->is_salted == true)
641 {
642 u32 t = hashconfig->salt_type;
643 const char *t_desc = (t == SALT_TYPE_EMBEDDED) ? "Embedded\0" : (t == SALT_TYPE_GENERIC) ? "Generic\0" : "Virtual\0";
644 event_log_info (hashcat_ctx, " Salt.Type...........: %s", t_desc);
645 event_log_info (hashcat_ctx, " Salt.Len.Min........: %d", hashconfig->salt_min);
646 event_log_info (hashcat_ctx, " Salt.Len.Max........: %d", hashconfig->salt_max);
647 }
648
649 // almost always 1 and -1
650 //event_log_info (hashcat_ctx, " Hashes.Count.Min....: %d", hashconfig->hashes_count_min);
651 //event_log_info (hashcat_ctx, " Hashes.Count.Max....: %u", hashconfig->hashes_count_max);
652
653 if ((hashconfig->has_pure_kernel) && (hashconfig->has_optimized_kernel))
654 {
655 event_log_info (hashcat_ctx, " Kernel.Type(s)......: pure, optimized");
656 }
657 else if (hashconfig->has_pure_kernel)
658 {
659 event_log_info (hashcat_ctx, " Kernel.Type(s)......: pure");
660 }
661 else if (hashconfig->has_optimized_kernel)
662 {
663 event_log_info (hashcat_ctx, " Kernel.Type(s)......: optimized");
664 }
665
666 if ((hashconfig->st_hash != NULL) && (hashconfig->st_pass != NULL))
667 {
668 if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
669 {
670 event_log_info (hashcat_ctx, " Example.Hash.Format.: hex-encoded");
671 event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash);
672 }
673 else
674 {
675 event_log_info (hashcat_ctx, " Example.Hash.Format.: plain");
676 event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash);
677 }
678
679 if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options_extra->separator, false))
680 {
681 char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
682
683 int tmp_len = 0;
684
685 tmp_buf[tmp_len++] = '$';
686 tmp_buf[tmp_len++] = 'H';
687 tmp_buf[tmp_len++] = 'E';
688 tmp_buf[tmp_len++] = 'X';
689 tmp_buf[tmp_len++] = '[';
690
691 exec_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), (u8 *) tmp_buf + tmp_len);
692
693 tmp_len += strlen (hashconfig->st_pass) * 2;
694
695 tmp_buf[tmp_len++] = ']';
696 tmp_buf[tmp_len++] = 0;
697
698 event_log_info (hashcat_ctx, " Example.Pass........: %s", tmp_buf);
699
700 hcfree (tmp_buf);
701 }
702 else
703 {
704 event_log_info (hashcat_ctx, " Example.Pass........: %s", hashconfig->st_pass);
705 }
706 }
707 else
708 {
709 event_log_info (hashcat_ctx, " Example.Hash.Format.: N/A");
710 event_log_info (hashcat_ctx, " Example.Hash........: N/A");
711 event_log_info (hashcat_ctx, " Example.Pass........: N/A");
712 }
713
714 if (hashconfig->benchmark_mask != NULL)
715 {
716 event_log_info (hashcat_ctx, " Benchmark.Mask......: %s", hashconfig->benchmark_mask);
717 }
718 else
719 {
720 event_log_info (hashcat_ctx, " Benchmark.Mask......: N/A");
721 }
722
723 event_log_info (hashcat_ctx, NULL);
724 }
725
726 hashconfig_destroy (hashcat_ctx);
727 }
728
hash_info(hashcat_ctx_t * hashcat_ctx)729 void hash_info (hashcat_ctx_t *hashcat_ctx)
730 {
731 folder_config_t *folder_config = hashcat_ctx->folder_config;
732 user_options_t *user_options = hashcat_ctx->user_options;
733 user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
734
735 event_log_info (hashcat_ctx, "Hash Info:");
736 event_log_info (hashcat_ctx, "==========");
737 event_log_info (hashcat_ctx, NULL);
738
739 if (user_options->hash_mode_chgd == true)
740 {
741 hash_info_single (hashcat_ctx, user_options_extra);
742 }
743 else
744 {
745 char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY);
746
747 for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++)
748 {
749 user_options->hash_mode = i;
750
751 module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY);
752
753 if (hc_path_exist (modulefile) == false) continue;
754
755 hash_info_single (hashcat_ctx, user_options_extra);
756 }
757
758 hcfree (modulefile);
759 }
760 }
761
backend_info(hashcat_ctx_t * hashcat_ctx)762 void backend_info (hashcat_ctx_t *hashcat_ctx)
763 {
764 const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
765
766 if (backend_ctx->cuda)
767 {
768 event_log_info (hashcat_ctx, "CUDA Info:");
769 event_log_info (hashcat_ctx, "==========");
770 event_log_info (hashcat_ctx, NULL);
771
772 int cuda_devices_cnt = backend_ctx->cuda_devices_cnt;
773 int cuda_driver_version = backend_ctx->cuda_driver_version;
774
775 event_log_info (hashcat_ctx, "CUDA.Version.: %d.%d", cuda_driver_version / 1000, (cuda_driver_version % 100) / 10);
776 event_log_info (hashcat_ctx, NULL);
777
778 for (int cuda_devices_idx = 0; cuda_devices_idx < cuda_devices_cnt; cuda_devices_idx++)
779 {
780 const int backend_devices_idx = backend_ctx->backend_device_from_cuda[cuda_devices_idx];
781
782 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
783
784 int device_id = device_param->device_id;
785 char *device_name = device_param->device_name;
786 u32 device_processors = device_param->device_processors;
787 u32 device_maxclock_frequency = device_param->device_maxclock_frequency;
788 u64 device_available_mem = device_param->device_available_mem;
789 u64 device_global_mem = device_param->device_global_mem;
790 u8 pcie_domain = device_param->pcie_domain;
791 u8 pcie_bus = device_param->pcie_bus;
792 u8 pcie_device = device_param->pcie_device;
793 u8 pcie_function = device_param->pcie_function;
794
795 if (device_param->device_id_alias_cnt)
796 {
797 event_log_info (hashcat_ctx, "Backend Device ID #%d (Alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1);
798 }
799 else
800 {
801 event_log_info (hashcat_ctx, "Backend Device ID #%d", device_id + 1);
802 }
803
804 event_log_info (hashcat_ctx, " Name...........: %s", device_name);
805 event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors);
806 event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency);
807 event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB", device_global_mem / 1024 / 1024);
808 event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024);
809 event_log_info (hashcat_ctx, " PCI.Addr.BDFe..: %04x:%02x:%02x.%d", (u16) pcie_domain, pcie_bus, pcie_device, pcie_function);
810 event_log_info (hashcat_ctx, NULL);
811 }
812 }
813
814 if (backend_ctx->hip)
815 {
816 event_log_info (hashcat_ctx, "HIP Info:");
817 event_log_info (hashcat_ctx, "=========");
818 event_log_info (hashcat_ctx, NULL);
819
820 int hip_devices_cnt = backend_ctx->hip_devices_cnt;
821 int hip_runtimeVersion = backend_ctx->hip_runtimeVersion;
822
823 if (hip_runtimeVersion > 1000)
824 {
825 int hip_version_major = (hip_runtimeVersion - 0) / 10000000;
826 int hip_version_minor = (hip_runtimeVersion - (hip_version_major * 10000000)) / 100000;
827 int hip_version_patch = (hip_runtimeVersion - (hip_version_major * 10000000) - (hip_version_minor * 100000));
828
829 event_log_info (hashcat_ctx, "HIP.Version.: %d.%d.%d", hip_version_major, hip_version_minor, hip_version_patch);
830 event_log_info (hashcat_ctx, NULL);
831 }
832 else
833 {
834 event_log_info (hashcat_ctx, "HIP.Version.: %d.%d", hip_runtimeVersion / 100, hip_runtimeVersion % 10);
835 event_log_info (hashcat_ctx, NULL);
836 }
837
838 for (int hip_devices_idx = 0; hip_devices_idx < hip_devices_cnt; hip_devices_idx++)
839 {
840 const int backend_devices_idx = backend_ctx->backend_device_from_hip[hip_devices_idx];
841
842 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
843
844 int device_id = device_param->device_id;
845 char *device_name = device_param->device_name;
846 u32 device_processors = device_param->device_processors;
847 u32 device_maxclock_frequency = device_param->device_maxclock_frequency;
848 u64 device_available_mem = device_param->device_available_mem;
849 u64 device_global_mem = device_param->device_global_mem;
850 u8 pcie_domain = device_param->pcie_domain;
851 u8 pcie_bus = device_param->pcie_bus;
852 u8 pcie_device = device_param->pcie_device;
853 u8 pcie_function = device_param->pcie_function;
854
855 if (device_param->device_id_alias_cnt)
856 {
857 event_log_info (hashcat_ctx, "Backend Device ID #%d (Alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1);
858 }
859 else
860 {
861 event_log_info (hashcat_ctx, "Backend Device ID #%d", device_id + 1);
862 }
863
864 event_log_info (hashcat_ctx, " Name...........: %s", device_name);
865 event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors);
866 event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency);
867 event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB", device_global_mem / 1024 / 1024);
868 event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024);
869 event_log_info (hashcat_ctx, " PCI.Addr.BDFe..: %04x:%02x:%02x.%d", (u16) pcie_domain, pcie_bus, pcie_device, pcie_function);
870 event_log_info (hashcat_ctx, NULL);
871 }
872 }
873
874 if (backend_ctx->ocl)
875 {
876 event_log_info (hashcat_ctx, "OpenCL Info:");
877 event_log_info (hashcat_ctx, "============");
878 event_log_info (hashcat_ctx, NULL);
879
880 cl_uint opencl_platforms_cnt = backend_ctx->opencl_platforms_cnt;
881 cl_uint *opencl_platforms_devices_cnt = backend_ctx->opencl_platforms_devices_cnt;
882 char **opencl_platforms_name = backend_ctx->opencl_platforms_name;
883 char **opencl_platforms_vendor = backend_ctx->opencl_platforms_vendor;
884 char **opencl_platforms_version = backend_ctx->opencl_platforms_version;
885
886 for (cl_uint opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++)
887 {
888 char *opencl_platform_vendor = opencl_platforms_vendor[opencl_platforms_idx];
889 char *opencl_platform_name = opencl_platforms_name[opencl_platforms_idx];
890 char *opencl_platform_version = opencl_platforms_version[opencl_platforms_idx];
891 cl_uint opencl_platform_devices_cnt = opencl_platforms_devices_cnt[opencl_platforms_idx];
892
893 event_log_info (hashcat_ctx, "OpenCL Platform ID #%u", opencl_platforms_idx + 1);
894 event_log_info (hashcat_ctx, " Vendor..: %s", opencl_platform_vendor);
895 event_log_info (hashcat_ctx, " Name....: %s", opencl_platform_name);
896 event_log_info (hashcat_ctx, " Version.: %s", opencl_platform_version);
897 event_log_info (hashcat_ctx, NULL);
898
899 for (cl_uint opencl_platform_devices_idx = 0; opencl_platform_devices_idx < opencl_platform_devices_cnt; opencl_platform_devices_idx++)
900 {
901 const int backend_devices_idx = backend_ctx->backend_device_from_opencl_platform[opencl_platforms_idx][opencl_platform_devices_idx];
902
903 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
904
905 int device_id = device_param->device_id;
906 char *device_name = device_param->device_name;
907 u32 device_processors = device_param->device_processors;
908 u32 device_maxclock_frequency = device_param->device_maxclock_frequency;
909 u64 device_maxmem_alloc = device_param->device_maxmem_alloc;
910 u64 device_available_mem = device_param->device_available_mem;
911 u64 device_global_mem = device_param->device_global_mem;
912 cl_device_type opencl_device_type = device_param->opencl_device_type;
913 cl_uint opencl_device_vendor_id = device_param->opencl_device_vendor_id;
914 char *opencl_device_vendor = device_param->opencl_device_vendor;
915 char *opencl_device_c_version = device_param->opencl_device_c_version;
916 char *opencl_device_version = device_param->opencl_device_version;
917 char *opencl_driver_version = device_param->opencl_driver_version;
918
919 if (device_param->device_id_alias_cnt)
920 {
921 event_log_info (hashcat_ctx, " Backend Device ID #%d (Alias: #%d)", device_id + 1, device_param->device_id_alias_buf[0] + 1);
922 }
923 else
924 {
925 event_log_info (hashcat_ctx, " Backend Device ID #%d", device_id + 1);
926 }
927
928 event_log_info (hashcat_ctx, " Type...........: %s", ((opencl_device_type & CL_DEVICE_TYPE_CPU) ? "CPU" : ((opencl_device_type & CL_DEVICE_TYPE_GPU) ? "GPU" : "Accelerator")));
929 event_log_info (hashcat_ctx, " Vendor.ID......: %u", opencl_device_vendor_id);
930 event_log_info (hashcat_ctx, " Vendor.........: %s", opencl_device_vendor);
931 event_log_info (hashcat_ctx, " Name...........: %s", device_name);
932 event_log_info (hashcat_ctx, " Version........: %s", opencl_device_version);
933 event_log_info (hashcat_ctx, " Processor(s)...: %u", device_processors);
934 event_log_info (hashcat_ctx, " Clock..........: %u", device_maxclock_frequency);
935 event_log_info (hashcat_ctx, " Memory.Total...: %" PRIu64 " MB (limited to %" PRIu64 " MB allocatable in one block)", device_global_mem / 1024 / 1024, device_maxmem_alloc / 1024 / 1024);
936 event_log_info (hashcat_ctx, " Memory.Free....: %" PRIu64 " MB", device_available_mem / 1024 / 1024);
937 event_log_info (hashcat_ctx, " OpenCL.Version.: %s", opencl_device_c_version);
938 event_log_info (hashcat_ctx, " Driver.Version.: %s", opencl_driver_version);
939
940 if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
941 {
942 u8 pcie_bus = device_param->pcie_bus;
943 u8 pcie_device = device_param->pcie_device;
944 u8 pcie_function = device_param->pcie_function;
945
946 if ((device_param->opencl_platform_vendor_id == VENDOR_ID_AMD) && (device_param->opencl_device_vendor_id == VENDOR_ID_AMD))
947 {
948 event_log_info (hashcat_ctx, " PCI.Addr.BDF...: %02x:%02x.%d", pcie_bus, pcie_device, pcie_function);
949 }
950
951 if ((device_param->opencl_platform_vendor_id == VENDOR_ID_NV) && (device_param->opencl_device_vendor_id == VENDOR_ID_NV))
952 {
953 event_log_info (hashcat_ctx, " PCI.Addr.BDF...: %02x:%02x.%d", pcie_bus, pcie_device, pcie_function);
954 }
955 }
956
957 event_log_info (hashcat_ctx, NULL);
958 }
959 }
960 }
961 }
962
backend_info_compact(hashcat_ctx_t * hashcat_ctx)963 void backend_info_compact (hashcat_ctx_t *hashcat_ctx)
964 {
965 const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
966 const user_options_t *user_options = hashcat_ctx->user_options;
967
968 if (user_options->quiet == true) return;
969 if (user_options->machine_readable == true) return;
970 if (user_options->status_json == true) return;
971
972 /**
973 * CUDA
974 */
975
976 if (backend_ctx->cuda)
977 {
978 int cuda_devices_cnt = backend_ctx->cuda_devices_cnt;
979 int cuda_driver_version = backend_ctx->cuda_driver_version;
980
981 const size_t len = event_log_info (hashcat_ctx, "CUDA API (CUDA %d.%d)", cuda_driver_version / 1000, (cuda_driver_version % 100) / 10);
982
983 char line[HCBUFSIZ_TINY] = { 0 };
984
985 memset (line, '=', len);
986
987 line[len] = 0;
988
989 event_log_info (hashcat_ctx, "%s", line);
990
991 for (int cuda_devices_idx = 0; cuda_devices_idx < cuda_devices_cnt; cuda_devices_idx++)
992 {
993 const int backend_devices_idx = backend_ctx->backend_device_from_cuda[cuda_devices_idx];
994
995 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
996
997 int device_id = device_param->device_id;
998 char *device_name = device_param->device_name;
999 u32 device_processors = device_param->device_processors;
1000 u64 device_global_mem = device_param->device_global_mem;
1001 u64 device_available_mem = device_param->device_available_mem;
1002
1003 if ((device_param->skipped == false) && (device_param->skipped_warning == false))
1004 {
1005 event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB, %uMCU",
1006 device_id + 1,
1007 device_name,
1008 device_available_mem / 1024 / 1024,
1009 device_global_mem / 1024 / 1024,
1010 device_processors);
1011 }
1012 else
1013 {
1014 event_log_info (hashcat_ctx, "* Device #%u: %s, skipped",
1015 device_id + 1,
1016 device_name);
1017 }
1018 }
1019
1020 event_log_info (hashcat_ctx, NULL);
1021 }
1022
1023 /**
1024 * HIP
1025 */
1026
1027 if (backend_ctx->hip)
1028 {
1029 int hip_devices_cnt = backend_ctx->hip_devices_cnt;
1030 int hip_runtimeVersion = backend_ctx->hip_runtimeVersion;
1031
1032 size_t len;
1033
1034 if (hip_runtimeVersion > 1000)
1035 {
1036 int hip_version_major = (hip_runtimeVersion - 0) / 10000000;
1037 int hip_version_minor = (hip_runtimeVersion - (hip_version_major * 10000000)) / 100000;
1038 int hip_version_patch = (hip_runtimeVersion - (hip_version_major * 10000000) - (hip_version_minor * 100000));
1039
1040 len = event_log_info (hashcat_ctx, "HIP API (HIP %d.%d.%d)", hip_version_major, hip_version_minor, hip_version_patch);
1041 }
1042 else
1043 {
1044 len = event_log_info (hashcat_ctx, "HIP API (HIP %d.%d)", hip_runtimeVersion / 100, hip_runtimeVersion % 10);
1045 }
1046
1047 char line[HCBUFSIZ_TINY] = { 0 };
1048
1049 memset (line, '=', len);
1050
1051 line[len] = 0;
1052
1053 event_log_info (hashcat_ctx, "%s", line);
1054
1055 for (int hip_devices_idx = 0; hip_devices_idx < hip_devices_cnt; hip_devices_idx++)
1056 {
1057 const int backend_devices_idx = backend_ctx->backend_device_from_hip[hip_devices_idx];
1058
1059 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
1060
1061 int device_id = device_param->device_id;
1062 char *device_name = device_param->device_name;
1063 u32 device_processors = device_param->device_processors;
1064 u64 device_global_mem = device_param->device_global_mem;
1065 u64 device_available_mem = device_param->device_available_mem;
1066
1067 if ((device_param->skipped == false) && (device_param->skipped_warning == false))
1068 {
1069 event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB, %uMCU",
1070 device_id + 1,
1071 device_name,
1072 device_available_mem / 1024 / 1024,
1073 device_global_mem / 1024 / 1024,
1074 device_processors);
1075 }
1076 else
1077 {
1078 event_log_info (hashcat_ctx, "* Device #%u: %s, skipped",
1079 device_id + 1,
1080 device_name);
1081 }
1082 }
1083
1084 event_log_info (hashcat_ctx, NULL);
1085 }
1086
1087 /**
1088 * OpenCL
1089 */
1090
1091 if (backend_ctx->ocl)
1092 {
1093 cl_uint opencl_platforms_cnt = backend_ctx->opencl_platforms_cnt;
1094 cl_uint *opencl_platforms_devices_cnt = backend_ctx->opencl_platforms_devices_cnt;
1095 char **opencl_platforms_vendor = backend_ctx->opencl_platforms_vendor;
1096 char **opencl_platforms_version = backend_ctx->opencl_platforms_version;
1097
1098 for (cl_uint opencl_platforms_idx = 0; opencl_platforms_idx < opencl_platforms_cnt; opencl_platforms_idx++)
1099 {
1100 char *opencl_platform_vendor = opencl_platforms_vendor[opencl_platforms_idx];
1101 char *opencl_platform_version = opencl_platforms_version[opencl_platforms_idx];
1102 cl_uint opencl_platform_devices_cnt = opencl_platforms_devices_cnt[opencl_platforms_idx];
1103
1104 const size_t len = event_log_info (hashcat_ctx, "OpenCL API (%s) - Platform #%u [%s]", opencl_platform_version, opencl_platforms_idx + 1, opencl_platform_vendor);
1105
1106 char line[HCBUFSIZ_TINY] = { 0 };
1107
1108 memset (line, '=', len);
1109
1110 line[len] = 0;
1111
1112 event_log_info (hashcat_ctx, "%s", line);
1113
1114 for (cl_uint opencl_platform_devices_idx = 0; opencl_platform_devices_idx < opencl_platform_devices_cnt; opencl_platform_devices_idx++)
1115 {
1116 const int backend_devices_idx = backend_ctx->backend_device_from_opencl_platform[opencl_platforms_idx][opencl_platform_devices_idx];
1117
1118 const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx;
1119
1120 int device_id = device_param->device_id;
1121 char *device_name = device_param->device_name;
1122 u32 device_processors = device_param->device_processors;
1123 u64 device_maxmem_alloc = device_param->device_maxmem_alloc;
1124 u64 device_global_mem = device_param->device_global_mem;
1125 u64 device_available_mem = device_param->device_available_mem;
1126
1127 if ((device_param->skipped == false) && (device_param->skipped_warning == false))
1128 {
1129 event_log_info (hashcat_ctx, "* Device #%u: %s, %" PRIu64 "/%" PRIu64 " MB (%" PRIu64 " MB allocatable), %uMCU",
1130 device_id + 1,
1131 device_name,
1132 device_available_mem / 1024 / 1024,
1133 device_global_mem / 1024 / 1024,
1134 device_maxmem_alloc / 1024 / 1024,
1135 device_processors);
1136 }
1137 else
1138 {
1139 event_log_info (hashcat_ctx, "* Device #%u: %s, skipped",
1140 device_id + 1,
1141 device_name);
1142 }
1143 }
1144
1145 event_log_info (hashcat_ctx, NULL);
1146 }
1147 }
1148 }
1149
status_display_machine_readable(hashcat_ctx_t * hashcat_ctx)1150 void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
1151 {
1152 const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
1153
1154 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
1155
1156 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
1157 {
1158 hcfree (hashcat_status);
1159
1160 return;
1161 }
1162
1163 printf ("STATUS\t%d\t", hashcat_status->status_number);
1164
1165 printf ("SPEED\t");
1166
1167 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1168 {
1169 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1170
1171 if (device_info->skipped_dev == true) continue;
1172
1173 if (device_info->skipped_warning_dev == true) continue;
1174
1175 printf ("%" PRIu64 "\t", (u64) (device_info->hashes_msec_dev * 1000));
1176
1177 // that 1\t is for backward compatibility
1178 printf ("1000\t");
1179 }
1180
1181 printf ("EXEC_RUNTIME\t");
1182
1183 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1184 {
1185 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1186
1187 if (device_info->skipped_dev == true) continue;
1188
1189 if (device_info->skipped_warning_dev == true) continue;
1190
1191 printf ("%f\t", device_info->exec_msec_dev);
1192 }
1193
1194 printf ("CURKU\t%" PRIu64 "\t", hashcat_status->restore_point);
1195
1196 printf ("PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip);
1197
1198 printf ("RECHASH\t%d\t%d\t", hashcat_status->digests_done, hashcat_status->digests_cnt);
1199
1200 printf ("RECSALT\t%d\t%d\t", hashcat_status->salts_done, hashcat_status->salts_cnt);
1201
1202 if (hwmon_ctx->enabled == true)
1203 {
1204 printf ("TEMP\t");
1205
1206 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1207 {
1208 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1209
1210 if (device_info->skipped_dev == true) continue;
1211
1212 if (device_info->skipped_warning_dev == true) continue;
1213
1214 const int temp = hm_get_temperature_with_devices_idx (hashcat_ctx, device_id);
1215
1216 printf ("%d\t", temp);
1217 }
1218 }
1219
1220 printf ("REJECTED\t%" PRIu64 "\t", hashcat_status->progress_rejected);
1221
1222 printf ("UTIL\t");
1223
1224 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1225 {
1226 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1227
1228 if (device_info->skipped_dev == true) continue;
1229
1230 if (device_info->skipped_warning_dev == true) continue;
1231
1232 // ok, little cheat here again...
1233
1234 const int util = hm_get_utilization_with_devices_idx (hashcat_ctx, device_id);
1235
1236 printf ("%d\t", util);
1237 }
1238
1239 fwrite (EOL, strlen (EOL), 1, stdout);
1240
1241 fflush (stdout);
1242
1243 status_status_destroy (hashcat_ctx, hashcat_status);
1244
1245 hcfree (hashcat_status);
1246 }
1247
status_display_status_json(hashcat_ctx_t * hashcat_ctx)1248 void status_display_status_json (hashcat_ctx_t *hashcat_ctx)
1249 {
1250 const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
1251
1252 const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
1253
1254 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
1255
1256 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
1257 {
1258 hcfree (hashcat_status);
1259
1260 return;
1261 }
1262
1263 time_t time_now;
1264
1265 time (&time_now);
1266
1267 time_t end;
1268
1269 time_t sec_etc = status_get_sec_etc (hashcat_ctx);
1270
1271 if (overflow_check_u64_add (time_now, sec_etc) == false)
1272 {
1273 end = 1;
1274 }
1275 else
1276 {
1277 end = time_now + sec_etc;
1278 }
1279
1280 /*
1281 * As the hash target can contain the hash (in case of a single attacked hash), especially
1282 * some salts can contain chars which need to be escaped to not break the JSON encoding.
1283 * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars
1284 * are getting escaped before being printed.
1285 */
1286
1287 char *target_json_encoded = (char *) hcmalloc (strlen (hashcat_status->hash_target) * 2);
1288
1289 unsigned long i, j;
1290
1291 for (i = 0, j = 0; i < strlen (hashcat_status->hash_target); i++, j++)
1292 {
1293 char c = hashcat_status->hash_target[i];
1294
1295 switch (c)
1296 {
1297 case '\b': c = 'b'; target_json_encoded[j] = '\\'; j++; break;
1298 case '\t': c = 't'; target_json_encoded[j] = '\\'; j++; break;
1299 case '\n': c = 'n'; target_json_encoded[j] = '\\'; j++; break;
1300 case '\f': c = 'f'; target_json_encoded[j] = '\\'; j++; break;
1301 case '\r': c = 'r'; target_json_encoded[j] = '\\'; j++; break;
1302 case '\\': c = '\\'; target_json_encoded[j] = '\\'; j++; break;
1303 case '"': c = '"'; target_json_encoded[j] = '\\'; j++; break;
1304 }
1305
1306 target_json_encoded[j] = c;
1307 }
1308
1309 target_json_encoded[j] = 0;
1310
1311 printf ("{ \"session\": \"%s\",", hashcat_status->session);
1312 printf (" \"status\": %d,", hashcat_status->status_number);
1313 printf (" \"target\": \"%s\",", target_json_encoded);
1314 printf (" \"progress\": [%" PRIu64 ", %" PRIu64 "],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip);
1315 printf (" \"restore_point\": %" PRIu64 ",", hashcat_status->restore_point);
1316 printf (" \"recovered_hashes\": [%d, %d],", hashcat_status->digests_done, hashcat_status->digests_cnt);
1317 printf (" \"recovered_salts\": [%d, %d],", hashcat_status->salts_done, hashcat_status->salts_cnt);
1318 printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected);
1319 printf (" \"devices\": [");
1320
1321 hcfree (target_json_encoded);
1322
1323 int device_num = 0;
1324
1325 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1326 {
1327 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1328
1329 if (device_info->skipped_dev == true) continue;
1330
1331 if (device_info->skipped_warning_dev == true) continue;
1332
1333 if (device_num != 0)
1334 {
1335 printf (",");
1336 }
1337
1338 printf (" { \"device_id\": %d,", device_id + 1);
1339 printf (" \"speed\": %" PRIu64 ",", (u64) (device_info->hashes_msec_dev * 1000));
1340
1341 if (hwmon_ctx->enabled == true)
1342 {
1343 const int temp = hm_get_temperature_with_devices_idx (hashcat_ctx, device_id);
1344
1345 printf (" \"temp\": %d,", temp);
1346 }
1347
1348 const int util = hm_get_utilization_with_devices_idx (hashcat_ctx, device_id);
1349
1350 printf (" \"util\": %d }", util);
1351
1352 device_num++;
1353 }
1354 printf (" ],");
1355 printf (" \"time_start\": %" PRIu64 ",", (u64) status_ctx->runtime_start);
1356 printf (" \"estimated_stop\": %" PRIu64 " }", (u64) end);
1357
1358 fwrite (EOL, strlen (EOL), 1, stdout);
1359
1360 fflush (stdout);
1361
1362 status_status_destroy (hashcat_ctx, hashcat_status);
1363
1364 hcfree (hashcat_status);
1365 }
1366
status_display(hashcat_ctx_t * hashcat_ctx)1367 void status_display (hashcat_ctx_t *hashcat_ctx)
1368 {
1369 const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
1370 const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
1371 const user_options_t *user_options = hashcat_ctx->user_options;
1372
1373 if (user_options->machine_readable == true)
1374 {
1375 status_display_machine_readable (hashcat_ctx);
1376
1377 return;
1378 }
1379
1380 if (user_options->status_json == true)
1381 {
1382 status_display_status_json (hashcat_ctx);
1383
1384 return;
1385 }
1386
1387 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
1388
1389 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
1390 {
1391 hcfree (hashcat_status);
1392
1393 return;
1394 }
1395
1396 /**
1397 * show something
1398 */
1399
1400 #ifdef WITH_BRAIN
1401 if (user_options->brain_client == true)
1402 {
1403 event_log_info (hashcat_ctx,
1404 "Session..........: %s (Brain Session/Attack:0x%08x/0x%08x)",
1405 hashcat_status->session,
1406 hashcat_status->brain_session,
1407 hashcat_status->brain_attack);
1408 }
1409 else
1410 {
1411 event_log_info (hashcat_ctx,
1412 "Session..........: %s",
1413 hashcat_status->session);
1414 }
1415 #else
1416 event_log_info (hashcat_ctx,
1417 "Session..........: %s",
1418 hashcat_status->session);
1419 #endif
1420
1421 event_log_info (hashcat_ctx,
1422 "Status...........: %s",
1423 hashcat_status->status_string);
1424
1425 event_log_info (hashcat_ctx,
1426 "Hash.Mode........: %d (%s)",
1427 hashconfig->hash_mode,
1428 hashcat_status->hash_name);
1429
1430 event_log_info (hashcat_ctx,
1431 "Hash.Target......: %s",
1432 hashcat_status->hash_target);
1433
1434 if (user_options->force == true)
1435 {
1436 event_log_info (hashcat_ctx,
1437 "Time.Started.....: %s, (%s)",
1438 hashcat_status->time_started_absolute,
1439 hashcat_status->time_started_relative);
1440 }
1441 else
1442 {
1443 event_log_info (hashcat_ctx,
1444 "Time.Started.....: %s (%s)",
1445 hashcat_status->time_started_absolute,
1446 hashcat_status->time_started_relative);
1447 }
1448
1449 if (user_options->force == true)
1450 {
1451 event_log_info (hashcat_ctx,
1452 "Time.Estimated...: %s, (%s)",
1453 hashcat_status->time_estimated_absolute,
1454 hashcat_status->time_estimated_relative);
1455 }
1456 else
1457 {
1458 event_log_info (hashcat_ctx,
1459 "Time.Estimated...: %s (%s)",
1460 hashcat_status->time_estimated_absolute,
1461 hashcat_status->time_estimated_relative);
1462 }
1463
1464 if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
1465 {
1466 event_log_info (hashcat_ctx, "Kernel.Feature...: Optimized Kernel");
1467 }
1468 else
1469 {
1470 event_log_info (hashcat_ctx, "Kernel.Feature...: Pure Kernel");
1471 }
1472
1473 switch (hashcat_status->guess_mode)
1474 {
1475 case GUESS_MODE_STRAIGHT_FILE:
1476
1477 event_log_info (hashcat_ctx,
1478 "Guess.Base.......: File (%s)",
1479 hashcat_status->guess_base);
1480
1481 break;
1482
1483 case GUESS_MODE_STRAIGHT_FILE_RULES_FILE:
1484
1485 event_log_info (hashcat_ctx,
1486 "Guess.Base.......: File (%s)",
1487 hashcat_status->guess_base);
1488
1489 event_log_info (hashcat_ctx,
1490 "Guess.Mod........: Rules (%s)",
1491 hashcat_status->guess_mod);
1492
1493 break;
1494
1495 case GUESS_MODE_STRAIGHT_FILE_RULES_GEN:
1496
1497 event_log_info (hashcat_ctx,
1498 "Guess.Base.......: File (%s)",
1499 hashcat_status->guess_base);
1500
1501 event_log_info (hashcat_ctx,
1502 "Guess.Mod........: Rules (Generated)");
1503
1504 break;
1505
1506 case GUESS_MODE_STRAIGHT_STDIN:
1507
1508 event_log_info (hashcat_ctx,
1509 "Guess.Base.......: Pipe");
1510
1511 break;
1512
1513 case GUESS_MODE_STRAIGHT_STDIN_RULES_FILE:
1514
1515 event_log_info (hashcat_ctx,
1516 "Guess.Base.......: Pipe");
1517
1518 event_log_info (hashcat_ctx,
1519 "Guess.Mod........: Rules (%s)",
1520 hashcat_status->guess_mod);
1521
1522 break;
1523
1524 case GUESS_MODE_STRAIGHT_STDIN_RULES_GEN:
1525
1526 event_log_info (hashcat_ctx,
1527 "Guess.Base.......: Pipe");
1528
1529 event_log_info (hashcat_ctx,
1530 "Guess.Mod........: Rules (Generated)");
1531
1532 break;
1533
1534 case GUESS_MODE_COMBINATOR_BASE_LEFT:
1535
1536 event_log_info (hashcat_ctx,
1537 "Guess.Base.......: File (%s), Left Side",
1538 hashcat_status->guess_base);
1539
1540 event_log_info (hashcat_ctx,
1541 "Guess.Mod........: File (%s), Right Side",
1542 hashcat_status->guess_mod);
1543
1544 break;
1545
1546 case GUESS_MODE_COMBINATOR_BASE_RIGHT:
1547
1548 event_log_info (hashcat_ctx,
1549 "Guess.Base.......: File (%s), Right Side",
1550 hashcat_status->guess_base);
1551
1552 event_log_info (hashcat_ctx,
1553 "Guess.Mod........: File (%s), Left Side",
1554 hashcat_status->guess_mod);
1555
1556 break;
1557
1558 case GUESS_MODE_MASK:
1559
1560 event_log_info (hashcat_ctx,
1561 "Guess.Mask.......: %s [%d]",
1562 hashcat_status->guess_base,
1563 hashcat_status->guess_mask_length);
1564
1565 break;
1566
1567 case GUESS_MODE_MASK_CS:
1568
1569 event_log_info (hashcat_ctx,
1570 "Guess.Mask.......: %s [%d]",
1571 hashcat_status->guess_base,
1572 hashcat_status->guess_mask_length);
1573
1574 event_log_info (hashcat_ctx,
1575 "Guess.Charset....: %s ",
1576 hashcat_status->guess_charset);
1577
1578 break;
1579
1580 case GUESS_MODE_HYBRID1:
1581
1582 event_log_info (hashcat_ctx,
1583 "Guess.Base.......: File (%s), Left Side",
1584 hashcat_status->guess_base);
1585
1586 event_log_info (hashcat_ctx,
1587 "Guess.Mod........: Mask (%s) [%d], Right Side",
1588 hashcat_status->guess_mod,
1589 hashcat_status->guess_mask_length);
1590
1591 break;
1592
1593 case GUESS_MODE_HYBRID1_CS:
1594
1595 event_log_info (hashcat_ctx,
1596 "Guess.Base.......: File (%s), Left Side",
1597 hashcat_status->guess_base);
1598
1599 event_log_info (hashcat_ctx,
1600 "Guess.Mod........: Mask (%s) [%d], Right Side",
1601 hashcat_status->guess_mod,
1602 hashcat_status->guess_mask_length);
1603
1604 event_log_info (hashcat_ctx,
1605 "Guess.Charset....: %s",
1606 hashcat_status->guess_charset);
1607
1608 break;
1609
1610 case GUESS_MODE_HYBRID2:
1611
1612 if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
1613 {
1614 event_log_info (hashcat_ctx,
1615 "Guess.Base.......: Mask (%s) [%d], Left Side",
1616 hashcat_status->guess_base,
1617 hashcat_status->guess_mask_length);
1618
1619 event_log_info (hashcat_ctx,
1620 "Guess.Mod........: File (%s), Right Side",
1621 hashcat_status->guess_mod);
1622 }
1623 else
1624 {
1625 event_log_info (hashcat_ctx,
1626 "Guess.Base.......: File (%s), Right Side",
1627 hashcat_status->guess_base);
1628
1629 event_log_info (hashcat_ctx,
1630 "Guess.Mod........: Mask (%s) [%d], Left Side",
1631 hashcat_status->guess_mod,
1632 hashcat_status->guess_mask_length);
1633 }
1634
1635 break;
1636
1637 case GUESS_MODE_HYBRID2_CS:
1638
1639 if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
1640 {
1641 event_log_info (hashcat_ctx,
1642 "Guess.Base.......: Mask (%s) [%d], Left Side",
1643 hashcat_status->guess_base,
1644 hashcat_status->guess_mask_length);
1645
1646 event_log_info (hashcat_ctx,
1647 "Guess.Mod........: File (%s), Right Side",
1648 hashcat_status->guess_mod);
1649
1650 event_log_info (hashcat_ctx,
1651 "Guess.Charset....: %s",
1652 hashcat_status->guess_charset);
1653 }
1654 else
1655 {
1656 event_log_info (hashcat_ctx,
1657 "Guess.Base.......: File (%s), Right Side",
1658 hashcat_status->guess_base);
1659
1660 event_log_info (hashcat_ctx,
1661 "Guess.Mod........: Mask (%s) [%d], Left Side",
1662 hashcat_status->guess_mod,
1663 hashcat_status->guess_mask_length);
1664
1665 event_log_info (hashcat_ctx,
1666 "Guess.Charset....: %s",
1667 hashcat_status->guess_charset);
1668 }
1669
1670 break;
1671 }
1672
1673 switch (hashcat_status->guess_mode)
1674 {
1675 case GUESS_MODE_STRAIGHT_FILE:
1676
1677 event_log_info (hashcat_ctx,
1678 "Guess.Queue......: %d/%d (%.02f%%)",
1679 hashcat_status->guess_base_offset,
1680 hashcat_status->guess_base_count,
1681 hashcat_status->guess_base_percent);
1682
1683 break;
1684
1685 case GUESS_MODE_STRAIGHT_FILE_RULES_FILE:
1686
1687 event_log_info (hashcat_ctx,
1688 "Guess.Queue......: %d/%d (%.02f%%)",
1689 hashcat_status->guess_base_offset,
1690 hashcat_status->guess_base_count,
1691 hashcat_status->guess_base_percent);
1692
1693 break;
1694
1695 case GUESS_MODE_STRAIGHT_FILE_RULES_GEN:
1696
1697 event_log_info (hashcat_ctx,
1698 "Guess.Queue......: %d/%d (%.02f%%)",
1699 hashcat_status->guess_base_offset,
1700 hashcat_status->guess_base_count,
1701 hashcat_status->guess_base_percent);
1702
1703 break;
1704
1705 case GUESS_MODE_MASK:
1706
1707 event_log_info (hashcat_ctx,
1708 "Guess.Queue......: %d/%d (%.02f%%)",
1709 hashcat_status->guess_base_offset,
1710 hashcat_status->guess_base_count,
1711 hashcat_status->guess_base_percent);
1712
1713 break;
1714
1715 case GUESS_MODE_MASK_CS:
1716
1717 event_log_info (hashcat_ctx,
1718 "Guess.Queue......: %d/%d (%.02f%%)",
1719 hashcat_status->guess_base_offset,
1720 hashcat_status->guess_base_count,
1721 hashcat_status->guess_base_percent);
1722
1723 break;
1724
1725 case GUESS_MODE_HYBRID1:
1726
1727 event_log_info (hashcat_ctx,
1728 "Guess.Queue.Base.: %d/%d (%.02f%%)",
1729 hashcat_status->guess_base_offset,
1730 hashcat_status->guess_base_count,
1731 hashcat_status->guess_base_percent);
1732
1733 event_log_info (hashcat_ctx,
1734 "Guess.Queue.Mod..: %d/%d (%.02f%%)",
1735 hashcat_status->guess_mod_offset,
1736 hashcat_status->guess_mod_count,
1737 hashcat_status->guess_mod_percent);
1738
1739 break;
1740
1741 case GUESS_MODE_HYBRID2:
1742
1743 event_log_info (hashcat_ctx,
1744 "Guess.Queue.Base.: %d/%d (%.02f%%)",
1745 hashcat_status->guess_base_offset,
1746 hashcat_status->guess_base_count,
1747 hashcat_status->guess_base_percent);
1748
1749 event_log_info (hashcat_ctx,
1750 "Guess.Queue.Mod..: %d/%d (%.02f%%)",
1751 hashcat_status->guess_mod_offset,
1752 hashcat_status->guess_mod_count,
1753 hashcat_status->guess_mod_percent);
1754
1755 break;
1756 }
1757
1758 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1759 {
1760 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1761
1762 if (device_info->skipped_dev == true) continue;
1763
1764 if (device_info->skipped_warning_dev == true) continue;
1765
1766 event_log_info (hashcat_ctx,
1767 "Speed.#%d.........: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1,
1768 device_info->speed_sec_dev,
1769 device_info->exec_msec_dev,
1770 device_info->kernel_accel_dev,
1771 device_info->kernel_loops_dev,
1772 device_info->kernel_threads_dev,
1773 device_info->vector_width_dev);
1774 }
1775
1776 if (hashcat_status->device_info_active > 1)
1777 {
1778 event_log_info (hashcat_ctx,
1779 "Speed.#*.........: %9sH/s",
1780 hashcat_status->speed_sec_all);
1781 }
1782
1783 if (hashcat_status->salts_cnt > 1)
1784 {
1785 event_log_info (hashcat_ctx,
1786 "Recovered........: %d/%d (%.2f%%) Digests, %d/%d (%.2f%%) Salts",
1787 hashcat_status->digests_done,
1788 hashcat_status->digests_cnt,
1789 hashcat_status->digests_percent,
1790 hashcat_status->salts_done,
1791 hashcat_status->salts_cnt,
1792 hashcat_status->salts_percent);
1793 }
1794 else
1795 {
1796 event_log_info (hashcat_ctx,
1797 "Recovered........: %d/%d (%.2f%%) Digests",
1798 hashcat_status->digests_done,
1799 hashcat_status->digests_cnt,
1800 hashcat_status->digests_percent);
1801 }
1802
1803 if (hashcat_status->digests_cnt > 1000)
1804 {
1805 const int digests_remain = hashcat_status->digests_cnt - hashcat_status->digests_done;
1806 const double digests_remain_percent = (double) digests_remain / (double) hashcat_status->digests_cnt * 100;
1807
1808 const int salts_remain = hashcat_status->salts_cnt - hashcat_status->salts_done;
1809 const double salts_remain_percent = (double) salts_remain / (double) hashcat_status->salts_cnt * 100;
1810
1811 if (hashcat_status->salts_cnt > 1)
1812 {
1813 event_log_info (hashcat_ctx,
1814 "Remaining........: %d (%.2f%%) Digests, %d (%.2f%%) Salts",
1815 digests_remain,
1816 digests_remain_percent,
1817 salts_remain,
1818 salts_remain_percent);
1819 }
1820 else
1821 {
1822 event_log_info (hashcat_ctx,
1823 "Remaining........: %d (%.2f%%) Digests",
1824 digests_remain,
1825 digests_remain_percent);
1826 }
1827 }
1828
1829 if (hashcat_status->digests_cnt > 1000)
1830 {
1831 event_log_info (hashcat_ctx,
1832 "Recovered/Time...: %s",
1833 hashcat_status->cpt);
1834 }
1835
1836 switch (hashcat_status->progress_mode)
1837 {
1838 case PROGRESS_MODE_KEYSPACE_KNOWN:
1839
1840 event_log_info (hashcat_ctx,
1841 "Progress.........: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
1842 hashcat_status->progress_cur_relative_skip,
1843 hashcat_status->progress_end_relative_skip,
1844 hashcat_status->progress_finished_percent);
1845
1846 event_log_info (hashcat_ctx,
1847 "Rejected.........: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
1848 hashcat_status->progress_rejected,
1849 hashcat_status->progress_cur_relative_skip,
1850 hashcat_status->progress_rejected_percent);
1851
1852 break;
1853
1854 case PROGRESS_MODE_KEYSPACE_UNKNOWN:
1855
1856 event_log_info (hashcat_ctx,
1857 "Progress.........: %" PRIu64,
1858 hashcat_status->progress_cur_relative_skip);
1859
1860 event_log_info (hashcat_ctx,
1861 "Rejected.........: %" PRIu64,
1862 hashcat_status->progress_rejected);
1863
1864 break;
1865 }
1866
1867 #ifdef WITH_BRAIN
1868 if (user_options->brain_client == true)
1869 {
1870 event_log_info (hashcat_ctx,
1871 "Brain.Link.All...: RX: %sB, TX: %sB",
1872 hashcat_status->brain_rx_all,
1873 hashcat_status->brain_tx_all);
1874
1875 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1876 {
1877 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1878
1879 if (device_info->skipped_dev == true) continue;
1880
1881 if (device_info->skipped_warning_dev == true) continue;
1882
1883 if (device_info->brain_link_status_dev == BRAIN_LINK_STATUS_CONNECTED)
1884 {
1885 event_log_info (hashcat_ctx,
1886 "Brain.Link.#%d....: RX: %sB (%sbps), TX: %sB (%sbps), idle", device_id + 1,
1887 device_info->brain_link_recv_bytes_dev,
1888 device_info->brain_link_recv_bytes_sec_dev,
1889 device_info->brain_link_send_bytes_dev,
1890 device_info->brain_link_send_bytes_sec_dev);
1891 }
1892 else if (device_info->brain_link_status_dev == BRAIN_LINK_STATUS_RECEIVING)
1893 {
1894 event_log_info (hashcat_ctx,
1895 "Brain.Link.#%d....: RX: %sB (%sbps), TX: %sB (%sbps), receiving", device_id + 1,
1896 device_info->brain_link_recv_bytes_dev,
1897 device_info->brain_link_recv_bytes_sec_dev,
1898 device_info->brain_link_send_bytes_dev,
1899 device_info->brain_link_send_bytes_sec_dev);
1900 }
1901 else if (device_info->brain_link_status_dev == BRAIN_LINK_STATUS_SENDING)
1902 {
1903 event_log_info (hashcat_ctx,
1904 "Brain.Link.#%d....: RX: %sB (%sbps), TX: %sB (%sbps), sending", device_id + 1,
1905 device_info->brain_link_recv_bytes_dev,
1906 device_info->brain_link_recv_bytes_sec_dev,
1907 device_info->brain_link_send_bytes_dev,
1908 device_info->brain_link_send_bytes_sec_dev);
1909 }
1910 else
1911 {
1912 if ((device_info->brain_link_time_recv_dev > 0) && (device_info->brain_link_time_send_dev > 0))
1913 {
1914 event_log_info (hashcat_ctx,
1915 "Brain.Link.#%d....: RX: %sB (%sbps), TX: %sB (%sbps)", device_id + 1,
1916 device_info->brain_link_recv_bytes_dev,
1917 device_info->brain_link_recv_bytes_sec_dev,
1918 device_info->brain_link_send_bytes_dev,
1919 device_info->brain_link_send_bytes_sec_dev);
1920 }
1921 else
1922 {
1923 event_log_info (hashcat_ctx,
1924 "Brain.Link.#%d....: N/A", device_id + 1);
1925 }
1926 }
1927 }
1928 }
1929 #endif
1930
1931 switch (hashcat_status->progress_mode)
1932 {
1933 case PROGRESS_MODE_KEYSPACE_KNOWN:
1934
1935 event_log_info (hashcat_ctx,
1936 "Restore.Point....: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
1937 hashcat_status->restore_point,
1938 hashcat_status->restore_total,
1939 hashcat_status->restore_percent);
1940
1941 break;
1942
1943 case PROGRESS_MODE_KEYSPACE_UNKNOWN:
1944
1945 event_log_info (hashcat_ctx,
1946 "Restore.Point....: %" PRIu64,
1947 hashcat_status->restore_point);
1948
1949 break;
1950 }
1951
1952 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1953 {
1954 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1955
1956 if (device_info->skipped_dev == true) continue;
1957
1958 if (device_info->skipped_warning_dev == true) continue;
1959
1960 event_log_info (hashcat_ctx,
1961 "Restore.Sub.#%d...: Salt:%d Amplifier:%d-%d Iteration:%d-%d", device_id + 1,
1962 device_info->salt_pos_dev,
1963 device_info->innerloop_pos_dev,
1964 device_info->innerloop_pos_dev + device_info->innerloop_left_dev,
1965 device_info->iteration_pos_dev,
1966 device_info->iteration_pos_dev + device_info->iteration_left_dev);
1967 }
1968
1969 //if (hashconfig->opts_type & OPTS_TYPE_SLOW_CANDIDATES)
1970 if (user_options->slow_candidates == true)
1971 {
1972 event_log_info (hashcat_ctx, "Candidate.Engine.: Host Generator + PCIe");
1973 }
1974 else
1975 {
1976 event_log_info (hashcat_ctx, "Candidate.Engine.: Device Generator");
1977 }
1978
1979 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
1980 {
1981 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
1982
1983 if (device_info->skipped_dev == true) continue;
1984
1985 if (device_info->skipped_warning_dev == true) continue;
1986
1987 if (device_info->guess_candidates_dev == NULL) continue;
1988
1989 event_log_info (hashcat_ctx,
1990 "Candidates.#%d....: %s", device_id + 1,
1991 device_info->guess_candidates_dev);
1992 }
1993
1994 if (hwmon_ctx->enabled == true)
1995 {
1996 #if defined(__APPLE__)
1997 bool first_dev = true;
1998 #endif
1999
2000 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2001 {
2002 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2003
2004 if (device_info->skipped_dev == true) continue;
2005
2006 if (device_info->skipped_warning_dev == true) continue;
2007
2008 if (device_info->hwmon_dev == NULL) continue;
2009
2010 #if defined(__APPLE__)
2011 if (first_dev && strlen (device_info->hwmon_fan_dev) > 0)
2012 {
2013 event_log_info (hashcat_ctx, "Hardware.Mon.SMC.: %s", device_info->hwmon_fan_dev);
2014 first_dev = false;
2015 }
2016 #endif
2017
2018 event_log_info (hashcat_ctx,
2019 "Hardware.Mon.#%d..: %s", device_id + 1,
2020 device_info->hwmon_dev);
2021 }
2022 }
2023
2024 status_status_destroy (hashcat_ctx, hashcat_status);
2025
2026 hcfree (hashcat_status);
2027 }
2028
status_benchmark_machine_readable(hashcat_ctx_t * hashcat_ctx)2029 void status_benchmark_machine_readable (hashcat_ctx_t *hashcat_ctx)
2030 {
2031 hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
2032
2033 const u32 hash_mode = hashconfig->hash_mode;
2034
2035 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2036
2037 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2038 {
2039 hcfree (hashcat_status);
2040
2041 return;
2042 }
2043
2044 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2045 {
2046 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2047
2048 if (device_info->skipped_dev == true) continue;
2049
2050 if (device_info->skipped_warning_dev == true) continue;
2051
2052 event_log_info (hashcat_ctx, "%d:%u:%d:%d:%.2f:%" PRIu64, device_id + 1, hash_mode, device_info->corespeed_dev, device_info->memoryspeed_dev, device_info->exec_msec_dev, (u64) (device_info->hashes_msec_dev_benchmark * 1000));
2053 }
2054
2055 status_status_destroy (hashcat_ctx, hashcat_status);
2056
2057 hcfree (hashcat_status);
2058 }
2059
status_benchmark(hashcat_ctx_t * hashcat_ctx)2060 void status_benchmark (hashcat_ctx_t *hashcat_ctx)
2061 {
2062 const user_options_t *user_options = hashcat_ctx->user_options;
2063
2064 if (user_options->machine_readable == true)
2065 {
2066 status_benchmark_machine_readable (hashcat_ctx);
2067
2068 return;
2069 }
2070
2071 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2072
2073 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2074 {
2075 hcfree (hashcat_status);
2076
2077 return;
2078 }
2079
2080 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2081 {
2082 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2083
2084 if (device_info->skipped_dev == true) continue;
2085
2086 if (device_info->skipped_warning_dev == true) continue;
2087
2088 event_log_info (hashcat_ctx,
2089 "Speed.#%d.........: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1,
2090 device_info->speed_sec_dev,
2091 device_info->exec_msec_dev,
2092 device_info->kernel_accel_dev,
2093 device_info->kernel_loops_dev,
2094 device_info->kernel_threads_dev,
2095 device_info->vector_width_dev);
2096 }
2097
2098 if (hashcat_status->device_info_active > 1)
2099 {
2100 event_log_info (hashcat_ctx,
2101 "Speed.#*.........: %9sH/s",
2102 hashcat_status->speed_sec_all);
2103 }
2104
2105 status_status_destroy (hashcat_ctx, hashcat_status);
2106
2107 hcfree (hashcat_status);
2108 }
2109
status_speed_machine_readable(hashcat_ctx_t * hashcat_ctx)2110 void status_speed_machine_readable (hashcat_ctx_t *hashcat_ctx)
2111 {
2112 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2113
2114 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2115 {
2116 hcfree (hashcat_status);
2117
2118 return;
2119 }
2120
2121 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2122 {
2123 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2124
2125 if (device_info->skipped_dev == true) continue;
2126
2127 if (device_info->skipped_warning_dev == true) continue;
2128
2129 event_log_info (hashcat_ctx, "%d:%" PRIu64, device_id + 1, (u64) (device_info->hashes_msec_dev_benchmark * 1000));
2130 }
2131
2132 status_status_destroy (hashcat_ctx, hashcat_status);
2133
2134 hcfree (hashcat_status);
2135 }
2136
status_speed_json(hashcat_ctx_t * hashcat_ctx)2137 void status_speed_json (hashcat_ctx_t *hashcat_ctx)
2138 {
2139 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2140
2141 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2142 {
2143 hcfree (hashcat_status);
2144
2145 return;
2146 }
2147
2148 printf ("{ \"devices\": [");
2149
2150 int device_num = 0;
2151
2152 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2153 {
2154 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2155
2156 if (device_info->skipped_dev == true) continue;
2157
2158 if (device_info->skipped_warning_dev == true) continue;
2159
2160 if (device_num != 0)
2161 {
2162 printf (",");
2163 }
2164
2165 printf (" { \"device_id\": %d,", device_id + 1);
2166 printf (" \"speed\": %" PRIu64 " }", (u64) (device_info->hashes_msec_dev_benchmark * 1000));
2167 device_num++;
2168 }
2169
2170 printf (" ] }");
2171
2172 status_status_destroy (hashcat_ctx, hashcat_status);
2173
2174 hcfree (hashcat_status);
2175 }
2176
status_speed(hashcat_ctx_t * hashcat_ctx)2177 void status_speed (hashcat_ctx_t *hashcat_ctx)
2178 {
2179 const user_options_t *user_options = hashcat_ctx->user_options;
2180
2181 if (user_options->machine_readable == true)
2182 {
2183 status_speed_machine_readable (hashcat_ctx);
2184
2185 return;
2186 }
2187
2188 if (user_options->status_json == true)
2189 {
2190 status_speed_json (hashcat_ctx);
2191
2192 return;
2193 }
2194
2195 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2196
2197 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2198 {
2199 hcfree (hashcat_status);
2200
2201 return;
2202 }
2203
2204 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2205 {
2206 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2207
2208 if (device_info->skipped_dev == true) continue;
2209
2210 if (device_info->skipped_warning_dev == true) continue;
2211
2212 event_log_info (hashcat_ctx,
2213 "Speed.#%d.........: %9sH/s (%0.2fms)", device_id + 1,
2214 device_info->speed_sec_dev,
2215 device_info->exec_msec_dev);
2216 }
2217
2218 if (hashcat_status->device_info_active > 1)
2219 {
2220 event_log_info (hashcat_ctx,
2221 "Speed.#*.........: %9sH/s",
2222 hashcat_status->speed_sec_all);
2223 }
2224
2225 status_status_destroy (hashcat_ctx, hashcat_status);
2226
2227 hcfree (hashcat_status);
2228 }
2229
status_progress_machine_readable(hashcat_ctx_t * hashcat_ctx)2230 void status_progress_machine_readable (hashcat_ctx_t *hashcat_ctx)
2231 {
2232 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2233
2234 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2235 {
2236 hcfree (hashcat_status);
2237
2238 return;
2239 }
2240
2241 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2242 {
2243 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2244
2245 if (device_info->skipped_dev == true) continue;
2246
2247 if (device_info->skipped_warning_dev == true) continue;
2248
2249 event_log_info (hashcat_ctx, "%d:%" PRIu64 ":%0.2f", device_id + 1, device_info->progress_dev, device_info->runtime_msec_dev);
2250 }
2251
2252 status_status_destroy (hashcat_ctx, hashcat_status);
2253
2254 hcfree (hashcat_status);
2255 }
2256
status_progress_json(hashcat_ctx_t * hashcat_ctx)2257 void status_progress_json (hashcat_ctx_t *hashcat_ctx)
2258 {
2259 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2260
2261 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2262 {
2263 hcfree (hashcat_status);
2264
2265 return;
2266 }
2267
2268 printf ("{ \"devices\": [");
2269
2270 int device_num = 0;
2271
2272 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2273 {
2274 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2275
2276 if (device_info->skipped_dev == true) continue;
2277
2278 if (device_info->skipped_warning_dev == true) continue;
2279
2280 if (device_num != 0)
2281 {
2282 printf (",");
2283 }
2284
2285 printf (" { \"device_id\": %d,", device_id + 1);
2286 printf (" \"progress\": %" PRIu64 ",", device_info->progress_dev);
2287 printf (" \"runtime\": %0.2f }", device_info->runtime_msec_dev);
2288 device_num++;
2289 }
2290
2291 printf (" ] }");
2292
2293 status_status_destroy (hashcat_ctx, hashcat_status);
2294
2295 hcfree (hashcat_status);
2296 }
2297
status_progress(hashcat_ctx_t * hashcat_ctx)2298 void status_progress (hashcat_ctx_t *hashcat_ctx)
2299 {
2300 const user_options_t *user_options = hashcat_ctx->user_options;
2301
2302 if (user_options->machine_readable == true)
2303 {
2304 status_progress_machine_readable (hashcat_ctx);
2305
2306 return;
2307 }
2308
2309 if (user_options->status_json == true)
2310 {
2311 status_progress_json (hashcat_ctx);
2312
2313 return;
2314 }
2315
2316 hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t));
2317
2318 if (hashcat_get_status (hashcat_ctx, hashcat_status) == -1)
2319 {
2320 hcfree (hashcat_status);
2321
2322 return;
2323 }
2324
2325 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2326 {
2327 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2328
2329 if (device_info->skipped_dev == true) continue;
2330
2331 if (device_info->skipped_warning_dev == true) continue;
2332
2333 event_log_info (hashcat_ctx,
2334 "Progress.#%d......: %" PRIu64, device_id + 1,
2335 device_info->progress_dev);
2336 }
2337
2338 for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
2339 {
2340 const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
2341
2342 if (device_info->skipped_dev == true) continue;
2343
2344 if (device_info->skipped_warning_dev == true) continue;
2345
2346 event_log_info (hashcat_ctx,
2347 "Runtime.#%d.......: %0.2fms", device_id + 1,
2348 device_info->runtime_msec_dev);
2349 }
2350
2351 status_status_destroy (hashcat_ctx, hashcat_status);
2352
2353 hcfree (hashcat_status);
2354 }
2355