mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 10:37:23 -07:00
move mifare stuff to its folder
This commit is contained in:
parent
1675b10c00
commit
3b21b17509
19 changed files with 1158 additions and 1147 deletions
|
@ -108,7 +108,7 @@ CORESRCS = uart_posix.c \
|
|||
|
||||
CMDSRCS = crapto1/crapto1.c \
|
||||
crapto1/crypto1.c \
|
||||
mfkey.c \
|
||||
mifare/mfkey.c \
|
||||
tea.c \
|
||||
fido/additional_ca.c \
|
||||
fido/cose.c \
|
||||
|
@ -126,7 +126,7 @@ CMDSRCS = crapto1/crapto1.c \
|
|||
loclass/elite_crack.c \
|
||||
loclass/fileutils.c \
|
||||
whereami.c \
|
||||
mifarehost.c \
|
||||
mifare/mifarehost.c \
|
||||
parity.c \
|
||||
crc.c \
|
||||
crc16.c \
|
||||
|
@ -156,7 +156,7 @@ CMDSRCS = crapto1/crapto1.c \
|
|||
emv/test/cda_test.c\
|
||||
emv/cmdemv.c \
|
||||
emv/emv_roca.c \
|
||||
mifare4.c \
|
||||
mifare/mifare4.c \
|
||||
cmdanalyse.c \
|
||||
cmdhf.c \
|
||||
cmdhflist.c \
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
#include <unistd.h>
|
||||
#include "cmdmain.h"
|
||||
#include "proxmark3.h"
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "ui.h" // PrintAndLog
|
||||
#include "util.h"
|
||||
#include "crc.h"
|
||||
#include "crc16.h" // crc16 ccitt
|
||||
#include "tea.h"
|
||||
#include "legic_prng.h"
|
||||
#include "loclass/elite_crack.h"
|
||||
#include "mfkey.h" //nonce2key
|
||||
#include "util_posix.h" // msclock
|
||||
#include "mifare/mfkey.h" //nonce2key
|
||||
#include "util_posix.h" // msclock
|
||||
|
||||
|
||||
int usage_analyse_lcr(void);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "cmdhfmf.h"
|
||||
#include "cmdhfmfu.h"
|
||||
#include "cmdhf.h" // list cmd
|
||||
#include "mifarehost.h"
|
||||
#include "mifare/mifarehost.h"
|
||||
#include "emv/apduinfo.h"
|
||||
#include "emv/emvcore.h"
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#include "emv/cmdemv.h" // EMV
|
||||
#include "protocols.h"
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "mifarehost.h"
|
||||
#include "mifaredefault.h"
|
||||
#include "mifare/mifarehost.h"
|
||||
#include "mifare/mifaredefault.h"
|
||||
#include "parity.h" // oddparity
|
||||
#include "iso15693tools.h" // ISO15693 crc
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "cmdhfmf.h"
|
||||
#include "mifare4.h"
|
||||
#include "mifare/mifare4.h"
|
||||
|
||||
#define MIFARE_4K_MAXBLOCK 256
|
||||
#define MIFARE_2K_MAXBLOCK 128
|
||||
|
@ -3216,18 +3216,28 @@ int CmdHF14AMfMAD(const char *cmd) {
|
|||
CLIParserFree();
|
||||
|
||||
uint8_t sector[16 * 4] = {0};
|
||||
if (mfReadSector(0, 0, (uint8_t *)g_mifare_mad_key, sector)) {
|
||||
if (mfReadSector(MF_MAD1_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector)) {
|
||||
PrintAndLogEx(ERR, "read sector 0 error. card don't have MAD or don't have MAD on default keys.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
for(int i = 0; i < 3; i ++)
|
||||
PrintAndLogEx(NORMAL, "[i] %s", sprint_hex(§or[i * 16], 16));
|
||||
for(int i = 0; i < 4; i ++)
|
||||
PrintAndLogEx(NORMAL, "[%d] %s", i, sprint_hex(§or[i * 16], 16));
|
||||
}
|
||||
/*
|
||||
bool haveMAD2 = false;
|
||||
MAD1DecodeAndPrint(sector, verbose, &haveMAD2);
|
||||
|
||||
// MADDecodeAndPrint(sector, verbose);
|
||||
|
||||
if (haveMAD2) {
|
||||
if (mfReadSector(MF_MAD2_SECTOR, MF_KEY_A, (uint8_t *)g_mifare_mad_key, sector)) {
|
||||
PrintAndLogEx(ERR, "read sector 0 error. card don't have MAD or don't have MAD on default keys.");
|
||||
return 2;
|
||||
}
|
||||
|
||||
MAD2DecodeAndPrint(sector, verbose);
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
#include "cmdparser.h"
|
||||
#include "common.h"
|
||||
#include "util.h"
|
||||
#include "mifare.h" // nonces_t struct
|
||||
#include "mfkey.h" // mfkey32_moebious
|
||||
#include "mifare.h" // nonces_t struct
|
||||
#include "mifare/mfkey.h" // mfkey32_moebious
|
||||
#include "cmdhfmfhard.h"
|
||||
#include "mifarehost.h" // icesector_t, sector_t
|
||||
#include "util_posix.h" // msclock
|
||||
#include "mifaredefault.h" // mifare default key array
|
||||
#include "cmdhf14a.h" // dropfield
|
||||
#include "cliparser/cliparser.h" // argtable
|
||||
#include "mifare/mifarehost.h" // icesector_t, sector_t
|
||||
#include "util_posix.h" // msclock
|
||||
#include "mifare/mifaredefault.h" // mifare default key array
|
||||
#include "cmdhf14a.h" // dropfield
|
||||
#include "cliparser/cliparser.h" // argtable
|
||||
#include "hardnested/hardnested_bf_core.h" // SetSIMDInstr
|
||||
|
||||
extern int CmdHFMF(const char *Cmd);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include "ui.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "mifare.h"
|
||||
#include "mifare4.h"
|
||||
#include "mifare/mifare4.h"
|
||||
#include "cliparser/cliparser.h"
|
||||
#include "crypto/libpcrypto.h"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef CMDHFMFP_H__
|
||||
#define CMDHFMFP_H__
|
||||
|
||||
#include "mifaredefault.h"
|
||||
#include "mifare/mifaredefault.h"
|
||||
|
||||
extern int CmdHFMFP(const char *Cmd);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#include <stdarg.h>
|
||||
#include "../ui.h"
|
||||
#include "../emv/emvjson.h"
|
||||
#include "mifare4.h"
|
||||
#include "mifare/mifare4.h"
|
||||
#include "cmdhfmfu.h"
|
||||
|
||||
typedef enum {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,103 +1,103 @@
|
|||
// Merlok, 2011
|
||||
// people from mifare@nethemba.com, 2010
|
||||
//
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency ISO14443A commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __MIFARE_HOST_H
|
||||
#define __MIFARE_HOST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "proxmark3.h" // time_t
|
||||
#include "common.h"
|
||||
#include "util.h" // FILE_PATH_SIZE
|
||||
#include "ui.h" // PrintAndLog...
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "mifare.h"
|
||||
#include "mfkey.h"
|
||||
#include "util_posix.h" // msclock
|
||||
|
||||
#define MIFARE_SECTOR_RETRY 10
|
||||
|
||||
// mifare tracer flags
|
||||
#define TRACE_IDLE 0x00
|
||||
#define TRACE_AUTH1 0x01
|
||||
#define TRACE_AUTH2 0x02
|
||||
#define TRACE_AUTH_OK 0x03
|
||||
#define TRACE_READ_DATA 0x04
|
||||
#define TRACE_WRITE_OK 0x05
|
||||
#define TRACE_WRITE_DATA 0x06
|
||||
#define TRACE_ERROR 0xFF
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct Crypto1State *slhead;
|
||||
uint64_t *keyhead;
|
||||
} head;
|
||||
union {
|
||||
struct Crypto1State *sltail;
|
||||
uint64_t *keytail;
|
||||
} tail;
|
||||
uint32_t len;
|
||||
uint32_t uid;
|
||||
uint32_t blockNo;
|
||||
uint32_t keyType;
|
||||
uint32_t nt;
|
||||
uint32_t ks1;
|
||||
} StateList_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t Key[2];
|
||||
uint8_t foundKey[2];
|
||||
} sector_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t keyA[6];
|
||||
uint8_t keyB[6];
|
||||
//uint8_t foundKey[2];
|
||||
} icesector_t;
|
||||
|
||||
extern char logHexFileName[FILE_PATH_SIZE];
|
||||
|
||||
extern int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key);
|
||||
extern int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * ResultKeys, bool calibrate);
|
||||
extern int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key);
|
||||
extern int mfCheckKeys_fast( uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
|
||||
uint8_t strategy, uint32_t size, uint8_t *keyBlock, sector_t *e_sector, bool use_flashmemory);
|
||||
extern int mfKeyBrute(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint64_t *resultkey);
|
||||
|
||||
extern int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data);
|
||||
|
||||
extern int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
extern int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
extern int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
|
||||
extern int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_t wipecard);
|
||||
extern int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params);
|
||||
extern int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);
|
||||
|
||||
extern int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
|
||||
extern int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);
|
||||
|
||||
extern int isTraceCardEmpty(void);
|
||||
extern int isBlockEmpty(int blockN);
|
||||
extern int isBlockTrailer(int blockN);
|
||||
extern int loadTraceCard(uint8_t *tuid, uint8_t uidlen);
|
||||
extern int saveTraceCard(void);
|
||||
extern int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);
|
||||
|
||||
extern int detect_classic_prng(void);
|
||||
extern int detect_classic_nackbug(bool verbose);
|
||||
extern void detect_classic_magic(void);
|
||||
extern void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool isEncrypted);
|
||||
// Merlok, 2011
|
||||
// people from mifare@nethemba.com, 2010
|
||||
//
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
// High frequency ISO14443A commands
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef __MIFARE_HOST_H
|
||||
#define __MIFARE_HOST_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "proxmark3.h" // time_t
|
||||
#include "common.h"
|
||||
#include "util.h" // FILE_PATH_SIZE
|
||||
#include "ui.h" // PrintAndLog...
|
||||
#include "crapto1/crapto1.h"
|
||||
#include "crc16.h"
|
||||
#include "protocols.h"
|
||||
#include "mifare.h"
|
||||
#include "mfkey.h"
|
||||
#include "util_posix.h" // msclock
|
||||
|
||||
#define MIFARE_SECTOR_RETRY 10
|
||||
|
||||
// mifare tracer flags
|
||||
#define TRACE_IDLE 0x00
|
||||
#define TRACE_AUTH1 0x01
|
||||
#define TRACE_AUTH2 0x02
|
||||
#define TRACE_AUTH_OK 0x03
|
||||
#define TRACE_READ_DATA 0x04
|
||||
#define TRACE_WRITE_OK 0x05
|
||||
#define TRACE_WRITE_DATA 0x06
|
||||
#define TRACE_ERROR 0xFF
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct Crypto1State *slhead;
|
||||
uint64_t *keyhead;
|
||||
} head;
|
||||
union {
|
||||
struct Crypto1State *sltail;
|
||||
uint64_t *keytail;
|
||||
} tail;
|
||||
uint32_t len;
|
||||
uint32_t uid;
|
||||
uint32_t blockNo;
|
||||
uint32_t keyType;
|
||||
uint32_t nt;
|
||||
uint32_t ks1;
|
||||
} StateList_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t Key[2];
|
||||
uint8_t foundKey[2];
|
||||
} sector_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t keyA[6];
|
||||
uint8_t keyB[6];
|
||||
//uint8_t foundKey[2];
|
||||
} icesector_t;
|
||||
|
||||
extern char logHexFileName[FILE_PATH_SIZE];
|
||||
|
||||
extern int mfDarkside(uint8_t blockno, uint8_t key_type, uint64_t *key);
|
||||
extern int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * ResultKeys, bool calibrate);
|
||||
extern int mfCheckKeys (uint8_t blockNo, uint8_t keyType, bool clear_trace, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key);
|
||||
extern int mfCheckKeys_fast( uint8_t sectorsCnt, uint8_t firstChunk, uint8_t lastChunk,
|
||||
uint8_t strategy, uint32_t size, uint8_t *keyBlock, sector_t *e_sector, bool use_flashmemory);
|
||||
extern int mfKeyBrute(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint64_t *resultkey);
|
||||
|
||||
extern int mfReadSector(uint8_t sectorNo, uint8_t keyType, uint8_t *key, uint8_t *data);
|
||||
|
||||
extern int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
extern int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount);
|
||||
extern int mfEmlSetMem_xt(uint8_t *data, int blockNum, int blocksCount, int blockBtWidth);
|
||||
|
||||
extern int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_t wipecard);
|
||||
extern int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params);
|
||||
extern int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);
|
||||
|
||||
extern int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
|
||||
extern int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);
|
||||
|
||||
extern int isTraceCardEmpty(void);
|
||||
extern int isBlockEmpty(int blockN);
|
||||
extern int isBlockTrailer(int blockN);
|
||||
extern int loadTraceCard(uint8_t *tuid, uint8_t uidlen);
|
||||
extern int saveTraceCard(void);
|
||||
extern int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);
|
||||
|
||||
extern int detect_classic_prng(void);
|
||||
extern int detect_classic_nackbug(bool verbose);
|
||||
extern void detect_classic_magic(void);
|
||||
extern void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool isEncrypted);
|
||||
#endif
|
0
client/obj/mifare/.dummy
Normal file
0
client/obj/mifare/.dummy
Normal file
|
@ -19,7 +19,7 @@
|
|||
#include "cmdmain.h"
|
||||
#include "comms.h"
|
||||
#include "util.h"
|
||||
#include "mifarehost.h"
|
||||
#include "mifare/mifarehost.h"
|
||||
#include "crc.h"
|
||||
#include "crc16.h"
|
||||
#include "crc64.h"
|
||||
|
|
|
@ -13,6 +13,12 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#define MF_KEY_A 0
|
||||
#define MF_KEY_B 1
|
||||
|
||||
#define MF_MAD1_SECTOR 0x00
|
||||
#define MF_MAD2_SECTOR 0x10
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ISO 14443A
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue