mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-14 10:36:58 -07:00
iso14a reader patches [Hagen Fritsch]
This commit is contained in:
parent
7e758047e4
commit
534983d735
12 changed files with 255 additions and 95 deletions
|
@ -45,6 +45,7 @@ CMDSRCS = \
|
|||
data.c \
|
||||
graph.c \
|
||||
ui.c \
|
||||
util.c \
|
||||
cmddata.c \
|
||||
cmdhf.c \
|
||||
cmdhf14a.c \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>, Hagen Fritsch
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
// at your option, any later version. See the LICENSE.txt file for the text of
|
||||
|
@ -17,6 +17,7 @@
|
|||
#include "ui.h"
|
||||
#include "cmdparser.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "common.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -147,6 +148,11 @@ int CmdHF14AList(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void iso14a_set_timeout(uint32_t timeout) {
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_SET_TIMEOUT, 0, timeout}};
|
||||
SendCommand(&c);
|
||||
}
|
||||
|
||||
int CmdHF14AMifare(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_READER_MIFARE, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
|
@ -156,9 +162,26 @@ int CmdHF14AMifare(const char *Cmd)
|
|||
|
||||
int CmdHF14AReader(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_CONNECT, 0, 0}};
|
||||
SendCommand(&c);
|
||||
UsbCommand * resp = WaitForResponse(CMD_ACK);
|
||||
uint8_t * uid = resp->d.asBytes;
|
||||
iso14a_card_select_t * card = uid + 12;
|
||||
|
||||
if(resp->arg[0] == 0) {
|
||||
PrintAndLog("iso14443a card select failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("ATQA : %02x %02x", card->atqa[0], card->atqa[1]);
|
||||
PrintAndLog(" UID : %s", sprint_hex(uid, 12));
|
||||
PrintAndLog(" SAK : %02x [%d]", card->sak, resp->arg[0]);
|
||||
if(resp->arg[0] == 1)
|
||||
PrintAndLog(" ATS : %s", sprint_hex(card->ats, card->ats_len));
|
||||
else
|
||||
PrintAndLog("proprietary non-iso14443a card found, RATS not supported");
|
||||
|
||||
return resp->arg[0];
|
||||
}
|
||||
|
||||
// ## simulate iso14443a tag
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
unsigned int current_command = CMD_UNKNOWN;
|
||||
unsigned int received_command = CMD_UNKNOWN;
|
||||
UsbCommand current_response;
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static int CmdQuit(const char *Cmd);
|
||||
|
@ -53,12 +54,25 @@ int CmdQuit(const char *Cmd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void WaitForResponse(uint32_t response_type)
|
||||
UsbCommand * WaitForResponseTimeout(uint32_t response_type, uint32_t ms_timeout) {
|
||||
UsbCommand * ret = ¤t_response;
|
||||
int i=0;
|
||||
|
||||
for(i=0; received_command != response_type && i < ms_timeout / 10; i++) {
|
||||
msleep(10); // XXX ugh
|
||||
}
|
||||
|
||||
if(received_command != response_type)
|
||||
ret = NULL;
|
||||
|
||||
received_command = CMD_UNKNOWN;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
UsbCommand * WaitForResponse(uint32_t response_type)
|
||||
{
|
||||
while (received_command != response_type) {
|
||||
msleep(10); // XXX ugh
|
||||
}
|
||||
received_command = CMD_UNKNOWN;
|
||||
return WaitForResponseTimeout(response_type, -1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -137,7 +151,11 @@ void UsbCommandReceived(UsbCommand *UC)
|
|||
return;
|
||||
default:
|
||||
unexpected_response:
|
||||
PrintAndLog("unrecognized command %08x\n", UC->cmd);
|
||||
break;
|
||||
|
||||
if(UC->cmd != CMD_ACK)
|
||||
PrintAndLog("unrecognized command %08x\n", UC->cmd);
|
||||
else
|
||||
memcpy(¤t_response, UC, sizeof(UsbCommand));
|
||||
received_command = UC->cmd;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
void UsbCommandReceived(UsbCommand *UC);
|
||||
void CommandReceived(char *Cmd);
|
||||
void WaitForResponse(uint32_t response_type);
|
||||
UsbCommand * WaitForResponseTimeout(uint32_t response_type, uint32_t ms_timeout);
|
||||
UsbCommand * WaitForResponse(uint32_t response_type);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -151,9 +151,10 @@ usb_dev_handle* findProxmark(int verbose, unsigned int *iface)
|
|||
|
||||
fprintf(stdout, "\nConnected units:\n");
|
||||
|
||||
for (int i = 0; i < iUnit; i++)
|
||||
fprintf(stdout, "\t%d. SN: %s\n", i+1, units[i].serial_number);
|
||||
|
||||
for (int i = 0; i < iUnit; i++) {
|
||||
struct usb_device * dev = usb_device(units[i].handle);
|
||||
fprintf(stdout, "\t%d. SN: %s [%s/%s]\n", i+1, units[i].serial_number, dev->bus->dirname, dev->filename);
|
||||
}
|
||||
if (iUnit > 1) {
|
||||
while (iSelection < 1 || iSelection > iUnit) {
|
||||
fprintf(stdout, "Which unit do you want to connect to? ");
|
||||
|
|
23
client/util.c
Normal file
23
client/util.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
void print_hex(const uint8_t * data, const size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i=0; i < len; i++)
|
||||
printf("%02x ", data[i]);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
char * sprint_hex(const uint8_t * data, const size_t len) {
|
||||
static char buf[1024];
|
||||
char * tmp = buf;
|
||||
size_t i;
|
||||
|
||||
for (i=0; i < len && i < 1024/3; i++, tmp += 3)
|
||||
sprintf(tmp, "%02x ", data[i]);
|
||||
|
||||
return buf;
|
||||
}
|
1
client/util.h
Normal file
1
client/util.h
Normal file
|
@ -0,0 +1 @@
|
|||
void print_hex(const uint8_t * data, const size_t len);
|
Loading…
Add table
Add a link
Reference in a new issue