1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00

Merge pull request #270 from philsmd/pr-hlfmt-hash-len-check

added check for hash_len/hash_buf after calls to hlfmt_hash ()
This commit is contained in:
Jens Steube 2016-03-13 19:01:59 +01:00
commit 5d886658da

View File

@ -97,6 +97,7 @@ double TARGET_MS_PROFILE[3] = { 8, 16, 96 };
#define HL_MODE_FILE 4
#define HL_MODE_ARG 5
#define HLFMTS_CNT 11
#define HLFMT_HASHCAT 0
#define HLFMT_PWDUMP 1
#define HLFMT_PASSWD 2
@ -107,7 +108,17 @@ double TARGET_MS_PROFILE[3] = { 8, 16, 96 };
#define HLFMT_NETNTLM2 8
#define HLFMT_NSLDAP 9
#define HLFMT_NSLDAPS 10
#define HLFMTS_CNT 11
#define HLFMT_TEXT_HASHCAT "native hashcat"
#define HLFMT_TEXT_PWDUMP "pwdump"
#define HLFMT_TEXT_PASSWD "passwd"
#define HLFMT_TEXT_SHADOW "shadow"
#define HLFMT_TEXT_DCC "DCC"
#define HLFMT_TEXT_DCC2 "DCC 2"
#define HLFMT_TEXT_NETNTLM1 "NetNTLMv1"
#define HLFMT_TEXT_NETNTLM2 "NetNTLMv2"
#define HLFMT_TEXT_NSLDAP "nsldap"
#define HLFMT_TEXT_NSLDAPS "nsldaps"
#define ATTACK_MODE_STRAIGHT 0
#define ATTACK_MODE_COMBI 1
@ -5148,6 +5159,25 @@ static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_le
}
}
char *strhlfmt (const uint hashfile_format)
{
switch (hashfile_format)
{
case HLFMT_HASHCAT: return ((char *) HLFMT_TEXT_HASHCAT); break;
case HLFMT_PWDUMP: return ((char *) HLFMT_TEXT_PWDUMP); break;
case HLFMT_PASSWD: return ((char *) HLFMT_TEXT_PASSWD); break;
case HLFMT_SHADOW: return ((char *) HLFMT_TEXT_SHADOW); break;
case HLFMT_DCC: return ((char *) HLFMT_TEXT_DCC); break;
case HLFMT_DCC2: return ((char *) HLFMT_TEXT_DCC2); break;
case HLFMT_NETNTLM1: return ((char *) HLFMT_TEXT_NETNTLM1); break;
case HLFMT_NETNTLM2: return ((char *) HLFMT_TEXT_NETNTLM2); break;
case HLFMT_NSLDAP: return ((char *) HLFMT_TEXT_NSLDAP); break;
case HLFMT_NSLDAPS: return ((char *) HLFMT_TEXT_NSLDAPS); break;
}
return ((char *) "Unknown");
}
static uint hlfmt_detect (FILE *fp, uint max_check)
{
// Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
@ -10914,7 +10944,16 @@ int main (int argc, char **argv)
hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
if (hash_len)
bool hash_fmt_error = 0;
if (hash_len < 1) hash_fmt_error = 1;
if (hash_buf == NULL) hash_fmt_error = 1;
if (hash_fmt_error)
{
log_info ("WARNING: failed to parse hashes using the '%s' format", strhlfmt (hashlist_format));
}
else
{
if (opts_type & OPTS_TYPE_HASH_COPY)
{
@ -11142,6 +11181,18 @@ int main (int argc, char **argv)
hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
bool hash_fmt_error = 0;
if (hash_len < 1) hash_fmt_error = 1;
if (hash_buf == NULL) hash_fmt_error = 1;
if (hash_fmt_error)
{
log_info ("WARNING: failed to parse hashes using the '%s' format", strhlfmt (hashlist_format));
continue;
}
if (username)
{
char *user_buf = NULL;