wifi_marauder_scene_start.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. //** Includes sniffbt and sniffskim for compatible ESP32-WROOM hardware.
  2. //wifi_marauder_app_i.h also changed **//
  3. #include "../wifi_marauder_app_i.h"
  4. // For each command, define whether additional arguments are needed
  5. // (enabling text input to fill them out), and whether the console
  6. // text box should focus at the start of the output or the end
  7. typedef enum { NO_ARGS = 0, INPUT_ARGS, TOGGLE_ARGS } InputArgs;
  8. typedef enum { FOCUS_CONSOLE_END = 0, FOCUS_CONSOLE_START, FOCUS_CONSOLE_TOGGLE } FocusConsole;
  9. #define SHOW_STOPSCAN_TIP (true)
  10. #define NO_TIP (false)
  11. #define MAX_OPTIONS (9)
  12. typedef struct {
  13. const char* item_string;
  14. const char* options_menu[MAX_OPTIONS];
  15. int num_options_menu;
  16. const char* actual_commands[MAX_OPTIONS];
  17. InputArgs needs_keyboard;
  18. FocusConsole focus_console;
  19. bool show_stopscan_tip;
  20. } WifiMarauderItem;
  21. // NUM_MENU_ITEMS defined in wifi_marauder_app_i.h - if you add an entry here, increment it!
  22. const WifiMarauderItem items[NUM_MENU_ITEMS] = {
  23. {"View Log from", {"start", "end"}, 2, {"", ""}, NO_ARGS, FOCUS_CONSOLE_TOGGLE, NO_TIP},
  24. {"Scan",
  25. {"ap", "station"},
  26. 2,
  27. {"scanap", "scansta"},
  28. NO_ARGS,
  29. FOCUS_CONSOLE_END,
  30. SHOW_STOPSCAN_TIP},
  31. {"SSID",
  32. {"add rand", "add name", "remove"},
  33. 3,
  34. {"ssid -a -g", "ssid -a -n", "ssid -r"},
  35. INPUT_ARGS,
  36. FOCUS_CONSOLE_START,
  37. NO_TIP},
  38. {"List",
  39. {"ap", "ssid", "station"},
  40. 3,
  41. {"list -a", "list -s", "list -c"},
  42. NO_ARGS,
  43. FOCUS_CONSOLE_START,
  44. NO_TIP},
  45. {"Select",
  46. {"ap", "ssid", "station"},
  47. 3,
  48. {"select -a", "select -s", "select -c"},
  49. INPUT_ARGS,
  50. FOCUS_CONSOLE_END,
  51. NO_TIP},
  52. {"Clear List",
  53. {"ap", "ssid", "station"},
  54. 3,
  55. {"clearlist -a", "clearlist -s", "clearlist -c"},
  56. NO_ARGS,
  57. FOCUS_CONSOLE_END,
  58. NO_TIP},
  59. {"Attack",
  60. {"deauth", "probe", "rickroll"},
  61. 3,
  62. {"attack -t deauth", "attack -t probe", "attack -t rickroll"},
  63. NO_ARGS,
  64. FOCUS_CONSOLE_END,
  65. SHOW_STOPSCAN_TIP},
  66. {"Targeted Deauth",
  67. {"station", "manual"},
  68. 2,
  69. {"attack -t deauth -c", "attack -t deauth -s"},
  70. TOGGLE_ARGS,
  71. FOCUS_CONSOLE_END,
  72. SHOW_STOPSCAN_TIP},
  73. {"Beacon Spam",
  74. {"ap list", "ssid list", "random"},
  75. 3,
  76. {"attack -t beacon -a", "attack -t beacon -l", "attack -t beacon -r"},
  77. NO_ARGS,
  78. FOCUS_CONSOLE_END,
  79. SHOW_STOPSCAN_TIP},
  80. {"Sniff",
  81. {"beacon", "deauth", "esp", "pmkid", "probe", "pwn", "raw", "bt", "skim"},
  82. 9,
  83. {"sniffbeacon",
  84. "sniffdeauth",
  85. "sniffesp",
  86. "sniffpmkid",
  87. "sniffprobe",
  88. "sniffpwn",
  89. "sniffraw",
  90. "sniffbt",
  91. "sniffskim"},
  92. NO_ARGS,
  93. FOCUS_CONSOLE_END,
  94. SHOW_STOPSCAN_TIP},
  95. {"Signal Monitor", {""}, 1, {"sigmon"}, NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP},
  96. {"Channel",
  97. {"get", "set"},
  98. 2,
  99. {"channel", "channel -s"},
  100. TOGGLE_ARGS,
  101. FOCUS_CONSOLE_END,
  102. NO_TIP},
  103. {"Settings",
  104. {"display", "restore", "ForcePMKID", "ForceProbe", "SavePCAP", "EnableLED", "other"},
  105. 7,
  106. {"settings",
  107. "settings -r",
  108. "settings -s ForcePMKID enable",
  109. "settings -s ForceProbe enable",
  110. "settings -s SavePCAP enable",
  111. "settings -s EnableLED enable",
  112. "settings -s"},
  113. TOGGLE_ARGS,
  114. FOCUS_CONSOLE_START,
  115. NO_TIP},
  116. {"Update", {"ota", "sd"}, 2, {"update -w", "update -s"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
  117. {"Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
  118. {"Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START, SHOW_STOPSCAN_TIP},
  119. {"Scripts", {""}, 1, {""}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
  120. {"Save to flipper sdcard", // keep as last entry or change logic in callback below
  121. {""},
  122. 1,
  123. {""},
  124. NO_ARGS,
  125. FOCUS_CONSOLE_START,
  126. NO_TIP},
  127. };
  128. static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uint32_t index) {
  129. furi_assert(context);
  130. WifiMarauderApp* app = context;
  131. furi_assert(index < NUM_MENU_ITEMS);
  132. const WifiMarauderItem* item = &items[index];
  133. const int selected_option_index = app->selected_option_index[index];
  134. furi_assert(selected_option_index < item->num_options_menu);
  135. app->selected_tx_string = item->actual_commands[selected_option_index];
  136. app->is_command = (1 <= index);
  137. app->is_custom_tx_string = false;
  138. app->selected_menu_index = index;
  139. app->focus_console_start = (item->focus_console == FOCUS_CONSOLE_TOGGLE) ?
  140. (selected_option_index == 0) :
  141. item->focus_console;
  142. app->show_stopscan_tip = item->show_stopscan_tip;
  143. if(!app->is_command && selected_option_index == 0) {
  144. // View Log from start
  145. view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartLogViewer);
  146. return;
  147. }
  148. if(app->selected_tx_string &&
  149. strncmp("sniffpmkid", app->selected_tx_string, strlen("sniffpmkid")) == 0) {
  150. // sniffpmkid submenu
  151. view_dispatcher_send_custom_event(
  152. app->view_dispatcher, WifiMarauderEventStartSniffPmkidOptions);
  153. return;
  154. }
  155. // Select automation script
  156. if(index == NUM_MENU_ITEMS - 2) {
  157. view_dispatcher_send_custom_event(
  158. app->view_dispatcher, WifiMarauderEventStartScriptSelect);
  159. return;
  160. }
  161. if(index == NUM_MENU_ITEMS - 1) {
  162. // "Save to flipper sdcard" special case - start SettingsInit widget
  163. view_dispatcher_send_custom_event(
  164. app->view_dispatcher, WifiMarauderEventStartSettingsInit);
  165. return;
  166. }
  167. bool needs_keyboard = (item->needs_keyboard == TOGGLE_ARGS) ? (selected_option_index != 0) :
  168. item->needs_keyboard;
  169. if(needs_keyboard) {
  170. view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard);
  171. } else {
  172. view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
  173. }
  174. }
  175. static void wifi_marauder_scene_start_var_list_change_callback(VariableItem* item) {
  176. furi_assert(item);
  177. WifiMarauderApp* app = variable_item_get_context(item);
  178. furi_assert(app);
  179. const WifiMarauderItem* menu_item = &items[app->selected_menu_index];
  180. uint8_t item_index = variable_item_get_current_value_index(item);
  181. furi_assert(item_index < menu_item->num_options_menu);
  182. variable_item_set_current_value_text(item, menu_item->options_menu[item_index]);
  183. app->selected_option_index[app->selected_menu_index] = item_index;
  184. }
  185. void wifi_marauder_scene_start_on_enter(void* context) {
  186. WifiMarauderApp* app = context;
  187. VariableItemList* var_item_list = app->var_item_list;
  188. variable_item_list_set_enter_callback(
  189. var_item_list, wifi_marauder_scene_start_var_list_enter_callback, app);
  190. VariableItem* item;
  191. for(int i = 0; i < NUM_MENU_ITEMS; ++i) {
  192. item = variable_item_list_add(
  193. var_item_list,
  194. items[i].item_string,
  195. items[i].num_options_menu,
  196. wifi_marauder_scene_start_var_list_change_callback,
  197. app);
  198. variable_item_set_current_value_index(item, app->selected_option_index[i]);
  199. variable_item_set_current_value_text(
  200. item, items[i].options_menu[app->selected_option_index[i]]);
  201. }
  202. variable_item_list_set_selected_item(
  203. var_item_list, scene_manager_get_scene_state(app->scene_manager, WifiMarauderSceneStart));
  204. view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewVarItemList);
  205. // Wait, if the user hasn't initialized sdcard settings, let's prompt them once (then come back here)
  206. if(app->need_to_prompt_settings_init) {
  207. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSettingsInit);
  208. }
  209. }
  210. bool wifi_marauder_scene_start_on_event(void* context, SceneManagerEvent event) {
  211. UNUSED(context);
  212. WifiMarauderApp* app = context;
  213. bool consumed = false;
  214. if(event.type == SceneManagerEventTypeCustom) {
  215. if(event.event == WifiMarauderEventStartKeyboard) {
  216. scene_manager_set_scene_state(
  217. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  218. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneTextInput);
  219. } else if(event.event == WifiMarauderEventStartConsole) {
  220. scene_manager_set_scene_state(
  221. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  222. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput);
  223. } else if(event.event == WifiMarauderEventStartSettingsInit) {
  224. scene_manager_set_scene_state(
  225. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  226. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSettingsInit);
  227. } else if(event.event == WifiMarauderEventStartLogViewer) {
  228. scene_manager_set_scene_state(
  229. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  230. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneLogViewer);
  231. } else if(event.event == WifiMarauderEventStartScriptSelect) {
  232. scene_manager_set_scene_state(
  233. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  234. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneScriptSelect);
  235. } else if(event.event == WifiMarauderEventStartSniffPmkidOptions) {
  236. scene_manager_set_scene_state(
  237. app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
  238. scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSniffPmkidOptions);
  239. }
  240. consumed = true;
  241. } else if(event.type == SceneManagerEventTypeTick) {
  242. app->selected_menu_index = variable_item_list_get_selected_item_index(app->var_item_list);
  243. consumed = true;
  244. } else if(event.type == SceneManagerEventTypeBack) {
  245. scene_manager_stop(app->scene_manager);
  246. view_dispatcher_stop(app->view_dispatcher);
  247. consumed = true;
  248. }
  249. return consumed;
  250. }
  251. void wifi_marauder_scene_start_on_exit(void* context) {
  252. WifiMarauderApp* app = context;
  253. variable_item_list_reset(app->var_item_list);
  254. }