1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-22 05:31:11 +00:00

Merge pull request #1439 from neheb/master

Change atoi family to strtol family
This commit is contained in:
Jens Steube 2017-11-13 09:10:57 +01:00 committed by GitHub
commit ea5425b344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 289 additions and 267 deletions

View File

@ -71,7 +71,7 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
do
{
int cpu_id = atoi (next);
int cpu_id = strtol (next, NULL, 10);
if (cpu_id == 0)
{

View File

@ -43,8 +43,6 @@ static void sysfs_close (hashcat_ctx_t *hashcat_ctx)
{
hcfree (sysfs);
}
return;
}
static char *hm_SYSFS_get_syspath_device (hashcat_ctx_t *hashcat_ctx, const int device_id)

View File

@ -2587,7 +2587,7 @@ int bcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
u8 *iter_pos = input_buf + 4;
salt->salt_iter = 1u << atoll ((const char *) iter_pos);
salt->salt_iter = 1u << strtoul ((const char *) iter_pos, NULL, 10);
u8 *salt_pos = (u8 *) strchr ((const char *) iter_pos, '$');
@ -3050,7 +3050,7 @@ int dcc2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
salt_t *salt = hash_buf->salt;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1)
{
@ -3186,8 +3186,8 @@ int dpapimk_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
contents_pos++;
u32 version = atoll ((const char *) version_pos);
u32 contents_len = atoll ((const char *) contents_len_pos);
u32 version = strtoul ((const char *) version_pos, NULL, 10);
u32 contents_len = strtoul ((const char *) contents_len_pos, NULL, 10);
if (version == 1 && contents_len != 208) return (PARSER_SALT_LENGTH);
if (version == 2 && contents_len != 288) return (PARSER_SALT_LENGTH);
@ -3200,9 +3200,9 @@ int dpapimk_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
if (effective_contents_len != contents_len) return (PARSER_SALT_LENGTH);
dpapimk->context = atoll ((const char *) context_pos);
dpapimk->context = strtoul ((const char *) context_pos, NULL, 10);
salt->salt_iter = (atoll ((const char *) rounds_pos)) - 1;
salt->salt_iter = strtoul ((const char *) rounds_pos, NULL, 10) - 1;
dpapimk->iv[0] = hex_to_u32 ((const u8 *) &iv_pos[ 0]);
dpapimk->iv[1] = hex_to_u32 ((const u8 *) &iv_pos[ 8]);
@ -3663,7 +3663,7 @@ int md5crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
salt_pos[0] = 0x0;
salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len));
salt->salt_iter = strtoul ((const char *) (salt_pos - iterations_len), NULL, 10);
salt_pos += 1;
@ -3722,7 +3722,7 @@ int md5apr1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
salt_pos[0] = 0x0;
salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len));
salt->salt_iter = strtoul ((const char *) (salt_pos - iterations_len), NULL, 10);
salt_pos += 1;
@ -5713,7 +5713,7 @@ int sha512crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB
salt_pos[0] = 0x0;
salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len));
salt->salt_iter = strtoul ((const char *) (salt_pos - iterations_len), NULL, 10);
salt_pos += 1;
@ -5834,7 +5834,7 @@ int chacha20_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
if (offset_marker == NULL) return (PARSER_SEPARATOR_UNMATCHED);
offset_marker++;
int offset = atoi ((char*) offset_marker);
int offset = strtol ((char*) offset_marker, NULL, 10);
if (offset > 63) return (PARSER_SALT_VALUE);
u8 *iv_marker = (u8 *) strchr ((const char *) offset_marker, '*');
@ -6467,9 +6467,9 @@ int sha1aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
u8 salt_iter[3] = { iter_pos[0], iter_pos[1], 0 };
salt->salt_sign[0] = atoll ((const char *) salt_iter);
salt->salt_sign[0] = strtoul ((const char *) salt_iter, NULL, 10);
salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1;
salt->salt_iter = (1u << strtoul ((const char *) salt_iter, NULL, 10)) - 1;
hash_pos++;
@ -6516,9 +6516,9 @@ int sha256aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 };
salt->salt_sign[0] = atoll ((const char *) salt_iter);
salt->salt_sign[0] = strtoul ((const char *) salt_iter, NULL, 10);
salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1;
salt->salt_iter = (1u << strtoul ((const char *) salt_iter, NULL, 10)) - 1;
hash_pos++;
@ -6568,9 +6568,9 @@ int sha512aix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
char salt_iter[3] = { iter_pos[0], iter_pos[1], 0 };
salt->salt_sign[0] = atoll ((const char *) salt_iter);
salt->salt_sign[0] = strtoul ((const char *) salt_iter, NULL, 10);
salt->salt_iter = (1u << atoll ((const char *) salt_iter)) - 1;
salt->salt_iter = (1u << strtoul ((const char *) salt_iter, NULL, 10)) - 1;
hash_pos++;
@ -6632,7 +6632,7 @@ int agilekey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
* pbkdf2 iterations
*/
salt->salt_iter = atoll ((const char *) iterations_pos) - 1;
salt->salt_iter = strtoul ((const char *) iterations_pos, NULL, 10) - 1;
/**
* handle salt encoding
@ -6742,7 +6742,7 @@ int lastpass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
salt->salt_len = salt_len;
salt->salt_iter = atoll ((const char *) iterations_pos) - 1;
salt->salt_iter = strtoul ((const char *) iterations_pos, NULL, 10) - 1;
if (is_valid_hex_string (hashbuf_pos, 32) == false) return (PARSER_HASH_ENCODING);
@ -6802,7 +6802,7 @@ int sha256crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB
salt_pos[0] = 0x0;
salt->salt_iter = atoll ((const char *) (salt_pos - iterations_len));
salt->salt_iter = strtoul ((const char *) (salt_pos - iterations_len), NULL, 10);
salt_pos += 1;
@ -6905,7 +6905,7 @@ int sha512macos_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB
salt->salt_buf[0] = pbkdf2_sha512->salt_buf[0];
salt->salt_iter = atoll ((const char *) iter_pos) - 1;
salt->salt_iter = strtoul ((const char *) iter_pos, NULL, 10) - 1;
return (PARSER_OK);
}
@ -7040,7 +7040,7 @@ int sha512grub_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
salt->salt_len = salt_len;
salt->salt_iter = atoll ((const char *) iter_pos) - 1;
salt->salt_iter = strtoul ((const char *) iter_pos, NULL, 10) - 1;
return (PARSER_OK);
}
@ -7931,7 +7931,7 @@ int cloudkey_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
// iteration
salt->salt_iter = atoll ((const char *) iteration_pos) - 1;
salt->salt_iter = strtoul ((const char *) iteration_pos, NULL, 10) - 1;
// data
@ -8071,7 +8071,7 @@ int nsec3_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
// iteration
salt->salt_iter = atoll ((const char *) iteration_pos);
salt->salt_iter = strtoul ((const char *) iteration_pos, NULL, 10);
return (PARSER_OK);
}
@ -8370,7 +8370,7 @@ int lotus8_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
tmp_iter_buf[10] = 0;
salt->salt_iter = atoll ((const char *) tmp_iter_buf);
salt->salt_iter = strtoul ((const char *) tmp_iter_buf, NULL, 10);
if (salt->salt_iter < 1) // well, the limit hopefully is much higher
{
@ -8752,7 +8752,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
N_pos++;
salt->scrypt_N = atoll ((const char *) N_pos);
salt->scrypt_N = strtoul ((const char *) N_pos, NULL, 10);
// r
@ -8762,7 +8762,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
r_pos++;
salt->scrypt_r = atoll ((const char *) r_pos);
salt->scrypt_r = strtoul ((const char *) r_pos, NULL, 10);
// p
@ -8772,7 +8772,7 @@ int scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNU
p_pos++;
salt->scrypt_p = atoll ((const char *) p_pos);
salt->scrypt_p = strtoul ((const char *) p_pos, NULL, 10);
// salt
@ -9062,10 +9062,10 @@ int office2007_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
if (osalt_len != 32) return (PARSER_SALT_LENGTH);
if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
const u32 version = atoll ((const char *) version_pos);
const u32 verifierHashSize = atoll ((const char *) verifierHashSize_pos);
const u32 keySize = atoll ((const char *) keySize_pos);
const u32 saltSize = atoll ((const char *) saltSize_pos);
const u32 version = strtoul ((const char *) version_pos, NULL, 10);
const u32 verifierHashSize = strtoul ((const char *) verifierHashSize_pos, NULL, 10);
const u32 keySize = strtoul ((const char *) keySize_pos, NULL, 10);
const u32 saltSize = strtoul ((const char *) saltSize_pos, NULL, 10);
if (version != 2007) return (PARSER_SALT_VALUE);
if (verifierHashSize != 20) return (PARSER_SALT_VALUE);
@ -9212,10 +9212,10 @@ int office2010_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
if (osalt_len != 32) return (PARSER_SALT_LENGTH);
if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
const u32 version = atoll ((const char *) version_pos);
const u32 spinCount = atoll ((const char *) spinCount_pos);
const u32 keySize = atoll ((const char *) keySize_pos);
const u32 saltSize = atoll ((const char *) saltSize_pos);
const u32 version = strtoul ((const char *) version_pos, NULL, 10);
const u32 spinCount = strtoul ((const char *) spinCount_pos, NULL, 10);
const u32 keySize = strtoul ((const char *) keySize_pos, NULL, 10);
const u32 saltSize = strtoul ((const char *) saltSize_pos, NULL, 10);
if (version != 2010) return (PARSER_SALT_VALUE);
if (spinCount != 100000) return (PARSER_SALT_VALUE);
@ -9366,10 +9366,10 @@ int office2013_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
if (osalt_len != 32) return (PARSER_SALT_LENGTH);
if (encryptedVerifier_len != 32) return (PARSER_SALT_LENGTH);
const u32 version = atoll ((const char *) version_pos);
const u32 spinCount = atoll ((const char *) spinCount_pos);
const u32 keySize = atoll ((const char *) keySize_pos);
const u32 saltSize = atoll ((const char *) saltSize_pos);
const u32 version = strtoul ((const char *) version_pos, NULL, 10);
const u32 spinCount = strtoul ((const char *) spinCount_pos, NULL, 10);
const u32 keySize = strtoul ((const char *) keySize_pos, NULL, 10);
const u32 saltSize = strtoul ((const char *) saltSize_pos, NULL, 10);
if (version != 2013) return (PARSER_SALT_VALUE);
if (spinCount != 100000) return (PARSER_SALT_VALUE);
@ -10072,7 +10072,7 @@ int djangopbkdf2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAY
u8 *iter_pos = input_buf + 14;
const int iter = atoi ((const char *) iter_pos);
const int iter = strtol ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
@ -10256,7 +10256,7 @@ int saph_sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
u8 *iter_pos = input_buf + 10;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1)
{
@ -10502,26 +10502,26 @@ int pdf11_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
// validate data
const int V = atoi ((const char *) V_pos);
const int R = atoi ((const char *) R_pos);
const int P = atoi ((const char *) P_pos);
const int V = strtol ((const char *) V_pos, NULL, 10);
const int R = strtol ((const char *) R_pos, NULL, 10);
const int P = strtol ((const char *) P_pos, NULL, 10);
if (V != 1) return (PARSER_SALT_VALUE);
if (R != 2) return (PARSER_SALT_VALUE);
const int enc_md = atoi ((const char *) enc_md_pos);
const int enc_md = strtol ((const char *) enc_md_pos, NULL, 10);
if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE);
const int id_len = atoi ((const char *) id_len_pos);
const int u_len = atoi ((const char *) u_len_pos);
const int o_len = atoi ((const char *) o_len_pos);
const int id_len = strtol ((const char *) id_len_pos, NULL, 10);
const int u_len = strtol ((const char *) u_len_pos, NULL, 10);
const int o_len = strtol ((const char *) o_len_pos, NULL, 10);
if (id_len != 16) return (PARSER_SALT_VALUE);
if (u_len != 32) return (PARSER_SALT_VALUE);
if (o_len != 32) return (PARSER_SALT_VALUE);
const int bits = atoi ((const char *) bits_pos);
const int bits = strtol ((const char *) bits_pos, NULL, 10);
if (bits != 40) return (PARSER_SALT_VALUE);
@ -10704,26 +10704,26 @@ int pdf11cm2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
// validate data
const int V = atoi ((const char *) V_pos);
const int R = atoi ((const char *) R_pos);
const int P = atoi ((const char *) P_pos);
const int V = strtol ((const char *) V_pos, NULL, 10);
const int R = strtol ((const char *) R_pos, NULL, 10);
const int P = strtol ((const char *) P_pos, NULL, 10);
if (V != 1) return (PARSER_SALT_VALUE);
if (R != 2) return (PARSER_SALT_VALUE);
const int enc_md = atoi ((const char *) enc_md_pos);
const int enc_md = strtol ((const char *) enc_md_pos, NULL, 10);
if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE);
const int id_len = atoi ((const char *) id_len_pos);
const int u_len = atoi ((const char *) u_len_pos);
const int o_len = atoi ((const char *) o_len_pos);
const int id_len = strtol ((const char *) id_len_pos, NULL, 10);
const int u_len = strtol ((const char *) u_len_pos, NULL, 10);
const int o_len = strtol ((const char *) o_len_pos, NULL, 10);
if (id_len != 16) return (PARSER_SALT_VALUE);
if (u_len != 32) return (PARSER_SALT_VALUE);
if (o_len != 32) return (PARSER_SALT_VALUE);
const int bits = atoi ((const char *) bits_pos);
const int bits = strtol ((const char *) bits_pos, NULL, 10);
if (bits != 40) return (PARSER_SALT_VALUE);
@ -10912,9 +10912,9 @@ int pdf14_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
// validate data
const int V = atoi ((const char *) V_pos);
const int R = atoi ((const char *) R_pos);
const int P = atoi ((const char *) P_pos);
const int V = strtol ((const char *) V_pos, NULL, 10);
const int R = strtol ((const char *) R_pos, NULL, 10);
const int P = strtol ((const char *) P_pos, NULL, 10);
int vr_ok = 0;
@ -10923,16 +10923,16 @@ int pdf14_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
if (vr_ok == 0) return (PARSER_SALT_VALUE);
const int id_len = atoi ((const char *) id_len_pos);
const int u_len = atoi ((const char *) u_len_pos);
const int o_len = atoi ((const char *) o_len_pos);
const int id_len = strtol ((const char *) id_len_pos, NULL, 10);
const int u_len = strtol ((const char *) u_len_pos, NULL, 10);
const int o_len = strtol ((const char *) o_len_pos, NULL, 10);
if ((id_len != 16) && (id_len != 32)) return (PARSER_SALT_VALUE);
if (u_len != 32) return (PARSER_SALT_VALUE);
if (o_len != 32) return (PARSER_SALT_VALUE);
const int bits = atoi ((const char *) bits_pos);
const int bits = strtol ((const char *) bits_pos, NULL, 10);
if (bits != 128) return (PARSER_SALT_VALUE);
@ -10940,7 +10940,7 @@ int pdf14_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUS
if (R >= 4)
{
enc_md = atoi ((const char *) enc_md_pos);
enc_md = strtol ((const char *) enc_md_pos, NULL, 10);
}
// copy data to esalt
@ -11182,8 +11182,8 @@ int pdf17l8_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
// validate data
const int V = atoi ((const char *) V_pos);
const int R = atoi ((const char *) R_pos);
const int V = strtol ((const char *) V_pos, NULL, 10);
const int R = strtol ((const char *) R_pos, NULL, 10);
int vr_ok = 0;
@ -11192,17 +11192,17 @@ int pdf17l8_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
if (vr_ok == 0) return (PARSER_SALT_VALUE);
const int bits = atoi ((const char *) bits_pos);
const int bits = strtol ((const char *) bits_pos, NULL, 10);
if (bits != 256) return (PARSER_SALT_VALUE);
int enc_md = atoi ((const char *) enc_md_pos);
int enc_md = strtol ((const char *) enc_md_pos, NULL, 10);
if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE);
const u32 id_len = atoll ((const char *) id_len_pos);
const u32 u_len = atoll ((const char *) u_len_pos);
const u32 o_len = atoll ((const char *) o_len_pos);
const u32 id_len = strtoul ((const char *) id_len_pos, NULL, 10);
const u32 u_len = strtoul ((const char *) u_len_pos, NULL, 10);
const u32 o_len = strtoul ((const char *) o_len_pos, NULL, 10);
if (V_len > 6) return (PARSER_SALT_LENGTH);
if (R_len > 6) return (PARSER_SALT_LENGTH);
@ -11266,7 +11266,7 @@ int pbkdf2_sha256_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA
u8 *iter_pos = input_buf + 7;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
if (iter > 999999) return (PARSER_SALT_ITERATION);
@ -11589,10 +11589,10 @@ int bitcoin_wallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, M
u32 public_key_buf_len = input_len - 1 - 7 - 1 - cry_master_len_len - 1 - cry_master_buf_len - 1 - cry_salt_len_len - 1 - cry_salt_buf_len - 1 - cry_rounds_len - 1 - ckey_len_len - 1 - ckey_buf_len - 1 - public_key_len_len - 1;
const u32 cry_master_len = atoll ((const char *) cry_master_len_pos);
const u32 cry_salt_len = atoll ((const char *) cry_salt_len_pos);
const u32 ckey_len = atoll ((const char *) ckey_len_pos);
const u32 public_key_len = atoll ((const char *) public_key_len_pos);
const u32 cry_master_len = strtoul ((const char *) cry_master_len_pos, NULL, 10);
const u32 cry_salt_len = strtoul ((const char *) cry_salt_len_pos, NULL, 10);
const u32 ckey_len = strtoul ((const char *) ckey_len_pos, NULL, 10);
const u32 public_key_len = strtoul ((const char *) public_key_len_pos, NULL, 10);
if (cry_master_buf_len != cry_master_len) return (PARSER_SALT_VALUE);
if (cry_salt_buf_len != cry_salt_len) return (PARSER_SALT_VALUE);
@ -11639,7 +11639,7 @@ int bitcoin_wallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, M
if (cry_rounds_len >= 7) return (PARSER_SALT_VALUE);
const u32 cry_rounds = atoll ((const char *) cry_rounds_pos);
const u32 cry_rounds = strtoul ((const char *) cry_rounds_pos, NULL, 10);
salt->salt_iter = cry_rounds - 1;
@ -12184,13 +12184,13 @@ int seven_zip_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
data_buf_len = input_len - 1 - 2 - 1 - data_type_len - 1 - NumCyclesPower_len - 1 - salt_len_len - 1 - salt_buf_len - 1 - iv_len_len - 1 - iv_buf_len - 1 - crc_buf_len - 1 - data_len_len - 1 - unpack_size_len - 1;
}
const u32 iter = atoll ((const char *) NumCyclesPower_pos);
const u32 crc = atoll ((const char *) crc_buf_pos);
const u32 data_type = atoll ((const char *) data_type_pos);
const u32 salt_len = atoll ((const char *) salt_len_pos);
const u32 iv_len = atoll ((const char *) iv_len_pos);
const u32 unpack_size = atoll ((const char *) unpack_size_pos);
const u32 data_len = atoll ((const char *) data_len_pos);
const u32 iter = strtoul ((const char *) NumCyclesPower_pos, NULL, 10);
const u32 crc = strtoul ((const char *) crc_buf_pos, NULL, 10);
const u32 data_type = strtoul ((const char *) data_type_pos, NULL, 10);
const u32 salt_len = strtoul ((const char *) salt_len_pos, NULL, 10);
const u32 iv_len = strtoul ((const char *) iv_len_pos, NULL, 10);
const u32 unpack_size = strtoul ((const char *) unpack_size_pos, NULL, 10);
const u32 data_len = strtoul ((const char *) data_len_pos, NULL, 10);
// if neither uncompressed nor truncated, then we need the length for crc and coder attributes
@ -12204,7 +12204,7 @@ int seven_zip_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_
coder_attributes_len = input_len - 1 - 2 - 1 - data_type_len - 1 - NumCyclesPower_len - 1 - salt_len_len - 1 - salt_buf_len - 1 - iv_len_len - 1 - iv_buf_len - 1 - crc_buf_len - 1 - data_len_len - 1 - unpack_size_len - 1 - data_buf_len - 1 - crc_len_len - 1;
crc_len = atoll ((const char *) crc_len_pos);
crc_len = strtoul ((const char *) crc_len_pos, NULL, 10);
}
/**
@ -12413,7 +12413,7 @@ int pbkdf2_md5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
u8 *iter_pos = input_buf + 4;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
if (iter > 999999) return (PARSER_SALT_ITERATION);
@ -12497,7 +12497,7 @@ int pbkdf2_sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB
u8 *iter_pos = input_buf + 5;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
if (iter > 999999) return (PARSER_SALT_ITERATION);
@ -12586,7 +12586,7 @@ int pbkdf2_sha512_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA
u8 *iter_pos = input_buf + 7;
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
if (iter > 999999) return (PARSER_SALT_ITERATION);
@ -12913,9 +12913,9 @@ int rar5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
u8 *iv = param3_pos;
u8 *pswcheck = param5_pos;
const u32 salt_len = atoll ((const char *) param0_pos);
const u32 iterations = atoll ((const char *) param2_pos);
const u32 pswcheck_len = atoll ((const char *) param4_pos);
const u32 salt_len = strtoul ((const char *) param0_pos, NULL, 10);
const u32 iterations = strtoul ((const char *) param2_pos, NULL, 10);
const u32 pswcheck_len = strtoul ((const char *) param4_pos, NULL, 10);
/**
* verify some data
@ -13105,7 +13105,7 @@ int axcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
u8 *data_pos;
salt->salt_iter = atoll ((const char *) wrapping_rounds_pos);
salt->salt_iter = strtoul ((const char *) wrapping_rounds_pos, NULL, 10);
salt_pos = (u8 *) strchr ((const char *) wrapping_rounds_pos, '*');
@ -13213,7 +13213,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
version_pos = input_buf + 8 + 1 + 1;
keepass->version = atoll ((const char *) version_pos);
keepass->version = strtoul ((const char *) version_pos, NULL, 10);
rounds_pos = (u8 *) strchr ((const char *) version_pos, '*');
@ -13221,7 +13221,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
rounds_pos++;
salt->salt_iter = (atoll ((const char *) rounds_pos));
salt->salt_iter = strtoul ((const char *) rounds_pos, NULL, 10);
algorithm_pos = (u8 *) strchr ((const char *) rounds_pos, '*');
@ -13229,7 +13229,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
algorithm_pos++;
keepass->algorithm = atoll ((const char *) algorithm_pos);
keepass->algorithm = strtoul ((const char *) algorithm_pos, NULL, 10);
final_random_seed_pos = (u8 *) strchr ((const char *) algorithm_pos, '*');
@ -13360,7 +13360,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
inline_flag_pos++;
u32 inline_flag = atoll ((const char *) inline_flag_pos);
u32 inline_flag = strtoul ((const char *) inline_flag_pos, NULL, 10);
if (inline_flag != 1) return (PARSER_SALT_LENGTH);
@ -13370,7 +13370,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
contents_len_pos++;
int contents_len = atoi ((const char *) contents_len_pos);
int contents_len = strtol ((const char *) contents_len_pos, NULL, 10);
if (contents_len > 50000) return (PARSER_SALT_LENGTH);
@ -13500,7 +13500,7 @@ int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
keyfile_len_pos++;
int keyfile_len = atoi ((const char *) keyfile_len_pos);
int keyfile_len = strtol ((const char *) keyfile_len_pos, NULL, 10);
keepass->keyfile_len = keyfile_len;
@ -13689,7 +13689,7 @@ int mywallet_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_U
if (data_buf_len % 16) return (PARSER_HASH_LENGTH);
u32 data_len = atoll ((const char *) data_len_pos);
u32 data_len = strtoul ((const char *) data_len_pos, NULL, 10);
if ((data_len * 2) != data_buf_len) return (PARSER_HASH_LENGTH);
@ -13783,11 +13783,11 @@ int mywalletv2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
if (data_buf_len % 16) return (PARSER_HASH_LENGTH);
u32 data_len = atoll ((const char *) data_len_pos);
u32 data_len = strtoul ((const char *) data_len_pos, NULL, 10);
if ((data_len * 2) != data_buf_len) return (PARSER_HASH_LENGTH);
u32 iter = atoll ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
/**
* salt
@ -13888,7 +13888,7 @@ int ms_drsr_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UN
salt->salt_len = salt_len / 2;
salt->salt_iter = atoll ((const char *) iter_pos) - 1u;
salt->salt_iter = strtoul ((const char *) iter_pos, NULL, 10) - 1ul;
/**
* digest buf
@ -14078,9 +14078,9 @@ int zip2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
u32 param7_len = param8_pos - param7_pos;
const u32 type = atoll ((const char *) param0_pos);
const u32 mode = atoll ((const char *) param1_pos);
const u32 magic = atoll ((const char *) param2_pos);
const u32 type = strtoul ((const char *) param0_pos, NULL, 10);
const u32 mode = strtoul ((const char *) param1_pos, NULL, 10);
const u32 magic = strtoul ((const char *) param2_pos, NULL, 10);
u8 *salt_buf = param3_pos;
@ -14091,7 +14091,7 @@ int zip2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE
return (PARSER_SALT_VALUE);
}
const u32 compress_length = atoll ((const char *) param5_pos);
const u32 compress_length = strtoul ((const char *) param5_pos, NULL, 10);
u8 *data_buf = param6_pos;
u8 *auth = param7_pos;
@ -14764,7 +14764,7 @@ int itunes_backup_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA
if ((version_len != 1) && (version_len != 2)) return (PARSER_SEPARATOR_UNMATCHED);
u32 version = atoi ((const char *) version_pos);
u32 version = strtoul ((const char *) version_pos, NULL, 10);
if (hash_mode == 14700)
{
@ -14780,7 +14780,7 @@ int itunes_backup_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA
if (iter_len < 1) return (PARSER_SALT_ITERATION);
if (iter_len > 6) return (PARSER_SALT_ITERATION);
u32 iter = atoi ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
@ -14801,7 +14801,7 @@ int itunes_backup_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA
if (dpic_len < 1) return (PARSER_SALT_ITERATION);
if (dpic_len > 9) return (PARSER_SALT_ITERATION);
dpic = atoi ((const char *) dpic_pos);
dpic = strtoul ((const char *) dpic_pos, NULL, 10);
if (dpic < 1) return (PARSER_SALT_ITERATION);
@ -15146,7 +15146,7 @@ int netbsd_sha1crypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf,
* verify data
*/
u32 iter = atoi ((const char *) iter_pos);
u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 99) return (PARSER_SALT_ITERATION); // (actually: CRYPT_SHA1_ITERATIONS should be 24680 or more)
@ -15478,7 +15478,7 @@ int ethereum_pbkdf2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf,
* verify some data
*/
const u32 iter = atoi ((const char *) iter_pos);
const u32 iter = strtoul ((const char *) iter_pos, NULL, 10);
if (iter < 1) return (PARSER_SALT_ITERATION);
@ -15618,9 +15618,9 @@ int ethereum_scrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf,
* verify some data
*/
const u32 scrypt_N = atoi ((const char *) scryptN_pos);
const u32 scrypt_r = atoi ((const char *) scryptr_pos);
const u32 scrypt_p = atoi ((const char *) scryptp_pos);
const u32 scrypt_N = strtoul ((const char *) scryptN_pos, NULL, 10);
const u32 scrypt_r = strtoul ((const char *) scryptr_pos, NULL, 10);
const u32 scrypt_p = strtoul ((const char *) scryptp_pos, NULL, 10);
if (salt_len != 64) return (PARSER_SALT_LENGTH);
if (ciphertext_len != 64) return (PARSER_SALT_LENGTH);

