From: Jens Steube Date: Sat, 25 Jun 2016 08:37:24 +0000 (+0200) Subject: windows path update X-Git-Tag: v3.00~21 X-Git-Url: https://www.flypig.org.uk/git/?p=hashcat.git;a=commitdiff_plain;h=e7df9b112a12960837e23e59fd43a03c4b444374 windows path update --- diff --git a/include/shared.h b/include/shared.h index 93aad09..d543fb6 100644 --- a/include/shared.h +++ b/include/shared.h @@ -1668,7 +1668,8 @@ int veracrypt_parse_hash_327661 (char *input_buf, uint input_len, hash_t *hash int veracrypt_parse_hash_655331 (char *input_buf, uint input_len, hash_t *hash_buf); int win8phone_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf); -void naive_escape (const char *cpath_real, char *cpath_escaped, const size_t cpath_escaped_len); +void naive_replace (char *s, const u8 key_char, const u8 replace_char); +void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char); void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources); void writeProgramBin (char *dst, u8 *binary, size_t binary_size); diff --git a/src/hashcat.c b/src/hashcat.c index 80282e1..49458b8 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -15410,6 +15410,10 @@ int main (int argc, char **argv) return -1; } + naive_replace (cpath_real, '\\', '/'); + + // not escaping here, windows has quotes + snprintf (build_opts, sizeof (build_opts) - 1, "-I \"%s\"", cpath_real); myfree (cpath_real); @@ -15427,14 +15431,12 @@ int main (int argc, char **argv) return -1; } - char cpath_escaped[1024] = { 0 }; + naive_escape (cpath_real, PATH_MAX, ' ', '\\'); - naive_escape (cpath_real, cpath_escaped, sizeof (cpath_escaped)); + snprintf (build_opts, sizeof (build_opts) - 1, "-I %s", cpath_real); myfree (cpath_real); - snprintf (build_opts, sizeof (build_opts) - 1, "-I %s", cpath_escaped); - #endif // we don't have sm_* on vendors not NV but it doesn't matter diff --git a/src/shared.c b/src/shared.c index 12d7706..a945a8d 100644 --- a/src/shared.c +++ b/src/shared.c @@ -9220,25 +9220,46 @@ void myquit () data.devices_status = STATUS_QUIT; } -void naive_escape (const char *cpath_real, char *cpath_escaped, const size_t cpath_escaped_len) +void naive_replace (char *s, const u8 key_char, const u8 replace_char) { - const size_t len = strlen (cpath_real); + const size_t len = strlen (s); + + for (size_t in = 0; in < len; in++) + { + const u8 c = s[in]; + + if (c == key_char) + { + s[in] = replace_char; + } + } +} + +void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char) +{ + char s_escaped[1024] = { 0 }; + + size_t s_escaped_max = sizeof (s_escaped); + + const size_t len = strlen (s); for (size_t in = 0, out = 0; in < len; in++, out++) { - const u8 c = cpath_real[in]; + const u8 c = s[in]; - if (c == ' ') + if (c == key_char) { - cpath_escaped[out] = '\\'; + s_escaped[out] = escape_char; out++; } - if (out == cpath_escaped_len) break; + if (out == s_escaped_max - 2) break; - cpath_escaped[out] = c; + s_escaped[out] = c; } + + strncpy (s, s_escaped, s_max - 1); } void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources)