From bbf4ed1aaf1706b23861a067e7e3c26bedf36124 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 20 Dec 2023 00:52:37 +0300 Subject: [PATCH] upd picopass --- base_pack/picopass/picopass.c | 11 ++++ base_pack/picopass/picopass_i.h | 3 ++ .../picopass/scenes/picopass_scene_config.h | 1 + .../scenes/picopass_scene_device_info.c | 9 ++++ .../scenes/picopass_scene_more_info.c | 50 +++++++++++++++++++ .../scenes/picopass_scene_read_card_success.c | 8 +-- 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 base_pack/picopass/scenes/picopass_scene_more_info.c diff --git a/base_pack/picopass/picopass.c b/base_pack/picopass/picopass.c index 14855870e65..9b5532e534d 100644 --- a/base_pack/picopass/picopass.c +++ b/base_pack/picopass/picopass.c @@ -76,6 +76,12 @@ Picopass* picopass_alloc() { PicopassViewByteInput, byte_input_get_view(picopass->byte_input)); + // TextBox + picopass->text_box = text_box_alloc(); + view_dispatcher_add_view( + picopass->view_dispatcher, PicopassViewTextBox, text_box_get_view(picopass->text_box)); + picopass->text_box_store = furi_string_alloc(); + // Custom Widget picopass->widget = widget_alloc(); view_dispatcher_add_view( @@ -123,6 +129,11 @@ void picopass_free(Picopass* picopass) { view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewByteInput); byte_input_free(picopass->byte_input); + // TextBox + view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewTextBox); + text_box_free(picopass->text_box); + furi_string_free(picopass->text_box_store); + // Custom Widget view_dispatcher_remove_view(picopass->view_dispatcher, PicopassViewWidget); widget_free(picopass->widget); diff --git a/base_pack/picopass/picopass_i.h b/base_pack/picopass/picopass_i.h index 98d4fa87e3e..dbb1a5d09af 100644 --- a/base_pack/picopass/picopass_i.h +++ b/base_pack/picopass/picopass_i.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,7 @@ struct Picopass { Loading* loading; TextInput* text_input; ByteInput* byte_input; + TextBox* text_box; Widget* widget; DictAttack* dict_attack; Loclass* loclass; @@ -115,6 +117,7 @@ typedef enum { PicopassViewLoading, PicopassViewTextInput, PicopassViewByteInput, + PicopassViewTextBox, PicopassViewWidget, PicopassViewDictAttack, PicopassViewLoclass, diff --git a/base_pack/picopass/scenes/picopass_scene_config.h b/base_pack/picopass/scenes/picopass_scene_config.h index 496591a2d50..0830834f811 100644 --- a/base_pack/picopass/scenes/picopass_scene_config.h +++ b/base_pack/picopass/scenes/picopass_scene_config.h @@ -20,3 +20,4 @@ ADD_SCENE(picopass, emulate, Emulate) ADD_SCENE(picopass, loclass, Loclass) ADD_SCENE(picopass, key_input, KeyInput) ADD_SCENE(picopass, nr_mac_saved, NrMacSaved) +ADD_SCENE(picopass, more_info, MoreInfo) diff --git a/base_pack/picopass/scenes/picopass_scene_device_info.c b/base_pack/picopass/scenes/picopass_scene_device_info.c index de794bb4ba3..2954d3fa079 100644 --- a/base_pack/picopass/scenes/picopass_scene_device_info.c +++ b/base_pack/picopass/scenes/picopass_scene_device_info.c @@ -77,6 +77,12 @@ void picopass_scene_device_info_on_enter(void* context) { "Back", picopass_scene_device_info_widget_callback, picopass); + widget_add_button_element( + picopass->widget, + GuiButtonTypeRight, + "More", + picopass_scene_device_info_widget_callback, + picopass); view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget); } @@ -88,6 +94,9 @@ bool picopass_scene_device_info_on_event(void* context, SceneManagerEvent event) if(event.type == SceneManagerEventTypeCustom) { if(event.event == GuiButtonTypeLeft) { consumed = scene_manager_previous_scene(picopass->scene_manager); + } else if(event.event == GuiButtonTypeRight) { + scene_manager_next_scene(picopass->scene_manager, PicopassSceneMoreInfo); + consumed = true; } else if(event.event == PicopassCustomEventViewExit) { view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewWidget); consumed = true; diff --git a/base_pack/picopass/scenes/picopass_scene_more_info.c b/base_pack/picopass/scenes/picopass_scene_more_info.c new file mode 100644 index 00000000000..f37cdae1fdf --- /dev/null +++ b/base_pack/picopass/scenes/picopass_scene_more_info.c @@ -0,0 +1,50 @@ +#include "../picopass_i.h" +#include + +void picopass_scene_more_info_widget_callback(GuiButtonType result, InputType type, void* context) { + Picopass* picopass = context; + if(type == InputTypeShort) { + view_dispatcher_send_custom_event(picopass->view_dispatcher, result); + } +} + +void picopass_scene_more_info_on_enter(void* context) { + Picopass* picopass = context; + PicopassBlock* AA1 = picopass->dev->dev_data.AA1; + + furi_string_reset(picopass->text_box_store); + + size_t app_limit = MIN(AA1[PICOPASS_CONFIG_BLOCK_INDEX].data[0], PICOPASS_MAX_APP_LIMIT); + FuriString* str = picopass->text_box_store; + + for(size_t i = 0; i < app_limit; i++) { + for(size_t j = 0; j < PICOPASS_BLOCK_LEN; j += 2) { + furi_string_cat_printf(str, "%02X%02X ", AA1[i].data[j], AA1[i].data[j + 1]); + } + } + + text_box_set_font(picopass->text_box, TextBoxFontHex); + text_box_set_text(picopass->text_box, furi_string_get_cstr(picopass->text_box_store)); + view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewTextBox); +} + +bool picopass_scene_more_info_on_event(void* context, SceneManagerEvent event) { + Picopass* picopass = context; + bool consumed = false; + + if(event.type == SceneManagerEventTypeCustom) { + if(event.event == GuiButtonTypeLeft) { + consumed = scene_manager_previous_scene(picopass->scene_manager); + } + } else if(event.type == SceneManagerEventTypeBack) { + consumed = scene_manager_previous_scene(picopass->scene_manager); + } + return consumed; +} + +void picopass_scene_more_info_on_exit(void* context) { + Picopass* picopass = context; + + // Clear views + widget_reset(picopass->widget); +} diff --git a/base_pack/picopass/scenes/picopass_scene_read_card_success.c b/base_pack/picopass/scenes/picopass_scene_read_card_success.c index 88f42eb1322..a2b602a328a 100644 --- a/base_pack/picopass/scenes/picopass_scene_read_card_success.c +++ b/base_pack/picopass/scenes/picopass_scene_read_card_success.c @@ -43,7 +43,8 @@ void picopass_scene_read_card_success_on_enter(void* context) { AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data, 0x00, PICOPASS_BLOCK_LEN); bool empty = picopass_is_memset( AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data, 0xFF, PICOPASS_BLOCK_LEN); - bool sio = 0x30 == AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0]; + bool SE = 0x30 == AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[0]; + bool configCard = (AA1[PICOPASS_ICLASS_PACS_CFG_BLOCK_INDEX].data[7] >> 2 & 3) == 2; if(no_key) { furi_string_cat_printf(wiegand_str, "Read Failed"); @@ -68,7 +69,8 @@ void picopass_scene_read_card_success_on_enter(void* context) { "More", picopass_scene_read_card_success_widget_callback, picopass); - + } else if(configCard) { + furi_string_cat_printf(wiegand_str, "Config Card"); } else if(empty) { furi_string_cat_printf(wiegand_str, "Empty"); widget_add_button_element( @@ -79,7 +81,7 @@ void picopass_scene_read_card_success_on_enter(void* context) { picopass); } else if(pacs->bitLength == 0 || pacs->bitLength == 255) { // Neither of these are valid. Indicates the block was all 0x00 or all 0xff - if(sio) { + if(SE) { furi_string_cat_printf(wiegand_str, "SIO"); } else { furi_string_cat_printf(wiegand_str, "Invalid PACS");