#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <string.h>
+//#include <string.h>
#include <stdint.h>
#include "iso14443crc.h"
#include "proxmark3.h"
int CmdHF14BSim(const char *Cmd)
{
- UsbCommand c={CMD_SIMULATE_TAG_ISO_14443B};
+ UsbCommand c={CMD_SIMULATE_TAG_ISO_14443B};
clearCommandBuffer();
SendCommand(&c);
return 0;
int CmdHF14BSnoop(const char *Cmd)
{
- UsbCommand c = {CMD_SNOOP_ISO_14443B};
+ UsbCommand c = {CMD_SNOOP_ISO_14443B};
clearCommandBuffer();
SendCommand(&c);
return 0;
if (!reply) return 1;
- if (!WaitForResponseTimeout(CMD_ACK,&resp,1000)) {
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
if (verbose) PrintAndLog("timeout while waiting for reply.");
- return 0;
- }
- *datalen = resp.arg[0];
- if (verbose) PrintAndLog("received %u octets", *datalen);
- if(*datalen<2) return 0;
+ return 0;
+ }
- memcpy(data, resp.d.asBytes, *datalen);
- if (verbose) PrintAndLog("%s", sprint_hex(data, *datalen));
+ int len = resp.arg[0];
+ if (verbose) {
+ PrintAndLog("received %u octets", len);
+ }
+ if ( len < 2 ) return 0;
- uint8_t first, second;
- ComputeCrc14443(CRC_14443_B, data, *datalen-2, &first, &second);
- if(data[*datalen-2] == first && data[*datalen-1] == second) {
- if (verbose) PrintAndLog("CRC OK");
- *crc = true;
- } else {
- if (verbose) PrintAndLog("CRC failed");
- *crc = false;
- }
+ memcpy(data, resp.d.asBytes, len);
+ if (verbose) PrintAndLog("%s", sprint_hex(data, len));
+
+ uint8_t first, second;
+ ComputeCrc14443(CRC_14443_B, data, len-2, &first, &second);
+ if(data[len-2] == first && data[len-1] == second) {
+ if (verbose) PrintAndLog("CRC OK");
+ *crc = true;
+ } else {
+ if (verbose) PrintAndLog("CRC failed");
+ *crc = false;
+ }
return 1;
}
bool crc = false;
bool power = false;
char buf[5]="";
- uint8_t data[100] = {0x00};
+ uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
uint8_t datalen = 0;
unsigned int temp;
int i = 0;
return;
}
-int HF14BStdReader(uint8_t *data, uint8_t *datalen){
+int HF14BStdInfo(uint8_t *data, uint8_t *datalen){
//05 00 00 = find one tag in field
//1d xx xx xx xx 20 00 08 01 00 = attrib xx=crc
print_atqb_resp(data);
return 1;
- }
+}
-int HF14B_ST_Reader(uint8_t *data, uint8_t *datalen){
+int HF14B_ST_Info(uint8_t *data, uint8_t *datalen){
bool crc = true;
*datalen = 2;
//wake cmd
}
// test for other 14b type tags (mimic another reader - don't have tags to identify)
-int HF14B_Other_Reader(uint8_t *data, uint8_t *datalen){
+int HF14B_Other_Info(uint8_t *data, uint8_t *datalen){
bool crc = true;
*datalen = 4;
//std read cmd
}
-int HF14BReader(bool verbose){
+int HF14BInfo(bool verbose){
uint8_t data[100];
uint8_t datalen = 5;
// try std 14b (atqb)
- if (HF14BStdReader(data, &datalen)) return 1;
+ if (HF14BStdInfo(data, &datalen)) return 1;
// try st 14b
- if (HF14B_ST_Reader(data, &datalen)) return 1;
+ if (HF14B_ST_Info(data, &datalen)) return 1;
// try unknown 14b read commands (to be identified later)
// could be read of calypso, CEPAS, moneo, or pico pass.
- if (HF14B_Other_Reader(data, &datalen)) return 1;
+ if (HF14B_Other_Info(data, &datalen)) return 1;
if (verbose) PrintAndLog("no 14443B tag found");
return 0;
}
-int CmdHF14BReader(const char *Cmd){
- return HF14BReader(true);
+int CmdHF14Binfo(const char *Cmd){
+ return HF14BInfo(true);
}
-int CmdHF14BWrite( const char *Cmd){
+int CmdSriWrite( const char *Cmd){
/*
* For SRIX4K blocks 00 - 7F
* hf 14b raw -c -p 09 $srix4kwblock $srix4kwdata
static command_t CommandTable[] =
{
{"help", CmdHelp, 1, "This help"},
+ {"info", CmdHF14Binfo, 0, "Find and print info about a 14b type tag (HF ISO 14443b)"},
{"list", CmdHF14BList, 0, "[Deprecated] List ISO 14443b history"},
- {"reader", CmdHF14BReader, 0, "Find 14b tag (HF ISO 14443b)"},
- {"sim", CmdHF14BSim, 0, "Fake ISO 14443B tag"},
-
- {"snoop", CmdHF14BSnoop, 0, "Eavesdrop ISO 14443B"},
+ {"sim", CmdHF14BSim, 0, "Fake ISO 14443B tag"},
+ {"snoop", CmdHF14BSnoop, 0, "Eavesdrop ISO 14443B"},
{"sri512read", CmdSri512Read, 0, "Read contents of a SRI512 tag"},
{"srix4kread", CmdSrix4kRead, 0, "Read contents of a SRIX4K tag"},
+ {"sriwrite", CmdSriWrite, 0, "Write data to a SRI512 | SRIX4K tag"},
{"raw", CmdHF14BCmdRaw, 0, "Send raw hex data to tag"},
- {"write", CmdHF14BWrite, 0, "Write data to a SRI512 | SRIX4K tag"},
{NULL, NULL, 0, NULL}
};