Skip to content
This repository was archived by the owner on Apr 12, 2025. It is now read-only.

Commit e1f65e5

Browse files
committed
Add NFC Emulate UID(works only for FeliCa)
1 parent d84b67d commit e1f65e5

16 files changed

Lines changed: 295 additions & 17 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Working Features:
3333

3434
- Wi-Fi support
3535
- BLE support
36-
- BadUSB support(Limited to 4-5 files in file browser)
36+
- BadUSB support
3737
- NFC support
3838
- Some network attacks
3939
- SubGHZ(Beta support, need more testing)

lib/UI/navigation/NFC/NFCNavigation.cpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -30,6 +30,7 @@
3030
#include "pages/NFC/NFCPollingResultPage.hpp"
3131
#include "pages/NFC/NFCPollingWaitingPage.hpp"
3232
#include "pages/NFC/NFCWriteResultPage.hpp"
33+
#include "pages/NFC/NFCEmulateTagPage.hpp"
3334
#include "posixsd.hpp"
3435
#include "sdcard_helper.hpp"
3536

@@ -44,6 +45,7 @@ static NFCBruteforceTagPage *nfc_bruteforce_tag_page = nullptr;
4445
static NFCFelicaPollingResultPage *nfc_felica_polling_result_page = nullptr;
4546
static FileBrowserPage *nfc_dump_file_browser_page = nullptr;
4647
static NFCWriteResultPage *nfc_write_result_page = nullptr;
48+
static NFCEmulateTagPage *nfc_emulate_tag_page = nullptr;
4749

4850
std::list<std::string> nfc_dumps_files; // NFC Dumps files
4951

@@ -76,7 +78,7 @@ void goto_nfc_polling_result_gui(uint8_t *uid, uint8_t len,
7678
const char *tag_name) {
7779
gui->reset();
7880
nfc_polling_result_page =
79-
new NFCPollingResultPage(5, 2, 1, gui->get_screen());
81+
new NFCPollingResultPage(6, 2, 1, gui->get_screen());
8082
gui->set_current_page(nfc_polling_result_page, false);
8183
nfc_polling_result_page->display(uid, len, tag_name);
8284
}
@@ -94,13 +96,25 @@ void nfc_cleanup() {
9496
}
9597
}
9698

99+
bool emulating = false;
100+
97101
void goto_home() {
102+
if(emulating) {
103+
stop_emulate();
104+
emulating = false;
105+
}
98106
reset_uid();
99107
reset_felica();
100108
nfc_cleanup();
101109
init_main_gui();
102110
}
103111

