mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
chg: hf 14a sim - uses NG
This commit is contained in:
parent
b05796c7c4
commit
58bed70ad0
4 changed files with 30 additions and 22 deletions
|
@ -1012,7 +1012,7 @@ static void PacketReceived(PacketCommandNG *packet) {
|
||||||
|
|
||||||
#ifdef WITH_ISO14443a
|
#ifdef WITH_ISO14443a
|
||||||
case CMD_SNIFF_ISO_14443a:
|
case CMD_SNIFF_ISO_14443a:
|
||||||
SniffIso14443a(packet->oldarg[0]);
|
SniffIso14443a(packet->data.asBytes[0]);
|
||||||
break;
|
break;
|
||||||
case CMD_READER_ISO_14443a:
|
case CMD_READER_ISO_14443a:
|
||||||
ReaderIso14443a(packet);
|
ReaderIso14443a(packet);
|
||||||
|
|
|
@ -626,7 +626,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
|
||||||
|
|
||||||
if (MF_DBGLEVEL >= MF_DBG_ERROR) {
|
if (MF_DBGLEVEL >= MF_DBG_ERROR) {
|
||||||
Dbprintf("maxDataLen=%d, Uart.state=%x, Uart.len=%d", maxDataLen, Uart.state, Uart.len);
|
Dbprintf("maxDataLen=%d, Uart.state=%x, Uart.len=%d", maxDataLen, Uart.state, Uart.len);
|
||||||
Dbprintf("traceLen=%d, Uart.output[0]=%08x", BigBuf_get_traceLen(), (uint32_t)Uart.output[0]);
|
Dbprintf("traceLen=" _YELLOW_("%d")", Uart.output[0]="_YELLOW_("%08x"), BigBuf_get_traceLen(), (uint32_t)Uart.output[0]);
|
||||||
}
|
}
|
||||||
switch_off();
|
switch_off();
|
||||||
}
|
}
|
||||||
|
@ -1069,9 +1069,9 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
// free eventually allocated BigBuf memory but keep Emulator Memory
|
// free eventually allocated BigBuf memory but keep Emulator Memory
|
||||||
BigBuf_free_keep_EM();
|
BigBuf_free_keep_EM();
|
||||||
|
|
||||||
|
|
||||||
if (SimulateIso14443aInit(tagType, flags, data, &responses, &cuid, counters, tearings, &pages) == false) {
|
if (SimulateIso14443aInit(tagType, flags, data, &responses, &cuid, counters, tearings, &pages) == false) {
|
||||||
BigBuf_free_keep_EM();
|
BigBuf_free_keep_EM();
|
||||||
|
reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_EINIT, NULL, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,6 +1095,8 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
int order = ORDER_NONE;
|
int order = ORDER_NONE;
|
||||||
int lastorder;
|
int lastorder;
|
||||||
|
|
||||||
|
int retval = PM3_SUCCESS;
|
||||||
|
|
||||||
// Just to allow some checks
|
// Just to allow some checks
|
||||||
int happened = 0;
|
int happened = 0;
|
||||||
int happened2 = 0;
|
int happened2 = 0;
|
||||||
|
@ -1113,6 +1115,7 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
// Clean receive command buffer
|
// Clean receive command buffer
|
||||||
if (!GetIso14443aCommandFromReader(receivedCmd, receivedCmdPar, &len)) {
|
if (!GetIso14443aCommandFromReader(receivedCmd, receivedCmdPar, &len)) {
|
||||||
Dbprintf("Emulator stopped. Trace length: %d ", BigBuf_get_traceLen());
|
Dbprintf("Emulator stopped. Trace length: %d ", BigBuf_get_traceLen());
|
||||||
|
retval = PM3_EOPABORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p_response = NULL;
|
p_response = NULL;
|
||||||
|
@ -1189,8 +1192,8 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
ar_nr_nonces[index].ar2 = ar;
|
ar_nr_nonces[index].ar2 = ar;
|
||||||
ar_nr_nonces[index].state = SECOND;
|
ar_nr_nonces[index].state = SECOND;
|
||||||
|
|
||||||
// send to client
|
// send to client (one struct nonces_t)
|
||||||
reply_old(CMD_ACK, CMD_SIMULATE_MIFARE_CARD, 0, 0, &ar_nr_nonces[index], sizeof(nonces_t));
|
reply_ng(CMD_SIMULATE_MIFARE_CARD, PM3_SUCCESS, (uint8_t*)&ar_nr_nonces[index], sizeof(nonces_t) );
|
||||||
|
|
||||||
ar_nr_nonces[index].state = EMPTY;
|
ar_nr_nonces[index].state = EMPTY;
|
||||||
ar_nr_nonces[index].sector = 0;
|
ar_nr_nonces[index].sector = 0;
|
||||||
|
@ -1503,7 +1506,6 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reply_old(CMD_ACK, 1, 0, 0, 0, 0);
|
|
||||||
switch_off();
|
switch_off();
|
||||||
|
|
||||||
set_tracing(false);
|
set_tracing(false);
|
||||||
|
@ -1515,6 +1517,8 @@ void SimulateIso14443aTag(uint8_t tagType, uint8_t flags, uint8_t *data) {
|
||||||
Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd);
|
Dbprintf("-[ Num of received cmd [%d]", cmdsRecvd);
|
||||||
Dbprintf("-[ Num of moebius tries [%d]", moebius_count);
|
Dbprintf("-[ Num of moebius tries [%d]", moebius_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply_ng(CMD_SIMULATE_MIFARE_CARD, retval, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare a delayed transfer. This simply shifts ToSend[] by a number
|
// prepare a delayed transfer. This simply shifts ToSend[] by a number
|
||||||
|
|
|
@ -414,7 +414,6 @@ int CmdHF14ASim(const char *Cmd) {
|
||||||
bool setEmulatorMem = false;
|
bool setEmulatorMem = false;
|
||||||
bool verbose = false;
|
bool verbose = false;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
nonces_t data[1];
|
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
@ -491,29 +490,32 @@ int CmdHF14ASim(const char *Cmd) {
|
||||||
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
PrintAndLogEx(SUCCESS, "press pm3-button to abort simulation");
|
||||||
|
|
||||||
while (!ukbhit()) {
|
while (!ukbhit()) {
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) continue;
|
if (WaitForResponseTimeout(CMD_SIMULATE_MIFARE_CARD, &resp, 1500) == 0) continue;
|
||||||
if (!(flags & FLAG_NR_AR_ATTACK)) break;
|
if (resp.status != PM3_SUCCESS) break;
|
||||||
if ((resp.oldarg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD) break;
|
|
||||||
|
|
||||||
memcpy(data, resp.data.asBytes, sizeof(data));
|
if ((flags & FLAG_NR_AR_ATTACK) != FLAG_NR_AR_ATTACK) break;
|
||||||
|
|
||||||
|
nonces_t *data = (nonces_t*)resp.data.asBytes;
|
||||||
readerAttack(data[0], setEmulatorMem, verbose);
|
readerAttack(data[0], setEmulatorMem, verbose);
|
||||||
}
|
}
|
||||||
|
if (resp.status == PM3_EOPABORTED && ((flags & FLAG_NR_AR_ATTACK) == FLAG_NR_AR_ATTACK) )
|
||||||
showSectorTable();
|
showSectorTable();
|
||||||
return 0;
|
|
||||||
|
PrintAndLogEx(INFO, "Done");
|
||||||
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdHF14ASniff(const char *Cmd) {
|
int CmdHF14ASniff(const char *Cmd) {
|
||||||
int param = 0;
|
uint8_t param = 0, ctmp;
|
||||||
uint8_t ctmp;
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
ctmp = tolower(param_getchar(Cmd, i));
|
ctmp = tolower(param_getchar(Cmd, i));
|
||||||
if (ctmp == 'h') return usage_hf_14a_sniff();
|
if (ctmp == 'h') return usage_hf_14a_sniff();
|
||||||
if (ctmp == 'c') param |= 0x01;
|
if (ctmp == 'c') param |= 0x01;
|
||||||
if (ctmp == 'r') param |= 0x02;
|
if (ctmp == 'r') param |= 0x02;
|
||||||
}
|
}
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandMIX(CMD_SNIFF_ISO_14443a, param, 0, 0, NULL, 0);
|
SendCommandNG(CMD_SNIFF_ISO_14443a, (uint8_t *)¶m, sizeof(uint8_t));
|
||||||
return 0;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen) {
|
int ExchangeRAW14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen) {
|
||||||
|
|
|
@ -494,6 +494,8 @@ typedef struct {
|
||||||
#define PM3_EFILE -13
|
#define PM3_EFILE -13
|
||||||
// Generic TTY error
|
// Generic TTY error
|
||||||
#define PM3_ENOTTY -14
|
#define PM3_ENOTTY -14
|
||||||
|
// Initialization error pm3: error related to trying to initalize the pm3 / fpga for different operations
|
||||||
|
#define PM3_EINIT -15
|
||||||
// No data pm3: no data available, no host frame available (not really an error)
|
// No data pm3: no data available, no host frame available (not really an error)
|
||||||
#define PM3_ENODATA -98
|
#define PM3_ENODATA -98
|
||||||
// Quit program client: reserved, order to quit the program
|
// Quit program client: reserved, order to quit the program
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue