diff --git a/libnfc_crypto1_crack.c b/libnfc_crypto1_crack.c index 5f1e283..1b41542 100755 --- a/libnfc_crypto1_crack.c +++ b/libnfc_crypto1_crack.c @@ -517,6 +517,7 @@ void * update_predictions_thread(void* p){ if(space){ total_states = craptev1_sizeof_space(space); } + sleep(1); // We don't need to check this more often than once per second } return NULL; } diff --git a/solve_bs.c b/solve_bs.c index 741202e..bf14d9a 100644 --- a/solve_bs.c +++ b/solve_bs.c @@ -8,6 +8,7 @@ #include "crypto1_bs.h" #include "crypto1_bs_crack.h" #include +#include #define __STDC_FORMAT_MACROS #define llx PRIx64 #define lli PRIi64 @@ -16,7 +17,7 @@ #define VT100_cleareol "\r\33[2K" uint32_t **space; -size_t thread_count = 1; +uint8_t thread_count = 1; uint64_t *readnonces(char* fname) { int i, j; @@ -120,7 +121,7 @@ int main(int argc, char* argv[]){ total_states_tested = 0; keys_found = 0; - printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states); + printf("Starting %u threads to test %"llu" (~2^%0.2f) states\n", thread_count, total_states, log(total_states) / log(2)); signal(SIGALRM, notify_status_offline); alarm(1); @@ -134,7 +135,9 @@ int main(int argc, char* argv[]){ alarm(0); - printf("Tested %"llu" states\n", total_states_tested); + printf("\nTested %"llu" states\n", total_states_tested); + + if(!keys_found) fprintf(stderr, "No solution found :(\n"); craptev1_destroy_space(space); return 0; diff --git a/solve_piwi_bs.c b/solve_piwi_bs.c index ac56717..1d149e7 100644 --- a/solve_piwi_bs.c +++ b/solve_piwi_bs.c @@ -8,6 +8,7 @@ #include "crypto1_bs.h" #include "crypto1_bs_crack.h" #include +#include #define __STDC_FORMAT_MACROS #define llx PRIx64 #define lli PRIi64 @@ -23,6 +24,10 @@ uint32_t uid; uint64_t *readnonces(char* fname){ int i; FILE *f = fopen(fname, "rb"); + if (f == NULL) { + fprintf(stderr, "Cannot open file.\n"); + exit(EXIT_FAILURE); + } uint64_t *nonces = malloc(sizeof (uint64_t) << 24); if(fread(&uid, 1, 4, f)){ uid = rev32(uid); @@ -119,7 +124,7 @@ int main(int argc, char* argv[]){ total_states_tested = 0; keys_found = 0; - printf("Starting %u threads to test %"llu" states\n", thread_count, total_states); + printf("Starting %u threads to test %"llu" (~2^%0.2f) states\n", thread_count, total_states, log(total_states) / log(2)); signal(SIGALRM, notify_status_offline); alarm(1);