blackhat_scene_start.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #include "../blackhat_app_i.h"
  2. BlackhatItem items[] = {
  3. {"Shell", {""}, 1, NULL, SHELL_CMD, false},
  4. {"Scan for Scripts", {""}, 1, NULL, SCAN_CMD, false},
  5. {"Run Script", {""}, 1, NULL, RUN_CMD, false},
  6. {"Connect WiFi", {""}, 1, NULL, WIFI_CON_CMD, FOCUS_CONSOLE_END},
  7. {"Set inet SSID", {""}, 1, NULL, SET_INET_SSID_CMD, true},
  8. {"Set inet Password", {""}, 1, NULL, SET_INET_PWD_CMD, true},
  9. {"Set AP SSID", {""}, 1, NULL, SET_AP_SSID_CMD, true},
  10. {"List Networks",
  11. {"wlan0", "wlan1", "wlan2"},
  12. 3,
  13. NULL,
  14. LIST_AP_CMD,
  15. FOCUS_CONSOLE_END},
  16. {"Wifi Device Info", {""}, 1, NULL, DEV_CMD, false},
  17. {"Enable AP", {""}, 1, NULL, START_AP_CMD, FOCUS_CONSOLE_END},
  18. {"Start Kismet",
  19. {"wlan0", "wlan1", "wlan2"},
  20. 3,
  21. NULL,
  22. START_KISMET_CMD,
  23. FOCUS_CONSOLE_END},
  24. {"Get IP", {""}, 1, NULL, GET_IP_CMD, false},
  25. {"Enable SSH", {""}, 1, NULL, START_SSH_CMD, false},
  26. {"Start Evil Twin", {""}, 1, NULL, ST_EVIL_TWIN_CMD, false},
  27. {"Start Evil Portal", {""}, 1, NULL, ST_EVIL_PORT_CMD, false},
  28. {"Test Internet (ping)", {""}, 1, NULL, TEST_INET, false},
  29. {"Get Params", {""}, 1, NULL, GET_CMD, false},
  30. {"Reboot", {""}, 1, NULL, REBOOT_CMD, false},
  31. };
  32. static void blackhat_scene_start_var_list_enter_callback(
  33. void* context, uint32_t index
  34. )
  35. {
  36. furi_assert(context);
  37. BlackhatApp* app = context;
  38. furi_assert(index < NUM_MENU_ITEMS);
  39. const BlackhatItem* item = &items[index];
  40. const int selected_option_index = app->selected_option_index[index];
  41. furi_assert(selected_option_index < item->num_options_menu);
  42. app->selected_tx_string = item->actual_command;
  43. app->text_input_req = item->text_input_req;
  44. app->selected_menu_index = index;
  45. app->selected_option_item_text = item->selected_option;
  46. scene_manager_next_scene(
  47. app->scene_manager, BlackhatAppViewConsoleOutput
  48. );
  49. }
  50. static void blackhat_scene_start_var_list_change_callback(VariableItem* item)
  51. {
  52. furi_assert(item);
  53. BlackhatApp* app = variable_item_get_context(item);
  54. furi_assert(app);
  55. const BlackhatItem* menu_item = &items[app->selected_menu_index];
  56. uint8_t item_index = variable_item_get_current_value_index(item);
  57. furi_assert(item_index < menu_item->num_options_menu);
  58. variable_item_set_current_value_text(
  59. item, menu_item->options_menu[item_index]
  60. );
  61. items[app->selected_menu_index].selected_option =
  62. menu_item->options_menu[item_index];
  63. app->selected_option_index[app->selected_menu_index] = item_index;
  64. }
  65. void blackhat_scene_start_on_enter(void* context)
  66. {
  67. BlackhatApp* app = context;
  68. VariableItemList* var_item_list = app->var_item_list;
  69. variable_item_list_set_enter_callback(
  70. var_item_list, blackhat_scene_start_var_list_enter_callback, app
  71. );
  72. VariableItem* item;
  73. for (int i = 0; i < NUM_MENU_ITEMS; ++i) {
  74. item = variable_item_list_add(
  75. var_item_list,
  76. items[i].item_string,
  77. items[i].num_options_menu,
  78. blackhat_scene_start_var_list_change_callback,
  79. app
  80. );
  81. items[i].selected_option = items[i].options_menu[0];
  82. variable_item_set_current_value_index(
  83. item, app->selected_option_index[i]
  84. );
  85. variable_item_set_current_value_text(
  86. item, items[i].options_menu[app->selected_option_index[i]]
  87. );
  88. }
  89. view_dispatcher_switch_to_view(
  90. app->view_dispatcher, BlackhatAppViewVarItemList
  91. );
  92. }
  93. bool blackhat_scene_start_on_event(void* context, SceneManagerEvent event)
  94. {
  95. UNUSED(context);
  96. UNUSED(event);
  97. return false;
  98. }
  99. void blackhat_scene_start_on_exit(void* context)
  100. {
  101. BlackhatApp* app = context;
  102. variable_item_list_reset(app->var_item_list);
  103. }