1 //-----------------------------------------------------------------------------
2 // Copyright (C) Samy Kamkar, 2012
3 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
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.
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 LF aka SamyRun by Samy Kamkar
18 //-----------------------------------------------------------------------------
19 #include "standalone.h" // standalone definitions
20 #include "proxmark3_arm.h"
22 #include "fpgaloader.h"
31 DbpString(" LF HID26 standalone - aka SamyRun (Samy Kamkar)");
34 // samy's sniff and repeat routine for LF
37 // A , B == which bank (recording)
38 // FLASHING A, B = clone bank
44 FpgaDownloadAndGo(FPGA_BITSTREAM_LF
);
45 Dbprintf(">> LF HID Read/Clone/Sim a.k.a SamyRun Started <<");
47 uint32_t high
[OPTS
], low
[OPTS
];
54 uint8_t state
= STATE_READ
;
60 // exit from SamyRun, send a usbcommand.
61 if (data_available()) break;
63 // Was our button held down or pressed?
64 int button_pressed
= BUTTON_HELD(280);
65 if (button_pressed
!= BUTTON_HOLD
)
68 if (state
== STATE_READ
) {
81 WAIT_BUTTON_RELEASED();
84 DbpString("[=] start recording");
86 // findone, high, low, no ledcontrol (A)
87 uint32_t hi
= 0, lo
= 0;
88 lf_hid_watch(1, &hi
, &lo
, true);
92 Dbprintf("[=] recorded %x | %x%08x", selected
, high
[selected
], low
[selected
]);
94 // got nothing. blink and loop.
95 if (hi
== 0 && lo
== 0) {
96 SpinErr((selected
== 0) ? LED_A
: LED_B
, 100, 12);
97 DbpString("[=] only got zeros, retry recording after click");
101 SpinErr((selected
== 0) ? LED_A
: LED_B
, 250, 2);
105 } else if (state
== STATE_SIM
) {
107 LED_C_ON(); // Simulate
109 WAIT_BUTTON_RELEASED();
111 Dbprintf("[=] simulating %x | %x%08x", selected
, high
[selected
], low
[selected
]);
113 // high, low, no led control(A) no time limit
114 CmdHIDsimTAGEx(0, high
[selected
], low
[selected
], 0, false, -1);
116 DbpString("[=] simulating done");
118 uint8_t leds
= ((selected
== 0) ? LED_A
: LED_B
) | LED_C
;
119 SpinErr(leds
, 250, 2);
123 } else if (state
== STATE_CLONE
) {
127 WAIT_BUTTON_RELEASED();
129 Dbprintf("[=] cloning %x | %x%08x", selected
, high
[selected
], low
[selected
]);
131 // high2, high, low, no longFMT
132 CopyHIDtoT55x7(0, high
[selected
], low
[selected
], 0, false, false, true);
134 DbpString("[=] cloned done");
137 uint8_t leds
= ((selected
== 0) ? LED_A
: LED_B
) | LED_D
;
138 SpinErr(leds
, 250, 2);
139 selected
= (selected
+ 1) % OPTS
;
144 SpinErr((LED_A
| LED_B
| LED_C
| LED_D
), 250, 5);
145 DbpString("[=] You can take shell back :) ...");