Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Proxmark/proxmark3
Browse files Browse the repository at this point in the history
Conflicts:
	armsrc/appmain.c
	armsrc/apps.h
	armsrc/iclass.c
	client/Makefile
	client/cmdhficlass.c
	client/loclass/cipher.c
	client/loclass/fileutils.c
	client/loclass/ikeys.h
	include/usb_cmd.h
  • Loading branch information
iceman1001 committed Sep 19, 2014
2 parents 3d93d4f + 92d255d commit 7546537
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 68 deletions.
1 change: 0 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,3 @@ Jonathan Westhues
user jwesthues, at host cq.cx

May 2007, Cambridge MA

2 changes: 1 addition & 1 deletion armsrc/apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void SimulateIClass(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain
void ReaderIClass(uint8_t arg0);
void ReaderIClass_Replay(uint8_t arg0,uint8_t *MAC);
void IClass_iso14443A_GetPublic(uint8_t arg0);

// hitag2.h
void SnoopHitag(uint32_t type);
void SimulateHitagTag(bool tag_mem_supplied, byte_t* data);
Expand Down
25 changes: 13 additions & 12 deletions armsrc/iclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
// different initial value (CRC_ICLASS)
#include "../common/iso14443crc.h"
#include "../common/iso15693tools.h"
#include "iso15693tools.h"


static int timeout = 4096;
Expand Down Expand Up @@ -1514,23 +1515,23 @@ void ReaderIClass(uint8_t arg0) {
{
WDT_HIT();

// Send act_all
ReaderTransmitIClass(act_all, 1);
// Card present?
if(ReaderReceiveIClass(resp)) {
// Send act_all
ReaderTransmitIClass(act_all, 1);
// Card present?
if(ReaderReceiveIClass(resp)) {

ReaderTransmitIClass(identify, 1);
ReaderTransmitIClass(identify, 1);

if(ReaderReceiveIClass(resp) == 10) {
if(ReaderReceiveIClass(resp) == 10) {
//Copy the Anti-collision CSN to our select-packet
memcpy(&select[1],resp,8);
memcpy(&select[1],resp,8);
//Dbprintf("Anti-collision CSN: %02x %02x %02x %02x %02x %02x %02x %02x",resp[0], resp[1], resp[2],
// resp[3], resp[4], resp[5],
// resp[6], resp[7]);
//Select the card
ReaderTransmitIClass(select, sizeof(select));
ReaderTransmitIClass(select, sizeof(select));

if(ReaderReceiveIClass(resp) == 10) {
if(ReaderReceiveIClass(resp) == 10) {
//Save CSN in response data
memcpy(card_data,resp,8);
datasize += 8;
Expand Down Expand Up @@ -1569,7 +1570,7 @@ void ReaderIClass(uint8_t arg0) {
break;
}
}
LED_A_OFF();
LED_A_OFF();
}

void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
Expand All @@ -1580,7 +1581,7 @@ void ReaderIClass_Replay(uint8_t arg0, uint8_t *MAC) {
uint8_t check[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
uint8_t read[] = { 0x0c, 0x00, 0x00, 0x00 };

uint16_t crc = 0;
uint16_t crc = 0;
uint8_t cardsize=0;
bool read_success=false;
uint8_t mem=0;
Expand Down Expand Up @@ -1814,7 +1815,7 @@ void IClass_iso14443A_write(uint8_t arg0, uint8_t blockNo, uint8_t *data, uint8_
memcpy(write+10,mac,4);
while(!send_success){
ReaderTransmitIClass(write, sizeof(write));
if(ReaderReceiveIClass(resp) == 10) {
if(ReaderReceiveIClass(resp) == 10) {
write_success=true;
}
}//
Expand Down
39 changes: 25 additions & 14 deletions armsrc/mifaredesfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ bool InitDesfireCard(){
return true;
}

// ARG0 flag enums
enum {
NONE = 0x00,
INIT = 0x01,
DISCONNECT = 0x02,
FOO = 0x04,
BAR = 0x08,
} CmdOptions ;

void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain){

/* ARG0 contains flags.
0x01 = init card.
0x02 =
0x02 = No Disconnect
0x03
*/
uint8_t flags = arg0;
Expand All @@ -53,28 +62,33 @@ void MifareSendCommand(uint8_t arg0, uint8_t arg1, uint8_t *datain){
memset(resp,0,sizeof(resp));

if (MF_DBGLEVEL >= 4) {
Dbprintf(" flags: %02X", flags);
Dbprintf(" len : %02X", datalen);
print_result("to send: ", datain, datalen);
Dbprintf(" flags : %02X", flags);
Dbprintf(" len : %02X", datalen);
print_result(" RX : ", datain, datalen);
}

if ( flags & 0x01 ){
if ( flags & INIT ){
if ( !InitDesfireCard() )
return;
}

int len = DesfireAPDU(datain, datalen, resp);
print_result(" <--: ", resp, len);
if ( !len ) {
if (MF_DBGLEVEL >= 4) {
print_result("ERR <--: ", resp, len);
}
OnError();
return;
}
cmd_send(CMD_ACK,1,len,0,resp,len);


OnSuccess();
// reset the pcb_blocknum,
pcb_blocknum = 0;

if ( flags & DISCONNECT )
OnSuccess();

cmd_send(CMD_ACK,1,len,0,resp,len);
}

void MifareDesfireGetInformation(){
Expand Down Expand Up @@ -556,19 +570,16 @@ void MifareDES_Auth2(uint32_t arg0, uint8_t *datain){
}

void OnSuccess(){
// transmit a DESELECT COMMAND for Desfire.
ReaderTransmit(deselect_cmd, 3 , NULL);
// reset the pcb_blocknum,
pcb_blocknum = 0;
ReaderTransmit(deselect_cmd, 3 , NULL);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
LEDsoff();
}

void OnError(){
cmd_send(CMD_ACK,0,0,0,0,0);
ReaderTransmit(deselect_cmd, 3 , NULL);
// reset the pcb_blocknum,
pcb_blocknum = 0;
ReaderTransmit(deselect_cmd, 3 , NULL);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
cmd_send(CMD_ACK,0,0,0,0,0);
LEDsoff();
}
7 changes: 6 additions & 1 deletion client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
MOC = $(QTDIR)/bin/moc
LUAPLATFORM = mingw
else ifeq ($(platform),Darwin)
CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
MOC = $(shell pkg-config --variable=moc_location QtCore)
LUAPLATFORM = macosx
else
CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
Expand Down Expand Up @@ -78,8 +83,8 @@ CMDSRCS = nonce2key/crapto1.c\
cmdhfdes.c \
cmdhw.c \
cmdlf.c \
cmdlfhid.c \
cmdlfio.c \
cmdlfhid.c \
cmdlfem4x.c \
cmdlfhitag.c \
cmdlfti.c \
Expand Down
16 changes: 10 additions & 6 deletions client/cmdhficlass.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int CmdHFiClassList(const char *Cmd)
first_timestamp = timestamp;
}

// Break and stick with current result if buffer was not completely full
// Break and stick with current result idf buffer was not completely full
if (frame[0] == 0x44 && frame[1] == 0x44 && frame[2] == 0x44 && frame[3] == 0x44) break;

char line[1000] = "";
Expand Down Expand Up @@ -437,7 +437,7 @@ int CmdHFiClassReader_Replay(const char *Cmd)
PrintAndLog("Usage: hf iclass replay <MAC>");
PrintAndLog(" sample: hf iclass replay 00112233");
return 0;
}
}

if (param_gethex(Cmd, 0, MAC, 8)) {
PrintAndLog("MAC must include 8 HEX symbols");
Expand Down Expand Up @@ -477,11 +477,12 @@ int CmdHFiClassReader_Dump(const char *Cmd)
return 0;
}

if (param_gethex(Cmd, 0, KEY, 16)) {
if (param_gethex(Cmd, 0, KEY, 16))
{
PrintAndLog("KEY must include 16 HEX symbols");
return 1;
}

if (param_getchar(Cmd, 1) == 'e')
{
PrintAndLog("Elite switch on");
Expand Down Expand Up @@ -593,7 +594,7 @@ int CmdHFiClass_iso14443A_write(const char *Cmd)
if (blockNo>32)
{
PrintAndLog("Error: Maximum number of blocks is 32 for iClass 2K Cards!");
return 1;
return 1;
}
if (param_gethex(Cmd, 2, bldata, 8))
{
Expand Down Expand Up @@ -649,7 +650,10 @@ static command_t CommandTable[] =
{"list", CmdHFiClassList, 0, "List iClass history"},
{"snoop", CmdHFiClassSnoop, 0, "Eavesdrop iClass communication"},
{"sim", CmdHFiClassSim, 0, "Simulate iClass tag"},
{"reader", CmdHFiClassReader, 0, "Read an iClass tag"},
{"reader",CmdHFiClassReader, 0, "Read an iClass tag"},
{"replay",CmdHFiClassReader_Replay, 0, "Read an iClass tag via Reply Attack"},
{"dump", CmdHFiClassReader_Dump, 0, "Authenticate and Dump iClass tag"},
{"write", CmdHFiClass_iso14443A_write, 0, "Authenticate and Write iClass block"},
{"replay", CmdHFiClassReader_Replay, 0, "Read an iClass tag via Reply Attack"},
{"dump", CmdHFiClassReader_Dump, 0, "Authenticate and Dump iClass tag"},
{"write", CmdHFiClass_iso14443A_write, 0, "Authenticate and Write iClass block"},
Expand Down
Loading

0 comments on commit 7546537

Please sign in to comment.