text
Some checks failed
MacOS Build and Test / macos-make-btaddon (push) Has been cancelled
MacOS Build and Test / macos-cmake (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-make-btaddon (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
MacOS Build and Test / macos-make (push) Has been cancelled
Ubuntu Build and Test / ubuntu-cmake (push) Has been cancelled
Windows Build and Test / proxspace (push) Has been cancelled
Windows Build and Test / wsl (push) Has been cancelled

This commit is contained in:
iceman1001 2025-06-22 20:34:54 +02:00
commit 5de4dd68e5
15 changed files with 107 additions and 66 deletions

View file

@ -5971,10 +5971,10 @@ static int CmdHFiClassSAM(const char *Cmd) {
}
if (snmp_data) {
uint8_t header[4] = {0xa0, cmdlen+2 , 0x94, cmdlen };
memmove(data + 4, data, cmdlen+1);
uint8_t header[4] = {0xa0, cmdlen + 2, 0x94, cmdlen };
memmove(data + 4, data, cmdlen + 1);
data[0] = flags;
memcpy(data+1, header, 4);
memcpy(data + 1, header, 4);
cmdlen += 4;
}
@ -6049,21 +6049,21 @@ static int CmdHFiClassSAM(const char *Cmd) {
} else {
//if it is an error decode it
if (memcmp(d, "\xBE\x07\x80\x01", 4) == 0) { //if it the string is 0xbe 0x07 0x80 0x01 the next byte will indicate the error code
PrintAndLogEx(ERR,_RED_("Sam Error Code: %02x"), d[4]);
PrintAndLogEx(ERR, _RED_("Sam Error Code: %02x"), d[4]);
print_hex(d, resp.length);
}else if (match_with_wildcard(d, snmp_pattern, snmp_mask, 6)){
} else if (match_with_wildcard(d, snmp_pattern, snmp_mask, 6)) {
is_snmp = true;
PrintAndLogEx(SUCCESS, _YELLOW_("[samSNMPMessageResponse] ")"%s", sprint_hex(d + 6, resp.length - 6));
}else if (match_with_wildcard(d,ok_pattern, ok_mask, 3)){
} else if (match_with_wildcard(d, ok_pattern, ok_mask, 3)) {
PrintAndLogEx(SUCCESS, _YELLOW_("[samResponseAcknowledge] ")"%s", sprint_hex(d + 4, resp.length - 4));
}else{
} else {
print_hex(d, resp.length);
}
}
if (decodeTLV && is_snmp == false) {
asn1_print(d, d[1] + 2, " ");
} else if (decodeTLV && is_snmp){
} else if (decodeTLV && is_snmp) {
asn1_print(d + 6, resp.length - 6, " ");
}

View file

@ -433,9 +433,10 @@ static int mf_read_uid(uint8_t *uid, int *uidlen, int *nxptype) {
}
static char *GenerateFilename(const char *prefix, const char *suffix) {
if (! IfPm3Iso14443a()) {
if (IfPm3Iso14443a() == false) {
return NULL;
}
uint8_t uid[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int uidlen = 0;
char *fptr = calloc(sizeof(char) * (strlen(prefix) + strlen(suffix)) + sizeof(uid) * 2 + 1, sizeof(uint8_t));
@ -924,7 +925,7 @@ static int mfc_read_tag(iso14a_card_select_t *card, uint8_t *carddata, uint8_t n
size_t alen = 0, blen = 0;
uint8_t *keyA = NULL, *keyB = NULL;
if (loadFileBinaryKey(keyfn, "", (void **)&keyA, (void **)&keyB, &alen, &blen) != PM3_SUCCESS) {
if (loadFileBinaryKey(keyfn, "", (void **)&keyA, (void **)&keyB, &alen, &blen, true) != PM3_SUCCESS) {
free(fptr);
return PM3_ESOFT;
}
@ -1565,7 +1566,7 @@ static int FastDumpWithEcFill(uint8_t numsectors) {
}
if (resp.status != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "fast dump reported back failure w KEY A, swapping to KEY B");
PrintAndLogEx(FAILED, "fast dump reported back failure w KEY A. Swapping to KEY B");
// ecfill key B
payload.keytype = MF_KEY_B;
@ -1823,12 +1824,10 @@ static int CmdHF14AMfRestore(const char *Cmd) {
//
size_t alen = 0, blen = 0;
uint8_t *keyA, *keyB;
if (loadFileBinaryKey(keyfilename, "", (void **)&keyA, (void **)&keyB, &alen, &blen) != PM3_SUCCESS) {
if (loadFileBinaryKey(keyfilename, "", (void **)&keyA, (void **)&keyB, &alen, &blen, true) != PM3_SUCCESS) {
return PM3_ESOFT;
}
PrintAndLogEx(INFO, "Using key file `" _YELLOW_("%s") "`", keyfilename);
// try reading card uid and create filename
if (datafnlen == 0) {
char *fptr = GenerateFilename("hf-mf-", "-dump.bin");
@ -7311,12 +7310,10 @@ int CmdHFMFNDEFFormat(const char *Cmd) {
//
size_t alen = 0, blen = 0;
uint8_t *tmpA, *tmpB;
if (loadFileBinaryKey(keyFilename, "", (void **)&tmpA, (void **)&tmpB, &alen, &blen) != PM3_SUCCESS) {
if (loadFileBinaryKey(keyFilename, "", (void **)&tmpA, (void **)&tmpB, &alen, &blen, true) != PM3_SUCCESS) {
goto skipfile;
}
PrintAndLogEx(INFO, "Using `" _YELLOW_("%s") "`", keyFilename);
for (int i = 0; i < numSectors; i++) {
memcpy(keyA[i], tmpA + (i * MIFARE_KEY_SIZE), MIFARE_KEY_SIZE);
memcpy(keyB[i], tmpB + (i * MIFARE_KEY_SIZE), MIFARE_KEY_SIZE);

View file

@ -1059,7 +1059,7 @@ static int AuthCheckDesfire(DesfireContext_t *dctx,
DesfireSetKeyNoClear(dctx, keyno, T_3DES, aeskeyList[curkey]);
res = DesfireAuthenticate(dctx, secureChannel, false);
if (res == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found 2TDEA Key %02u : " _GREEN_("%s"), curaid, keyno, sprint_hex(aeskeyList[curkey], 16));
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found 2TDEA Key %02u... " _GREEN_("%s"), curaid, keyno, sprint_hex_inrow(aeskeyList[curkey], 16));
foundKeys[1][keyno][0] = 0x01;
*result = true;
memcpy(&foundKeys[1][keyno][1], aeskeyList[curkey], 16);
@ -1091,7 +1091,7 @@ static int AuthCheckDesfire(DesfireContext_t *dctx,
DesfireSetKeyNoClear(dctx, keyno, T_AES, aeskeyList[curkey]);
res = DesfireAuthenticate(dctx, secureChannel, false);
if (res == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found AES Key %02u : " _GREEN_("%s"), curaid, keyno, sprint_hex(aeskeyList[curkey], 16));
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found AES Key %02u... " _GREEN_("%s"), curaid, keyno, sprint_hex_inrow(aeskeyList[curkey], 16));
foundKeys[2][keyno][0] = 0x01;
*result = true;
memcpy(&foundKeys[2][keyno][1], aeskeyList[curkey], 16);
@ -1123,7 +1123,7 @@ static int AuthCheckDesfire(DesfireContext_t *dctx,
DesfireSetKeyNoClear(dctx, keyno, T_3K3DES, k3kkeyList[curkey]);
res = DesfireAuthenticate(dctx, secureChannel, false);
if (res == PM3_SUCCESS) {
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found 3TDEA Key %02u : " _GREEN_("%s"), curaid, keyno, sprint_hex(k3kkeyList[curkey], 24));
PrintAndLogEx(SUCCESS, "AID 0x%06X, Found 3TDEA Key %02u... " _GREEN_("%s"), curaid, keyno, sprint_hex_inrow(k3kkeyList[curkey], 24));
foundKeys[3][keyno][0] = 0x01;
*result = true;
memcpy(&foundKeys[3][keyno][1], k3kkeyList[curkey], 16);

View file

@ -508,7 +508,7 @@ static void init_bitflip_bitarrays(void) {
{
char progress_text[100];
memset(progress_text, 0, sizeof(progress_text));
snprintf(progress_text, sizeof(progress_text), "Loaded " _YELLOW_("%u") " RAW / " _YELLOW_("%u") " LZ4 / " _YELLOW_("%u") " BZ2 in %"PRIu64" ms"
snprintf(progress_text, sizeof(progress_text), "Loaded " _YELLOW_("%u") " RAW / " _YELLOW_("%u") " LZ4 / " _YELLOW_("%u") " BZ2 in %4"PRIu64" ms"
, nraw
, nlz4
, nbz2

View file

@ -231,7 +231,7 @@ static int execute_system_command(const char *command) {
int ret;
#if defined(_WIN32)
#if defined(_WIN32)
char wrapped_command[255];
strncat(wrapped_command, "cmd /C \"", 9);
strncat(wrapped_command, command, strlen(command));

View file

@ -181,7 +181,7 @@ static uint16_t extractChallenges(uint16_t tracepos, uint16_t traceLen, uint8_t
}
*/
// extract MFU-C KEY when written.
// extract UL-C KEY when written.
switch (frame[0]) {
case MIFARE_ULC_AUTH_1: {

View file

@ -2353,7 +2353,7 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo
keylen = 6;
}
size_t block_size = 10 * keylen;
size_t block_size = 1000 * keylen;
// double up since its chars
keylen <<= 1;
@ -2428,10 +2428,9 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo
continue;
}
if (hex_to_bytes(
line,
(uint8_t *)*pdata + (*keycnt * (keylen >> 1)),
keylen >> 1) != (keylen >> 1)) {
int ret = hex_to_bytes(line, (uint8_t *)*pdata + (*keycnt * (keylen >> 1)), keylen >> 1);
if (ret != (keylen >> 1)) {
PrintAndLogEx(INFO, "hex to bytes wrong %i", ret);
continue;
}
@ -2450,16 +2449,16 @@ out:
return retval;
}
int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya, void **keyb, size_t *alen, size_t *blen) {
int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya, void **keyb, size_t *alen, size_t *blen, bool verbose) {
char *path;
int res = searchFile(&path, RESOURCES_SUBDIR, preferredName, suffix, false);
if (res != PM3_SUCCESS) {
return PM3_EFILE;
return PM3_ENOFILE;
}
FILE *f = fopen(path, "rb");
if (!f) {
if (f == NULL) {
PrintAndLogEx(WARNING, "file not found or locked `" _YELLOW_("%s") "`", path);
free(path);
return PM3_EFILE;
@ -2502,7 +2501,9 @@ int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya
*blen = fread(*keyb, 1, fsize, f);
fclose(f);
PrintAndLogEx(SUCCESS, "Loaded binary key file `" _YELLOW_("%s") "`", path);
if (verbose) {
PrintAndLogEx(SUCCESS, "Loaded binary key file `" _YELLOW_("%s") "`", path);
}
free(path);
return PM3_SUCCESS;
}

View file

@ -307,7 +307,7 @@ int loadFileDICTIONARY_safe_ex(const char *preferredName, const char *suffix, vo
*/
int loadFileXML_safe(const char *preferredName, const char *suffix, void **pdata, size_t *datalen);
int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya, void **keyb, size_t *alen, size_t *blen);
int loadFileBinaryKey(const char *preferredName, const char *suffix, void **keya, void **keyb, size_t *alen, size_t *blen, bool verbose);
/**
* @brief Utility function to check and convert plain mfu dump format to new mfu binary format.

View file

@ -64,7 +64,7 @@ int mf_dark_side(uint8_t blockno, uint8_t key_type, uint64_t *key) {
//flush queue
while (kbd_enter_pressed()) {
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
PrintAndLogEx(WARNING, "Aborted via keyboard");
PrintAndLogEx(WARNING, "aborted via keyboard");
return PM3_EOPABORTED;
}
@ -90,7 +90,7 @@ int mf_dark_side(uint8_t blockno, uint8_t key_type, uint64_t *key) {
//TODO: Not really stopping the command in time.
if (kbd_enter_pressed()) {
SendCommandNG(CMD_BREAK_LOOP, NULL, 0);
PrintAndLogEx(WARNING, "\nAborted via keyboard");
PrintAndLogEx(WARNING, "\naborted via keyboard");
return PM3_EOPABORTED;
}

View file

@ -18,38 +18,38 @@ typedef int pthread_spinlock_t;
#endif
static inline int pthread_spin_init(pthread_spinlock_t *lock, int pshared) {
__asm__ __volatile__ ("" ::: "memory");
*lock = 0;
return 0;
__asm__ __volatile__("" ::: "memory");
*lock = 0;
return 0;
}
static inline int pthread_spin_destroy(pthread_spinlock_t *lock) {
return 0;
return 0;
}
static inline int pthread_spin_lock(pthread_spinlock_t *lock) {
while (1) {
int i;
for (i=0; i < 10000; i++) {
if (__sync_bool_compare_and_swap(lock, 0, 1)) {
return 0;
}
}
sched_yield();
}
while (1) {
int i;
for (i = 0; i < 10000; i++) {
if (__sync_bool_compare_and_swap(lock, 0, 1)) {
return 0;
}
}
sched_yield();
}
}
static inline int pthread_spin_trylock(pthread_spinlock_t *lock) {
if (__sync_bool_compare_and_swap(lock, 0, 1)) {
return 0;
}
return 16; // EBUSY;
if (__sync_bool_compare_and_swap(lock, 0, 1)) {
return 0;
}
return 16; // EBUSY;
}
static inline int pthread_spin_unlock(pthread_spinlock_t *lock) {
__asm__ __volatile__ ("" ::: "memory");
*lock = 0;
return 0;
__asm__ __volatile__("" ::: "memory");
*lock = 0;
return 0;
}
#endif