mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-31 19:01:05 +00:00
Parameter: Detect and error when users try to use a non-digit where a digit is expected
Fixes https://github.com/hashcat/hashcat/issues/1189
This commit is contained in:
parent
d78a58414c
commit
378f852cec
@ -29,8 +29,9 @@
|
||||
##
|
||||
|
||||
- Building: Added missing prototypes for atlassian_parse_hash function
|
||||
- Files: Detect and warn when users try to use -r with a parameter which is not a file
|
||||
- Parameter: Detect and warn when users try to use an empty string (length 0) for parameters like --session=
|
||||
- Files: Detect and error when users try to use -r with a parameter which is not a file
|
||||
- Parameter: Detect and error when users try to use an empty string (length 0) for parameters like --session=
|
||||
- Parameter: Detect and error when users try to use a non-digit where a digit is expected
|
||||
- Sessions: Improved string comparison in case user sets --session to "hashcat"
|
||||
|
||||
* changes v3.30 -> v3.40:
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
|
||||
bool overflow_check_u32_add (const u32 a, const u32 b);
|
||||
bool overflow_check_u32_mul (const u32 a, const u32 b);
|
||||
@ -53,4 +54,6 @@ bool hc_path_read (const char *path);
|
||||
bool hc_path_write (const char *path);
|
||||
bool hc_path_create (const char *path);
|
||||
|
||||
bool hc_string_is_digit (const char *s);
|
||||
|
||||
#endif // _SHARED_H
|
||||
|
18
src/shared.c
18
src/shared.c
@ -298,6 +298,24 @@ bool hc_path_create (const char *path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hc_string_is_digit (const char *s)
|
||||
{
|
||||
if (s == NULL) return false;
|
||||
|
||||
const size_t len = strlen (s);
|
||||
|
||||
if (len == 0) return false;
|
||||
|
||||
for (size_t i = 0; i < len; i++)
|
||||
{
|
||||
const int c = (const int) s[i];
|
||||
|
||||
if (isdigit (c) == 0) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void setup_environment_variables ()
|
||||
{
|
||||
char *compute = getenv ("COMPUTE");
|
||||
|
@ -228,10 +228,60 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
||||
|
||||
int c = -1;
|
||||
|
||||
int option_index;
|
||||
|
||||
optind = 1;
|
||||
optopt = 0;
|
||||
|
||||
int option_index = 0;
|
||||
option_index = 0;
|
||||
|
||||
while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case IDX_REMOVE_TIMER:
|
||||
case IDX_DEBUG_MODE:
|
||||
case IDX_SKIP:
|
||||
case IDX_LIMIT:
|
||||
case IDX_STATUS_TIMER:
|
||||
case IDX_WEAK_HASH_THRESHOLD:
|
||||
case IDX_HASH_MODE:
|
||||
case IDX_RUNTIME:
|
||||
case IDX_ATTACK_MODE:
|
||||
case IDX_RP_GEN:
|
||||
case IDX_RP_GEN_FUNC_MIN:
|
||||
case IDX_RP_GEN_FUNC_MAX:
|
||||
case IDX_RP_GEN_SEED:
|
||||
case IDX_MARKOV_THRESHOLD:
|
||||
case IDX_OUTFILE_FORMAT:
|
||||
case IDX_OUTFILE_CHECK_TIMER:
|
||||
case IDX_OPENCL_VECTOR_WIDTH:
|
||||
case IDX_WORKLOAD_PROFILE:
|
||||
case IDX_KERNEL_ACCEL:
|
||||
case IDX_KERNEL_LOOPS:
|
||||
case IDX_NVIDIA_SPIN_DAMP:
|
||||
case IDX_GPU_TEMP_ABORT:
|
||||
case IDX_GPU_TEMP_RETAIN:
|
||||
case IDX_HCCAPX_MESSAGE_PAIR:
|
||||
case IDX_NONCE_ERROR_CORRECTIONS:
|
||||
case IDX_VERACRYPT_PIM:
|
||||
case IDX_SEGMENT_SIZE:
|
||||
case IDX_SCRYPT_TMTO:
|
||||
case IDX_BITMAP_MIN:
|
||||
case IDX_BITMAP_MAX:
|
||||
case IDX_INCREMENT_MIN:
|
||||
case IDX_INCREMENT_MAX:
|
||||
|
||||
if (hc_string_is_digit (optarg) == false)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Not a number '%s'", optarg);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
option_index = 0;
|
||||
|
||||
while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user