mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
first draft at having a ATR lookup list available in project
This commit is contained in:
parent
88308ea727
commit
dd391cda01
5 changed files with 1743 additions and 0 deletions
|
@ -238,6 +238,7 @@ set (TARGET_SOURCES
|
||||||
${PM3_ROOT}/client/src/ui/overlays.ui
|
${PM3_ROOT}/client/src/ui/overlays.ui
|
||||||
${PM3_ROOT}/client/src/ui/image.ui
|
${PM3_ROOT}/client/src/ui/image.ui
|
||||||
${PM3_ROOT}/client/src/aidsearch.c
|
${PM3_ROOT}/client/src/aidsearch.c
|
||||||
|
${PM3_ROOT}/client/src/atrs.c
|
||||||
${PM3_ROOT}/client/src/cmdanalyse.c
|
${PM3_ROOT}/client/src/cmdanalyse.c
|
||||||
${PM3_ROOT}/client/src/cmdcrc.c
|
${PM3_ROOT}/client/src/cmdcrc.c
|
||||||
${PM3_ROOT}/client/src/cmddata.c
|
${PM3_ROOT}/client/src/cmddata.c
|
||||||
|
|
|
@ -490,6 +490,7 @@ POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
|
||||||
|
|
||||||
SRCS = mifare/aiddesfire.c \
|
SRCS = mifare/aiddesfire.c \
|
||||||
aidsearch.c \
|
aidsearch.c \
|
||||||
|
atrs.c \
|
||||||
cmdanalyse.c \
|
cmdanalyse.c \
|
||||||
cmdcrc.c \
|
cmdcrc.c \
|
||||||
cmddata.c \
|
cmddata.c \
|
||||||
|
|
62
client/atr_scrap_eftlab.py
Executable file
62
client/atr_scrap_eftlab.py
Executable file
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# python3 -m pip install pandas, lxml, html5lib
|
||||||
|
import sys
|
||||||
|
import pandas as pd
|
||||||
|
import requests
|
||||||
|
|
||||||
|
ATR_URL = 'https://www.eftlab.co.uk/knowledge-base/171-atr-list-full/'
|
||||||
|
|
||||||
|
def print_atr(df):
|
||||||
|
for i in df.index:
|
||||||
|
|
||||||
|
a = df['atr'][i];
|
||||||
|
b = df['desc'][i];
|
||||||
|
|
||||||
|
if type(a) is not str or type(b) is not str:
|
||||||
|
continue
|
||||||
|
a = a.replace(' ','')
|
||||||
|
|
||||||
|
if (len(a) == 0 or len(b) == 0):
|
||||||
|
continue
|
||||||
|
|
||||||
|
b = b.replace('\\', '\\\\')
|
||||||
|
|
||||||
|
print(f' {{ "{a}", "{b}" }},')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
r = requests.get(ATR_URL)
|
||||||
|
r.status_code
|
||||||
|
list_atr = pd.read_html(r.text, header=0, keep_default_na=False)
|
||||||
|
df = list_atr[0]
|
||||||
|
df.columns = ['atr', 'desc']
|
||||||
|
df = df.astype('string')
|
||||||
|
|
||||||
|
print(
|
||||||
|
"""#ifndef ATRS_H__
|
||||||
|
|
||||||
|
#define ATRS_H__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
typedef struct atr_s {
|
||||||
|
const char *bytes;
|
||||||
|
const char *desc;
|
||||||
|
} atr_t;
|
||||||
|
|
||||||
|
const char *getAtrInfo(const char *atr_str);
|
||||||
|
|
||||||
|
// atr_t array are expected to be NULL terminated
|
||||||
|
static atr_t AtrTable[] = {""")
|
||||||
|
|
||||||
|
print_atr(df)
|
||||||
|
|
||||||
|
print(""" {NULL, "no ATR info available"}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif""")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
55
client/src/atrs.c
Normal file
55
client/src/atrs.c
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) Iceman
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
// the license.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// ATR information lookup
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
#include "atrs.h"
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "commonutil.h" // ARRAYLEN
|
||||||
|
#include "util.h" // startswith
|
||||||
|
|
||||||
|
// get a ATR description based on the atr bytes
|
||||||
|
// returns description of the best match
|
||||||
|
const char *getAtrInfo(const char *atr_str) {
|
||||||
|
|
||||||
|
for (int i = 0; i < ARRAYLEN(AtrTable); ++i) {
|
||||||
|
|
||||||
|
// check for dots in atr table.
|
||||||
|
// dots indicate those bytes at those positions are optional.
|
||||||
|
// need a special case for them
|
||||||
|
if (strstr(AtrTable[i].bytes, "..") != NULL) {
|
||||||
|
|
||||||
|
// need to loop
|
||||||
|
const char *foo = atr_str;
|
||||||
|
int j = 0;
|
||||||
|
while (foo++, j++) {
|
||||||
|
|
||||||
|
char c = foo[0];
|
||||||
|
if (c == '.') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// mismatch, return default message
|
||||||
|
if (c != AtrTable[i].bytes[j]) {
|
||||||
|
return AtrTable[ARRAYLEN(AtrTable) - 1].desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return AtrTable[i].desc;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (str_startswith(atr_str, AtrTable[i].bytes)) {
|
||||||
|
return AtrTable[i].desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//No match, return default
|
||||||
|
return AtrTable[ARRAYLEN(AtrTable) - 1].desc;
|
||||||
|
}
|
1624
client/src/atrs.h
Normal file
1624
client/src/atrs.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue