diff --git a/Firmware/Chameleon-Mini/Application/MifareClassic.c b/Firmware/Chameleon-Mini/Application/MifareClassic.c index 15faea1..fed2f4e 100644 --- a/Firmware/Chameleon-Mini/Application/MifareClassic.c +++ b/Firmware/Chameleon-Mini/Application/MifareClassic.c @@ -1020,12 +1020,20 @@ uint16_t MifareClassicAppProcess(uint8_t *Buffer, uint16_t BitCount) { } } else if (Buffer[0] == CMD_WRITE) { if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) { - DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2); - /* Write command. Store the address and prepare for the upcoming data. - * Respond with ACK. */ - CurrentAddress = Buffer[1]; - State = STATE_WRITE; - Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); + // not allow to write block 0 + if (Buffer[1] == 0x00) { + State = STATE_HALT; + Buffer[0] = NAK_NOT_AUTHED ^ Crypto1Nibble(); + return ACK_NAK_FRAME_SIZE; + } + else { + DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2); + /* Write command. Store the address and prepare for the upcoming data. + * Respond with ACK. */ + CurrentAddress = Buffer[1]; + State = STATE_WRITE; + Buffer[0] = ACK_VALUE ^ Crypto1Nibble(); + } } else { LogEntry(LOG_ERR_APP_CHECKSUM_FAIL, Buffer, 4); Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble();