Merge branch 'dev' into ntag-auto-pwd-capture

This commit is contained in:
Yukai Li
2022-10-09 16:18:38 -06:00
158 changed files with 2073 additions and 1535 deletions

View File

@@ -27,7 +27,7 @@ void nfc_scene_mf_classic_keys_list_prepare(Nfc* nfc, MfClassicDict* dict) {
char* current_key = (char*)malloc(sizeof(char) * 13);
strncpy(current_key, furi_string_get_cstr(temp_key), 12);
MfClassicUserKeys_push_back(nfc->mfc_key_strs, current_key);
FURI_LOG_D("ListKeys", "Key %d: %s", index, current_key);
FURI_LOG_D("ListKeys", "Key %ld: %s", index, current_key);
submenu_add_item(
submenu, current_key, index++, nfc_scene_mf_classic_keys_list_submenu_callback, nfc);
}

View File

@@ -28,11 +28,11 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
furi_string_cat_printf(temp_str, "\n%d", bytes_total);
furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
if(data->version.sw_storage & 1) {
furi_string_push_back(temp_str, '+');
}
furi_string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;

View File

@@ -59,11 +59,11 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
MifareDesfireData* data = &dev_data->mf_df_data;
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
furi_string_cat_printf(temp_str, "\n%d", bytes_total);
furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
if(data->version.sw_storage & 1) {
furi_string_push_back(temp_str, '+');
}
furi_string_cat_printf(temp_str, " bytes, %d bytes free\n", bytes_free);
furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;

View File

@@ -64,10 +64,7 @@ static bool detect_reader_input_callback(InputEvent* event, void* context) {
uint8_t nonces = 0;
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
nonces = model->nonces;
return false;
});
detect_reader->view, DetectReaderViewModel * model, { nonces = model->nonces; }, false);
if(event->type == InputTypeShort) {
if(event->key == InputKeyOk) {
@@ -103,12 +100,14 @@ void detect_reader_reset(DetectReader* detect_reader) {
furi_assert(detect_reader);
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
detect_reader->view,
DetectReaderViewModel * model,
{
model->nonces = 0;
model->nonces_max = 0;
model->state = DetectReaderStateStart;
return false;
});
},
false);
}
View* detect_reader_get_view(DetectReader* detect_reader) {
@@ -132,27 +131,24 @@ void detect_reader_set_nonces_max(DetectReader* detect_reader, uint16_t nonces_m
furi_assert(detect_reader);
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
model->nonces_max = nonces_max;
return false;
});
detect_reader->view,
DetectReaderViewModel * model,
{ model->nonces_max = nonces_max; },
false);
}
void detect_reader_set_nonces_collected(DetectReader* detect_reader, uint16_t nonces_collected) {
furi_assert(detect_reader);
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
model->nonces = nonces_collected;
return false;
});
detect_reader->view,
DetectReaderViewModel * model,
{ model->nonces = nonces_collected; },
false);
}
void detect_reader_set_state(DetectReader* detect_reader, DetectReaderState state) {
furi_assert(detect_reader);
with_view_model(
detect_reader->view, (DetectReaderViewModel * model) {
model->state = state;
return true;
});
detect_reader->view, DetectReaderViewModel * model, { model->state = state; }, true);
}

View File

@@ -80,20 +80,20 @@ DictAttack* dict_attack_alloc() {
view_set_input_callback(dict_attack->view, dict_attack_input_callback);
view_set_context(dict_attack->view, dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
model->header = furi_string_alloc();
return false;
});
dict_attack->view,
DictAttackViewModel * model,
{ model->header = furi_string_alloc(); },
false);
return dict_attack;
}
void dict_attack_free(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
furi_string_free(model->header);
return false;
});
dict_attack->view,
DictAttackViewModel * model,
{ furi_string_free(model->header); },
false);
view_free(dict_attack->view);
free(dict_attack);
}
@@ -101,7 +101,9 @@ void dict_attack_free(DictAttack* dict_attack) {
void dict_attack_reset(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
model->state = DictAttackStateRead;
model->type = MfClassicType1k;
model->sectors_total = 0;
@@ -112,8 +114,8 @@ void dict_attack_reset(DictAttack* dict_attack) {
model->dict_keys_total = 0;
model->dict_keys_current = 0;
furi_string_reset(model->header);
return false;
});
},
false);
}
View* dict_attack_get_view(DictAttack* dict_attack) {
@@ -133,99 +135,103 @@ void dict_attack_set_header(DictAttack* dict_attack, const char* header) {
furi_assert(header);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
furi_string_set(model->header, header);
return true;
});
dict_attack->view,
DictAttackViewModel * model,
{ furi_string_set(model->header, header); },
true);
}
void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
model->state = DictAttackStateRead;
model->sectors_total = mf_classic_get_total_sectors_num(type);
model->keys_total = model->sectors_total * 2;
return true;
});
},
true);
}
void dict_attack_set_card_removed(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
model->state = DictAttackStateCardRemoved;
return true;
});
dict_attack->view,
DictAttackViewModel * model,
{ model->state = DictAttackStateCardRemoved; },
true);
}
void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
model->sectors_read = sec_read;
return true;
});
dict_attack->view, DictAttackViewModel * model, { model->sectors_read = sec_read; }, true);
}
void dict_attack_set_keys_found(DictAttack* dict_attack, uint8_t keys_found) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
model->keys_found = keys_found;
return true;
});
dict_attack->view, DictAttackViewModel * model, { model->keys_found = keys_found; }, true);
}
void dict_attack_set_current_sector(DictAttack* dict_attack, uint8_t curr_sec) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
model->sector_current = curr_sec;
model->dict_keys_current = 0;
return true;
});
},
true);
}
void dict_attack_inc_current_sector(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
if(model->sector_current < model->sectors_total) {
model->sector_current++;
model->dict_keys_current = 0;
}
return true;
});
},
true);
}
void dict_attack_inc_keys_found(DictAttack* dict_attack) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
if(model->keys_found < model->keys_total) {
model->keys_found++;
}
return true;
});
},
true);
}
void dict_attack_set_total_dict_keys(DictAttack* dict_attack, uint16_t dict_keys_total) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
model->dict_keys_total = dict_keys_total;
return true;
});
dict_attack->view,
DictAttackViewModel * model,
{ model->dict_keys_total = dict_keys_total; },
true);
}
void dict_attack_inc_current_dict_key(DictAttack* dict_attack, uint16_t keys_tried) {
furi_assert(dict_attack);
with_view_model(
dict_attack->view, (DictAttackViewModel * model) {
dict_attack->view,
DictAttackViewModel * model,
{
if(model->dict_keys_current + keys_tried < model->dict_keys_total) {
model->dict_keys_current += keys_tried;
}
return true;
});
},
true);
}