text and style

This commit is contained in:
iceman1001 2025-06-17 18:24:40 +02:00
commit 79400d0779
10 changed files with 25 additions and 36 deletions

View file

@ -274,7 +274,7 @@ void MifareUC_Auth(uint8_t arg0, uint8_t *keybytes) {
return; return;
}; };
if (!mifare_ultra_auth(keybytes)) { if (mifare_ultra_auth(keybytes) == 0) {
if (g_dbglevel >= DBG_ERROR) Dbprintf("Authentication failed"); if (g_dbglevel >= DBG_ERROR) Dbprintf("Authentication failed");
OnError(1); OnError(1);
return; return;
@ -304,7 +304,7 @@ void MifareUL_AES_Auth(bool turn_off_field, uint8_t keyno, uint8_t *keybytes) {
return; return;
}; };
if (!mifare_ultra_aes_auth(keyno, keybytes)) { if (mifare_ultra_aes_auth(keyno, keybytes) == 0) {
if (g_dbglevel >= DBG_ERROR) Dbprintf("Authentication failed"); if (g_dbglevel >= DBG_ERROR) Dbprintf("Authentication failed");
OnErrorNG(CMD_HF_MIFAREULAES_AUTH, PM3_ESOFT); OnErrorNG(CMD_HF_MIFAREULAES_AUTH, PM3_ESOFT);
return; return;

View file

@ -579,21 +579,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
counter++; counter++;
} }
/*
// find reader field
if (cardSTATE == MFEMUL_NOFIELD) {
vHf = (MAX_ADC_HF_VOLTAGE * SumAdc(ADC_CHAN_HF, 32)) >> 15;
if (vHf > MF_MINFIELDV) {
cardSTATE_TO_IDLE();
LED_A_ON();
}
button_pushed = BUTTON_PRESS();
continue;
}
*/
FpgaEnableTracing(); FpgaEnableTracing();
//Now, get data //Now, get data
int res = EmGetCmd(receivedCmd, sizeof(receivedCmd), &receivedCmd_len, receivedCmd_par); int res = EmGetCmd(receivedCmd, sizeof(receivedCmd), &receivedCmd_len, receivedCmd_par);
@ -760,10 +745,6 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *uid, uint16_t
// WORK // WORK
case MFEMUL_WORK: { case MFEMUL_WORK: {
if (g_dbglevel >= DBG_EXTENDED) {
// Dbprintf("[MFEMUL_WORK] Enter in case");
}
if (receivedCmd_len == 0) { if (receivedCmd_len == 0) {
if (g_dbglevel >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] NO CMD received"); if (g_dbglevel >= DBG_EXTENDED) Dbprintf("[MFEMUL_WORK] NO CMD received");
break; break;

View file

@ -957,14 +957,17 @@ int CmdHF14ASim(const char *Cmd) {
bool keypress = kbd_enter_pressed(); bool keypress = kbd_enter_pressed();
while (keypress == false) { while (keypress == false) {
if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false) if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false) {
continue; continue;
}
if (resp.status != PM3_SUCCESS) if (resp.status != PM3_SUCCESS) {
break; break;
}
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) {
break; break;
}
const nonces_t *data = (nonces_t *)resp.data.asBytes; const nonces_t *data = (nonces_t *)resp.data.asBytes;
readerAttack(k_sector, k_sectors_cnt, data[0], setEmulatorMem, verbose); readerAttack(k_sector, k_sectors_cnt, data[0], setEmulatorMem, verbose);

View file

@ -2130,9 +2130,10 @@ static int CmdHFiClassDump(const char *Cmd) {
return PM3_EOPABORTED; return PM3_EOPABORTED;
} }
if (WaitForResponseTimeout(CMD_HF_ICLASS_DUMP, &resp, 2000)) if (WaitForResponseTimeout(CMD_HF_ICLASS_DUMP, &resp, 2000)) {
break; break;
} }
}
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
if (resp.status != PM3_SUCCESS) { if (resp.status != PM3_SUCCESS) {

View file

@ -3939,7 +3939,9 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
firstChunk = true; firstChunk = true;
lastChunk = false; lastChunk = false;
if (blockn != -1) break; if (blockn != -1) {
break;
}
} // end strategy } // end strategy
} }
out: out:
@ -5247,7 +5249,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
// update expected blocks to match converted data. // update expected blocks to match converted data.
block_cnt = bytes_read / MFU_BLOCK_SIZE; block_cnt = bytes_read / MFU_BLOCK_SIZE;
PrintAndLogEx(INFO, "MIFARE Ultralight override, will use %d blocks ( %u bytes )", block_cnt, block_cnt * block_width); PrintAndLogEx(INFO, "MIFARE Ultralight override, will use " _YELLOW_("%d") " blocks ( " _YELLOW_("%u") " bytes )", block_cnt, block_cnt * block_width);
} }
PrintAndLogEx(INFO, "Uploading to emulator memory"); PrintAndLogEx(INFO, "Uploading to emulator memory");

