mirror of
https://github.com/hashcat/hashcat.git
synced 2025-04-26 12:09:05 +00:00
parent
ab46265f5f
commit
4a9171ca5d
@ -83,4 +83,6 @@ float get_entropy (const u8 *buf, const int len);
|
|||||||
int select_read_timeout (int sockfd, const int sec);
|
int select_read_timeout (int sockfd, const int sec);
|
||||||
int select_write_timeout (int sockfd, const int sec);
|
int select_write_timeout (int sockfd, const int sec);
|
||||||
|
|
||||||
|
int select_read_timeout_console (const int sec);
|
||||||
|
|
||||||
#endif // _SHARED_H
|
#endif // _SHARED_H
|
||||||
|
@ -171,7 +171,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
|
|||||||
|
|
||||||
while (device_param->pws_pre_cnt < device_param->kernel_power)
|
while (device_param->pws_pre_cnt < device_param->kernel_power)
|
||||||
{
|
{
|
||||||
const int rc_select = select_read_timeout (fileno (stdin), 1);
|
const int rc_select = select_read_timeout_console (1);
|
||||||
|
|
||||||
if (rc_select == -1) break;
|
if (rc_select == -1) break;
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
|
|||||||
|
|
||||||
while (device_param->pws_cnt < device_param->kernel_power)
|
while (device_param->pws_cnt < device_param->kernel_power)
|
||||||
{
|
{
|
||||||
const int rc_select = select_read_timeout (fileno (stdin), 1);
|
const int rc_select = select_read_timeout_console (1);
|
||||||
|
|
||||||
if (rc_select == -1) break;
|
if (rc_select == -1) break;
|
||||||
|
|
||||||
|
48
src/shared.c
48
src/shared.c
@ -739,3 +739,51 @@ int select_write_timeout (int sockfd, const int sec)
|
|||||||
|
|
||||||
return select (sockfd + 1, NULL, &fds, NULL, &tv);
|
return select (sockfd + 1, NULL, &fds, NULL, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (_WIN)
|
||||||
|
|
||||||
|
int select_read_timeout_console (const int sec)
|
||||||
|
{
|
||||||
|
const HANDLE hStdIn = GetStdHandle (STD_INPUT_HANDLE);
|
||||||
|
|
||||||
|
const DWORD rc = WaitForSingleObject (hStdIn, sec * 1000);
|
||||||
|
|
||||||
|
if (rc == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
DWORD dwRead;
|
||||||
|
|
||||||
|
INPUT_RECORD inRecords;
|
||||||
|
|
||||||
|
PeekConsoleInput (hStdIn, &inRecords, 1, &dwRead);
|
||||||
|
|
||||||
|
if (inRecords.EventType == KEY_EVENT)
|
||||||
|
{
|
||||||
|
// those are good ones
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// but we don't want that stuff like windows focus etc. in our stream
|
||||||
|
|
||||||
|
ReadConsoleInput (hStdIn, &inRecords, 1, &dwRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
return select_read_timeout_console (sec);
|
||||||
|
}
|
||||||
|
else if (rc == WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int select_read_timeout_console (const int sec)
|
||||||
|
{
|
||||||
|
return select_read_timeout (fileno (stdin), sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user