112+
void nfc_return_back() {
113+
stop_emulate();
114+
gui->reset();
115+
gui->set_current_page(nfc_polling_result_page);
116+
}
117+
104118
void save_dump_to_sd() {
105119
Serial.println("save_dump_to_sd");
106120
save_file(DUMP_SAVE_PATH, nfc_attacks->get_scanned_tag()->get_data(), 224);
@@ -189,7 +203,7 @@ void write_felica_tag() {
189203
void init_nfc_felica_polling_result_gui(uint8_t *idm, uint8_t *pmm,
190204
uint16_t sys_code) {
191205
nfc_felica_polling_result_page =
192-
new NFCFelicaPollingResultPage(5, 4, 1, gui->get_screen());
206+
new NFCFelicaPollingResultPage(6, 4, 1, gui->get_screen());
193207
nfc_felica_polling_result_page->display(idm, pmm, sys_code);
194208
gui->set_current_page(nfc_felica_polling_result_page, false);
195209
nfc_polling_waiting_page = nullptr;
@@ -200,6 +214,31 @@ void felica_dump() {
200214
dump_felica(gui, nfc_attacks);
201215
}
202216

217+
extern uint8_t uid[8];
218+
219+
void emulate_iso14443a() {
220+
gui->reset();
221+
nfc_emulate_tag_page = new NFCEmulateTagPage(1, 1, 1, gui->get_screen());
222+
gui->set_current_page(nfc_emulate_tag_page, true, false);
223+
emulate_iso14443a_tag(uid, nfc_attacks);
224+
emulating = true;
225+
}
226+
227+
extern uint8_t idm[8];
228+
extern uint8_t pmm[8];
229+
extern uint16_t sys_code;
230+
231+
void emulate_iso18092() {
232+
gui->reset();
233+
nfc_emulate_tag_page = new NFCEmulateTagPage(2, 1, 1, gui->get_screen());
234+
gui->set_current_page(nfc_emulate_tag_page, true, false);
235+
uint8_t _sys_code[2];
236+
_sys_code[0] = sys_code >> 8;
237+
_sys_code[1] = sys_code & 0xff;
238+
emulate_iso18092_tag(idm, pmm, _sys_code, nfc_attacks);
239+
emulating = true;
240+
}
241+
203242
void set_dumped_sectors(int sectors) {
204243
nfc_dump_result_page->set_dumped(sectors);
205244
};

lib/UI/navigation/NFC/NFCNavigation.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -28,10 +28,13 @@ void nfc_mifare_polling();
2828
void nfc_felica_polling();
2929
void format_nfc_tag();
3030
void goto_home();
31+
void nfc_return_back();
3132
void open_nfc_dump_browser();
3233
void bruteforce_a_tag();
3334
void init_nfc_felica_polling_result_gui(uint8_t *idm, uint8_t *pmm,
3435
uint16_t sys_code);
36+
void emulate_iso14443a();
37+
void emulate_iso18092();
3538
void set_dumped_sectors(int sectors);
3639
void set_unreadable_sectors(int sectors);
3740
void set_unauthenticated_sectors(int sectors);

lib/UI/pages/NFC/FeliCaPages/NFCFelicaPollingResultPage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -39,6 +39,7 @@ void NFCFelicaPollingResultPage::display(uint8_t *idm, uint8_t *pmm,
3939
english_words->at(NFC_FELICA_SYSTEM_CODE_KEY) + String(sys_code, HEX));
4040
dump_to_sd = new List(screen, english_words->at(NFC_DUMP_TAG_TO_SD), 2,
4141
ST77XX_WHITE, 20, ST77XX_BLACK, felica_dump);
42+
emulate_tag = new List(screen, "Emulate UID", 2, ST77XX_WHITE, 20, ST77XX_BLACK, emulate_iso18092);
4243
// write_tag = new List(screen, "Write tag", 2, ST77XX_WHITE, 20,
4344
// ST77XX_BLACK); format_tag = new List(screen,
4445
// english_words->at(NFC_FORMAT_TAG_TO_SD), 2,
@@ -55,6 +56,7 @@ void NFCFelicaPollingResultPage::display(uint8_t *idm, uint8_t *pmm,
5556
// grid->add(write_tag);
5657
// grid->add(format_tag);
5758
// grid->add(bruteforce_tag);
59+
grid->add(emulate_tag);
5860
grid->add(exit_page);
5961
grid->set_selected(4, true);
6062
grid->set_y_spacing(20);

lib/UI/pages/NFC/FeliCaPages/NFCFelicaPollingResultPage.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@ class NFCFelicaPollingResultPage : public Page {
3434
List *write_tag;
3535
List *format_tag;
3636
List *bruteforce_tag;
37+
List *emulate_tag;
3738
List *exit_page;
3839

3940
public:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
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, version 3.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include "NFCEmulateTagPage.hpp"
19+
#include "../../navigation/NFC/NFCNavigation.hpp"
20+
21+
#include "gui.hpp"
22+
23+
NFCEmulateTagPage::~NFCEmulateTagPage() {
24+
delete emulate_text;
25+
delete exit_page;
26+
}
27+
28+
void NFCEmulateTagPage::display() {
29+
grid = new Grid(screen, 2, 1);
30+
emulate_text =
31+
new Text(screen, ST77XX_WHITE, "Emulating tag...");
32+
exit_page = new List(screen, "Exit", 2, ST77XX_WHITE, 20, ST77XX_BLACK, goto_home);
33+
grid->add(emulate_text);
34+
grid->add(exit_page);
35+
grid->set_y_spacing(20);
36+
grid->set_selected(1, true);
37+
grid->display();
38+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
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, version 3.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
#include "../../i18n.hpp"
19+
#include "../../i18n/NFC/nfc_format_page_keys.h"
20+
#include "../Page.hpp"
21+
#include "Grid.hpp"
22+
#include "List.hpp"
23+
#include "Text.hpp"
24+
25+
#ifndef NFC_EMULATE_PAGE_H
26+
#define NFC_EMULATE_PAGE_H
27+
28+
class NFCEmulateTagPage : public Page {
29+
private:
30+
Text *emulate_text;
31+
List *exit_page;
32+
33+
public:
34+
NFCEmulateTagPage(uint8_t _position_limit, uint8_t _lower_limit,
35+
uint8_t _position_increment, GFXForms *screen)
36+
: Page(_position_limit, _lower_limit, _position_increment, screen) {
37+
};
38+
~NFCEmulateTagPage();
39+
void display();
40+
41+
void click(int pos, void callback()) { grid->click(pos, callback); };
42+
void set_selected(int pos, bool status) { grid->set_selected(pos, status); };
43+
};
44+
45+
#endif

lib/UI/pages/NFC/NFCPollingResultPage.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -43,13 +43,15 @@ void NFCPollingResultPage::display(uint8_t *uid, uint8_t length,
4343
bruteforce_tag =
4444
new List(screen, english_words->at(NFC_BRUTEFORCE_TAG_KEY), 2,
4545
ST77XX_WHITE, 20, ST77XX_BLACK, bruteforce_a_tag);
46+
emulate_tag = new List(screen, "Emulate UID", 2, ST77XX_WHITE, 20, ST77XX_BLACK, emulate_iso14443a);
4647
exit_page = new List(screen, english_words->at(NFC_GO_BACK_KEY), 2,
4748
ST77XX_WHITE, 20, ST77XX_BLACK, goto_home);
4849
grid->add(tag_info);
4950
grid->add(uid_text);
5051
grid->add(write_tag);
5152
grid->add(format_tag);
5253
grid->add(bruteforce_tag);
54+
grid->add(emulate_tag);
5355
grid->add(exit_page);
5456
grid->set_selected(2, true);
5557
grid->set_y_spacing(20);

lib/UI/pages/NFC/NFCPollingResultPage.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -32,6 +32,7 @@ class NFCPollingResultPage : public Page {
3232
List *write_tag;
3333
List *format_tag;
3434
List *bruteforce_tag;
35+
List *emulate_tag;
3536
List *exit_page;
3637

3738
public:

lib/nfc_attacks/nfc_attacks.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* This file is part of the Capibara zero (https://github.com/CapibaraZero/fw or
3-
* https://capibarazero.github.io/). Copyright (c) 2024 Andrea Canale.
3+
* https://capibarazero.github.io/). Copyright (c) 2025 Andrea Canale.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -562,4 +562,12 @@ NFCTag NFCAttacks::get_felica_towrite() {
562562
memcpy(&data[i][0], &buffer[i * 16], 16);
563563
}
564564
return NFCTag(idm, pmm, sys_code, data);
565-
}
565+
}
566+
567+
bool NFCAttacks::emulate_tag(uint8_t *uid) {
568+
return nfc_framework.emulate_tag(uid);
569+
}
570+
571+
bool NFCAttacks::emulate_tag(uint8_t *idm, uint8_t *pmm, uint8_t *sys_code) {
572+
return nfc_framework.emulate_tag(idm, pmm, sys_code);
573+
};

0 commit comments

Comments
 (0)