View file

@ -315,7 +315,7 @@ static int mfp_load_keys(uint8_t **pkeyBlock, uint32_t *pkeycnt, uint8_t *userke
int len = hex_to_bytes(g_mifare_plus_default_keys[cnt], (uint8_t *)(*pkeyBlock + (*pkeycnt + cnt) * AES_KEY_LEN), AES_KEY_LEN); int len = hex_to_bytes(g_mifare_plus_default_keys[cnt], (uint8_t *)(*pkeyBlock + (*pkeycnt + cnt) * AES_KEY_LEN), AES_KEY_LEN);
PrintAndLogEx(DEBUG, _YELLOW_("%2d") " - %s", *pkeycnt + cnt, sprint_hex_inrow(*pkeyBlock + (*pkeycnt + cnt) * AES_KEY_LEN, AES_KEY_LEN)); PrintAndLogEx(DEBUG, _YELLOW_("%2u") " - %s", *pkeycnt + cnt, sprint_hex_inrow(*pkeyBlock + (*pkeycnt + cnt) * AES_KEY_LEN, AES_KEY_LEN));
if (len != AES_KEY_LEN) { if (len != AES_KEY_LEN) {
break; break;
} }

View file

@ -287,8 +287,9 @@ int CmdsParse(const command_t Commands[], const char *Cmd) {
} }
// Comment // Comment
if (cmd_name[0] == '#') if (cmd_name[0] == '#') {
return PM3_SUCCESS; return PM3_SUCCESS;
}
// find args, check for -h / --help // find args, check for -h / --help
int tmplen = len; int tmplen = len;

View file

@ -55,14 +55,16 @@ void des_decrypt(void *out, const void *in, const void *key) {
} }
void des_encrypt_ecb(void *out, const void *in, const int length, const void *key) { void des_encrypt_ecb(void *out, const void *in, const int length, const void *key) {
for (int i = 0; i < length; i += 8) for (int i = 0; i < length; i += 8) {
des_encrypt((uint8_t *)out + i, (uint8_t *)in + i, key); des_encrypt((uint8_t *)out + i, (uint8_t *)in + i, key);
} }
}
void des_decrypt_ecb(void *out, const void *in, const int length, const void *key) { void des_decrypt_ecb(void *out, const void *in, const int length, const void *key) {
for (int i = 0; i < length; i += 8) for (int i = 0; i < length; i += 8) {
des_decrypt((uint8_t *)out + i, (uint8_t *)in + i, key); des_decrypt((uint8_t *)out + i, (uint8_t *)in + i, key);
} }
}
void des_encrypt_cbc(void *out, const void *in, const int length, const void *key, uint8_t *iv) { void des_encrypt_cbc(void *out, const void *in, const int length, const void *key, uint8_t *iv) {
mbedtls_des_context ctx; mbedtls_des_context ctx;

View file

@ -72,9 +72,7 @@ DumpFileType_t get_filetype(const char *filename) {
size_t len = strlen(filename); size_t len = strlen(filename);
if (len > 4) { if (len > 4) {
// check if valid file extension and attempt to load data // check if valid file extension and attempt to load data
char s[FILE_PATH_SIZE]; char *s = str_dup(filename);
memset(s, 0, sizeof(s));
memcpy(s, filename, len);
str_lower(s); str_lower(s);
if (str_endswith(s, "bin")) { if (str_endswith(s, "bin")) {
@ -97,6 +95,8 @@ DumpFileType_t get_filetype(const char *filename) {
// log is text // log is text
// .pm3 is text values of signal data // .pm3 is text values of signal data
} }
free(s);
} }
return o; return o;
} }
@ -2577,7 +2577,7 @@ int detect_nfc_dump_format(const char *preferredName, nfc_df_e *dump_type, bool
} }
FILE *f = fopen(path, "r"); FILE *f = fopen(path, "r");
if (!f) { if (f == NULL) {
PrintAndLogEx(WARNING, "file not found or locked `" _YELLOW_("%s") "`", path); PrintAndLogEx(WARNING, "file not found or locked `" _YELLOW_("%s") "`", path);
free(path); free(path);
return PM3_EFILE; return PM3_EFILE;

View file

@ -317,7 +317,6 @@ static int MADInfoByteDecode(const uint8_t *sector, bool swapmad, int mad_ver, b
void MADPrintHeader(void) { void MADPrintHeader(void) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, "--- " _CYAN_("MIFARE App Directory Information") " ----------------"); PrintAndLogEx(INFO, "--- " _CYAN_("MIFARE App Directory Information") " ----------------");
PrintAndLogEx(INFO, "-----------------------------------------------------");
} }
int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMAD2) { int MAD1DecodeAndPrint(uint8_t *sector, bool swapmad, bool verbose, bool *haveMAD2) {