mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-14 10:36:58 -07:00
1. small bugfix in hf 14a mifare
2. now in cmd hf 14a mifare - blinks LED_C 3. bugfix in readblock 2. bugfix in USB CommandReceived 3. small improvements
This commit is contained in:
parent
f89c705002
commit
50193c1e3e
5 changed files with 165 additions and 46 deletions
|
@ -444,14 +444,19 @@ int CmdHF14AMfRdSc(const char *Cmd)
|
|||
|
||||
int CmdHF14AMfNested(const char *Cmd)
|
||||
{
|
||||
int i, temp;
|
||||
int i, temp, len;
|
||||
uint8_t sectorNo = 0;
|
||||
uint8_t keyType = 0;
|
||||
uint8_t key[6] = {0, 0, 0, 0, 0, 0};
|
||||
uint8_t isEOF;
|
||||
uint8_t * data;
|
||||
uint32_t uid;
|
||||
fnVector * vector = NULL;
|
||||
int lenVector = 0;
|
||||
UsbCommand * resp = NULL;
|
||||
|
||||
const char *cmdp = Cmd;
|
||||
|
||||
|
||||
if (strlen(Cmd)<3) {
|
||||
PrintAndLog("Usage: hf 14a nested <sector number> <key A/B> <key (12 hex symbols)>");
|
||||
PrintAndLog(" sample: hf 14a nested 0 A FFFFFFFFFFFF ");
|
||||
|
@ -485,24 +490,69 @@ int CmdHF14AMfNested(const char *Cmd)
|
|||
cmdp++;
|
||||
}
|
||||
PrintAndLog(" sector no:%02x key type:%02x key:%s ", sectorNo, keyType, sprint_hex(key, 6));
|
||||
|
||||
// flush queue
|
||||
while (WaitForResponseTimeout(CMD_ACK, 500) != NULL) ;
|
||||
|
||||
UsbCommand c = {CMD_MIFARE_NESTED, {sectorNo, keyType, 0}};
|
||||
memcpy(c.d.asBytes, key, 6);
|
||||
SendCommand(&c);
|
||||
UsbCommand * resp = WaitForResponseTimeout(CMD_ACK, 1500);
|
||||
PrintAndLog(" ");
|
||||
|
||||
if (resp != NULL) {
|
||||
uint8_t isOK = resp->arg[0] & 0xff;
|
||||
uint8_t * data = resp->d.asBytes;
|
||||
PrintAndLog("\n");
|
||||
printf("-------------------------------------------------------------------------\n");
|
||||
|
||||
PrintAndLog("isOk:%02x", isOK);
|
||||
for (i = 0; i < 2; i++) {
|
||||
PrintAndLog("data:%s", sprint_hex(data + i * 16, 16));
|
||||
// wait cycle
|
||||
while (true) {
|
||||
printf(".");
|
||||
if (kbhit()) {
|
||||
getchar();
|
||||
printf("\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
resp = WaitForResponseTimeout(CMD_ACK, 1500);
|
||||
|
||||
if (resp != NULL) {
|
||||
isEOF = resp->arg[0] & 0xff;
|
||||
data = resp->d.asBytes;
|
||||
|
||||
PrintAndLog("isEOF:%02x", isEOF);
|
||||
for (i = 0; i < 2; i++) {
|
||||
PrintAndLog("data:%s", sprint_hex(data + i * 16, 16));
|
||||
}
|
||||
if (isEOF) break;
|
||||
|
||||
len = resp->arg[1] & 0xff;
|
||||
if (len == 0) continue;
|
||||
|
||||
memcpy(&uid, resp->d.asBytes, 4);
|
||||
PrintAndLog("uid:%08x len=%d trgbl=%d trgkey=%d", uid, len, resp->arg[2] & 0xff, (resp->arg[2] >> 8) & 0xff);
|
||||
|
||||
vector = (fnVector *) realloc((void *)vector, (lenVector + len) * sizeof(fnVector) + 200);
|
||||
if (vector == NULL) {
|
||||
PrintAndLog("Memory allocation error for fnVector. len: %d bytes: %d", lenVector + len, (lenVector + len) * sizeof(fnVector));
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
vector[lenVector + i].blockNo = resp->arg[2] & 0xff;
|
||||
vector[lenVector + i].keyType = (resp->arg[2] >> 8) & 0xff;
|
||||
vector[lenVector + i].uid = uid;
|
||||
|
||||
memcpy(&vector[lenVector + i].nt, (void *)(resp->d.asBytes + 8 + i * 8 + 0), 4);
|
||||
memcpy(&vector[lenVector + i].ks1, (void *)(resp->d.asBytes + 8 + i * 8 + 4), 4);
|
||||
|
||||
PrintAndLog("i=%d nt:%08x ks1:%08x", i, vector[lenVector + i].nt, vector[lenVector + i].ks1);
|
||||
}
|
||||
|
||||
lenVector += len;
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// finalize
|
||||
free(vector);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 2011, Merlok
|
||||
// Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
|
||||
//
|
||||
// This code is licensed to you under the terms of the GNU GPL, version 2 or,
|
||||
|
@ -11,6 +12,8 @@
|
|||
#ifndef CMDHF14A_H__
|
||||
#define CMDHF14A_H__
|
||||
|
||||
typedef struct fnVector { uint8_t blockNo, keyType; uint32_t uid, nt, ks1; } fnVector;
|
||||
|
||||
int CmdHF14A(const char *Cmd);
|
||||
|
||||
int CmdHF14AList(const char *Cmd);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
unsigned int current_command = CMD_UNKNOWN;
|
||||
unsigned int received_command = CMD_UNKNOWN;
|
||||
UsbCommand current_response;
|
||||
UsbCommand current_response_user;
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
static int CmdQuit(const char *Cmd);
|
||||
|
@ -55,12 +56,16 @@ int CmdQuit(const char *Cmd)
|
|||
}
|
||||
|
||||
UsbCommand * WaitForResponseTimeout(uint32_t response_type, uint32_t ms_timeout) {
|
||||
UsbCommand * ret = ¤t_response;
|
||||
UsbCommand * ret = NULL;
|
||||
int i=0;
|
||||
|
||||
for(i=0; received_command != response_type && i < ms_timeout / 10; i++) {
|
||||
msleep(10); // XXX ugh
|
||||
}
|
||||
|
||||
// There was evil BUG
|
||||
memcpy(¤t_response_user, ¤t_response, sizeof(UsbCommand));
|
||||
ret = ¤t_response_user;
|
||||
|
||||
if(received_command != response_type)
|
||||
ret = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue