Merge pull request #2654 from Antiklesys/master
[RRG-proxmark3.git] / include / em4x50.h
blob1b4d7fa7f7c02d753f4471c535dacb19fd9bf1ac
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // Low frequency EM4x50 structs
17 //-----------------------------------------------------------------------------
19 #ifndef EM4X50_H__
20 #define EM4X50_H__
22 #include "common.h"
23 #include "bruteforce.h"
25 #define EM4X50_NO_WORDS 34
26 #define EM4X50_SIZE_WORD 4
28 // special words
29 #define EM4X50_DEVICE_PASSWORD 0
30 #define EM4X50_PROTECTION 1
31 #define EM4X50_CONTROL 2
32 #define EM4X50_DEVICE_SERIAL 32
33 #define EM4X50_DEVICE_ID 33
35 // control word (word = 4 bytes)
36 #define FIRST_WORD_READ 0 // first byte
37 #define LAST_WORD_READ 1 // second byte
38 #define CONFIG_BLOCK 2 // third byte
39 #define PASSWORD_CHECK 0x80 // first bit in third byte
40 #define READ_AFTER_WRITE 0x40 // second bit in third byte
42 // protection word
43 #define FIRST_WORD_READ_PROTECTED 0 // first byte
44 #define LAST_WORD_READ_PROTECTED 1 // second byte
45 #define FIRST_WORD_WRITE_INHIBITED 2 // third byte
46 #define LAST_WORD_WRITE_INHIBITED 3 // fourth byte
48 // commands
49 #define EM4X50_COMMAND_LOGIN 0x01
50 #define EM4X50_COMMAND_RESET 0x80
51 #define EM4X50_COMMAND_WRITE 0x12
52 #define EM4X50_COMMAND_WRITE_PASSWORD 0x11
53 #define EM4X50_COMMAND_SELECTIVE_READ 0x0A
54 #define EM4X50_COMMAND_STANDARD_READ 0x02 // virtual command
56 // misc
57 #define EM4X50_TIMEOUT_CMD 3000
58 #define EM4X50_DUMP_FILESIZE 136
60 typedef struct {
61 bool addr_given;
62 bool pwd_given;
63 uint32_t password1;
64 uint32_t password2;
65 uint32_t word;
66 uint32_t addresses;
67 bruteforce_mode_t bruteforce_mode;
68 bruteforce_charset_t bruteforce_charset;
69 } PACKED em4x50_data_t;
71 typedef struct {
72 uint8_t byte[4];
73 } PACKED em4x50_word_t;
75 typedef struct {
76 uint8_t count;
77 uint32_t *words;
78 } PACKED em4x50_read_data_response_t;
80 // Global variables...
81 extern bool g_Login;
82 extern bool g_WritePasswordProcess;
83 extern uint32_t g_Password;
85 #endif /* EM4X50_H__ */