blackhat_scene_start.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. {"Start RAT Driver", {""}, 1, NULL, ST_RAT_CMD, false},
  29. {"Get Params", {""}, 1, NULL, GET_CMD, false},
  30. {"Reboot", {""}, 1, NULL, REBOOT_CMD, false},
  31. {"Help", {""}, 1, NULL, HELP_CMD, false},
  32. };
  33. static void blackhat_scene_start_var_list_enter_callback(
  34. void* context, uint32_t index
  35. )
  36. {
  37. furi_assert(context);
  38. BlackhatApp* app = context;
  39. furi_assert(index < NUM_MENU_ITEMS);
  40. const BlackhatItem* item = &items[index];
  41. const int selected_option_index = app->selected_option_index[index];
  42. furi_assert(selected_option_index < item->num_options_menu);
  43. app->selected_tx_string = item->actual_command;
  44. app->text_input_req = item->text_input_req;
  45. app->selected_menu_index = index;
  46. app->selected_option_item_text = item->selected_option;
  47. scene_manager_set_scene_state(
  48. app->scene_manager, BlackhatSceneStart, app->selected_menu_index
  49. );
  50. scene_manager_next_scene(
  51. app->scene_manager, BlackhatAppViewConsoleOutput
  52. );
  53. }
  54. static void blackhat_scene_start_var_list_change_callback(VariableItem* item)
  55. {
  56. furi_assert(item);
  57. BlackhatApp* app = variable_item_get_context(item);
  58. furi_assert(app);
  59. const BlackhatItem* menu_item = &items[app->selected_menu_index];
  60. uint8_t item_index = variable_item_get_current_value_index(item);
  61. furi_assert(item_index < menu_item->num_options_menu);
  62. variable_item_set_current_value_text(
  63. item, menu_item->options_menu[item_index]
  64. );
  65. items[app->selected_menu_index].selected_option =
  66. menu_item->options_menu[item_index];
  67. app->selected_option_index[app->selected_menu_index] = item_index;
  68. }
  69. void blackhat_scene_start_on_enter(void* context)
  70. {
  71. BlackhatApp* app = context;
  72. VariableItemList* var_item_list = app->var_item_list;
  73. variable_item_list_set_enter_callback(
  74. var_item_list, blackhat_scene_start_var_list_enter_callback, app
  75. );
  76. VariableItem* item;
  77. for (int i = 0; i < NUM_MENU_ITEMS; ++i) {
  78. item = variable_item_list_add(
  79. var_item_list,
  80. items[i].item_string,
  81. items[i].num_options_menu,
  82. blackhat_scene_start_var_list_change_callback,
  83. app
  84. );
  85. items[i].selected_option = items[i].options_menu[0];
  86. variable_item_set_current_value_index(
  87. item, app->selected_option_index[i]
  88. );
  89. variable_item_set_current_value_text(
  90. item, items[i].options_menu[app->selected_option_index[i]]
  91. );
  92. }
  93. variable_item_list_set_selected_item(
  94. var_item_list,
  95. scene_manager_get_scene_state(app->scene_manager, BlackhatSceneStart)
  96. );
  97. view_dispatcher_switch_to_view(
  98. app->view_dispatcher, BlackhatAppViewVarItemList
  99. );
  100. }
  101. bool blackhat_scene_start_on_event(void* context, SceneManagerEvent event)
  102. {
  103. UNUSED(context);
  104. UNUSED(event);
  105. return false;
  106. }
  107. void blackhat_scene_start_on_exit(void* context)
  108. {
  109. BlackhatApp* app = context;
  110. variable_item_list_reset(app->var_item_list);
  111. }