2022-09-01 15:03:18 +00:00
|
|
|
#include "flipfrid_scene_run_attack.h"
|
2022-09-08 02:00:53 +00:00
|
|
|
#include <gui/elements.h>
|
2022-09-01 15:03:18 +00:00
|
|
|
|
|
|
|
uint8_t counter = 0;
|
2022-10-04 20:43:15 +00:00
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
uint8_t id_list[17][5] = {
|
2022-09-01 15:03:18 +00:00
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00}, // Null bytes
|
|
|
|
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, // Only FF
|
|
|
|
{0x11, 0x11, 0x11, 0x11, 0x11}, // Only 11
|
|
|
|
{0x22, 0x22, 0x22, 0x22, 0x22}, // Only 22
|
|
|
|
{0x33, 0x33, 0x33, 0x33, 0x33}, // Only 33
|
|
|
|
{0x44, 0x44, 0x44, 0x44, 0x44}, // Only 44
|
|
|
|
{0x55, 0x55, 0x55, 0x55, 0x55}, // Only 55
|
|
|
|
{0x66, 0x66, 0x66, 0x66, 0x66}, // Only 66
|
|
|
|
{0x77, 0x77, 0x77, 0x77, 0x77}, // Only 77
|
|
|
|
{0x88, 0x88, 0x88, 0x88, 0x88}, // Only 88
|
|
|
|
{0x99, 0x99, 0x99, 0x99, 0x99}, // Only 99
|
|
|
|
{0x12, 0x34, 0x56, 0x78, 0x9A}, // Incremental UID
|
2022-09-20 18:45:16 +00:00
|
|
|
{0x9A, 0x78, 0x56, 0x34, 0x12}, // Decremental UID
|
2022-09-01 15:03:18 +00:00
|
|
|
{0x04, 0xd0, 0x9b, 0x0d, 0x6a}, // From arha
|
|
|
|
{0x34, 0x00, 0x29, 0x3d, 0x9e}, // From arha
|
|
|
|
{0x04, 0xdf, 0x00, 0x00, 0x01}, // From arha
|
|
|
|
{0xCA, 0xCA, 0xCA, 0xCA, 0xCA}, // From arha
|
|
|
|
};
|
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
uint8_t id_list_hid[14][6] = {
|
|
|
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // Null bytes
|
|
|
|
{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, // Only FF
|
|
|
|
{0x11, 0x11, 0x11, 0x11, 0x11, 0x11}, // Only 11
|
|
|
|
{0x22, 0x22, 0x22, 0x22, 0x22, 0x22}, // Only 22
|
|
|
|
{0x33, 0x33, 0x33, 0x33, 0x33, 0x33}, // Only 33
|
|
|
|
{0x44, 0x44, 0x44, 0x44, 0x44, 0x44}, // Only 44
|
|
|
|
{0x55, 0x55, 0x55, 0x55, 0x55, 0x55}, // Only 55
|
|
|
|
{0x66, 0x66, 0x66, 0x66, 0x66, 0x66}, // Only 66
|
|
|
|
{0x77, 0x77, 0x77, 0x77, 0x77, 0x77}, // Only 77
|
|
|
|
{0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, // Only 88
|
|
|
|
{0x99, 0x99, 0x99, 0x99, 0x99, 0x99}, // Only 99
|
|
|
|
{0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC}, // Incremental UID
|
|
|
|
{0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12}, // Decremental UID
|
|
|
|
{0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA}, // From arha
|
|
|
|
};
|
|
|
|
|
2022-10-03 23:30:36 +00:00
|
|
|
uint8_t id_list_pac[17][4] = {
|
|
|
|
{0x00, 0x00, 0x00, 0x00}, // Null bytes
|
|
|
|
{0xFF, 0xFF, 0xFF, 0xFF}, // Only FF
|
|
|
|
{0x11, 0x11, 0x11, 0x11}, // Only 11
|
|
|
|
{0x22, 0x22, 0x22, 0x22}, // Only 22
|
|
|
|
{0x33, 0x33, 0x33, 0x33}, // Only 33
|
|
|
|
{0x44, 0x44, 0x44, 0x44}, // Only 44
|
|
|
|
{0x55, 0x55, 0x55, 0x55}, // Only 55
|
|
|
|
{0x66, 0x66, 0x66, 0x66}, // Only 66
|
|
|
|
{0x77, 0x77, 0x77, 0x77}, // Only 77
|
|
|
|
{0x88, 0x88, 0x88, 0x88}, // Only 88
|
|
|
|
{0x99, 0x99, 0x99, 0x99}, // Only 99
|
|
|
|
{0x12, 0x34, 0x56, 0x78}, // Incremental UID
|
|
|
|
{0x9A, 0x78, 0x56, 0x34}, // Decremental UID
|
|
|
|
{0x04, 0xd0, 0x9b, 0x0d}, // From arha
|
|
|
|
{0x34, 0x00, 0x29, 0x3d}, // From arha
|
|
|
|
{0x04, 0xdf, 0x00, 0x00}, // From arha
|
|
|
|
{0xCA, 0xCA, 0xCA, 0xCA}, // From arha
|
|
|
|
};
|
|
|
|
|
2022-10-04 00:15:28 +00:00
|
|
|
uint8_t id_list_h[14][3] = {
|
|
|
|
{0x00, 0x00, 0x00}, // Null bytes
|
|
|
|
{0xFF, 0xFF, 0xFF}, // Only FF
|
|
|
|
{0x11, 0x11, 0x11}, // Only 11
|
|
|
|
{0x22, 0x22, 0x22}, // Only 22
|
|
|
|
{0x33, 0x33, 0x33}, // Only 33
|
|
|
|
{0x44, 0x44, 0x44}, // Only 44
|
|
|
|
{0x55, 0x55, 0x55}, // Only 55
|
|
|
|
{0x66, 0x66, 0x66}, // Only 66
|
|
|
|
{0x77, 0x77, 0x77}, // Only 77
|
|
|
|
{0x88, 0x88, 0x88}, // Only 88
|
|
|
|
{0x99, 0x99, 0x99}, // Only 99
|
|
|
|
{0x12, 0x34, 0x56}, // Incremental UID
|
|
|
|
{0x56, 0x34, 0x12}, // Decremental UID
|
|
|
|
{0xCA, 0xCA, 0xCA}, // From arha
|
|
|
|
};
|
|
|
|
|
2022-09-01 15:03:18 +00:00
|
|
|
void flipfrid_scene_run_attack_on_enter(FlipFridState* context) {
|
2022-10-04 20:43:15 +00:00
|
|
|
context->time_between_cards = 10;
|
2022-09-01 15:03:18 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
context->dict = protocol_dict_alloc(lfrfid_protocols, LFRFIDProtocolMax);
|
|
|
|
context->worker = lfrfid_worker_alloc(context->dict);
|
2022-09-21 05:43:07 +00:00
|
|
|
if(context->proto == HIDProx) {
|
|
|
|
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "HIDProx");
|
2022-10-03 23:30:36 +00:00
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "PAC/Stanley");
|
2022-10-04 00:15:28 +00:00
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "H10301");
|
2022-09-21 05:43:07 +00:00
|
|
|
} else {
|
|
|
|
context->protocol = protocol_dict_get_protocol_by_name(context->dict, "EM4100");
|
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flipfrid_scene_run_attack_on_exit(FlipFridState* context) {
|
2022-11-12 23:56:32 +00:00
|
|
|
if(context->workr_rund) {
|
|
|
|
lfrfid_worker_stop(context->worker);
|
|
|
|
lfrfid_worker_stop_thread(context->worker);
|
|
|
|
context->workr_rund = false;
|
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
lfrfid_worker_free(context->worker);
|
|
|
|
protocol_dict_free(context->dict);
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void flipfrid_scene_run_attack_on_tick(FlipFridState* context) {
|
|
|
|
if(context->is_attacking) {
|
|
|
|
if(1 == counter) {
|
2022-09-20 18:45:16 +00:00
|
|
|
protocol_dict_set_data(context->dict, context->protocol, context->payload, 6);
|
2022-09-04 21:32:58 +00:00
|
|
|
lfrfid_worker_free(context->worker);
|
2022-09-01 15:03:18 +00:00
|
|
|
context->worker = lfrfid_worker_alloc(context->dict);
|
|
|
|
lfrfid_worker_start_thread(context->worker);
|
2022-09-04 21:32:58 +00:00
|
|
|
lfrfid_worker_emulate_start(context->worker, context->protocol);
|
2022-11-12 23:56:32 +00:00
|
|
|
context->workr_rund = true;
|
2022-09-01 15:03:18 +00:00
|
|
|
} else if(0 == counter) {
|
2022-11-12 23:56:32 +00:00
|
|
|
if(context->workr_rund) {
|
|
|
|
lfrfid_worker_stop(context->worker);
|
|
|
|
lfrfid_worker_stop_thread(context->worker);
|
|
|
|
context->workr_rund = false;
|
2022-11-15 01:42:54 +00:00
|
|
|
furi_delay_ms(200);
|
2022-11-12 23:56:32 +00:00
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
switch(context->attack) {
|
|
|
|
case FlipFridAttackDefaultValues:
|
2022-09-20 18:45:16 +00:00
|
|
|
if(context->proto == EM4100) {
|
|
|
|
context->payload[0] = id_list[context->attack_step][0];
|
|
|
|
context->payload[1] = id_list[context->attack_step][1];
|
|
|
|
context->payload[2] = id_list[context->attack_step][2];
|
|
|
|
context->payload[3] = id_list[context->attack_step][3];
|
|
|
|
context->payload[4] = id_list[context->attack_step][4];
|
|
|
|
|
2022-10-03 23:30:36 +00:00
|
|
|
if(context->attack_step == 16) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
context->payload[0] = id_list_pac[context->attack_step][0];
|
|
|
|
context->payload[1] = id_list_pac[context->attack_step][1];
|
|
|
|
context->payload[2] = id_list_pac[context->attack_step][2];
|
|
|
|
context->payload[3] = id_list_pac[context->attack_step][3];
|
|
|
|
|
|
|
|
if(context->attack_step == 16) {
|
2022-09-20 18:45:16 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
2022-10-04 00:15:28 +00:00
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
context->payload[0] = id_list_h[context->attack_step][0];
|
|
|
|
context->payload[1] = id_list_h[context->attack_step][1];
|
|
|
|
context->payload[2] = id_list_h[context->attack_step][2];
|
|
|
|
|
|
|
|
if(context->attack_step == 13) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
} else {
|
2022-09-20 18:45:16 +00:00
|
|
|
context->payload[0] = id_list_hid[context->attack_step][0];
|
|
|
|
context->payload[1] = id_list_hid[context->attack_step][1];
|
|
|
|
context->payload[2] = id_list_hid[context->attack_step][2];
|
|
|
|
context->payload[3] = id_list_hid[context->attack_step][3];
|
|
|
|
context->payload[4] = id_list_hid[context->attack_step][4];
|
|
|
|
context->payload[5] = id_list_hid[context->attack_step][5];
|
2022-09-20 20:24:34 +00:00
|
|
|
|
2022-10-03 23:30:36 +00:00
|
|
|
if(context->attack_step == 13) {
|
2022-09-20 18:45:16 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case FlipFridAttackBfCustomerId:
|
2022-09-20 18:45:16 +00:00
|
|
|
if(context->proto == EM4100) {
|
|
|
|
context->payload[0] = context->attack_step;
|
|
|
|
context->payload[1] = 0x00;
|
|
|
|
context->payload[2] = 0x00;
|
|
|
|
context->payload[3] = 0x00;
|
|
|
|
context->payload[4] = 0x00;
|
|
|
|
|
2022-10-03 23:30:36 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
context->payload[0] = context->attack_step;
|
|
|
|
context->payload[1] = 0x00;
|
|
|
|
context->payload[2] = 0x00;
|
|
|
|
context->payload[3] = 0x00;
|
|
|
|
|
2022-10-04 00:15:28 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
context->payload[0] = context->attack_step;
|
|
|
|
context->payload[1] = 0x00;
|
|
|
|
context->payload[2] = 0x00;
|
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
} else {
|
2022-09-20 18:45:16 +00:00
|
|
|
context->payload[0] = context->attack_step;
|
|
|
|
context->payload[1] = 0x00;
|
|
|
|
context->payload[2] = 0x00;
|
|
|
|
context->payload[3] = 0x00;
|
|
|
|
context->payload[4] = 0x00;
|
|
|
|
context->payload[5] = 0x00;
|
|
|
|
|
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
2022-09-20 20:24:34 +00:00
|
|
|
|
2022-09-01 15:03:18 +00:00
|
|
|
case FlipFridAttackLoadFile:
|
2022-09-20 18:45:16 +00:00
|
|
|
if(context->proto == EM4100) {
|
|
|
|
context->payload[0] = context->data[0];
|
|
|
|
context->payload[1] = context->data[1];
|
|
|
|
context->payload[2] = context->data[2];
|
|
|
|
context->payload[3] = context->data[3];
|
|
|
|
context->payload[4] = context->data[4];
|
2022-09-01 15:03:18 +00:00
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
context->payload[context->key_index] = context->attack_step;
|
|
|
|
|
2022-10-03 23:30:36 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
context->payload[0] = context->data[0];
|
|
|
|
context->payload[1] = context->data[1];
|
|
|
|
context->payload[2] = context->data[2];
|
|
|
|
context->payload[3] = context->data[3];
|
|
|
|
|
|
|
|
context->payload[context->key_index] = context->attack_step;
|
|
|
|
|
2022-10-04 00:15:28 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
context->payload[0] = context->data[0];
|
|
|
|
context->payload[1] = context->data[1];
|
|
|
|
context->payload[2] = context->data[2];
|
|
|
|
|
|
|
|
context->payload[context->key_index] = context->attack_step;
|
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
if(context->attack_step == 255) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
2022-09-04 21:32:58 +00:00
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
} else {
|
2022-09-20 18:45:16 +00:00
|
|
|
context->payload[0] = context->data[0];
|
|
|
|
context->payload[1] = context->data[1];
|
|
|
|
context->payload[2] = context->data[2];
|
|
|
|
context->payload[3] = context->data[3];
|
|
|
|
context->payload[4] = context->data[4];
|
|
|
|
context->payload[5] = context->data[5];
|
|
|
|
|
|
|
|
context->payload[context->key_index] = context->attack_step;
|
|
|
|
|
|
|
|
if(context->attack_step == 255) {
|
2022-09-04 21:32:58 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
break;
|
2022-09-20 18:45:16 +00:00
|
|
|
} else {
|
|
|
|
context->attack_step++;
|
|
|
|
}
|
2022-09-04 21:32:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-09-20 18:45:16 +00:00
|
|
|
|
|
|
|
case FlipFridAttackLoadFileCustomUids:
|
|
|
|
if(context->proto == EM4100) {
|
2022-10-03 23:30:36 +00:00
|
|
|
bool end_of_list = false;
|
2022-09-20 18:45:16 +00:00
|
|
|
while(true) {
|
2022-10-05 18:27:13 +00:00
|
|
|
furi_string_reset(context->data_str);
|
2022-09-20 18:45:16 +00:00
|
|
|
if(!stream_read_line(context->uids_stream, context->data_str)) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
2022-10-03 22:15:15 +00:00
|
|
|
stream_rewind(context->uids_stream);
|
2022-10-03 23:30:36 +00:00
|
|
|
end_of_list = true;
|
2022-09-20 18:45:16 +00:00
|
|
|
break;
|
|
|
|
};
|
2022-10-05 18:27:13 +00:00
|
|
|
if(furi_string_get_char(context->data_str, 0) == '#') continue;
|
|
|
|
if(furi_string_size(context->data_str) != 11) break;
|
2022-09-20 18:45:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-10-03 23:30:36 +00:00
|
|
|
if(end_of_list) break;
|
2022-10-05 18:27:13 +00:00
|
|
|
FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
|
|
|
|
if(furi_string_size(context->data_str) != 11) {
|
2022-10-03 23:30:36 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_error);
|
|
|
|
break;
|
|
|
|
};
|
2022-09-20 18:45:16 +00:00
|
|
|
|
|
|
|
// string is valid, parse it in context->payload
|
|
|
|
for(uint8_t i = 0; i < 5; i++) {
|
|
|
|
char temp_str[3];
|
2022-10-05 18:27:13 +00:00
|
|
|
temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
|
|
|
|
temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
|
2022-09-20 18:45:16 +00:00
|
|
|
temp_str[2] = '\0';
|
|
|
|
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
|
}
|
|
|
|
break;
|
2022-10-03 23:30:36 +00:00
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
bool end_of_list = false;
|
|
|
|
while(true) {
|
2022-10-05 18:27:13 +00:00
|
|
|
furi_string_reset(context->data_str);
|
2022-10-03 23:30:36 +00:00
|
|
|
if(!stream_read_line(context->uids_stream, context->data_str)) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
stream_rewind(context->uids_stream);
|
|
|
|
end_of_list = true;
|
|
|
|
break;
|
|
|
|
};
|
2022-10-05 18:27:13 +00:00
|
|
|
if(furi_string_get_char(context->data_str, 0) == '#') continue;
|
|
|
|
if(furi_string_size(context->data_str) != 9) break;
|
2022-10-03 23:30:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(end_of_list) break;
|
2022-10-05 18:27:13 +00:00
|
|
|
FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
|
|
|
|
if(furi_string_size(context->data_str) != 9) {
|
2022-10-03 23:30:36 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_error);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
// string is valid, parse it in context->payload
|
|
|
|
for(uint8_t i = 0; i < 4; i++) {
|
|
|
|
char temp_str[3];
|
2022-10-05 18:27:13 +00:00
|
|
|
temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
|
|
|
|
temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
|
2022-10-03 23:30:36 +00:00
|
|
|
temp_str[2] = '\0';
|
|
|
|
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
|
}
|
|
|
|
break;
|
2022-10-04 00:15:28 +00:00
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
bool end_of_list = false;
|
|
|
|
while(true) {
|
2022-10-05 18:27:13 +00:00
|
|
|
furi_string_reset(context->data_str);
|
2022-10-04 00:15:28 +00:00
|
|
|
if(!stream_read_line(context->uids_stream, context->data_str)) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
stream_rewind(context->uids_stream);
|
|
|
|
end_of_list = true;
|
|
|
|
break;
|
|
|
|
};
|
2022-10-05 18:27:13 +00:00
|
|
|
if(furi_string_get_char(context->data_str, 0) == '#') continue;
|
|
|
|
if(furi_string_size(context->data_str) != 7) break;
|
2022-10-04 00:15:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(end_of_list) break;
|
2022-10-05 18:27:13 +00:00
|
|
|
FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
|
|
|
|
if(furi_string_size(context->data_str) != 7) {
|
2022-10-04 00:15:28 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_error);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
// string is valid, parse it in context->payload
|
|
|
|
for(uint8_t i = 0; i < 3; i++) {
|
|
|
|
char temp_str[3];
|
2022-10-05 18:27:13 +00:00
|
|
|
temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
|
|
|
|
temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
|
2022-10-04 00:15:28 +00:00
|
|
|
temp_str[2] = '\0';
|
|
|
|
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
|
}
|
|
|
|
break;
|
2022-09-20 18:45:16 +00:00
|
|
|
} else {
|
2022-10-03 23:30:36 +00:00
|
|
|
bool end_of_list = false;
|
2022-09-20 18:45:16 +00:00
|
|
|
while(true) {
|
2022-10-05 18:27:13 +00:00
|
|
|
furi_string_reset(context->data_str);
|
2022-09-20 18:45:16 +00:00
|
|
|
if(!stream_read_line(context->uids_stream, context->data_str)) {
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
2022-10-03 22:15:15 +00:00
|
|
|
stream_rewind(context->uids_stream);
|
2022-10-03 23:30:36 +00:00
|
|
|
end_of_list = true;
|
2022-09-20 18:45:16 +00:00
|
|
|
break;
|
|
|
|
};
|
2022-10-05 18:27:13 +00:00
|
|
|
if(furi_string_get_char(context->data_str, 0) == '#') continue;
|
|
|
|
if(furi_string_size(context->data_str) != 13) break;
|
2022-09-20 18:45:16 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-10-05 18:27:13 +00:00
|
|
|
FURI_LOG_D(TAG, furi_string_get_cstr(context->data_str));
|
2022-10-03 23:30:36 +00:00
|
|
|
if(end_of_list) break;
|
2022-10-05 18:27:13 +00:00
|
|
|
if(furi_string_size(context->data_str) != 13) {
|
2022-10-03 23:30:36 +00:00
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_error);
|
|
|
|
break;
|
|
|
|
};
|
2022-09-20 18:45:16 +00:00
|
|
|
|
|
|
|
// string is valid, parse it in context->payload
|
|
|
|
for(uint8_t i = 0; i < 6; i++) {
|
|
|
|
char temp_str[3];
|
2022-10-05 18:27:13 +00:00
|
|
|
temp_str[0] = furi_string_get_cstr(context->data_str)[i * 2];
|
|
|
|
temp_str[1] = furi_string_get_cstr(context->data_str)[i * 2 + 1];
|
2022-09-20 18:45:16 +00:00
|
|
|
temp_str[2] = '\0';
|
|
|
|
context->payload[i] = (uint8_t)strtol(temp_str, NULL, 16);
|
|
|
|
}
|
|
|
|
break;
|
2022-09-04 21:32:58 +00:00
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-04 20:43:15 +00:00
|
|
|
|
|
|
|
if(counter > context->time_between_cards) {
|
|
|
|
counter = 0;
|
2022-09-03 20:10:07 +00:00
|
|
|
} else {
|
2022-10-04 20:43:15 +00:00
|
|
|
counter++;
|
2022-09-03 20:10:07 +00:00
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void flipfrid_scene_run_attack_on_event(FlipFridEvent event, FlipFridState* context) {
|
|
|
|
if(event.evt_type == EventTypeKey) {
|
|
|
|
if(event.input_type == InputTypeShort) {
|
|
|
|
switch(event.key) {
|
|
|
|
case InputKeyDown:
|
2022-10-04 20:43:15 +00:00
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
case InputKeyUp:
|
2022-10-04 20:43:15 +00:00
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
case InputKeyLeft:
|
2022-10-04 20:43:15 +00:00
|
|
|
if(!context->is_attacking) {
|
2022-11-15 01:42:54 +00:00
|
|
|
if(context->time_between_cards > 5) {
|
2022-10-04 20:43:15 +00:00
|
|
|
context->time_between_cards--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
case InputKeyRight:
|
2022-10-04 20:43:15 +00:00
|
|
|
if(!context->is_attacking) {
|
2022-11-11 14:05:33 +00:00
|
|
|
if(context->time_between_cards < 70) {
|
2022-10-04 20:43:15 +00:00
|
|
|
context->time_between_cards++;
|
|
|
|
}
|
|
|
|
}
|
2022-09-03 20:10:07 +00:00
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
case InputKeyOk:
|
|
|
|
counter = 0;
|
|
|
|
if(!context->is_attacking) {
|
|
|
|
notification_message(context->notify, &sequence_blink_start_blue);
|
|
|
|
context->is_attacking = true;
|
|
|
|
} else {
|
|
|
|
context->is_attacking = false;
|
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
|
|
|
notification_message(context->notify, &sequence_single_vibro);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case InputKeyBack:
|
2022-10-11 00:39:48 +00:00
|
|
|
context->is_attacking = false;
|
|
|
|
context->attack_step = 0;
|
|
|
|
counter = 0;
|
|
|
|
|
2022-09-04 21:32:58 +00:00
|
|
|
if(context->attack == FlipFridAttackLoadFileCustomUids) {
|
2022-10-10 13:43:31 +00:00
|
|
|
furi_string_reset(context->data_str);
|
|
|
|
stream_rewind(context->uids_stream);
|
2022-09-04 21:32:58 +00:00
|
|
|
buffered_file_stream_close(context->uids_stream);
|
|
|
|
}
|
|
|
|
|
2022-10-05 18:27:13 +00:00
|
|
|
furi_string_reset(context->notification_msg);
|
2022-09-01 15:03:18 +00:00
|
|
|
notification_message(context->notify, &sequence_blink_stop);
|
2022-10-10 13:43:31 +00:00
|
|
|
context->current_scene = SceneEntryPoint;
|
2022-09-01 15:03:18 +00:00
|
|
|
break;
|
2022-11-02 20:07:00 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-11 14:05:33 +00:00
|
|
|
if(event.input_type == InputTypeLong) {
|
|
|
|
switch(event.key) {
|
|
|
|
case InputKeyLeft:
|
|
|
|
if(!context->is_attacking) {
|
|
|
|
if(context->time_between_cards > 0) {
|
2022-11-15 01:42:54 +00:00
|
|
|
if((context->time_between_cards - 10) > 5) {
|
|
|
|
context->time_between_cards -= 10;
|
|
|
|
}
|
2022-11-11 14:05:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case InputKeyRight:
|
|
|
|
if(!context->is_attacking) {
|
|
|
|
if(context->time_between_cards < 70) {
|
|
|
|
context->time_between_cards += 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void flipfrid_scene_run_attack_on_draw(Canvas* canvas, FlipFridState* context) {
|
|
|
|
canvas_clear(canvas);
|
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
|
|
|
|
|
|
// Frame
|
2022-09-08 02:00:53 +00:00
|
|
|
//canvas_draw_frame(canvas, 0, 0, 128, 64);
|
2022-09-01 15:03:18 +00:00
|
|
|
|
|
|
|
// Title
|
|
|
|
canvas_set_font(canvas, FontPrimary);
|
|
|
|
canvas_draw_str_aligned(
|
2022-10-05 18:27:13 +00:00
|
|
|
canvas, 64, 2, AlignCenter, AlignTop, furi_string_get_cstr(context->attack_name));
|
2022-09-20 20:24:34 +00:00
|
|
|
|
2022-09-20 18:45:16 +00:00
|
|
|
char uid[18];
|
2022-10-04 20:43:15 +00:00
|
|
|
char speed[16];
|
2022-09-21 05:43:07 +00:00
|
|
|
if(context->proto == HIDProx) {
|
2022-09-20 18:45:16 +00:00
|
|
|
snprintf(
|
2022-09-20 20:24:34 +00:00
|
|
|
uid,
|
|
|
|
sizeof(uid),
|
|
|
|
"%02X:%02X:%02X:%02X:%02X:%02X",
|
|
|
|
context->payload[0],
|
|
|
|
context->payload[1],
|
|
|
|
context->payload[2],
|
|
|
|
context->payload[3],
|
|
|
|
context->payload[4],
|
|
|
|
context->payload[5]);
|
2022-10-03 23:30:36 +00:00
|
|
|
} else if(context->proto == PAC) {
|
|
|
|
snprintf(
|
|
|
|
uid,
|
|
|
|
sizeof(uid),
|
|
|
|
"%02X:%02X:%02X:%02X",
|
|
|
|
context->payload[0],
|
|
|
|
context->payload[1],
|
|
|
|
context->payload[2],
|
|
|
|
context->payload[3]);
|
2022-10-04 00:15:28 +00:00
|
|
|
} else if(context->proto == H10301) {
|
|
|
|
snprintf(
|
|
|
|
uid,
|
|
|
|
sizeof(uid),
|
|
|
|
"%02X:%02X:%02X",
|
|
|
|
context->payload[0],
|
|
|
|
context->payload[1],
|
|
|
|
context->payload[2]);
|
2022-09-20 18:45:16 +00:00
|
|
|
} else {
|
|
|
|
snprintf(
|
2022-09-20 20:24:34 +00:00
|
|
|
uid,
|
|
|
|
sizeof(uid),
|
|
|
|
"%02X:%02X:%02X:%02X:%02X",
|
|
|
|
context->payload[0],
|
|
|
|
context->payload[1],
|
|
|
|
context->payload[2],
|
|
|
|
context->payload[3],
|
|
|
|
context->payload[4]);
|
2022-09-20 18:45:16 +00:00
|
|
|
}
|
2022-09-20 20:24:34 +00:00
|
|
|
|
2022-10-04 20:43:15 +00:00
|
|
|
canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignTop, uid);
|
2022-09-01 15:03:18 +00:00
|
|
|
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
2022-10-03 23:30:36 +00:00
|
|
|
|
|
|
|
canvas_draw_str_aligned(
|
2022-10-05 18:27:13 +00:00
|
|
|
canvas, 64, 26, AlignCenter, AlignTop, furi_string_get_cstr(context->proto_name));
|
2022-10-04 20:43:15 +00:00
|
|
|
|
|
|
|
snprintf(speed, sizeof(speed), "Time delay: %d", context->time_between_cards);
|
|
|
|
|
|
|
|
//canvas_draw_str_aligned(canvas, 0, 22, AlignLeft, AlignTop, "Speed:");
|
|
|
|
canvas_draw_str_aligned(canvas, 64, 14, AlignCenter, AlignTop, speed);
|
2022-09-08 02:00:53 +00:00
|
|
|
//char start_stop_msg[20];
|
2022-09-01 15:03:18 +00:00
|
|
|
if(context->is_attacking) {
|
2022-09-08 02:00:53 +00:00
|
|
|
elements_button_center(canvas, "Stop");
|
|
|
|
//snprintf(start_stop_msg, sizeof(start_stop_msg), " Press OK to stop ");
|
2022-09-01 15:03:18 +00:00
|
|
|
} else {
|
2022-09-08 02:00:53 +00:00
|
|
|
elements_button_center(canvas, "Start");
|
2022-10-04 20:43:15 +00:00
|
|
|
elements_button_left(canvas, "TD -");
|
|
|
|
elements_button_right(canvas, "+ TD");
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|
2022-09-08 02:00:53 +00:00
|
|
|
//canvas_draw_str_aligned(canvas, 64, 44, AlignCenter, AlignTop, start_stop_msg);
|
2022-09-01 15:03:18 +00:00
|
|
|
}
|