Merge pull request #2741 from Donny-Guo/hidbrute
[RRG-proxmark3.git] / armsrc / Standalone / hf_tmudford.c
blobaa986aba042111799b274a428bcf0a2623a9265f
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2021 Tim Mudford <tim.mudford1@gmail.com>
3 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // See LICENSE.txt for the text of the license.
16 //-----------------------------------------------------------------------------
17 // main code for hf_tmudford
18 // `hf_tmudford` Continuously scans for ISO15693 card UID and then emulates it.
19 //-----------------------------------------------------------------------------
21 #include "standalone.h"
22 #include "proxmark3_arm.h"
23 #include "appmain.h"
24 #include "fpgaloader.h"
25 #include "util.h"
26 #include "dbprint.h"
27 #include "ticks.h"
29 #include "iso15693.h"
30 #include "iso15.h"
32 #define STATE_READ 0
33 #define STATE_EMUL 1
35 void ModInfo(void) {
36 DbpString("HF TMUDFORD mode - Scans and emulates ISO15693 UID (Tim Mudford)");
39 void RunMod(void) {
40 StandAloneMode();
41 Dbprintf(_YELLOW_("HF TMUDFORD mode started"));
42 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
44 for (;;) {
45 WDT_HIT();
46 if (data_available()) break;
48 SpinDelay(500);
50 // 0 = search, 1 = read, 2 = emul
51 int state = STATE_READ;
52 iso15_card_select_t card;
54 DbpString("Scanning...");
55 int button_pressed = BUTTON_NO_CLICK;
56 for (;;) {
57 // Was our button held down or pressed?
58 button_pressed = BUTTON_HELD(1000);
60 if (button_pressed != BUTTON_NO_CLICK || data_available())
61 break;
62 else if (state == STATE_READ) {
63 Iso15693InitReader();
64 ReaderIso15693(&card);
66 if (card.uidlen == 0) {
67 LED_D_OFF();
68 SpinDelay(500);
69 continue;
70 } else {
71 Dbprintf("Found card with UID: ");
72 Dbhexdump(card.uidlen, card.uid, 0);
73 state = STATE_EMUL;
75 } else if (state == STATE_EMUL) {
76 Iso15693InitTag();
77 Dbprintf("Starting simulation, press " _GREEN_("pm3 button") " to stop and go back to search state.");
78 // default block size is 4..
79 // iceman: which can be 4,8 all the way to 32
80 SimTagIso15693(card.uid, 4);
82 state = STATE_READ;
85 if (button_pressed == BUTTON_HOLD)
86 break;
89 Dbprintf("-=[ exit ]=-");
90 LEDsoff();