Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/mfcuk-0.3.8+git20180720/src/mifare.h Examining data/mfcuk-0.3.8+git20180720/src/xgetopt.c Examining data/mfcuk-0.3.8+git20180720/src/nfc-utils.h Examining data/mfcuk-0.3.8+git20180720/src/crapto1.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.h Examining data/mfcuk-0.3.8+git20180720/src/crapto1.h Examining data/mfcuk-0.3.8+git20180720/src/nfc-utils.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.h Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_utils.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk.c Examining data/mfcuk-0.3.8+git20180720/src/xgetopt.h Examining data/mfcuk-0.3.8+git20180720/src/crypto1.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk.h Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_utils.h Examining data/mfcuk-0.3.8+git20180720/src/mifare.c Examining data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.c FINAL RESULTS: data/mfcuk-0.3.8+git20180720/src/mfcuk_utils.c:102:3: [4] (shell) system: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. system("cls"); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:980:16: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. while ((ch = getopt(argc, argv, "htTDCi:I:o:O:V:R:S:s:v:M:U:d:n:P:p:F:")) != -1) { // -1 or EOF data/mfcuk-0.3.8+git20180720/src/xgetopt.c:159:5: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int getopt(int argc, char *argv[], char *optstring) data/mfcuk-0.3.8+git20180720/src/xgetopt.h:25:5: [3] (buffer) getopt: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. int getopt(int argc, char *argv[], char *optstring); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:867:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(ti, &ti_tmp, sizeof(ti_tmp)); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:876:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char strOutputFilename[256] = {0}; // Initialize with '\0' character data/mfcuk-0.3.8+git20180720/src/mfcuk.c:946:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(current_default_keys, mfcuk_default_keys, numDefKeys * MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1018:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(current_default_keys[numDefKeys - 1]), &keyOpt, MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1029:19: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (!(i = atoi(optarg)) || (i < 1)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1038:19: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (!(i = atoi(optarg)) || (!IS_MIFARE_CLASSIC_1K(i) && !IS_MIFARE_CLASSIC_4K(i))) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1065:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(tag_recover_verify.tag_basic.amb[0].mbm.abtUID, uidOpt, MIFARE_CLASSIC_UID_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1071:19: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (!(i = atoi(optarg)) || (i < 1) || (i > 10000)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1080:19: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (!(i = atoi(optarg)) || (i < 1) || (i > 10000)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1104:30: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). if (!(sector = atoi(token)) && (token[0] != '0')) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1187:19: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(ptr_trailer->abtKeyA[0]), keyOpt, sizeof(keyOpt)); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1192:19: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(ptr_trailer->abtKeyB[0]), keyOpt, sizeof(keyOpt)); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1409:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(ptr_trailer->abtKeyA[0]), &(ptr_trailer_dump->abtKeyA[0]), MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1415:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(ptr_trailer->abtKeyB[0]), &(ptr_trailer_dump->abtKeyB[0]), MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1425:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(ptr_trailer, ptr_trailer_dump, sizeof(*ptr_trailer)); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1473:3: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(tag_on_reader.tag_basic.amb[0].mbm.abtUID, ti.nti.nai.abtUid, MIFARE_CLASSIC_UID_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1478:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(tag_recover_verify.tag_basic.amb[0].mbm.abtUID, ti.nti.nai.abtUid, MIFARE_CLASSIC_UID_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1519:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(current_default_keys[0][0]), (k == keyA) ? (&(ptr_trailer->abtKeyA[0])) : ((&(ptr_trailer->abtKeyB[0]))), MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1566:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(mp.mpa.abtAuthUid, tag_recover_verify.tag_basic.amb[0].mbm.abtUID, MIFARE_CLASSIC_UID_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1567:9: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(mp.mpa.abtKey, &(current_default_keys[j][0]), MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1580:11: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy((k == keyA) ? (ptr_trailer->abtKeyA) : (ptr_trailer->abtKeyB), current_default_keys[j], MIFARE_CLASSIC_KEY_BYTELENGTH); data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.c:106:43: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. if (((char *)(&tmpl->values))[i] == ((char *)dump)[i]) { data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.c:131:10: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(mfcuk_finger_db[i].tmpl_filename, "rb"); data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.c:159:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(tmpl_new->mask), &(mask), sizeof(mask)); data/mfcuk-0.3.8+git20180720/src/mfcuk_finger.c:160:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(&(tmpl_new->values), &(values), sizeof(values)); data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.c:287:8: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename, "wb"); data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.c:310:8: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename, "wb"); data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.c:333:8: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename, "rb"); data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.c:356:8: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fp = fopen(filename, "rb"); data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.h:105:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char datetime[14]; // non-zero-terminated date-time of dump in format YYYYMMDDH24MISS, example 20091114231541 - 14 Nov 2009, 11:15:41 PM data/mfcuk-0.3.8+git20180720/src/mfcuk_mifare.h:106:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char description[MFCUK_EXTENDED_DESCRIPTION_LENGTH]; // a description of the tag dump, example "RATB_DUMP_BEFORE_PAY" data/mfcuk-0.3.8+git20180720/src/mifare.c:98:5: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(abtCmd + 2, (uint8_t *) pmp, szParamLen); data/mfcuk-0.3.8+git20180720/src/mifare.c:130:7: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(pmp->mpd.abtData, abtRx, 16); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:984:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tag_recover_verify.description, optarg, sizeof(tag_recover_verify.description)); data/mfcuk-0.3.8+git20180720/src/mfcuk.c:993:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (strlen(optarg) != (MIFARE_CLASSIC_KEY_BYTELENGTH * 2)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1048:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (strlen(optarg) != (MIFARE_CLASSIC_UID_BYTELENGTH * 2)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1166:19: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if (strlen(token) != (MIFARE_CLASSIC_KEY_BYTELENGTH * 2)) { data/mfcuk-0.3.8+git20180720/src/mfcuk.c:1229:11: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(strOutputFilename, optarg, sizeof(strOutputFilename)); data/mfcuk-0.3.8+git20180720/src/mfcuk_utils.c:95:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(millis * 1000); ANALYSIS SUMMARY: Hits = 43 Lines analyzed = 4348 in approximately 0.15 seconds (29782 lines/second) Physical Source Lines of Code (SLOC) = 2428 Hits@level = [0] 117 [1] 6 [2] 33 [3] 3 [4] 1 [5] 0 Hits@level+ = [0+] 160 [1+] 43 [2+] 37 [3+] 4 [4+] 1 [5+] 0 Hits/KSLOC@level+ = [0+] 65.8979 [1+] 17.71 [2+] 15.2389 [3+] 1.64745 [4+] 0.411862 [5+] 0 Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.