fix bad string formatters and pointer is always NULL no need to check

This commit is contained in:
iceman1001 2024-09-06 10:01:32 +02:00
commit d5015c8ba0

View file

@ -51,7 +51,8 @@ static int bin_to_uint8_arr(const char *bin_str, uint8_t bit_arr[], uint8_t arr_
}
static uint64_t *generate_keys(uint64_t authuid, uint32_t nt, uint32_t nt_enc, uint32_t nt_par_enc, uint32_t *keyCount) {
uint64_t *result_keys = (uint64_t *)malloc(KEY_SPACE_SIZE * sizeof(uint64_t));
uint64_t *result_keys = (uint64_t *)calloc(1, KEY_SPACE_SIZE * sizeof(uint64_t));
if (result_keys == NULL) {
fprintf(stderr, "\nMalloc error in generate_and_intersect_keys!\n");
return NULL;
@ -67,9 +68,9 @@ static uint64_t *generate_keys(uint64_t authuid, uint32_t nt, uint32_t nt_enc, u
free(result_keys);
return NULL;
}
if (revstate_start == NULL) {
revstate_start = revstate;
}
revstate_start = revstate;
s = crypto1_create(0);
if (s == NULL) {
fprintf(stderr, "\nMalloc error in generate_keys!\n");
@ -77,6 +78,7 @@ static uint64_t *generate_keys(uint64_t authuid, uint32_t nt, uint32_t nt_enc, u
crypto1_destroy(revstate_start);
return 0;
}
while ((revstate->odd != 0x0) || (revstate->even != 0x0)) {
lfsr_rollback_word(revstate, nt ^ authuid, 0);
crypto1_get_lfsr(revstate, &lfsr);
@ -99,6 +101,7 @@ static uint64_t *generate_keys(uint64_t authuid, uint32_t nt, uint32_t nt_enc, u
}
revstate++;
}
crypto1_destroy(s);
crypto1_destroy(revstate_start);
revstate_start = NULL;
@ -140,11 +143,11 @@ int main(int argc, char *const argv[]) {
printf("Finding key candidates...\n");
keys = generate_keys(authuid, nt, nt_enc, nt_par_enc, &keyCount);
printf("Finding phase complete, found %i keys\n", keyCount);
printf("Finding phase complete, found %u keys\n", keyCount);
FILE *fptr;
char filename[30];
snprintf(filename, sizeof(filename), "keys_%08x_%02i_%08x.dic", authuid, sector, nt);
snprintf(filename, sizeof(filename), "keys_%08x_%02u_%08x.dic", authuid, sector, nt);
fptr = fopen(filename, "w");
if (fptr != NULL) {