mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-29 19:18:35 -07:00
moved includes, added clear_trace flag (it was there...) and fixed multiapdu iso14443 stream
This commit is contained in:
parent
1d6f7bc8ac
commit
eb6e8de45d
4 changed files with 39 additions and 23 deletions
|
@ -1916,19 +1916,18 @@ void ReaderIso14443a(UsbCommand *c)
|
||||||
uint8_t par[MAX_PARITY_SIZE];
|
uint8_t par[MAX_PARITY_SIZE];
|
||||||
bool cantSELECT = false;
|
bool cantSELECT = false;
|
||||||
|
|
||||||
if(param & ISO14A_CONNECT) {
|
set_tracing(true);
|
||||||
|
|
||||||
|
if(param & ISO14A_CLEAR_TRACE) {
|
||||||
clear_trace();
|
clear_trace();
|
||||||
}
|
}
|
||||||
|
|
||||||
set_tracing(true);
|
|
||||||
|
|
||||||
if(param & ISO14A_REQUEST_TRIGGER) {
|
if(param & ISO14A_REQUEST_TRIGGER) {
|
||||||
iso14a_set_trigger(true);
|
iso14a_set_trigger(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(param & ISO14A_CONNECT) {
|
if(param & ISO14A_CONNECT) {
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
clear_trace();
|
|
||||||
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
|
||||||
if(!(param & ISO14A_NO_SELECT)) {
|
if(!(param & ISO14A_NO_SELECT)) {
|
||||||
iso14a_card_select_t *card = (iso14a_card_select_t*)buf;
|
iso14a_card_select_t *card = (iso14a_card_select_t*)buf;
|
||||||
|
|
|
@ -11,9 +11,25 @@
|
||||||
|
|
||||||
#include "cmdhf14a.h"
|
#include "cmdhf14a.h"
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "util_posix.h"
|
||||||
|
#include "iso14443crc.h"
|
||||||
|
#include "data.h"
|
||||||
|
#include "proxmark3.h"
|
||||||
|
#include "ui.h"
|
||||||
|
#include "cmdparser.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "cmdmain.h"
|
||||||
|
#include "mifare.h"
|
||||||
|
#include "cmdhfmfu.h"
|
||||||
|
#include "mifarehost.h"
|
||||||
|
#include "emv/apduinfo.h"
|
||||||
|
#include "emv/emvcore.h"
|
||||||
|
|
||||||
static int CmdHelp(const char *Cmd);
|
static int CmdHelp(const char *Cmd);
|
||||||
static int waitCmd(uint8_t iLen);
|
static int waitCmd(uint8_t iLen);
|
||||||
|
|
||||||
|
|
||||||
const manufactureName manufactureMapping[] = {
|
const manufactureName manufactureMapping[] = {
|
||||||
// ID, "Vendor Country"
|
// ID, "Vendor Country"
|
||||||
{ 0x01, "Motorola UK" },
|
{ 0x01, "Motorola UK" },
|
||||||
|
@ -621,17 +637,22 @@ int CmdHF14ASnoop(const char *Cmd) {
|
||||||
int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int *dataoutlen) {
|
int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool leaveSignalON, uint8_t *dataout, int *dataoutlen) {
|
||||||
uint8_t data[USB_CMD_DATA_SIZE];
|
uint8_t data[USB_CMD_DATA_SIZE];
|
||||||
int datalen;
|
int datalen;
|
||||||
uint8_t cmdc = 0;
|
uint16_t cmdc = 0;
|
||||||
uint8_t first, second;
|
uint8_t first, second;
|
||||||
|
static uint8_t iso14_pcb_blocknum;
|
||||||
|
|
||||||
if (activateField)
|
if (activateField) {
|
||||||
cmdc |= ISO14A_CONNECT;
|
cmdc |= ISO14A_CONNECT | ISO14A_CLEAR_TRACE;
|
||||||
|
iso14_pcb_blocknum = 0;
|
||||||
|
}
|
||||||
if (leaveSignalON)
|
if (leaveSignalON)
|
||||||
cmdc |= ISO14A_NO_DISCONNECT;
|
cmdc |= ISO14A_NO_DISCONNECT;
|
||||||
|
|
||||||
// ISO 14443 APDU frame: PCB [CID] [NAD] APDU CRC PCB=0x02
|
// ISO 14443 APDU frame: PCB [CID] [NAD] APDU CRC PCB=0x02
|
||||||
memcpy(data + 1, datain, datainlen);
|
memcpy(data + 1, datain, datainlen);
|
||||||
data[0] = 0x02; // bnr,nad,cid,chn=0; i-block(0x00)
|
data[0] = 0x02; // bnr,nad,cid,chn=0; i-block(0x00)
|
||||||
|
data[0] += iso14_pcb_blocknum; // add block number (bnr)
|
||||||
|
|
||||||
datalen = datainlen + 1;
|
datalen = datainlen + 1;
|
||||||
|
|
||||||
ComputeCrc14443(CRC_14443_A, data, datalen, &first, &second);
|
ComputeCrc14443(CRC_14443_A, data, datalen, &first, &second);
|
||||||
|
@ -673,6 +694,14 @@ int ExchangeAPDU14a(uint8_t *datain, int datainlen, bool activateField, bool lea
|
||||||
PrintAndLog("APDU ERROR: Small APDU response.");
|
PrintAndLog("APDU ERROR: Small APDU response.");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// invert block number field in PCB byte
|
||||||
|
if ( ((recv[0] & 0xC0) == 0 // I-Block
|
||||||
|
|| (recv[0] & 0xD0) == 0x80) // R-Block with ACK bit set to 0
|
||||||
|
&& (recv[0] & 0x01) == iso14_pcb_blocknum) // equal block numbers
|
||||||
|
{
|
||||||
|
iso14_pcb_blocknum ^= 1;
|
||||||
|
}
|
||||||
|
|
||||||
// check block
|
// check block
|
||||||
if (data[0] != recv[0]) {
|
if (data[0] != recv[0]) {
|
||||||
|
@ -905,7 +934,7 @@ int CmdHF14ACmdRaw(const char *cmd) {
|
||||||
|
|
||||||
if(active || active_select)
|
if(active || active_select)
|
||||||
{
|
{
|
||||||
c.arg[0] |= ISO14A_CONNECT;
|
c.arg[0] |= ISO14A_CONNECT | ISO14A_CLEAR_TRACE;
|
||||||
if(active)
|
if(active)
|
||||||
c.arg[0] |= ISO14A_NO_SELECT;
|
c.arg[0] |= ISO14A_NO_SELECT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,20 +18,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "util.h"
|
#include <stdbool.h>
|
||||||
#include "util_posix.h"
|
|
||||||
#include "iso14443crc.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "proxmark3.h"
|
|
||||||
#include "ui.h"
|
|
||||||
#include "cmdparser.h"
|
|
||||||
#include "common.h"
|
|
||||||
#include "cmdmain.h"
|
|
||||||
#include "mifare.h"
|
|
||||||
#include "cmdhfmfu.h"
|
|
||||||
#include "mifarehost.h"
|
|
||||||
#include "emv/apduinfo.h"
|
|
||||||
#include "emv/emvcore.h"
|
|
||||||
|
|
||||||
// structure and database for uid -> tagtype lookups
|
// structure and database for uid -> tagtype lookups
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -35,7 +35,8 @@ typedef enum ISO14A_COMMAND {
|
||||||
ISO14A_SET_TIMEOUT = (1 << 6),
|
ISO14A_SET_TIMEOUT = (1 << 6),
|
||||||
ISO14A_NO_SELECT = (1 << 7),
|
ISO14A_NO_SELECT = (1 << 7),
|
||||||
ISO14A_TOPAZMODE = (1 << 8),
|
ISO14A_TOPAZMODE = (1 << 8),
|
||||||
ISO14A_NO_RATS = (1 << 9)
|
ISO14A_NO_RATS = (1 << 9),
|
||||||
|
ISO14A_CLEAR_TRACE = (1 << 10)
|
||||||
} iso14a_command_t;
|
} iso14a_command_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue