From 3b033af7d656a201209b7aae2100be58619289f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?= Date: Sat, 10 Sep 2022 22:35:02 +0200 Subject: [PATCH] Escape some fields of --status-json output --- src/terminal.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 836e7f202..aa7848a37 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1828,11 +1828,24 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) end = time_now + sec_etc; } - printf ("{ \"session\": \"%s\",", hashcat_status->session); + char *session_json_encoded = (char *) hcmalloc (strlen (hashcat_status->session) * 2); + + json_encode (hashcat_status->session, session_json_encoded); + + printf ("{ \"session\": \"%s\",", session_json_encoded); + + hcfree (session_json_encoded); + printf (" \"guess\": {"); if (hashcat_status->guess_base) { - printf (" \"guess_base\": \"%s\",", hashcat_status->guess_base); + char *guess_base_json_encoded = (char *) hcmalloc (strlen (hashcat_status->guess_base) * 2); + + json_encode (hashcat_status->guess_base, guess_base_json_encoded); + + printf (" \"guess_base\": \"%s\",", guess_base_json_encoded); + + hcfree (guess_base_json_encoded); } else { @@ -1846,7 +1859,13 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) if (hashcat_status->guess_mod) { - printf (" \"guess_mod\": \"%s\",", hashcat_status->guess_mod); + char *guess_mod_json_encoded = (char *) hcmalloc (strlen (hashcat_status->guess_mod) * 2); + + json_encode (hashcat_status->guess_mod, guess_mod_json_encoded); + + printf (" \"guess_mod\": \"%s\",", guess_mod_json_encoded); + + hcfree (guess_mod_json_encoded); } else {