From 5597c36217b9a2a4d90e491d330d87dc53130602 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 15 May 2024 21:22:37 +0300 Subject: [PATCH] upd picopass --- base_pack/picopass/application.fam | 4 ++-- base_pack/picopass/picopass_device.c | 20 ++++++++++++++---- base_pack/picopass/picopass_device.h | 3 ++- base_pack/picopass/readme.md | 12 +++++++++++ .../scenes/picopass_scene_card_menu.c | 21 +++++++++++++++++-- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 base_pack/picopass/readme.md diff --git a/base_pack/picopass/application.fam b/base_pack/picopass/application.fam index bfcb54b73d8..c8186144a03 100644 --- a/base_pack/picopass/application.fam +++ b/base_pack/picopass/application.fam @@ -13,7 +13,7 @@ App( ], stack_size=4 * 1024, fap_description="App to communicate with NFC tags using the PicoPass(iClass) format", - fap_version="1.13", + fap_version="1.15", fap_icon="125_10px.png", fap_category="NFC", fap_libs=["mbedtls"], @@ -28,7 +28,7 @@ App( ) App( - appid="plugin_wiegand", + appid="picopass_plugin_wiegand", apptype=FlipperAppType.PLUGIN, entry_point="plugin_wiegand_ep", requires=["picopass"], diff --git a/base_pack/picopass/picopass_device.c b/base_pack/picopass/picopass_device.c index 8a40248fd55..42b5012c0bc 100644 --- a/base_pack/picopass/picopass_device.c +++ b/base_pack/picopass/picopass_device.c @@ -193,7 +193,8 @@ static bool picopass_device_save_file( furi_string_printf(temp_str, "%s/%s%s", folder, dev_name, extension); } - if(dev->format == PicopassDeviceSaveFormatHF || + if(dev->format == PicopassDeviceSaveFormatOriginal || + dev->format == PicopassDeviceSaveFormatLegacy || dev->format == PicopassDeviceSaveFormatPartial) { // Open file if(!flipper_format_file_open_always(file, furi_string_get_cstr(temp_str))) break; @@ -215,6 +216,12 @@ static bool picopass_device_save_file( for(size_t i = 0; i < app_limit; i++) { furi_string_printf(temp_str, "Block %d", i); if(card_data[i].valid) { + if(dev->format == PicopassDeviceSaveFormatLegacy) { + if(i == PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX) { + card_data[i].data[0] = 0x03; + } + } + if(!flipper_format_write_hex( file, furi_string_get_cstr(temp_str), @@ -249,7 +256,7 @@ static bool picopass_device_save_file( } bool picopass_device_save(PicopassDevice* dev, const char* dev_name) { - if(dev->format == PicopassDeviceSaveFormatHF) { + if(dev->format == PicopassDeviceSaveFormatOriginal) { return picopass_device_save_file( dev, dev_name, STORAGE_APP_DATA_PATH_PREFIX, PICOPASS_APP_EXTENSION, true); } else if(dev->format == PicopassDeviceSaveFormatLF) { @@ -260,6 +267,11 @@ bool picopass_device_save(PicopassDevice* dev, const char* dev_name) { } else if(dev->format == PicopassDeviceSaveFormatPartial) { return picopass_device_save_file( dev, dev_name, STORAGE_APP_DATA_PATH_PREFIX, PICOPASS_APP_EXTENSION, true); + } else if(dev->format == PicopassDeviceSaveFormatLegacy) { + return picopass_device_save_file( + dev, dev_name, STORAGE_APP_DATA_PATH_PREFIX, PICOPASS_APP_EXTENSION, true); + } else { + FURI_LOG_E(TAG, "Unknown format"); } return false; @@ -382,7 +394,7 @@ void picopass_device_clear(PicopassDevice* dev) { picopass_device_data_clear(&dev->dev_data); memset(&dev->dev_data, 0, sizeof(dev->dev_data)); - dev->format = PicopassDeviceSaveFormatHF; + dev->format = PicopassDeviceSaveFormatOriginal; furi_string_reset(dev->load_path); } @@ -441,7 +453,7 @@ void picopass_device_data_clear(PicopassDeviceData* dev_data) { bool picopass_device_delete(PicopassDevice* dev, bool use_load_path) { furi_assert(dev); - if(dev->format != PicopassDeviceSaveFormatHF) { + if(dev->format != PicopassDeviceSaveFormatOriginal) { // Never delete other formats (LF, Seader, etc) return false; } diff --git a/base_pack/picopass/picopass_device.h b/base_pack/picopass/picopass_device.h index 78ed6645c09..ea0ec6c911e 100644 --- a/base_pack/picopass/picopass_device.h +++ b/base_pack/picopass/picopass_device.h @@ -68,7 +68,8 @@ typedef enum { } PicopassEncryption; typedef enum { - PicopassDeviceSaveFormatHF, + PicopassDeviceSaveFormatOriginal, + PicopassDeviceSaveFormatLegacy, PicopassDeviceSaveFormatLF, PicopassDeviceSaveFormatSeader, PicopassDeviceSaveFormatPartial, diff --git a/base_pack/picopass/readme.md b/base_pack/picopass/readme.md new file mode 100644 index 00000000000..eaf0ea442ec --- /dev/null +++ b/base_pack/picopass/readme.md @@ -0,0 +1,12 @@ +# Picopass + +https://lab.flipper.net/apps/picopass + +## Build + +```bash +git clone https://gitlab.com/bettse/picopass.git +cd picopass +git submodule init && git submodule update +ufbt +``` diff --git a/base_pack/picopass/scenes/picopass_scene_card_menu.c b/base_pack/picopass/scenes/picopass_scene_card_menu.c index 9d44f5642d9..7d643d8ec06 100644 --- a/base_pack/picopass/scenes/picopass_scene_card_menu.c +++ b/base_pack/picopass/scenes/picopass_scene_card_menu.c @@ -9,6 +9,7 @@ enum SubmenuIndex { SubmenuIndexWrite, SubmenuIndexEmulate, SubmenuIndexSavePartial, + SubmenuIndexSaveLegacy, }; void picopass_scene_card_menu_submenu_callback(void* context, uint32_t index) { @@ -27,7 +28,8 @@ void picopass_scene_card_menu_on_enter(void* context) { bool SE = card_data[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].valid && 0x30 == card_data[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0]; - bool SR = card_data[10].valid && 0x30 == card_data[10].data[0]; + bool SR = card_data[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0] == 0xA3 && + card_data[10].valid && 0x30 == card_data[10].data[0]; bool has_sio = SE || SR; bool secured = (card_data[PICOPASS_CONFIG_BLOCK_INDEX].data[7] & PICOPASS_FUSE_CRYPT10) != PICOPASS_FUSE_CRYPT0; @@ -62,6 +64,15 @@ void picopass_scene_card_menu_on_enter(void* context) { picopass_scene_card_menu_submenu_callback, picopass); + if(SR) { + submenu_add_item( + submenu, + "Save as Legacy", + SubmenuIndexSaveLegacy, + picopass_scene_card_menu_submenu_callback, + picopass); + } + if(plugin) { // Convert from byte array to uint64_t uint64_t credential = 0; @@ -119,7 +130,7 @@ bool picopass_scene_card_menu_on_event(void* context, SceneManagerEvent event) { scene_manager_set_scene_state( picopass->scene_manager, PicopassSceneCardMenu, SubmenuIndexSave); scene_manager_next_scene(picopass->scene_manager, PicopassSceneSaveName); - picopass->dev->format = PicopassDeviceSaveFormatHF; + picopass->dev->format = PicopassDeviceSaveFormatOriginal; consumed = true; } else if(event.event == SubmenuIndexSavePartial) { scene_manager_set_scene_state( @@ -155,6 +166,12 @@ bool picopass_scene_card_menu_on_event(void* context, SceneManagerEvent event) { picopass->scene_manager, PicopassSceneCardMenu, SubmenuIndexParse); scene_manager_next_scene(picopass->scene_manager, PicopassSceneFormats); consumed = true; + } else if(event.event == SubmenuIndexSaveLegacy) { + scene_manager_set_scene_state( + picopass->scene_manager, PicopassSceneCardMenu, SubmenuIndexSaveLegacy); + picopass->dev->format = PicopassDeviceSaveFormatLegacy; + scene_manager_next_scene(picopass->scene_manager, PicopassSceneSaveName); + consumed = true; } } else if(event.type == SceneManagerEventTypeBack) { consumed = scene_manager_search_and_switch_to_previous_scene(