mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
aid search works
This commit is contained in:
parent
766262033a
commit
2a4a9745c9
3 changed files with 69 additions and 18 deletions
|
@ -102,37 +102,51 @@ bool aidCompare(const char *aidlarge, const char *aidsmall) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen) {
|
||||
*aidlen = 0;
|
||||
const char *hexaid = jsonStrGet(data, "AID");
|
||||
if (hexaid == NULL || strlen(hexaid) == 0)
|
||||
return false;
|
||||
|
||||
int res = param_gethex_to_eol(hexaid, 0, aid, aidmaxlen, aidlen);
|
||||
if (res)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int PrintAIDDescription(char *aid, bool verbose) {
|
||||
int retval = PM3_SUCCESS;
|
||||
|
||||
int elmindx = 0;
|
||||
json_t *root = AIDSearchInit();
|
||||
if (root == NULL)
|
||||
goto out;
|
||||
|
||||
json_t *elm = NULL;
|
||||
for (int elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
||||
json_t *data = AIDSearchGetElm(root, elmindx);
|
||||
if (data == NULL)
|
||||
goto out;
|
||||
|
||||
while (aidCompare(jsonStrGet(data, "AID"), aid)) {
|
||||
elmindx++;
|
||||
if (elmindx > json_array_size(root))
|
||||
goto out;
|
||||
data = AIDSearchGetElm(root, elmindx);
|
||||
|
||||
if (data == NULL)
|
||||
goto out;
|
||||
continue;
|
||||
if (aidCompare(jsonStrGet(data, "AID"), aid)) {
|
||||
elm = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (elm == NULL)
|
||||
goto out;
|
||||
|
||||
// print here
|
||||
const char *vaid = jsonStrGet(data, "AID");
|
||||
const char *vendor = jsonStrGet(data, "Vendor");
|
||||
const char *name = jsonStrGet(data, "Name");
|
||||
const char *country = jsonStrGet(data, "Country");
|
||||
const char *description = jsonStrGet(data, "Description");
|
||||
const char *type = jsonStrGet(data, "Type");
|
||||
const char *vaid = jsonStrGet(elm, "AID");
|
||||
const char *vendor = jsonStrGet(elm, "Vendor");
|
||||
const char *name = jsonStrGet(elm, "Name");
|
||||
const char *country = jsonStrGet(elm, "Country");
|
||||
const char *description = jsonStrGet(elm, "Description");
|
||||
const char *type = jsonStrGet(elm, "Type");
|
||||
|
||||
if (!verbose) {
|
||||
PrintAndLogEx(SUCCESS, "AID %s | %s | %s", vaid, vendor, name);
|
||||
} else {
|
||||
PrintAndLogEx(NORMAL, "----------------------------------------");
|
||||
PrintAndLogEx(SUCCESS, "Input AID: %s", aid);
|
||||
if (aid)
|
||||
PrintAndLogEx(SUCCESS, "Found AID: %s", vaid);
|
||||
|
@ -153,4 +167,7 @@ out:
|
|||
return retval;
|
||||
}
|
||||
|
||||
int PrintAIDDescriptionBuf(uint8_t *aid, size_t aidlen, bool verbose) {
|
||||
return PrintAIDDescription(sprint_hex_inrow(aid, aidlen), verbose);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
#include <jansson.h>
|
||||
|
||||
int PrintAIDDescription(char *aid, bool verbose);
|
||||
int PrintAIDDescriptionBuf(uint8_t *aid, size_t aidlen, bool verbose);
|
||||
json_t *AIDSearchInit();
|
||||
json_t *AIDSearchGetElm(json_t *root, int elmindx);
|
||||
bool AIDGetFromElm(json_t *data, uint8_t *aid, size_t aidmaxlen, int *aidlen);
|
||||
int AIDSearchFree();
|
||||
|
||||
#endif
|
|
@ -1496,7 +1496,39 @@ int infoHF14A(bool verbose, bool do_nack_test, bool do_aid_search) {
|
|||
}
|
||||
|
||||
if (do_aid_search) {
|
||||
PrintAIDDescription("315041592E5359532E4444463031", true);
|
||||
int elmindx = 0;
|
||||
json_t *root = AIDSearchInit();
|
||||
if (root != NULL) {
|
||||
bool ActivateField = true;
|
||||
for (elmindx = 0; elmindx < json_array_size(root); elmindx++) {
|
||||
json_t *data = AIDSearchGetElm(root, elmindx);
|
||||
uint8_t vaid[200] = {0};
|
||||
int vaidlen = 0;
|
||||
if (!AIDGetFromElm(data, vaid, sizeof(vaid), &vaidlen) || !vaidlen)
|
||||
continue;
|
||||
|
||||
uint16_t sw = 0;
|
||||
uint8_t result[1024] = {0};
|
||||
size_t resultlen = 0;
|
||||
int res = EMVSelect(ECC_CONTACTLESS, ActivateField, true, vaid, vaidlen, result, sizeof(result), &resultlen, &sw, NULL);
|
||||
ActivateField = false;
|
||||
if (res)
|
||||
continue;
|
||||
|
||||
if (sw == 0x9000) {
|
||||
PrintAndLogEx(NORMAL, "------------- Application OK -----------");
|
||||
PrintAndLogEx(NORMAL, "res: %s", sprint_hex(result, resultlen));
|
||||
PrintAIDDescriptionBuf(vaid, vaidlen, true);
|
||||
}
|
||||
|
||||
if (sw == 0x6283 || sw == 0x6285) {
|
||||
PrintAndLogEx(NORMAL, "----------- Application blocked --------");
|
||||
PrintAIDDescriptionBuf(vaid, vaidlen, true);
|
||||
}
|
||||
|
||||
}
|
||||
DropField();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PrintAndLogEx(INFO, "proprietary non iso14443-4 card found, RATS not supported");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue