fixes #2271: added --brain-server-timer for scheduled backup time
This commit is contained in:
+9
-4
@@ -1950,11 +1950,15 @@ void *brain_server_handle_dumps (void *p)
|
||||
|
||||
brain_server_dbs_t *brain_server_dbs = brain_server_dumper_options->brain_server_dbs;
|
||||
|
||||
int i = 0;
|
||||
u32 brain_server_timer = brain_server_dumper_options->brain_server_timer;
|
||||
|
||||
if (brain_server_timer == 0) return NULL;
|
||||
|
||||
u32 i = 0;
|
||||
|
||||
while (keep_running == true)
|
||||
{
|
||||
if (i == BRAIN_SERVER_DUMP_EVERY)
|
||||
if (i == brain_server_timer)
|
||||
{
|
||||
brain_server_write_hash_dumps (brain_server_dbs, ".");
|
||||
brain_server_write_attack_dumps (brain_server_dbs, ".");
|
||||
@@ -2923,7 +2927,7 @@ void *brain_server_handle_client (void *p)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist)
|
||||
int brain_server (const char *listen_host, const int listen_port, const char *brain_password, const char *brain_session_whitelist, const u32 brain_server_timer)
|
||||
{
|
||||
#if defined (_WIN)
|
||||
WSADATA wsaData;
|
||||
@@ -3193,7 +3197,8 @@ int brain_server (const char *listen_host, const int listen_port, const char *br
|
||||
|
||||
brain_server_dumper_options_t brain_server_dumper_options;
|
||||
|
||||
brain_server_dumper_options.brain_server_dbs = brain_server_dbs;
|
||||
brain_server_dumper_options.brain_server_dbs = brain_server_dbs;
|
||||
brain_server_dumper_options.brain_server_timer = brain_server_timer;
|
||||
|
||||
hc_thread_t dump_thr;
|
||||
|
||||
|
||||
+1
-1
@@ -1125,7 +1125,7 @@ int main (int argc, char **argv)
|
||||
#ifdef WITH_BRAIN
|
||||
if (user_options->brain_server == true)
|
||||
{
|
||||
const int rc = brain_server (user_options->brain_host, user_options->brain_port, user_options->brain_password, user_options->brain_session_whitelist);
|
||||
const int rc = brain_server (user_options->brain_host, user_options->brain_port, user_options->brain_password, user_options->brain_session_whitelist, user_options->brain_server_timer);
|
||||
|
||||
hcfree (hashcat_ctx);
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] =
|
||||
" -S, --slow-candidates | | Enable slower (but advanced) candidate generators |",
|
||||
#ifdef WITH_BRAIN
|
||||
" --brain-server | | Enable brain server |",
|
||||
" --brain-server-timer | Num | Update the brain server dump each X seconds (min:60) | --brain-server-timer=300",
|
||||
" -z, --brain-client | | Enable brain client, activates -S |",
|
||||
" --brain-client-features | Num | Define brain client features, see below | --brain-client-features=3",
|
||||
" --brain-host | Str | Brain server host (IP or domain) | --brain-host=127.0.0.1",
|
||||
|
||||
@@ -129,6 +129,7 @@ static const struct option long_options[] =
|
||||
{"brain-client", no_argument, NULL, IDX_BRAIN_CLIENT},
|
||||
{"brain-client-features", required_argument, NULL, IDX_BRAIN_CLIENT_FEATURES},
|
||||
{"brain-server", no_argument, NULL, IDX_BRAIN_SERVER},
|
||||
{"brain-server-timer", required_argument, NULL, IDX_BRAIN_SERVER_TIMER},
|
||||
{"brain-host", required_argument, NULL, IDX_BRAIN_HOST},
|
||||
{"brain-port", required_argument, NULL, IDX_BRAIN_PORT},
|
||||
{"brain-password", required_argument, NULL, IDX_BRAIN_PASSWORD},
|
||||
@@ -169,6 +170,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options->brain_host = NULL;
|
||||
user_options->brain_port = BRAIN_PORT;
|
||||
user_options->brain_server = BRAIN_SERVER;
|
||||
user_options->brain_server_timer = BRAIN_SERVER_DUMP_EVERY;
|
||||
user_options->brain_session = BRAIN_SESSION;
|
||||
user_options->brain_session_whitelist = NULL;
|
||||
#endif
|
||||
@@ -481,6 +483,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
||||
case IDX_BRAIN_CLIENT: user_options->brain_client = true; break;
|
||||
case IDX_BRAIN_CLIENT_FEATURES: user_options->brain_client_features = hc_strtoul (optarg, NULL, 10); break;
|
||||
case IDX_BRAIN_SERVER: user_options->brain_server = true; break;
|
||||
case IDX_BRAIN_SERVER_TIMER: user_options->brain_server_timer = hc_strtoul (optarg, NULL, 10);
|
||||
user_options->brain_server_timer_chgd = true; break;
|
||||
case IDX_BRAIN_PASSWORD: user_options->brain_password = optarg;
|
||||
user_options->brain_password_chgd = true; break;
|
||||
case IDX_BRAIN_HOST: user_options->brain_host = optarg;
|
||||
@@ -540,6 +544,26 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user_options->brain_server_timer_chgd)
|
||||
{
|
||||
if (user_options->brain_server == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "The --brain-server-timer flag requires --brain-server.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user_options->brain_server_timer != 0) // special case (no intermediate dumps)
|
||||
{
|
||||
if (user_options->brain_server_timer < 60)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Brain server backup timer must be at least 60 seconds.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (user_options->slow_candidates == true)
|
||||
@@ -2890,6 +2914,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
|
||||
logfile_top_uint (user_options->brain_client);
|
||||
logfile_top_uint (user_options->brain_client_features);
|
||||
logfile_top_uint (user_options->brain_server);
|
||||
logfile_top_uint (user_options->brain_server_timer);
|
||||
logfile_top_uint (user_options->brain_port);
|
||||
logfile_top_uint (user_options->brain_session);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user