tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
add mfoc, Mifare Classic Offline Cracker
Jaka Hudoklin
11 years ago
8eed86fb
f26c32f9
+121
3 changed files
expand all
collapse all
unified
split
pkgs
tools
security
mfoc
default.nix
mf_mini.patch
top-level
all-packages.nix
+23
pkgs/tools/security/mfoc/default.nix
···
1
1
+
{ stdenv, fetchurl, pkgconfig, libnfc }:
2
2
+
3
3
+
stdenv.mkDerivation rec {
4
4
+
name = "mfoc-${version}";
5
5
+
version = "0.10.6";
6
6
+
7
7
+
src = fetchurl {
8
8
+
url = "http://mfoc.googlecode.com/files/${name}.tar.gz";
9
9
+
sha1 = "3adce3029dce9124ff3bc7d0fad86fa0c374a9e3";
10
10
+
};
11
11
+
12
12
+
patches = [./mf_mini.patch];
13
13
+
14
14
+
buildInputs = [ pkgconfig libnfc ];
15
15
+
16
16
+
meta = with stdenv.lib; {
17
17
+
description = "Mifare Classic Offline Cracker";
18
18
+
license = licenses.gpl2;
19
19
+
homepage = http://code.google.com/p/mfoc/;
20
20
+
maintainers = with maintainers; [ offline ];
21
21
+
platforms = with platforms; unix;
22
22
+
};
23
23
+
}
+96
pkgs/tools/security/mfoc/mf_mini.patch
···
1
1
+
diff --git a/src/mfoc.c b/src/mfoc.c
2
2
+
index 0cb917d..195de68 100644
3
3
+
--- a/src/mfoc.c
4
4
+
+++ b/src/mfoc.c
5
5
+
@@ -93,8 +93,8 @@ int main(int argc, char *const argv[])
6
6
+
{0x58, 0x7e, 0xe5, 0xf9, 0x35, 0x0f},
7
7
+
{0xa0, 0x47, 0x8c, 0xc3, 0x90, 0x91},
8
8
+
{0x53, 0x3c, 0xb6, 0xc7, 0x23, 0xf6},
9
9
+
- {0x8f, 0xd0, 0xa4, 0xf2, 0x56, 0xe9}
10
10
+
-
11
11
+
+ {0x8f, 0xd0, 0xa4, 0xf2, 0x56, 0xe9},
12
12
+
+ {0xb4, 0xc1, 0x32, 0x43, 0x9e, 0xef}
13
13
+
};
14
14
+
15
15
+
mftag t;
16
16
+
@@ -219,12 +219,31 @@ int main(int argc, char *const argv[])
17
17
+
goto error;
18
18
+
}
19
19
+
20
20
+
- // Save tag's block size (b4K)
21
21
+
- t.b4K = (t.nt.nti.nai.abtAtqa[1] == 0x02);
22
22
+
t.authuid = (uint32_t) bytes_to_num(t.nt.nti.nai.abtUid + t.nt.nti.nai.szUidLen - 4, 4);
23
23
+
24
24
+
- t.num_blocks = (t.b4K) ? 0xff : 0x3f;
25
25
+
- t.num_sectors = t.b4K ? NR_TRAILERS_4k : NR_TRAILERS_1k;
26
26
+
+ // Get Mifare Classic type from SAK
27
27
+
+ // see http://www.nxp.com/documents/application_note/AN10833.pdf Section 3.2
28
28
+
+ switch (t.nt.nti.nai.btSak)
29
29
+
+ {
30
30
+
+ case 0x08:
31
31
+
+ printf("Found Mifare Classic 1k tag\n");
32
32
+
+ t.num_sectors = NR_TRAILERS_1k;
33
33
+
+ t.num_blocks = NR_BLOCKS_1k;
34
34
+
+ break;
35
35
+
+ case 0x09:
36
36
+
+ printf("Found Mifare Classic Mini tag\n");
37
37
+
+ t.num_sectors = NR_TRAILERS_MINI;
38
38
+
+ t.num_blocks = NR_BLOCKS_MINI;
39
39
+
+ break;
40
40
+
+ case 0x18:
41
41
+
+ printf("Found Mifare Classic 4k tag\n");
42
42
+
+ t.num_sectors = NR_TRAILERS_4k;
43
43
+
+ t.num_blocks = NR_BLOCKS_4k;
44
44
+
+ break;
45
45
+
+ defaul:
46
46
+
+ ERR("Cannot determine card type from SAK");
47
47
+
+ goto error;
48
48
+
+ }
49
49
+
50
50
+
t.sectors = (void *) calloc(t.num_sectors, sizeof(sector));
51
51
+
if (t.sectors == NULL) {
52
52
+
@@ -564,7 +583,7 @@ void usage(FILE *stream, int errno)
53
53
+
fprintf(stream, " k try the specified key in addition to the default keys\n");
54
54
+
// fprintf(stream, " D number of distance probes, default is 20\n");
55
55
+
// fprintf(stream, " S number of sets with keystreams, default is 5\n");
56
56
+
- fprintf(stream, " P number of probes per sector, instead of default of 20\n");
57
57
+
+ fprintf(stream, " P number of probes per sector, instead of default of 150\n");
58
58
+
fprintf(stream, " T nonce tolerance half-range, instead of default of 20\n (i.e., 40 for the total range, in both directions)\n");
59
59
+
// fprintf(stream, " s specify the list of sectors to crack, for example -s 0,1,3,5\n");
60
60
+
fprintf(stream, " O file in which the card contents will be written (REQUIRED)\n");
61
61
+
diff --git a/src/mfoc.h b/src/mfoc.h
62
62
+
index b411670..532e834 100644
63
63
+
--- a/src/mfoc.h
64
64
+
+++ b/src/mfoc.h
65
65
+
@@ -2,11 +2,21 @@
66
66
+
#define TRY_KEYS 50
67
67
+
68
68
+
// Number of trailers == number of sectors
69
69
+
-// 16x64b = 16
70
70
+
+// Mifare Classic 1k 16x64b = 16
71
71
+
#define NR_TRAILERS_1k (16)
72
72
+
-// 32x64b + 8*256b = 40
73
73
+
+// Mifare Classic Mini
74
74
+
+#define NR_TRAILERS_MINI (5)
75
75
+
+// Mifare Classic 4k 32x64b + 8*256b = 40
76
76
+
#define NR_TRAILERS_4k (40)
77
77
+
78
78
+
+// Number of blocks
79
79
+
+// Mifare Classic 1k
80
80
+
+#define NR_BLOCKS_1k 0x3f
81
81
+
+// Mifare Classic Mini
82
82
+
+#define NR_BLOCKS_MINI 0x13
83
83
+
+// Mifare Classic 4k
84
84
+
+#define NR_BLOCKS_4k 0xff
85
85
+
+
86
86
+
#define MAX_FRAME_LEN 264
87
87
+
88
88
+
// Used for counting nonce distances, explore [nd-value, nd+value]
89
89
+
@@ -46,7 +56,6 @@ typedef struct {
90
90
+
uint8_t num_sectors;
91
91
+
uint8_t num_blocks;
92
92
+
uint32_t authuid;
93
93
+
- bool b4K;
94
94
+
} mftag;
95
95
+
96
96
+
typedef struct {
+2
pkgs/top-level/all-packages.nix
···
1607
1607
1608
1608
mfcuk = callPackage ../tools/security/mfcuk { };
1609
1609
1610
1610
+
mfoc = callPackage ../tools/security/mfoc { };
1611
1611
+
1610
1612
minecraft = callPackage ../games/minecraft { };
1611
1613
1612
1614
minecraft-server = callPackage ../games/minecraft-server { };