From b112787d4f40c5fd948594303653f6b0ce444700 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Tue, 19 Jan 2016 21:48:29 +0100 Subject: [PATCH] ADD: Some instructions for configure CoverityScan using alternative compiler like the ARM-NONE-EABI-GCC FIX: stupid clock() == -1 on systems who doesn't have it.. --- README.md | 20 ++++++++ client/cmdhfmf.c | 24 +++++---- client/cmdhfmfhard.c | 94 +++++++++++++++++++----------------- client/loclass/elite_crack.c | 4 +- 4 files changed, 87 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 077ff0f6..3378f33c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,24 @@ NEWS: [![Coverity Scan Build Status](https://scan.coverity.com/projects/5117/badge.svg)](https://scan.coverity.com/projects/proxmark3-iceman-fork) +## Coverity Scan Config && Run + +Download the Coverity Scan Self-buld and install it. +You will need to configure ARM-NON-EABI- Compiler for it to use: + +:: Configure +cov-configure --comptype gcc --compiler /opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc + +::run it (I'm running on Ubuntu) +cov-build --dir cov-int make all UBUNTU_1404_QT4=1 + +:: make a tarball +tar czvf proxmark3.tgz cov-int + +:: upload it to coverity.com + +## Whats changed? + Whats in this fork? I have scraped the web for different enhancements to the PM3 source code and not all of them ever found their way to the master branch. Among the stuff is @@ -39,6 +57,8 @@ Among the stuff is * A Bruteforce for T55XX passwords against tag. * A Bruteforce for AWID 26, starting w a facilitycode then trying all 0xFFFF cardnumbers via simulation. To be used against a AWID Reader. + * Blaposts Crapto1 v3.3 + Give me a hint, and I'll see if I can't merge in the stuff you have. diff --git a/client/cmdhfmf.c b/client/cmdhfmf.c index b189e19b..bd7fa589 100644 --- a/client/cmdhfmf.c +++ b/client/cmdhfmf.c @@ -30,7 +30,7 @@ int CmdHF14AMifare(const char *Cmd) printf("Press button on the proxmark3 device to abort both proxmark3 and client.\n"); printf("-------------------------------------------------------------------------\n"); - clock_t t = clock(); + clock_t t1 = clock(); start: clearCommandBuffer(); @@ -91,9 +91,10 @@ start: printf("------------------------------------------------------------------\n"); PrintAndLog("Found valid key: %012"llx" \n", r_key); } - t = clock() - t; - //printf("Time in darkside: %d ticks - %1.2f seconds\n", t, ((float)t)/CLOCKS_PER_SEC); - printf("Time in darkside: %Lf ticks - %1.2Lf seconds\n", (long double)t, ((long double)t)/CLOCKS_PER_SEC); + t1 = clock() - t1; + if ( t1 > 0 ){ + PrintAndLog("Time in darkside: %f ticks - %1.2f sec\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC); + } return 0; } @@ -675,7 +676,7 @@ int CmdHF14AMfNested(const char *Cmd) } } else { // ------------------------------------ multiple sectors working - clock_t time1 = clock(); + clock_t t1 = clock(); e_sector = calloc(SectorsCnt, sizeof(sector)); if (e_sector == NULL) return 1; @@ -776,7 +777,10 @@ int CmdHF14AMfNested(const char *Cmd) } } - PrintAndLog("Time in nested: %1.2f (%1.2f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/iterations/CLOCKS_PER_SEC); + t1 = clock() - t1; + if ( t1 > 0 ) { + PrintAndLog("Time in nested: %f ticks %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/iterations/CLOCKS_PER_SEC); + } PrintAndLog("-----------------------------------------------\nIterations count: %d\n\n", iterations); //print them @@ -1131,7 +1135,7 @@ int CmdHF14AMfChk(const char *Cmd) } } // time - clock_t time1 = clock(); + clock_t t1 = clock(); for ( int t = !keyType; t < 2; keyType==2?(t++):(t=2) ) { int b=blockNo; @@ -1154,8 +1158,10 @@ int CmdHF14AMfChk(const char *Cmd) b<127?(b+=4):(b+=16); } } - printf("Time in checkkeys: %1.3f (%1.3f sec per key)\n\n", ((float)clock() - time1)/CLOCKS_PER_SEC, ((float)clock() - time1)/keycnt/CLOCKS_PER_SEC); - + t1 = clock() - t1; + if ( t1 > 0 ){ + printf("Time in checkkeys: %f ticks %1.2f sec (%1.2f sec per key)\n\n", (float)t1, ((float)t1)/CLOCKS_PER_SEC, ((float)t1)/keycnt/CLOCKS_PER_SEC); + } if (transferToEml) { uint8_t block[16]; diff --git a/client/cmdhfmfhard.c b/client/cmdhfmfhard.c index f506f4fd..f7c2f650 100644 --- a/client/cmdhfmfhard.c +++ b/client/cmdhfmfhard.c @@ -750,11 +750,13 @@ static void simulate_acquire_nonces() } while (num_good_first_bytes < GOOD_BYTES_REQUIRED); + time1 = clock() - time1; + if ( time1 > 0 ) { PrintAndLog("Acquired a total of %d nonces in %1.1f seconds (%0.0f nonces/minute)", total_num_nonces, - ((float)clock()-time1)/CLOCKS_PER_SEC, - total_num_nonces*60.0*CLOCKS_PER_SEC/((float)clock()-time1)); - + ((float)time1)/CLOCKS_PER_SEC, + total_num_nonces * 60.0 * CLOCKS_PER_SEC/(float)time1); + } fprintf(fstats, "%d;%d;%d;%1.2f;", total_num_nonces, total_added_nonces, num_good_first_bytes, CONFIDENCE_THRESHOLD); } @@ -876,11 +878,14 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_ fclose(fnonces); } + time1 = clock() - time1; + if ( time1 > 0 ) { PrintAndLog("Acquired a total of %d nonces in %1.1f seconds (%0.0f nonces/minute)", total_num_nonces, - ((float)clock()-time1)/CLOCKS_PER_SEC, - total_num_nonces*60.0*CLOCKS_PER_SEC/((float)clock()-time1)); - + ((float)time1)/CLOCKS_PER_SEC, + total_num_nonces * 60.0 * CLOCKS_PER_SEC/(float)time1 + ); + } return 0; } @@ -1434,47 +1439,48 @@ int mfnestedhard(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_t trgBloc fclose(fstats); } else { init_nonce_memory(); - if (nonce_file_read) { // use pre-acquired data from file nonces.bin - if (read_nonce_file() != 0) { - return 3; - } - Check_for_FilterFlipProperties(); - num_good_first_bytes = MIN(estimate_second_byte_sum(), GOOD_BYTES_REQUIRED); - } else { // acquire nonces. - uint16_t is_OK = acquire_nonces(blockNo, keyType, key, trgBlockNo, trgKeyType, nonce_file_write, slow); - if (is_OK != 0) { - return is_OK; + if (nonce_file_read) { // use pre-acquired data from file nonces.bin + if (read_nonce_file() != 0) { + return 3; + } + Check_for_FilterFlipProperties(); + num_good_first_bytes = MIN(estimate_second_byte_sum(), GOOD_BYTES_REQUIRED); + } else { // acquire nonces. + uint16_t is_OK = acquire_nonces(blockNo, keyType, key, trgBlockNo, trgKeyType, nonce_file_write, slow); + if (is_OK != 0) { + return is_OK; + } } - } - Tests(); - - PrintAndLog(""); - PrintAndLog("Sum(a0) = %d", first_byte_Sum); - // PrintAndLog("Best 10 first bytes: %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x", - // best_first_bytes[0], - // best_first_bytes[1], - // best_first_bytes[2], - // best_first_bytes[3], - // best_first_bytes[4], - // best_first_bytes[5], - // best_first_bytes[6], - // best_first_bytes[7], - // best_first_bytes[8], - // best_first_bytes[9] ); - PrintAndLog("Number of first bytes with confidence > %2.1f%%: %d", CONFIDENCE_THRESHOLD*100.0, num_good_first_bytes); - - clock_t start_time = clock(); - generate_candidates(first_byte_Sum, nonces[best_first_bytes[0]].Sum8_guess); - PrintAndLog("Time for generating key candidates list: %1.0f seconds", (float)(clock() - start_time)/CLOCKS_PER_SEC); - - brute_force(); - free_nonces_memory(); - free_statelist_cache(); - free_candidates_memory(candidates); - candidates = NULL; - } + Tests(); + + PrintAndLog(""); + PrintAndLog("Sum(a0) = %d", first_byte_Sum); + // PrintAndLog("Best 10 first bytes: %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x", + // best_first_bytes[0], + // best_first_bytes[1], + // best_first_bytes[2], + // best_first_bytes[3], + // best_first_bytes[4], + // best_first_bytes[5], + // best_first_bytes[6], + // best_first_bytes[7], + // best_first_bytes[8], + // best_first_bytes[9] ); + PrintAndLog("Number of first bytes with confidence > %2.1f%%: %d", CONFIDENCE_THRESHOLD*100.0, num_good_first_bytes); + + clock_t time1 = clock(); + generate_candidates(first_byte_Sum, nonces[best_first_bytes[0]].Sum8_guess); + time1 = clock() - time1; + if ( time1 > 0 ) + PrintAndLog("Time for generating key candidates list: %1.0f seconds", ((float)time1)/CLOCKS_PER_SEC); + brute_force(); + free_nonces_memory(); + free_statelist_cache(); + free_candidates_memory(candidates); + candidates = NULL; + } return 0; } diff --git a/client/loclass/elite_crack.c b/client/loclass/elite_crack.c index 2329e597..a282ec50 100644 --- a/client/loclass/elite_crack.c +++ b/client/loclass/elite_crack.c @@ -522,8 +522,8 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) errors += bruteforceItem(*attack, keytable); } free(attack); - clock_t t2 = clock(); - float diff = (((float)t2 - (float)t1) / CLOCKS_PER_SEC ); + t1 = clock() - t1; + float diff = ((float)t1 / CLOCKS_PER_SEC ); prnlog("\nPerformed full crack in %f seconds",diff); // Pick out the first 16 bytes of the keytable. -- 2.39.2