mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-14 01:03:01 -07:00
Merge branch 'master' into fix_iclass_sim
This commit is contained in:
commit
f31b4cd888
9 changed files with 29 additions and 41 deletions
|
@ -15,7 +15,8 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
|
||||||
- Wrong UID at HitagS simulation
|
- Wrong UID at HitagS simulation
|
||||||
- `hf 15 sim` now works as expected (piwi)
|
- `hf 15 sim` now works as expected (piwi)
|
||||||
- `hf mf chk t` save to emulator memory now works as expected (mwalker)
|
- `hf mf chk t` save to emulator memory now works as expected (mwalker)
|
||||||
- Fix `hf mf sim` - wrong access rights to write key B in trailer (@McEloff)
|
- Fix `hf mf sim` - wrong access rights to write key B in trailer (@McEloff)
|
||||||
|
- allow files > 512Bytes in 'hf iclass eload' (@Sherhannn79)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added to `hf 14a apdu` print apdu and compose apdu (@merlokk)
|
- Added to `hf 14a apdu` print apdu and compose apdu (@merlokk)
|
||||||
|
|
|
@ -998,7 +998,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||||
switch(c->cmd) {
|
switch(c->cmd) {
|
||||||
#ifdef WITH_LF
|
#ifdef WITH_LF
|
||||||
case CMD_SET_LF_SAMPLING_CONFIG:
|
case CMD_SET_LF_SAMPLING_CONFIG:
|
||||||
setSamplingConfig((sample_config *) c->d.asBytes);
|
setSamplingConfig(c->d.asBytes);
|
||||||
break;
|
break;
|
||||||
case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
case CMD_ACQUIRE_RAW_ADC_SAMPLES_125K:
|
||||||
cmd_send(CMD_ACK,SampleLF(c->arg[0], c->arg[1]),0,0,0,0);
|
cmd_send(CMD_ACK,SampleLF(c->arg[0], c->arg[1]),0,0,0,0);
|
||||||
|
@ -1324,9 +1324,6 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||||
case CMD_ICLASS_WRITEBLOCK:
|
case CMD_ICLASS_WRITEBLOCK:
|
||||||
iClass_WriteBlock(c->arg[0], c->d.asBytes);
|
iClass_WriteBlock(c->arg[0], c->d.asBytes);
|
||||||
break;
|
break;
|
||||||
case CMD_ICLASS_READCHECK: // auth step 1
|
|
||||||
iClass_ReadCheck(c->arg[0], c->arg[1]);
|
|
||||||
break;
|
|
||||||
case CMD_ICLASS_READBLOCK:
|
case CMD_ICLASS_READBLOCK:
|
||||||
iClass_ReadBlk(c->arg[0]);
|
iClass_ReadBlk(c->arg[0]);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1405,7 +1405,7 @@ void CodeIClassCommand(const uint8_t *cmd, int len) {
|
||||||
for (j = 0; j < 4; j++) {
|
for (j = 0; j < 4; j++) {
|
||||||
for (k = 0; k < 4; k++) {
|
for (k = 0; k < 4; k++) {
|
||||||
if (k == (b & 3)) {
|
if (k == (b & 3)) {
|
||||||
ToSend[++ToSendMax] = 0xf0;
|
ToSend[++ToSendMax] = 0x0f;
|
||||||
} else {
|
} else {
|
||||||
ToSend[++ToSendMax] = 0x00;
|
ToSend[++ToSendMax] = 0x00;
|
||||||
}
|
}
|
||||||
|
@ -1696,6 +1696,7 @@ void ReaderIClass(uint8_t arg0) {
|
||||||
if ( (result_status ^ FLAG_ICLASS_READER_CSN ^ flagReadConfig ^ flagReadCC ^ flagReadAA) == 0) {
|
if ( (result_status ^ FLAG_ICLASS_READER_CSN ^ flagReadConfig ^ flagReadCC ^ flagReadAA) == 0) {
|
||||||
cmd_send(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
|
cmd_send(CMD_ACK, result_status, 0, 0, card_data, sizeof(card_data));
|
||||||
if (abort_after_read) {
|
if (abort_after_read) {
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
return;
|
return;
|
||||||
|
@ -1847,17 +1848,10 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
|
||||||
card_data,
|
card_data,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LED_A_OFF();
|
LED_A_OFF();
|
||||||
}
|
}
|
||||||
|
|
||||||
void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType) {
|
|
||||||
uint8_t readcheck[] = { keyType, blockNo };
|
|
||||||
uint8_t resp[] = {0,0,0,0,0,0,0,0};
|
|
||||||
size_t isOK = 0;
|
|
||||||
isOK = sendCmdGetResponseWithRetries(readcheck, sizeof(readcheck), resp, sizeof(resp), 6);
|
|
||||||
cmd_send(CMD_ACK,isOK, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void iClass_Authentication(uint8_t *MAC) {
|
void iClass_Authentication(uint8_t *MAC) {
|
||||||
uint8_t check[] = { ICLASS_CMD_CHECK_KD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
uint8_t check[] = { ICLASS_CMD_CHECK_KD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||||
uint8_t resp[ICLASS_BUFFER_SIZE];
|
uint8_t resp[ICLASS_BUFFER_SIZE];
|
||||||
|
@ -1867,7 +1861,7 @@ void iClass_Authentication(uint8_t *MAC) {
|
||||||
cmd_send(CMD_ACK,isOK, 0, 0, 0, 0);
|
cmd_send(CMD_ACK,isOK, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool iClass_ReadBlock(uint8_t blockNo, uint8_t *readdata) {
|
static bool iClass_ReadBlock(uint8_t blockNo, uint8_t *readdata) {
|
||||||
uint8_t readcmd[] = {ICLASS_CMD_READ_OR_IDENTIFY, blockNo, 0x00, 0x00}; //0x88, 0x00 // can i use 0C?
|
uint8_t readcmd[] = {ICLASS_CMD_READ_OR_IDENTIFY, blockNo, 0x00, 0x00}; //0x88, 0x00 // can i use 0C?
|
||||||
char bl = blockNo;
|
char bl = blockNo;
|
||||||
uint16_t rdCrc = iclass_crc16(&bl, 1);
|
uint16_t rdCrc = iclass_crc16(&bl, 1);
|
||||||
|
@ -1888,6 +1882,7 @@ void iClass_ReadBlk(uint8_t blockno) {
|
||||||
bool isOK = false;
|
bool isOK = false;
|
||||||
isOK = iClass_ReadBlock(blockno, readblockdata);
|
isOK = iClass_ReadBlock(blockno, readblockdata);
|
||||||
cmd_send(CMD_ACK, isOK, 0, 0, readblockdata, 8);
|
cmd_send(CMD_ACK, isOK, 0, 0, readblockdata, 8);
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iClass_Dump(uint8_t blockno, uint8_t numblks) {
|
void iClass_Dump(uint8_t blockno, uint8_t numblks) {
|
||||||
|
@ -1958,6 +1953,7 @@ void iClass_WriteBlock(uint8_t blockNo, uint8_t *data) {
|
||||||
Dbprintf("Write block [%02x] failed", blockNo);
|
Dbprintf("Write block [%02x] failed", blockNo);
|
||||||
}
|
}
|
||||||
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
cmd_send(CMD_ACK, isOK, 0, 0, 0, 0);
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data) {
|
void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data) {
|
||||||
|
|
|
@ -25,9 +25,7 @@ extern void IClass_iso14443A_GetPublic(uint8_t arg0);
|
||||||
extern void iClass_Authentication(uint8_t *MAC);
|
extern void iClass_Authentication(uint8_t *MAC);
|
||||||
extern void iClass_WriteBlock(uint8_t blockNo, uint8_t *data);
|
extern void iClass_WriteBlock(uint8_t blockNo, uint8_t *data);
|
||||||
extern void iClass_ReadBlk(uint8_t blockNo);
|
extern void iClass_ReadBlk(uint8_t blockNo);
|
||||||
extern bool iClass_ReadBlock(uint8_t blockNo, uint8_t *readdata);
|
|
||||||
extern void iClass_Dump(uint8_t blockno, uint8_t numblks);
|
extern void iClass_Dump(uint8_t blockno, uint8_t numblks);
|
||||||
extern void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data);
|
extern void iClass_Clone(uint8_t startblock, uint8_t endblock, uint8_t *data);
|
||||||
extern void iClass_ReadCheck(uint8_t blockNo, uint8_t keyType);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,17 +39,17 @@ void printConfig()
|
||||||
* @brief setSamplingConfig
|
* @brief setSamplingConfig
|
||||||
* @param sc
|
* @param sc
|
||||||
*/
|
*/
|
||||||
void setSamplingConfig(sample_config *sc)
|
void setSamplingConfig(uint8_t *config_data) {
|
||||||
{
|
sample_config *sc = (sample_config *)config_data;
|
||||||
if(sc->divisor != 0) config.divisor = sc->divisor;
|
if (sc->divisor != 0) config.divisor = sc->divisor;
|
||||||
if(sc->bits_per_sample!= 0) config.bits_per_sample= sc->bits_per_sample;
|
if (sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
|
||||||
if(sc->decimation!= 0) config.decimation= sc->decimation;
|
if (sc->decimation != 0) config.decimation = sc->decimation;
|
||||||
if(sc->trigger_threshold != -1) config.trigger_threshold= sc->trigger_threshold;
|
if (sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
|
||||||
if(sc->samples_to_skip != -1) config.samples_to_skip = sc->samples_to_skip;
|
if (sc->samples_to_skip != -1) config.samples_to_skip = sc->samples_to_skip;
|
||||||
|
|
||||||
config.averaging= sc->averaging;
|
config.averaging= sc->averaging;
|
||||||
if(config.bits_per_sample > 8) config.bits_per_sample = 8;
|
if (config.bits_per_sample > 8) config.bits_per_sample = 8;
|
||||||
if(config.decimation < 1) config.decimation = 1;
|
if (config.decimation < 1) config.decimation = 1;
|
||||||
|
|
||||||
printConfig();
|
printConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef LFSAMPLING_H
|
#ifndef LFSAMPLING_H__
|
||||||
#define LFSAMPLING_H
|
#define LFSAMPLING_H__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* acquisition of Cotag LF signal. Similar to other LF, since the Cotag has such long datarate RF/384
|
* acquisition of Cotag LF signal. Similar to other LF, since the Cotag has such long datarate RF/384
|
||||||
|
@ -45,7 +45,7 @@ uint32_t DoAcquisition_config(bool silent, int sample_size);
|
||||||
* Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
|
* Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
|
||||||
* if not already loaded, sets divisor and starts up the antenna.
|
* if not already loaded, sets divisor and starts up the antenna.
|
||||||
* @param divisor : 1, 88> 255 or negative ==> 134.8 KHz
|
* @param divisor : 1, 88> 255 or negative ==> 134.8 KHz
|
||||||
* 0 or 95 ==> 125 KHz
|
* 0 or 95 ==> 125 KHz
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
void LFSetupFPGAForADC(int divisor, bool lf_field);
|
void LFSetupFPGAForADC(int divisor, bool lf_field);
|
||||||
|
@ -61,9 +61,9 @@ void LFSetupFPGAForADC(int divisor, bool lf_field);
|
||||||
* @brief setSamplingConfig
|
* @brief setSamplingConfig
|
||||||
* @param sc
|
* @param sc
|
||||||
*/
|
*/
|
||||||
void setSamplingConfig(sample_config *sc);
|
void setSamplingConfig(uint8_t *config_data);
|
||||||
|
|
||||||
sample_config * getSamplingConfig();
|
sample_config *getSamplingConfig();
|
||||||
|
|
||||||
void printConfig();
|
void printConfig();
|
||||||
|
|
||||||
|
|
|
@ -308,14 +308,13 @@ int CmdHFiClassELoad(const char *Cmd) {
|
||||||
//File handling and reading
|
//File handling and reading
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char filename[FILE_PATH_SIZE];
|
char filename[FILE_PATH_SIZE];
|
||||||
if(opt == 'f' && param_getstr(Cmd, 1, filename, sizeof(filename)) > 0)
|
if (opt == 'f' && param_getstr(Cmd, 1, filename, sizeof(filename)) > 0) {
|
||||||
{
|
|
||||||
f = fopen(filename, "rb");
|
f = fopen(filename, "rb");
|
||||||
}else{
|
} else {
|
||||||
return hf_iclass_eload_usage();
|
return hf_iclass_eload_usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!f) {
|
if (!f) {
|
||||||
PrintAndLog("Failed to read from file '%s'", filename);
|
PrintAndLog("Failed to read from file '%s'", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +337,7 @@ int CmdHFiClassELoad(const char *Cmd) {
|
||||||
printIclassDumpInfo(dump);
|
printIclassDumpInfo(dump);
|
||||||
//Validate
|
//Validate
|
||||||
|
|
||||||
if (bytes_read < fsize)
|
if (bytes_read < fsize) {
|
||||||
{
|
|
||||||
prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
|
prnlog("Error, could only read %d bytes (should be %d)",bytes_read, fsize );
|
||||||
free(dump);
|
free(dump);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -348,10 +346,10 @@ int CmdHFiClassELoad(const char *Cmd) {
|
||||||
uint32_t bytes_sent = 0;
|
uint32_t bytes_sent = 0;
|
||||||
uint32_t bytes_remaining = bytes_read;
|
uint32_t bytes_remaining = bytes_read;
|
||||||
|
|
||||||
while(bytes_remaining > 0){
|
while (bytes_remaining > 0) {
|
||||||
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
|
uint32_t bytes_in_packet = MIN(USB_CMD_DATA_SIZE, bytes_remaining);
|
||||||
UsbCommand c = {CMD_ICLASS_EML_MEMSET, {bytes_sent,bytes_in_packet,0}};
|
UsbCommand c = {CMD_ICLASS_EML_MEMSET, {bytes_sent,bytes_in_packet,0}};
|
||||||
memcpy(c.d.asBytes, dump, bytes_in_packet);
|
memcpy(c.d.asBytes, dump+bytes_sent, bytes_in_packet);
|
||||||
SendCommand(&c);
|
SendCommand(&c);
|
||||||
bytes_remaining -= bytes_in_packet;
|
bytes_remaining -= bytes_in_packet;
|
||||||
bytes_sent += bytes_in_packet;
|
bytes_sent += bytes_in_packet;
|
||||||
|
|
|
@ -124,7 +124,6 @@ typedef struct {
|
||||||
#define CMD_WRITER_LEGIC_RF 0x0389
|
#define CMD_WRITER_LEGIC_RF 0x0389
|
||||||
#define CMD_EPA_PACE_COLLECT_NONCE 0x038A
|
#define CMD_EPA_PACE_COLLECT_NONCE 0x038A
|
||||||
|
|
||||||
#define CMD_ICLASS_READCHECK 0x038F
|
|
||||||
#define CMD_ICLASS_CLONE 0x0390
|
#define CMD_ICLASS_CLONE 0x0390
|
||||||
#define CMD_ICLASS_DUMP 0x0391
|
#define CMD_ICLASS_DUMP 0x0391
|
||||||
#define CMD_SNOOP_ICLASS 0x0392
|
#define CMD_SNOOP_ICLASS 0x0392
|
||||||
|
|
|
@ -156,7 +156,6 @@ typedef struct{
|
||||||
#define CMD_EPA_PACE_COLLECT_NONCE 0x038A
|
#define CMD_EPA_PACE_COLLECT_NONCE 0x038A
|
||||||
#define CMD_EPA_PACE_REPLAY 0x038B
|
#define CMD_EPA_PACE_REPLAY 0x038B
|
||||||
|
|
||||||
#define CMD_ICLASS_READCHECK 0x038F
|
|
||||||
#define CMD_ICLASS_CLONE 0x0390
|
#define CMD_ICLASS_CLONE 0x0390
|
||||||
#define CMD_ICLASS_DUMP 0x0391
|
#define CMD_ICLASS_DUMP 0x0391
|
||||||
#define CMD_SNOOP_ICLASS 0x0392
|
#define CMD_SNOOP_ICLASS 0x0392
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue