Skip to content

Commit 92a601d

Browse files
committed
Misc cleanup and README updates
1 parent 366030e commit 92a601d

File tree

6 files changed

+24
-243
lines changed

6 files changed

+24
-243
lines changed

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
# magspoof_flipper
22
WIP of MagSpoof for the Flipper Zero. Currently rewriting from the ground up; basic TX of saved files should now work over both RFID (using the Flipper's internal coil) and GPIO (pins A6 and A7: such that one can connect an H-bridge and external coil). A sample file with test data is included in `assets`, for anyone wishing to experiment. Using this README as coarse notes of what remains to be done; anyone is welcome to contribute!
33

4-
Disclaimer: use responsibly, and at your own risk. While in my testing, I've seen no reason to believe this could damage the RFID hardware, this is inherently driving the coil in ways it was not designed or intended for; I take no responsibility for fried/bricked Flippers. Similarly, please only use this with magstripe cards and mag readers you own — this is solely meant as a proof of concept for educational purposes, and I neither condone nor am sympathetic to malicious uses of my code.
4+
Disclaimer: use responsibly, and at your own risk. While in my testing, I've seen no reason to believe this could damage the RFID hardware, this is inherently driving the coil in ways it was not designed or intended for; I take no responsibility for fried/bricked Flippers. Similarly, please only use this with magstripe cards and mag readers you own — this is solely meant as a proof of concept for educational purposes. I neither condone nor am sympathetic to malicious uses of my code.
55

66
## TODO
77
Emulation:
8-
- Clean up old testing scenes, remove deprecated helpers
9-
- Reverse track precomputation
10-
- Does the main timing-sensitive section need to be branchless? (Remove `if`s from the `FURI_CRITICAL...` section of `mag_spoof()`?)
11-
- Implement/integrate better bitmap than hacky first pass? antirez's better approach (from ProtoView) included at bottom of `helpers/mag_helpers.c`
8+
- General code cleanup
9+
- Reverse track precompute & replay
10+
- Implement/integrate better bitmap than hacky first pass? Boilerplate from [antirez](https://github.com/antirez)'s better approach (from [ProtoView](https://github.com/antirez/protoview)) included at the bottom of `helpers/mag_helpers.c`
11+
- Should the main timing-sensitive section be branchless? (Remove `if` and `switch` statements from the `FURI_CRITICAL...` section of `mag_spoof()`?)
1212
- Pursue skunkworks TX improvement ideas listed below
1313

1414
Scenes:
15-
- Complete emulation config scene (include reverse track functionality; possibly expand settings list to include prefix/between/suffix options)
15+
- Finish emulation config scene (reverse track functionality; possibly expand settings list to include prefix/between/suffix options)
1616
- Improved saved info display (better text wrapping options? remove and just include that info on the emulate scene? decode data to fields?)
17-
- Edit saved card scene
17+
- "About" scene?
18+
- "Edit" scene (generalize "Add manually")
1819

1920
File management:
20-
- Parsing loaded files into relevent fields (would we need to specify card type as well, to decode correctly?)
21-
- Modify manual add scene to allow editing and renaming of existing files
2221
- Validation of card track data?
22+
- Parsing loaded files into human-readable fields (would we need to specify card type to decode correctly?)
2323
- Update Add Manually flow to reflect new file format (currently only sets Track 2, and Info/Emulate scene only displays Track 2)
2424

2525
Known bugs:
2626
- Custom text input scene with expanded characterset (Add Manually) has odd behavior when navigating the keys near the numpad
2727
- Track 1 data typically starts with a `%` sign. Unless escaped, it won't be displayed when printed, as C considers it a special character. To confirm: how does this impact the emulation when iterating through the chars? Does it get played correctly?
28+
- Possible file format issues when Track 2 data exists but Track 1 is left empty; doesn't seem to load happily.
29+
- Attempting to play a track that doesn't have data results in a crash (as one might expect). Need to lock out users from selecting empty tracks in the config menu or do better error handling
2830

2931
## Skunkworks ideas
3032
Internal TX improvements:
3133
- Attempt downstream modulation techniques, in addition to upstream, like the LF RFID worker does when writing, for stronger signal
3234
- Implement using the timer system, rather than direct-writing to pins
3335
- Use the NFC (HF RFID) coil instead of or in addition to the LF coil (likely unfruitful from initial tests; we can enable/disable the oscillating field, but even with transparent mode to the ST25R3916, it seems we don't get low-enough-level control to pull it high/low correctly)
3436

35-
External RX options (What is simplest read module?):
36-
- Some UART mag reader (bulky, but likely easiest to read over GPIO, and means one can read all tracks)
37-
- Square audio jack mag reader (this may be DOA; seems like newer versions of the Square modules have some form of preprocessing, that also modifies the signal, perhaps in an effort to discourage folks using their hardware independent of their software. Thanks @[arha](https://github.com/arha) for your work investigating this)
37+
External RX options:
38+
- UART-connected mag reader (bulky, but likely easiest to read over GPIO, and means one can read all tracks)
39+
- Square audio jack mag reader (this may be DOA; seems like newer versions of the Square modules have some form of preprocessing that also modifies the signal, perhaps in an effort to discourage folks using their hardware independent of their software. Thanks [@arha](https://github.com/arha) for your work investigating this)
3840
- Some read-head directly connected to GPIO, ADC'd, and parsed all on the Flipper. Likely the most compact and cheapest module option, but also would require the most work.
39-
- USB HID input feasible? Flipper seemingly can't act as an HID host, is there any way to circumvent this or is it due to a hardware incompatibility? This would be the easiest / best option all-around if feasible.
41+
- USB HID input likely infeasible; seems the FZ cannot act as an HID host.
4042

4143
----
4244
## Credits
43-
This project interpolates work from [Samy Kamkar's original MagSpoof project](https://github.com/samyk/magspoof), [dunaevai135's Flipper hackathon project](https://github.com/dunaevai135/flipperzero-firmware), and the Flipper team's [LF RFID](https://github.com/flipperdevices/flipperzero-firmware/tree/dev/applications/main/lfrfid) and [SubGhz](https://github.com/flipperdevices/flipperzero-firmware/tree/dev/applications/main/subghz) apps.
45+
This project interpolates work from [Samy Kamkar's original MagSpoof project](https://github.com/samyk/magspoof), [dunaevai135 & AlexYaro's Flipper hackathon project](https://github.com/dunaevai135/flipperzero-firmware), and the Flipper team's [LF RFID](https://github.com/flipperdevices/flipperzero-firmware/tree/dev/applications/main/lfrfid) and [SubGhz](https://github.com/flipperdevices/flipperzero-firmware/tree/dev/applications/main/subghz) apps.
4446

4547
Many thanks to everyone who has helped in addition to those above, most notably:
4648
- [antirez](https://github.com/antirez) for bitmapping suggestions and general C wisdom

application.fam

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ App(
55
entry_point="mag_app",
66
cdefines=["APP_MAG"],
77
requires=[
8-
"gui",
8+
"gui",
99
"storage",
1010
"notification",
1111
"dialogs",
12-
'toolbox',
1312
],
1413
provides=[],
1514
stack_size=2 * 1024,
1615
order=20,
1716
fap_icon="icons/mag_10px.png",
1817
fap_category="Tools",
1918
fap_icon_assets="icons",
19+
fap_version=(0, 1), # major, minor
20+
fap_description="WIP MagSpoof port using the RFID subsystem",
21+
fap_author="Zachary Weiss",
22+
fap_weburl="https://github.com/zacharyweiss/magspoof_flipper",
2023
)

helpers/mag_helpers.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,8 @@ void track_to_bits(uint8_t* bit_array, const char* track_data, uint8_t track_ind
190190
bit_array[i] = 2;
191191
i++;
192192

193-
// Log the output
193+
// Log the output (messy but works)
194194
char output[100] = {0x0};
195-
//FURI_LOG_D(TAG, "%s", bit_array);
196195
FuriString* tmp_str;
197196
tmp_str = furi_string_alloc();
198197
for(uint8_t j = 0; bit_array[j] != 2; j++) {
@@ -201,16 +200,13 @@ void track_to_bits(uint8_t* bit_array, const char* track_data, uint8_t track_ind
201200
}
202201
FURI_LOG_D(TAG, "Track %d: %s", (track_index + 1), output);
203202
furi_string_free(tmp_str);
204-
205-
//bool is_correct_length = (i == (strlen(track_data) * bitlen[track_index]));
206-
//furi_assert(is_correct_length);
207203
}
208204

209205
void mag_spoof(Mag* mag) {
210206
MagSetting* setting = mag->setting;
211207

212208
// precompute tracks (WIP; ignores reverse and 3rd track)
213-
// likely will be reworked to Samy's bitmap method anyway...
209+
// likely will be reworked to antirez's bitmap method anyway...
214210
const char* data1 = furi_string_get_cstr(mag->mag_dev->dev_data.track[0].str);
215211
const char* data2 = furi_string_get_cstr(mag->mag_dev->dev_data.track[1].str);
216212
uint8_t bit_array1[(strlen(data1) * bitlen[0]) + 1];

scenes/mag_scene_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
ADD_SCENE(mag, start, Start)
2-
ADD_SCENE(mag, emulate_test, EmulateTest)
32
ADD_SCENE(mag, emulate, Emulate)
43
ADD_SCENE(mag, emulate_config, EmulateConfig)
54
ADD_SCENE(mag, file_select, FileSelect)

scenes/mag_scene_emulate_test.c

Lines changed: 0 additions & 209 deletions
This file was deleted.

scenes/mag_scene_start.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "../mag_i.h"
22

33
typedef enum {
4-
//SubmenuIndexEmulateTest,
54
SubmenuIndexSaved,
65
SubmenuIndexAddManually,
76
} SubmenuIndex;
@@ -16,15 +15,10 @@ void mag_scene_start_on_enter(void* context) {
1615
Mag* mag = context;
1716
Submenu* submenu = mag->submenu;
1817

19-
/*submenu_add_item(
20-
submenu,
21-
"Emulate (Hardcoded)",
22-
SubmenuIndexEmulateTest,
23-
mag_scene_start_submenu_callback,
24-
mag);*/
2518
submenu_add_item(submenu, "Saved", SubmenuIndexSaved, mag_scene_start_submenu_callback, mag);
2619
submenu_add_item(
2720
submenu, "Add Manually", SubmenuIndexAddManually, mag_scene_start_submenu_callback, mag);
21+
// TODO: "About" scene?
2822

2923
submenu_set_selected_item(
3024
submenu, scene_manager_get_scene_state(mag->scene_manager, MagSceneStart));
@@ -40,10 +34,6 @@ bool mag_scene_start_on_event(void* context, SceneManagerEvent event) {
4034
bool consumed = false;
4135

4236
if(event.type == SceneManagerEventTypeCustom) {
43-
/*if(event.event == SubmenuIndexEmulateTest) {
44-
scene_manager_next_scene(mag->scene_manager, MagSceneEmulateTest);
45-
consumed = true;
46-
} else */
4737
if(event.event == SubmenuIndexSaved) {
4838
furi_string_set(mag->file_path, MAG_APP_FOLDER);
4939
scene_manager_next_scene(mag->scene_manager, MagSceneFileSelect);

0 commit comments

Comments
 (0)