Add progress display to solve_bs and solve_piwi_bs

This commit is contained in:
unkernet
2017-08-27 20:25:54 +03:00
parent c3f2c015c4
commit ee432c7932
2 changed files with 34 additions and 4 deletions

View File

@ -12,6 +12,7 @@
#define lli PRIi64
#define llu PRIu64
#define lu PRIu32
#define VT100_cleareol "\r\33[2K"
uint32_t **space;
size_t thread_count = 1;
@ -51,20 +52,27 @@ void* crack_states_thread(void* x){
break;
} else if(keys_found){
break;
} else {
printf("Cracking... %6.02f%%\n", (total_states_tested/(total_states/100.0)));
}
}
return NULL;
}
void notify_status_offline(int sig){
printf(VT100_cleareol "Cracking... %6.02f%%", (100.0*total_states_tested/(total_states)));
alarm(1);
fflush(stdout);
signal(SIGALRM, notify_status_offline);
}
int main(int argc, char* argv[]){
if(argc != 3){
printf("Usage: %s <nonces.txt> <uid>\n", argv[0]);
return -1;
}
printf("Reading nonces...\n");
uint64_t *nonces = readnonces(argv[1]);
uint32_t uid = strtoul(argv[2], NULL, 16);
printf("Deriving search space...\n");
space = craptev1_get_space(nonces, 95, uid);
total_states = craptev1_sizeof_space(space);
@ -108,12 +116,19 @@ int main(int argc, char* argv[]){
keys_found = 0;
printf("Starting %zu threads to test %"llu" states\n", thread_count, total_states);
signal(SIGALRM, notify_status_offline);
alarm(1);
for(i = 0; i < thread_count; i++){
pthread_create(&threads[i], NULL, crack_states_thread, (void*) i);
}
for(i = 0; i < thread_count; i++){
pthread_join(threads[i], 0);
}
alarm(0);
printf("Tested %"llu" states\n", total_states_tested);
craptev1_destroy_space(space);

View File

@ -12,6 +12,7 @@
#define lli PRIi64
#define llu PRIu64
#define lu PRIu32
#define VT100_cleareol "\r\33[2K"
uint64_t split(uint8_t p){
return (((p & 0x8) >>3 )| ((p & 0x4) >> 2) << 8 | ((p & 0x2) >> 1) << 16 | (p & 0x1) << 24 );
@ -54,19 +55,26 @@ void* crack_states_thread(void* x){
break;
} else if(keys_found){
break;
} else {
printf("Cracking... %6.02f%%\n", (100.0*total_states_tested/(total_states)));
}
}
return NULL;
}
void notify_status_offline(int sig){
printf(VT100_cleareol "Cracking... %6.02f%%", (100.0*total_states_tested/(total_states)));
alarm(1);
fflush(stdout);
signal(SIGALRM, notify_status_offline);
}
int main(int argc, char* argv[]){
if(argc != 2){
printf("Usage: %s <nonces.bin>\n", argv[0]);
return -1;
}
printf("Reading nonces...\n");
uint64_t *nonces = readnonces(argv[1]);
printf("Deriving search space...\n");
space = craptev1_get_space(nonces, 95, uid);
total_states = craptev1_sizeof_space(space);
@ -111,12 +119,19 @@ int main(int argc, char* argv[]){
keys_found = 0;
printf("Starting %u threads to test %"llu" states\n", thread_count, total_states);
signal(SIGALRM, notify_status_offline);
alarm(1);
for(i = 0; i < thread_count; i++){
pthread_create(&threads[i], NULL, crack_states_thread, (void*) i);
}
for(i = 0; i < thread_count; i++){
pthread_join(threads[i], 0);
}
alarm(0);
printf("Tested %"llu" states\n", total_states_tested);
craptev1_destroy_space(space);