View File

@ -123,7 +123,7 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char
do
{
int platform = atoi (next);
int platform = strtol (next, NULL, 10);
if (platform < 1 || platform > 32)
{
@ -166,7 +166,7 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_
do
{
int device_id = atoi (next);
int device_id = strtol (next, NULL, 10);
if (device_id < 1 || device_id > 32)
{
@ -209,7 +209,7 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op
do
{
int device_type = atoi (next);
int device_type = strtol (next, NULL, 10);
if (device_type < 1 || device_type > 3)
{
@ -3338,23 +3338,23 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
// ROCm is so much better, we should give the user some hint and remove this block
// AMDGPU-PRO Driver 16.40 and higher
if (atoi (device_param->driver_version) >= 2117) amd_warn = false;
if (strtoul (device_param->driver_version, NULL, 10) >= 2117) amd_warn = false;
// AMDGPU-PRO Driver 16.50 is known to be broken
if (atoi (device_param->driver_version) == 2236) amd_warn = true;
if (strtoul (device_param->driver_version, NULL, 10) == 2236) amd_warn = true;
// AMDGPU-PRO Driver 16.60 is known to be broken
if (atoi (device_param->driver_version) == 2264) amd_warn = true;
if (strtoul (device_param->driver_version, NULL, 10) == 2264) amd_warn = true;
// AMDGPU-PRO Driver 17.10 is known to be broken
if (atoi (device_param->driver_version) == 2348) amd_warn = true;
if (strtoul (device_param->driver_version, NULL, 10) == 2348) amd_warn = true;
// AMDGPU-PRO Driver 17.20 (2416) is fine, doesn't need check will match >= 2117
}
else
{
// Support for ROCm platform
if (atof (device_param->driver_version) >= 1.1) amd_warn = false;
if (strtof (device_param->driver_version, NULL) >= 1.1) amd_warn = false;
}
#elif defined (_WIN)
// AMD Radeon Software 14.9 and higher, should be updated to 15.12
if (atoi (device_param->driver_version) >= 1573) amd_warn = false;
if (strtoul (device_param->driver_version, NULL, 10) >= 1573) amd_warn = false;
#else
// we have no information about other os
if (amd_warn == true) amd_warn = false;
@ -3379,7 +3379,7 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
int nv_warn = true;
// nvidia driver 367.x and higher
if (atoi (device_param->driver_version) >= 367) nv_warn = false;
if (strtoul (device_param->driver_version, NULL, 10) >= 367) nv_warn = false;
if (nv_warn == true)
{
@ -4277,7 +4277,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
{
if (device_param->platform_vendor_id == VENDOR_ID_INTEL_SDK)
{
strncat (build_opts_new, " -cl-opt-disable", sizeof (build_opts_new) - 1);
strncat (build_opts_new, " -cl-opt-disable", 16);
}
}

View File

@ -454,7 +454,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign
tmp_buf[tmp_len++] = 'X';
tmp_buf[tmp_len++] = '[';
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
exec_hexify (plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
tmp_len += plain_len * 2;
@ -477,7 +477,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign
if (outfile_ctx->outfile_format & OUTFILE_FMT_HEXPLAIN)
{
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
exec_hexify (plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
tmp_len += plain_len * 2;

View File

@ -389,7 +389,8 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (has_base_left == true)
{
@ -400,7 +401,8 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
return GUESS_MODE_COMBINATOR_BASE_RIGHT;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (has_mask_cs == true)
{
@ -411,7 +413,8 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
return GUESS_MODE_MASK;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if (has_mask_cs == true)
{
@ -422,7 +425,8 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
return GUESS_MODE_HYBRID1;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (has_mask_cs == true)
{
@ -452,7 +456,8 @@ char *status_get_guess_base (const hashcat_ctx_t *hashcat_ctx)
return strdup (straight_ctx->dict);
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
@ -465,19 +470,22 @@ char *status_get_guess_base (const hashcat_ctx_t *hashcat_ctx)
return strdup (combinator_ctx->dict2);
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return strdup (mask_ctx->mask);
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return strdup (straight_ctx->dict);
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
@ -507,23 +515,27 @@ int status_get_guess_base_offset (const hashcat_ctx_t *hashcat_ctx)
return straight_ctx->dicts_pos + 1;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_pos + 1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return straight_ctx->dicts_pos + 1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
@ -553,23 +565,27 @@ int status_get_guess_base_count (const hashcat_ctx_t *hashcat_ctx)
return straight_ctx->dicts_cnt;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_cnt;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return straight_ctx->dicts_cnt;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
@ -662,21 +678,25 @@ int status_get_guess_mod_offset (const hashcat_ctx_t *hashcat_ctx)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_pos + 1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{
@ -704,21 +724,25 @@ int status_get_guess_mod_count (const hashcat_ctx_t *hashcat_ctx)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
return 1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_cnt;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
{

View File

@ -179,9 +179,9 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
int kernel_accel = -1;
int kernel_loops = -1;
if (token_ptr[1][0] != '*') attack_mode = atoi (token_ptr[1]);
if (token_ptr[2][0] != '*') hash_type = atoi (token_ptr[2]);
if (token_ptr[3][0] != 'N') vector_width = atoi (token_ptr[3]);
if (token_ptr[1][0] != '*') attack_mode = strtol (token_ptr[1], NULL, 10);
if (token_ptr[2][0] != '*') hash_type = strtol (token_ptr[2], NULL, 10);
if (token_ptr[3][0] != 'N') vector_width = strtol (token_ptr[3], NULL, 10);
if (token_ptr[4][0] == 'A')
{
@ -193,7 +193,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
kernel_accel = atoi (token_ptr[4]);
kernel_accel = strtol (token_ptr[4], NULL, 10);
if ((kernel_accel < 1) || (kernel_accel > 1024))
{
@ -224,7 +224,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
kernel_loops = atoi (token_ptr[5]);
kernel_loops = strtol (token_ptr[5], NULL, 10);
if (kernel_loops < 1)
{