mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-05-12 11:18:11 -07:00
Merge pull request #101 from marshmellow42/master
hf mfu updates + hf search + bug fixes
This commit is contained in:
+11
-14
@@ -738,7 +738,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
ReaderHitag((hitag_function)c->arg[0],(hitag_data*)c->d.asBytes);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WITH_ISO15693
|
||||
case CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693:
|
||||
AcquireRawAdcSamplesIso15693();
|
||||
@@ -818,25 +818,22 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
break;
|
||||
|
||||
case CMD_READER_MIFARE:
|
||||
ReaderMifare(c->arg[0]);
|
||||
ReaderMifare(c->arg[0]);
|
||||
break;
|
||||
case CMD_MIFARE_READBL:
|
||||
MifareReadBlock(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREU_READBL:
|
||||
MifareUReadBlock(c->arg[0],c->d.asBytes);
|
||||
MifareUReadBlock(c->arg[0],c->arg[1], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREUC_AUTH1:
|
||||
MifareUC_Auth1(c->arg[0],c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREUC_AUTH2:
|
||||
MifareUC_Auth2(c->arg[0],c->d.asBytes);
|
||||
case CMD_MIFAREUC_AUTH:
|
||||
MifareUC_Auth(c->arg[0],c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREU_READCARD:
|
||||
MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes);
|
||||
MifareUReadCard(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFAREUC_READCARD:
|
||||
MifareUReadCard(c->arg[0], c->arg[1], c->d.asBytes);
|
||||
case CMD_MIFAREUC_SETPWD:
|
||||
MifareUSetPwd(c->arg[0], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFARE_READSC:
|
||||
MifareReadSector(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
@@ -846,10 +843,10 @@ void UsbPacketReceived(uint8_t *packet, int len)
|
||||
break;
|
||||
case CMD_MIFAREU_WRITEBL_COMPAT:
|
||||
MifareUWriteBlock(c->arg[0], c->d.asBytes);
|
||||
break;
|
||||
break;
|
||||
case CMD_MIFAREU_WRITEBL:
|
||||
MifareUWriteBlock_Special(c->arg[0], c->d.asBytes);
|
||||
break;
|
||||
MifareUWriteBlock_Special(c->arg[0], c->d.asBytes);
|
||||
break;
|
||||
case CMD_MIFARE_NESTED:
|
||||
MifareNested(c->arg[0], c->arg[1], c->arg[2], c->d.asBytes);
|
||||
break;
|
||||
|
||||
+4
-4
@@ -165,10 +165,9 @@ void EPA_PACE_Collect_Nonce(UsbCommand * c);
|
||||
void ReaderMifare(bool first_try);
|
||||
int32_t dist_nt(uint32_t nt1, uint32_t nt2);
|
||||
void MifareReadBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *data);
|
||||
void MifareUReadBlock(uint8_t arg0,uint8_t *datain);
|
||||
void MifareUC_Auth1(uint8_t arg0, uint8_t *datain);
|
||||
void MifareUC_Auth2(uint32_t arg0, uint8_t *datain);
|
||||
void MifareUReadCard(uint8_t arg0, int Pages, uint8_t *datain);
|
||||
void MifareUReadBlock(uint8_t arg0, uint8_t arg1, uint8_t *datain);
|
||||
void MifareUC_Auth(uint8_t arg0, uint8_t *datain);
|
||||
void MifareUReadCard(uint8_t arg0, uint16_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareReadSector(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareWriteBlock(uint8_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain);
|
||||
void MifareUWriteBlock(uint8_t arg0,uint8_t *datain);
|
||||
@@ -184,6 +183,7 @@ void MifareECardLoad(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datai
|
||||
void MifareCSetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain); // Work with "magic Chinese" card
|
||||
void MifareCGetBlock(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *datain);
|
||||
void MifareCIdent(); // is "magic chinese" card?
|
||||
void MifareUSetPwd(uint8_t arg0, uint8_t *datain);
|
||||
|
||||
//desfire
|
||||
void Mifare_DES_Auth1(uint8_t arg0,uint8_t *datain);
|
||||
|
||||
@@ -378,6 +378,60 @@ void tdes_dec(void* out, void* in, const uint8_t* key){
|
||||
des_dec(out, out, (uint8_t*)key + 0);
|
||||
}
|
||||
|
||||
void tdes_2key_enc(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]){
|
||||
|
||||
if( length % 8 ) return;
|
||||
|
||||
uint8_t i;
|
||||
uint8_t* tin = (uint8_t*) in;
|
||||
uint8_t* tout = (uint8_t*) out;
|
||||
|
||||
while( length > 0 )
|
||||
{
|
||||
for ( i = 0; i < 8; i++ )
|
||||
tout[i] = (unsigned char)(tin[i] ^ iv[i]);
|
||||
|
||||
des_enc(tout, tin, (uint8_t*)key + 0);
|
||||
des_dec(tout, tout, (uint8_t*)key + 8);
|
||||
des_enc(tout, tout, (uint8_t*)key + 0);
|
||||
|
||||
memcpy(iv, tout, 8);
|
||||
|
||||
tin += 8;
|
||||
tout += 8;
|
||||
length -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void tdes_2key_dec(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]){
|
||||
|
||||
if( length % 8 ) return;
|
||||
|
||||
uint8_t i;
|
||||
unsigned char temp[8];
|
||||
uint8_t* tin = (uint8_t*) in;
|
||||
uint8_t* tout = (uint8_t*) out;
|
||||
|
||||
while( length > 0 )
|
||||
{
|
||||
memcpy(temp, tin, 8);
|
||||
|
||||
des_dec(tout, tin, (uint8_t*)key + 0);
|
||||
des_enc(tout, tout, (uint8_t*)key + 8);
|
||||
des_dec(tout, tout, (uint8_t*)key + 0);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
tout[i] = (unsigned char)(tout[i] ^ iv[i]);
|
||||
|
||||
memcpy(iv, temp, 8);
|
||||
|
||||
tin += 8;
|
||||
tout += 8;
|
||||
length -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ void tdes_enc(void* out, const void* in, const void* key);
|
||||
*/
|
||||
void tdes_dec(void* out, const void* in, const void* key);
|
||||
|
||||
void tdes_2key_enc(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
|
||||
void tdes_2key_dec(void* out, const void* in, size_t length, const void* key, unsigned char iv[8]);
|
||||
|
||||
#endif /*DES_H_*/
|
||||
|
||||
// Copied from des.h in desfire imp.
|
||||
|
||||
+10
-8
@@ -1677,7 +1677,7 @@ void ReaderIClass(uint8_t arg0) {
|
||||
|
||||
uint8_t card_data[6 * 8]={0};
|
||||
memset(card_data, 0xFF, sizeof(card_data));
|
||||
uint8_t last_csn[8]={0};
|
||||
uint8_t last_csn[8]={0};
|
||||
|
||||
//Read conf block CRC(0x01) => 0xfa 0x22
|
||||
uint8_t readConf[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x01, 0xfa, 0x22};
|
||||
@@ -1685,16 +1685,18 @@ void ReaderIClass(uint8_t arg0) {
|
||||
uint8_t readAA[] = { ICLASS_CMD_READ_OR_IDENTIFY,0x05, 0xde, 0x64};
|
||||
|
||||
|
||||
int read_status= 0;
|
||||
int read_status= 0;
|
||||
uint8_t result_status = 0;
|
||||
bool abort_after_read = arg0 & FLAG_ICLASS_READER_ONLY_ONCE;
|
||||
|
||||
bool abort_after_read = arg0 & FLAG_ICLASS_READER_ONLY_ONCE;
|
||||
bool try_once = arg0 & FLAG_ICLASS_READER_ONE_TRY;
|
||||
set_tracing(TRUE);
|
||||
setupIclassReader();
|
||||
setupIclassReader();
|
||||
|
||||
uint16_t tryCnt=0;
|
||||
while(!BUTTON_PRESS())
|
||||
{
|
||||
|
||||
{
|
||||
if (try_once && tryCnt > 5) break;
|
||||
tryCnt++;
|
||||
if(!tracing) {
|
||||
DbpString("Trace full");
|
||||
break;
|
||||
@@ -1761,7 +1763,7 @@ void ReaderIClass(uint8_t arg0) {
|
||||
|
||||
}
|
||||
LED_B_OFF();
|
||||
}
|
||||
}
|
||||
cmd_send(CMD_ACK,0,0,0,card_data, 0);
|
||||
LED_A_OFF();
|
||||
}
|
||||
|
||||
+1
-1
@@ -651,7 +651,7 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
|
||||
int ledcontrol = 1;
|
||||
int n=0, i=0;
|
||||
uint8_t clk = (arg1 >> 8) & 0xFF;
|
||||
uint8_t encoding = arg1 & 1;
|
||||
uint8_t encoding = arg1 & 0xFF;
|
||||
uint8_t separator = arg2 & 1;
|
||||
uint8_t invert = (arg2 >> 8) & 1;
|
||||
|
||||
|
||||
+282
-207
File diff suppressed because it is too large
Load Diff
+258
-184
File diff suppressed because it is too large
Load Diff
+23
-22
@@ -52,33 +52,34 @@ extern int MF_DBGLEVEL;
|
||||
|
||||
#define cardSTATE_TO_IDLE() cardSTATE = MFEMUL_IDLE; LED_B_OFF(); LED_C_OFF();
|
||||
|
||||
//functions
|
||||
int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_short_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
//functions
|
||||
int mifare_sendcmd_short(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_short_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
|
||||
int mifare_sendcmd_short_mfucauth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
|
||||
int mifare_sendcmd_short_mfuev1auth(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t *data, uint8_t *answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_shortex(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
|
||||
int mifare_classic_auth(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested);
|
||||
int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested, uint32_t * ntptr, uint32_t *timing);
|
||||
int mifare_classic_readblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_auth1(uint32_t cuid, uint8_t *blockData);
|
||||
int mifare_ultra_auth2(uint32_t cuid, uint8_t *key, uint8_t *blockData);
|
||||
int mifare_ultra_readblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_writeblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_special_writeblock(uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid);
|
||||
int mifare_ultra_halt(uint32_t uid);
|
||||
int mifare_classic_authex(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t keyType, uint64_t ui64Key, uint8_t isNested, uint32_t * ntptr, uint32_t *timing);
|
||||
int mifare_classic_readblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ul_ev1_auth(uint8_t *key, uint8_t *pack);
|
||||
int mifare_ultra_auth(uint8_t *key);
|
||||
int mifare_ultra_readblock(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_writeblock(struct Crypto1State *pcs, uint32_t uid, uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_writeblock(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_ultra_special_writeblock(uint8_t blockNo, uint8_t *blockData);
|
||||
int mifare_classic_halt(struct Crypto1State *pcs, uint32_t uid);
|
||||
int mifare_ultra_halt();
|
||||
|
||||
// desfire
|
||||
int mifare_sendcmd_special(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer, uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_sendcmd_special2(struct Crypto1State *pcs, uint8_t crypted, uint8_t cmd, uint8_t* data, uint8_t* answer,uint8_t *answer_parity, uint32_t *timing);
|
||||
int mifare_desfire_des_auth1(uint32_t uid, uint8_t *blockData);
|
||||
int mifare_desfire_des_auth2(uint32_t uid, uint8_t *key, uint8_t *blockData);
|
||||
|
||||
// crypto functions
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *receivedCmd, int len);
|
||||
|
||||
// crypto functions
|
||||
void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *receivedCmd, int len);
|
||||
void mf_crypto1_encrypt(struct Crypto1State *pcs, uint8_t *data, uint16_t len, uint8_t *par);
|
||||
uint8_t mf_crypto1_encrypt4bit(struct Crypto1State *pcs, uint8_t data);
|
||||
|
||||
@@ -93,7 +94,7 @@ void emlGetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
void emlGetMemBt(uint8_t *data, int bytePtr, int byteCount);
|
||||
uint64_t emlGetKey(int sectorNum, int keyType);
|
||||
int emlGetValBl(uint32_t *blReg, uint8_t *blBlock, int blockNum);
|
||||
int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum);
|
||||
int emlCheckValBl(int blockNum);
|
||||
|
||||
#endif
|
||||
int emlSetValBl(uint32_t blReg, uint8_t blBlock, int blockNum);
|
||||
int emlCheckValBl(int blockNum);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -68,6 +68,7 @@ CMDSRCS = nonce2key/crapto1.c\
|
||||
mifarehost.c\
|
||||
crc.c \
|
||||
crc16.c \
|
||||
crc64.c \
|
||||
iso14443crc.c \
|
||||
iso15693tools.c \
|
||||
data.c \
|
||||
|
||||
+3
-3
@@ -26,7 +26,7 @@
|
||||
|
||||
uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
uint8_t g_debugMode;
|
||||
int DemodBufferLen;
|
||||
size_t DemodBufferLen;
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
//set the demod buffer with given array of binary (one bit per byte)
|
||||
@@ -1484,7 +1484,7 @@ int CmdIndalaDecode(const char *Cmd)
|
||||
return 0;
|
||||
}
|
||||
uint8_t invert=0;
|
||||
ans = indala26decode(DemodBuffer,(size_t *) &DemodBufferLen, &invert);
|
||||
ans = indala26decode(DemodBuffer, &DemodBufferLen, &invert);
|
||||
if (ans < 1) {
|
||||
if (g_debugMode==1)
|
||||
PrintAndLog("Error2: %d",ans);
|
||||
@@ -1892,7 +1892,7 @@ int getSamples(const char *Cmd, bool silent)
|
||||
PrintAndLog("Unpacking...");
|
||||
BitstreamOut bout = { got, bits_per_sample * n, 0};
|
||||
int j =0;
|
||||
for (j = 0; j * bits_per_sample < n * 8 && j < sizeof(GraphBuffer); j++) {
|
||||
for (j = 0; j * bits_per_sample < n * 8 && j < n; j++) {
|
||||
uint8_t sample = getByte(bits_per_sample, &bout);
|
||||
GraphBuffer[j] = ((int) sample )- 128;
|
||||
}
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ int getSamples(const char *Cmd, bool silent);
|
||||
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
extern int DemodBufferLen;
|
||||
extern size_t DemodBufferLen;
|
||||
extern uint8_t g_debugMode;
|
||||
#define BIGBUF_SIZE 40000
|
||||
|
||||
|
||||
+77
-4
@@ -71,11 +71,57 @@ void annotateIso14443a(char *exp, size_t size, uint8_t* cmd, uint8_t cmdsize)
|
||||
case MIFARE_CMD_DEC: snprintf(exp,size,"DEC(%d)",cmd[1]); break;
|
||||
case MIFARE_CMD_RESTORE: snprintf(exp,size,"RESTORE(%d)",cmd[1]); break;
|
||||
case MIFARE_CMD_TRANSFER: snprintf(exp,size,"TRANSFER(%d)",cmd[1]); break;
|
||||
case MIFARE_AUTH_KEYA: snprintf(exp,size,"AUTH-A(%d)",cmd[1]); break;
|
||||
case MIFARE_AUTH_KEYA:{
|
||||
if ( cmdsize > 3)
|
||||
snprintf(exp,size,"AUTH-A(%d)",cmd[1]);
|
||||
else
|
||||
// case MIFARE_ULEV1_VERSION : both 0x60.
|
||||
snprintf(exp,size,"EV1 VERSION");
|
||||
break;
|
||||
}
|
||||
case MIFARE_AUTH_KEYB: snprintf(exp,size,"AUTH-B(%d)",cmd[1]); break;
|
||||
case MIFARE_MAGICWUPC1: snprintf(exp,size,"MAGIC WUPC1"); break;
|
||||
case MIFARE_MAGICWUPC2: snprintf(exp,size,"MAGIC WUPC2"); break;
|
||||
case MIFARE_MAGICWIPEC: snprintf(exp,size,"MAGIC WIPEC"); break;
|
||||
case MIFARE_ULC_AUTH_1: snprintf(exp,size,"AUTH "); break;
|
||||
case MIFARE_ULC_AUTH_2: snprintf(exp,size,"AUTH_ANSW"); break;
|
||||
case MIFARE_ULEV1_AUTH:
|
||||
if ( cmdsize == 7 )
|
||||
snprintf(exp,size,"PWD-AUTH KEY: 0x%02x%02x%02x%02x", cmd[1], cmd[2], cmd[3], cmd[4] );
|
||||
else
|
||||
snprintf(exp,size,"PWD-AUTH");
|
||||
break;
|
||||
case MIFARE_ULEV1_FASTREAD:{
|
||||
if ( cmdsize >=3 && cmd[2] <= 0xE6)
|
||||
snprintf(exp,size,"READ RANGE (%d-%d)",cmd[1],cmd[2]);
|
||||
else
|
||||
snprintf(exp,size,"?");
|
||||
break;
|
||||
}
|
||||
case MIFARE_ULC_WRITE:{
|
||||
if ( cmd[1] < 0x21 )
|
||||
snprintf(exp,size,"WRITEBLOCK(%d)",cmd[1]);
|
||||
else
|
||||
snprintf(exp,size,"?");
|
||||
break;
|
||||
}
|
||||
case MIFARE_ULEV1_READ_CNT:{
|
||||
if ( cmd[1] < 5 )
|
||||
snprintf(exp,size,"READ CNT(%d)",cmd[1]);
|
||||
else
|
||||
snprintf(exp,size,"?");
|
||||
break;
|
||||
}
|
||||
case MIFARE_ULEV1_INCR_CNT:{
|
||||
if ( cmd[1] < 5 )
|
||||
snprintf(exp,size,"INCR(%d)",cmd[1]);
|
||||
else
|
||||
snprintf(exp,size,"?");
|
||||
break;
|
||||
}
|
||||
case MIFARE_ULEV1_READSIG: snprintf(exp,size,"READ_SIG"); break;
|
||||
case MIFARE_ULEV1_CHECKTEAR: snprintf(exp,size,"CHK_TEARING(%d)",cmd[1]); break;
|
||||
case MIFARE_ULEV1_VCSL: snprintf(exp,size,"VCSL"); break;
|
||||
default: snprintf(exp,size,"?"); break;
|
||||
}
|
||||
return;
|
||||
@@ -503,6 +549,32 @@ int CmdHFList(const char *Cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHFSearch(const char *Cmd){
|
||||
int ans = 0;
|
||||
PrintAndLog("");
|
||||
ans = CmdHF14AReader("s");
|
||||
if (ans > 0) {
|
||||
PrintAndLog("\nValid ISO14443A Tag Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
ans = HFiClassReader("", false, false);
|
||||
if (ans) {
|
||||
PrintAndLog("\nValid iClass Tag (or PicoPass Tag) Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
ans = HF15Reader("", false);
|
||||
if (ans) {
|
||||
PrintAndLog("\nValid ISO15693 Tag Found - Quiting Search\n");
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
//14b has issues currently...
|
||||
//ans = CmdHF14BRead(Cmd);
|
||||
//if (ans > 0) return ans;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static command_t CommandTable[] =
|
||||
{
|
||||
@@ -513,10 +585,11 @@ static command_t CommandTable[] =
|
||||
{"epa", CmdHFEPA, 1, "{ German Identification Card... }"},
|
||||
{"legic", CmdHFLegic, 0, "{ LEGIC RFIDs... }"},
|
||||
{"iclass", CmdHFiClass, 1, "{ ICLASS RFIDs... }"},
|
||||
{"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
|
||||
{"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
|
||||
{"mf", CmdHFMF, 1, "{ MIFARE RFIDs... }"},
|
||||
{"mfu", CmdHFMFUltra, 1, "{ MIFARE Ultralight RFIDs... }"},
|
||||
{"tune", CmdHFTune, 0, "Continuously measure HF antenna tuning"},
|
||||
{"list", CmdHFList, 1, "List protocol data in trace buffer"},
|
||||
{"list", CmdHFList, 1, "List protocol data in trace buffer"},
|
||||
{"search", CmdHFSearch, 1, "Search for known HF tags [preliminary]"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
+39
-2
@@ -23,6 +23,7 @@
|
||||
#include "common.h"
|
||||
#include "cmdmain.h"
|
||||
#include "mifare.h"
|
||||
#include "cmdhfmfu.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static void waitCmd(uint8_t iLen);
|
||||
@@ -143,7 +144,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||
uint64_t select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
|
||||
|
||||
if(select_status == 0) {
|
||||
PrintAndLog("iso14443a card select failed");
|
||||
if (Cmd[0] != 's') PrintAndLog("iso14443a card select failed");
|
||||
// disconnect
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = 0;
|
||||
@@ -169,6 +170,42 @@ int CmdHF14AReader(const char *Cmd)
|
||||
|
||||
switch (card.sak) {
|
||||
case 0x00:
|
||||
|
||||
//***************************************test****************
|
||||
// disconnect
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = 0;
|
||||
c.arg[2] = 0;
|
||||
SendCommand(&c);
|
||||
|
||||
uint32_t tagT = GetHF14AMfU_Type();
|
||||
ul_print_type(tagT, 0);
|
||||
|
||||
//reconnect for further tests
|
||||
c.arg[0] = ISO14A_CONNECT | ISO14A_NO_DISCONNECT;
|
||||
c.arg[1] = 0;
|
||||
c.arg[2] = 0;
|
||||
|
||||
SendCommand(&c);
|
||||
|
||||
UsbCommand resp;
|
||||
WaitForResponse(CMD_ACK,&resp);
|
||||
|
||||
memcpy(&card, (iso14a_card_select_t *)resp.d.asBytes, sizeof(iso14a_card_select_t));
|
||||
|
||||
select_status = resp.arg[0]; // 0: couldn't read, 1: OK, with ATS, 2: OK, no ATS
|
||||
|
||||
if(select_status == 0) {
|
||||
//PrintAndLog("iso14443a card select failed");
|
||||
// disconnect
|
||||
c.arg[0] = 0;
|
||||
c.arg[1] = 0;
|
||||
c.arg[2] = 0;
|
||||
SendCommand(&c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* orig
|
||||
// check if the tag answers to GETVERSION (0x60)
|
||||
c.arg[0] = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT;
|
||||
c.arg[1] = 1;
|
||||
@@ -187,7 +224,7 @@ int CmdHF14AReader(const char *Cmd)
|
||||
case 0x01:PrintAndLog("TYPE : NXP MIFARE Ultralight C");break;
|
||||
case 0x00:PrintAndLog("TYPE : NXP MIFARE Ultralight");break;
|
||||
}
|
||||
|
||||
*/
|
||||
break;
|
||||
case 0x01: PrintAndLog("TYPE : NXP TNP3xxx Activision Game Appliance"); break;
|
||||
case 0x04: PrintAndLog("TYPE : NXP MIFARE (various !DESFire !DESFire EV1)"); break;
|
||||
|
||||
+16
-2
@@ -374,6 +374,20 @@ int CmdHF15Record(const char *Cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HF15Reader(const char *Cmd, bool verbose)
|
||||
{
|
||||
uint8_t uid[8];
|
||||
|
||||
if (!getUID(uid)) {
|
||||
if (verbose) PrintAndLog("No Tag found.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
PrintAndLog("Tag UID : %s",sprintUID(NULL,uid));
|
||||
PrintAndLog("Tag Info: %s",getTagInfo(uid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CmdHF15Reader(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_READER_ISO_15693, {strtol(Cmd, NULL, 0), 0, 0}};
|
||||
@@ -469,7 +483,7 @@ int CmdHF15DumpMem(const char*Cmd) {
|
||||
// PrintAndLog("bn=%i",blocknum);
|
||||
} else {
|
||||
PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
} // else PrintAndLog("crc");
|
||||
} // else PrintAndLog("r null");
|
||||
@@ -481,7 +495,7 @@ int CmdHF15DumpMem(const char*Cmd) {
|
||||
// PrintAndLog("CRC Failed");
|
||||
// else
|
||||
// PrintAndLog("Tag returned Error %i: %s",recv[1],TagErrorStr(recv[1]));
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ int CmdHF15(const char *Cmd);
|
||||
|
||||
int CmdHF15Demod(const char *Cmd);
|
||||
int CmdHF15Read(const char *Cmd);
|
||||
int HF15Reader(const char *Cmd, bool verbose);
|
||||
int CmdHF15Reader(const char *Cmd);
|
||||
int CmdHF15Sim(const char *Cmd);
|
||||
int CmdHF15Record(const char *Cmd);
|
||||
|
||||
+22
-9
@@ -165,34 +165,47 @@ int CmdHFiClassSim(const char *Cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdHFiClassReader(const char *Cmd)
|
||||
int HFiClassReader(const char *Cmd, bool loop, bool verbose)
|
||||
{
|
||||
bool tagFound = false;
|
||||
UsbCommand c = {CMD_READER_ICLASS, {FLAG_ICLASS_READER_CSN|
|
||||
FLAG_ICLASS_READER_CONF|FLAG_ICLASS_READER_AA}};
|
||||
if (!loop) c.arg[0] |= FLAG_ICLASS_READER_ONLY_ONCE | FLAG_ICLASS_READER_ONE_TRY;
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
while(!ukbhit()){
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t * data = resp.d.asBytes;
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp, 4500)) {
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t *data = resp.d.asBytes;
|
||||
|
||||
PrintAndLog("Readstatus:%02x", readStatus);
|
||||
if (verbose)
|
||||
PrintAndLog("Readstatus:%02x", readStatus);
|
||||
if( readStatus == 0){
|
||||
//Aborted
|
||||
PrintAndLog("Quitting...");
|
||||
if (verbose) PrintAndLog("Quitting...");
|
||||
return 0;
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CSN) PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CSN){
|
||||
PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
tagFound = true;
|
||||
}
|
||||
if( readStatus & FLAG_ICLASS_READER_CC) PrintAndLog("CC: %s",sprint_hex(data+16,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CONF){
|
||||
printIclassDumpInfo(data);
|
||||
}
|
||||
if (tagFound && !loop) return 1;
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
if (verbose) PrintAndLog("Command execute timeout");
|
||||
}
|
||||
if (!loop) break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int CmdHFiClassReader(const char *Cmd)
|
||||
{
|
||||
return HFiClassReader(Cmd, true, true);
|
||||
}
|
||||
|
||||
int CmdHFiClassReader_Replay(const char *Cmd)
|
||||
|
||||
@@ -17,6 +17,7 @@ int CmdHFiClass(const char *Cmd);
|
||||
int CmdHFiClassSnoop(const char *Cmd);
|
||||
int CmdHFiClassSim(const char *Cmd);
|
||||
int CmdHFiClassList(const char *Cmd);
|
||||
int HFiClassReader(const char *Cmd, bool loop, bool verbose);
|
||||
int CmdHFiClassReader(const char *Cmd);
|
||||
int CmdHFiClassReader_Replay(const char *Cmd);
|
||||
|
||||
|
||||
+6
-4
@@ -547,7 +547,7 @@ int CmdHF14AMfNested(const char *Cmd)
|
||||
uint8_t trgKeyType = 0;
|
||||
uint8_t SectorsCnt = 0;
|
||||
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint8_t keyBlock[13*6];
|
||||
uint8_t keyBlock[14*6];
|
||||
uint64_t key64 = 0;
|
||||
bool transferToEml = false;
|
||||
|
||||
@@ -1202,7 +1202,7 @@ int CmdHF14AMfELoad(const char *Cmd)
|
||||
|
||||
if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;
|
||||
|
||||
fnameptr += len;
|
||||
fnameptr += len-4;
|
||||
|
||||
sprintf(fnameptr, ".eml");
|
||||
|
||||
@@ -1311,7 +1311,7 @@ int CmdHF14AMfESave(const char *Cmd)
|
||||
for (j = 0; j < 7; j++, fnameptr += 2)
|
||||
sprintf(fnameptr, "%02X", buf[j]);
|
||||
} else {
|
||||
fnameptr += len;
|
||||
fnameptr += len-4;
|
||||
}
|
||||
|
||||
// add file extension
|
||||
@@ -1575,7 +1575,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
|
||||
if (len > FILE_PATH_SIZE) len = FILE_PATH_SIZE;
|
||||
|
||||
memcpy(filename, Cmd, len);
|
||||
fnameptr += len;
|
||||
fnameptr += len-4;
|
||||
|
||||
sprintf(fnameptr, ".eml");
|
||||
|
||||
@@ -1592,6 +1592,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (fgets(buf, sizeof(buf), f) == NULL) {
|
||||
fclose(f);
|
||||
PrintAndLog("File reading error.");
|
||||
return 2;
|
||||
}
|
||||
@@ -1600,6 +1601,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
|
||||
if(strlen(buf) && feof(f))
|
||||
break;
|
||||
PrintAndLog("File content error. Block data must include 32 HEX symbols");
|
||||
fclose(f);
|
||||
return 2;
|
||||
}
|
||||
for (i = 0; i < 32; i += 2)
|
||||
|
||||
+1302
-285
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user