Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3 from zacharyweiss/alt_tx
Browse files Browse the repository at this point in the history
Zero prefix/between/suffix bugfix
  • Loading branch information
zacharyweiss authored Feb 3, 2023
2 parents 21a3a06 + c954330 commit a4df68c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ File management:
Internal TX improvements:
- [ ] Attempt downstream modulation techniques in addition to upstream, like the LF RFID worker does when writing.
- [ ] Implement using the timer system, rather than direct-writing to pins
- [ ] 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)
- [X] 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)
- [ ] Add "subcarriers" to each half-bit transmitted (wiggle the pin high and low rapidly)
- [ ] Piezo subcarrier tests
- [ ] LF subcarrier tests
- [ ] Retry NFC oscillating field?
- [X] Retry NFC oscillating field?

External RX options:
1. [TTL / PS/2 mag reader connected to UART](https://www.alibaba.com/product-detail/Mini-portable-12-3-tracks-usb_60679900708.html) (bulky, harder to source, but likely easiest to read over GPIO, and means one can read all tracks)
Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ App(
fap_icon="icons/mag_10px.png",
fap_category="Tools",
fap_icon_assets="icons",
fap_version=(0, 4), # major, minor
fap_version=(0, 5), # major, minor
fap_description="WIP MagSpoof port using the RFID subsystem",
fap_author="Zachary Weiss",
fap_weburl="https://github.com/zacharyweiss/magspoof_flipper",
Expand Down
57 changes: 53 additions & 4 deletions helpers/mag_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,55 @@ void play_halfbit(bool value, MagSetting* setting) {
switch(setting->tx) {
case MagTxStateRFID:
furi_hal_gpio_write(RFID_PIN_OUT, value);
/*furi_hal_gpio_write(RFID_PIN_OUT, !value);
furi_hal_gpio_write(RFID_PIN_OUT, value);
furi_hal_gpio_write(RFID_PIN_OUT, !value);
furi_hal_gpio_write(RFID_PIN_OUT, value);*/
break;
case MagTxStateGPIO:
furi_hal_gpio_write(GPIO_PIN_A, value);
furi_hal_gpio_write(GPIO_PIN_B, !value);
break;
case MagTxStatePiezo:
furi_hal_gpio_write(&gpio_speaker, value);
/*furi_hal_gpio_write(&gpio_speaker, !value);
furi_hal_gpio_write(&gpio_speaker, value);
furi_hal_gpio_write(&gpio_speaker, !value);
furi_hal_gpio_write(&gpio_speaker, value);*/

break;
case MagTxStateLF_P:
furi_hal_gpio_write(RFID_PIN_OUT, value);
furi_hal_gpio_write(&gpio_speaker, value);

/* // Weaker but cleaner signal
if(value) {
furi_hal_gpio_write(RFID_PIN_OUT, value);
furi_hal_gpio_write(&gpio_speaker, value);
furi_delay_us(10);
furi_hal_gpio_write(RFID_PIN_OUT, !value);
furi_hal_gpio_write(&gpio_speaker, !value);
} else {
furi_delay_us(10);
}*/

/*furi_hal_gpio_write(RFID_PIN_OUT, value);
furi_hal_gpio_write(&gpio_speaker, value);
furi_hal_gpio_write(RFID_PIN_OUT, !value);
furi_hal_gpio_write(&gpio_speaker, !value);
furi_hal_gpio_write(RFID_PIN_OUT, value);
furi_hal_gpio_write(&gpio_speaker, value);*/
break;
case MagTxStateNFC:
// turn on for duration of half-bit? or "blip" the field on / off?
// getting nothing from the mag reader either way
//(value) ? furi_hal_nfc_ll_txrx_on() : furi_hal_nfc_ll_txrx_off();

if(last_value == 2 || value != (bool)last_value) {
furi_hal_nfc_ll_txrx_on();
//furi_delay_us(64);
furi_hal_nfc_ll_txrx_off();
}
break;
case MagTxCC1101_434:
case MagTxCC1101_868:
Expand Down Expand Up @@ -167,6 +205,9 @@ bool tx_init(MagSetting* setting) {
tx_init_piezo();
tx_init_rfid();
break;
case MagTxStateNFC:
furi_hal_nfc_exit_sleep();
break;
case MagTxCC1101_434:
tx_init_rf(434000000);
break;
Expand Down Expand Up @@ -202,6 +243,10 @@ bool tx_deinit(MagSetting* setting) {
tx_deinit_piezo();
tx_deinit_rfid();
break;
case MagTxStateNFC:
furi_hal_nfc_ll_txrx_off();
furi_hal_nfc_start_sleep();
break;
case MagTxCC1101_434:
case MagTxCC1101_868:
furi_hal_gpio_write(&gpio_cc1101_g0, false);
Expand Down Expand Up @@ -251,7 +296,11 @@ void mag_spoof(Mag* mag) {
data3, (uint8_t*)bits_t3_manchester, (uint8_t*)bits_t3_raw, bitlen[2], sublen[2]);

if(furi_log_get_level() >= FuriLogLevelDebug) {
printf("Manchester bitcount: T1: %d, T2: %d\r\n", bits_t1_count, bits_t2_count);
printf(
"Manchester bitcount: T1: %d, T2: %d, T3: %d\r\n",
bits_t1_count,
bits_t2_count,
bits_t3_count);
printf("T1 raw: ");
for(int i = 0; i < bits_t1_count / 16; i++) printf("%02x ", bits_t1_raw[i]);
printf("\r\nT1 manchester: ");
Expand All @@ -275,7 +324,7 @@ void mag_spoof(Mag* mag) {
FURI_CRITICAL_ENTER();
for(uint16_t i = 0; i < (ZERO_PREFIX * 2); i++) {
// is this right?
bit ^= 0xFF;
if(!!(i % 2)) bit ^= 1;
play_halfbit(bit, setting);
furi_delay_us(setting->us_clock);
}
Expand All @@ -285,7 +334,7 @@ void mag_spoof(Mag* mag) {

if((setting->track == MagTrackStateOneAndTwo))
for(uint16_t i = 0; i < (ZERO_BETWEEN * 2); i++) {
bit ^= 0xFF;
if(!!(i % 2)) bit ^= 1;
play_halfbit(bit, setting);
furi_delay_us(setting->us_clock);
}
Expand All @@ -301,7 +350,7 @@ void mag_spoof(Mag* mag) {
play_track((uint8_t*)bits_t3_manchester, bits_t3_count, setting, false);

for(uint16_t i = 0; i < (ZERO_SUFFIX * 2); i++) {
bit ^= 0xFF;
if(!!(i % 2)) bit ^= 1;
play_halfbit(bit, setting);
furi_delay_us(setting->us_clock);
}
Expand Down
3 changes: 2 additions & 1 deletion helpers/mag_types.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define MAG_VERSION_APP "0.04"
#define MAG_VERSION_APP "0.05"
#define MAG_DEVELOPER "Zachary Weiss"
#define MAG_GITHUB "github.com/zacharyweiss/magspoof_flipper"

Expand Down Expand Up @@ -32,6 +32,7 @@ typedef enum {
MagTxStateGPIO,
MagTxStatePiezo,
MagTxStateLF_P, // combo of RFID and Piezo
MagTxStateNFC,
MagTxCC1101_434,
MagTxCC1101_868,
} MagTxState;
4 changes: 3 additions & 1 deletion scenes/mag_scene_emulate_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ enum MagSettingIndex {
MagSettingIndexInterpacket,
};

#define TX_COUNT 6
#define TX_COUNT 7
const char* const tx_text[TX_COUNT] = {
"RFID",
"GPIO",
"Piezo",
"LF + P",
"NFC",
"434MHz",
"868MHz",
};
Expand All @@ -24,6 +25,7 @@ const uint32_t tx_value[TX_COUNT] = {
MagTxStateGPIO,
MagTxStatePiezo,
MagTxStateLF_P,
MagTxStateNFC,
MagTxCC1101_434,
MagTxCC1101_868,
};
Expand Down

0 comments on commit a4df68c

Please sign in to comment.