]> git.zerfleddert.de Git - proxmark3-svn/blob - client/mifarehost.h
tweaked sim command, added mfkey32
[proxmark3-svn] / client / mifarehost.h
1 // Merlok, 2011
2 // people from mifare@nethemba.com, 2010
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // High frequency ISO14443A commands
9 //-----------------------------------------------------------------------------
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include "common.h"
15 #include "cmdmain.h"
16 #include "ui.h"
17 #include "data.h"
18 //#include "proxusb.h"
19 #include "util.h"
20 #include "nonce2key/nonce2key.h"
21 #include "nonce2key/crapto1.h"
22 #include "iso14443crc.h"
23
24 #define MEM_CHUNK 1000000
25 #define NESTED_SECTOR_RETRY 10
26
27 // mfCSetBlock work flags
28 #define CSETBLOCK_UID 0x01
29 #define CSETBLOCK_WUPC 0x02
30 #define CSETBLOCK_HALT 0x04
31 #define CSETBLOCK_INIT_FIELD 0x08
32 #define CSETBLOCK_RESET_FIELD 0x10
33 #define CSETBLOCK_SINGLE_OPER 0x1F
34
35 // mifare tracer flags
36 #define TRACE_IDLE 0x00
37 #define TRACE_AUTH1 0x01
38 #define TRACE_AUTH2 0x02
39 #define TRACE_AUTH_OK 0x03
40 #define TRACE_READ_DATA 0x04
41 #define TRACE_WRITE_OK 0x05
42 #define TRACE_WRITE_DATA 0x06
43
44 #define TRACE_ERROR 0xFF
45
46 typedef struct fnVector { uint8_t blockNo, keyType; uint32_t uid, nt, ks1; } fnVector;
47
48 typedef struct {
49 uint64_t Key[2];
50 int foundKey[2];
51 } sector;
52
53 typedef struct {
54 uint64_t *possibleKeys;
55 uint32_t size;
56 } pKeys;
57
58 typedef struct {
59 uint64_t key;
60 int count;
61 } countKeys;
62
63 extern char logHexFileName[200];
64
65 int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * ResultKeys);
66 int mfCheckKeys (uint8_t blockNo, uint8_t keyType, uint8_t keycnt, uint8_t * keyBlock, uint64_t * key);
67
68 int mfEmlGetMem(uint8_t *data, int blockNum, int blocksCount);
69 int mfEmlSetMem(uint8_t *data, int blockNum, int blocksCount);
70
71 int mfCSetUID(uint8_t *uid, uint8_t *oldUID, int wantWipe);
72 int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe, uint8_t params);
73 int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);
74
75 int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);
76 int mfTraceDecode(uint8_t *data_src, int len, uint32_t parity, bool wantSaveToEmlFile);
77
78 int isTraceCardEmpty(void);
79 int isBlockEmpty(int blockN);
80 int isBlockTrailer(int blockN);
81 int loadTraceCard(uint8_t *tuid);
82 int saveTraceCard(void);
Impressum, Datenschutz