CommandLine.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #ifndef CommandLine_h
  2. #define CommandLine_h
  3. #include "configs.h"
  4. #ifdef HAS_SCREEN
  5. #include "MenuFunctions.h"
  6. #include "Display.h"
  7. #endif
  8. #include "WiFiScan.h"
  9. #include "Web.h"
  10. #ifdef USE_SD_MMC_ALTERNATIVE
  11. #include "SD_MMCInterface.h"
  12. #else
  13. #include "SDInterface.h"
  14. #endif
  15. #include "settings.h"
  16. #ifdef HAS_SCREEN
  17. extern MenuFunctions menu_function_obj;
  18. extern Display display_obj;
  19. #endif
  20. extern WiFiScan wifi_scan_obj;
  21. extern Web web_obj;
  22. extern SDInterface sd_obj;
  23. extern Settings settings_obj;
  24. extern LinkedList<AccessPoint>* access_points;
  25. extern LinkedList<ssid>* ssids;
  26. extern LinkedList<Station>* stations;
  27. extern const String PROGMEM version_number;
  28. //// Commands
  29. #ifdef ESP32_CAM
  30. // Camera functions
  31. const char PROGMEM CAM_PHOTO[] = "photo";
  32. const char PROGMEM CAM_STREAM[] = "stream";
  33. #endif
  34. // Admin
  35. const char PROGMEM CH_CMD[] = "channel";
  36. const char PROGMEM CLEARAP_CMD[] = "clearlist";
  37. const char PROGMEM REBOOT_CMD[] = "reboot";
  38. const char PROGMEM UPDATE_CMD[] = "update";
  39. const char PROGMEM HELP_CMD[] = "help";
  40. const char PROGMEM SETTINGS_CMD[] = "settings";
  41. // WiFi sniff/scan
  42. const char PROGMEM SCANAP_CMD[] = "scanap";
  43. const char PROGMEM SCANSTA_CMD[] = "scansta";
  44. const char PROGMEM SNIFF_RAW_CMD[] = "sniffraw";
  45. const char PROGMEM SNIFF_BEACON_CMD[] = "sniffbeacon";
  46. const char PROGMEM SNIFF_PROBE_CMD[] = "sniffprobe";
  47. const char PROGMEM SNIFF_PWN_CMD[] = "sniffpwn";
  48. const char PROGMEM SNIFF_ESP_CMD[] = "sniffesp";
  49. const char PROGMEM SNIFF_DEAUTH_CMD[] = "sniffdeauth";
  50. const char PROGMEM SNIFF_PMKID_CMD[] = "sniffpmkid";
  51. const char PROGMEM STOPSCAN_CMD[] = "stopscan";
  52. // WiFi attack
  53. const char PROGMEM ATTACK_CMD[] = "attack";
  54. const char PROGMEM ATTACK_TYPE_DEAUTH[] = "deauth";
  55. const char PROGMEM ATTACK_TYPE_BEACON[] = "beacon";
  56. const char PROGMEM ATTACK_TYPE_PROBE[] = "probe";
  57. const char PROGMEM ATTACK_TYPE_RR[] = "rickroll";
  58. // WiFi Aux
  59. const char PROGMEM LIST_AP_CMD[] = "list";
  60. const char PROGMEM SEL_CMD[] = "select";
  61. const char PROGMEM SSID_CMD[] = "ssid";
  62. // Bluetooth sniff/scan
  63. const char PROGMEM BT_SNIFF_CMD[] = "sniffbt";
  64. const char PROGMEM BT_SKIM_CMD[] = "sniffskim";
  65. //// Command help messages
  66. // Admin
  67. const char PROGMEM HELP_HEAD[] = "============ Commands ============";
  68. const char PROGMEM HELP_CH_CMD[] = "channel [-s <channel>]";
  69. const char PROGMEM HELP_CLEARAP_CMD_A[] = "clearlist -a/-c/-s";
  70. const char PROGMEM HELP_REBOOT_CMD[] = "reboot";
  71. const char PROGMEM HELP_UPDATE_CMD_A[] = "update -s/-w";
  72. const char PROGMEM HELP_SETTINGS_CMD[] = "settings [-s <setting> enable/disable>]/[-r]";
  73. // WiFi sniff/scan
  74. const char PROGMEM HELP_SCANAP_CMD[] = "scanap";
  75. const char PROGMEM HELP_SCANSTA_CMD[] = "scansta";
  76. const char PROGMEM HELP_SNIFF_RAW_CMD[] = "sniffraw";
  77. const char PROGMEM HELP_SNIFF_BEACON_CMD[] = "sniffbeacon";
  78. const char PROGMEM HELP_SNIFF_PROBE_CMD[] = "sniffprobe";
  79. const char PROGMEM HELP_SNIFF_PWN_CMD[] = "sniffpwn";
  80. const char PROGMEM HELP_SNIFF_ESP_CMD[] = "sniffesp";
  81. const char PROGMEM HELP_SNIFF_DEAUTH_CMD[] = "sniffdeauth";
  82. const char PROGMEM HELP_SNIFF_PMKID_CMD[] = "sniffpmkid [-c <channel>]";
  83. const char PROGMEM HELP_STOPSCAN_CMD[] = "stopscan";
  84. // WiFi attack
  85. const char PROGMEM HELP_ATTACK_CMD[] = "attack -t <beacon [-l/-r/-a]/deauth [-c]/[-s <src mac>] [-d <dst mac>]/probe/rickroll>";
  86. // WiFi Aux
  87. const char PROGMEM HELP_LIST_AP_CMD_A[] = "list -s";
  88. const char PROGMEM HELP_LIST_AP_CMD_B[] = "list -a";
  89. const char PROGMEM HELP_LIST_AP_CMD_C[] = "list -c";
  90. const char PROGMEM HELP_SEL_CMD_A[] = "select -a/-s/-c <index (comma separated)>";
  91. const char PROGMEM HELP_SSID_CMD_A[] = "ssid -a [-g <count>/-n <name>]";
  92. const char PROGMEM HELP_SSID_CMD_B[] = "ssid -r <index>";
  93. // Bluetooth sniff/scan
  94. const char PROGMEM HELP_BT_SNIFF_CMD[] = "sniffbt";
  95. const char PROGMEM HELP_BT_SKIM_CMD[] = "sniffskim";
  96. const char PROGMEM HELP_FOOT[] = "==================================";
  97. class CommandLine {
  98. private:
  99. String getSerialInput();
  100. LinkedList<String> parseCommand(String input, char* delim);
  101. void runCommand(String input);
  102. bool checkValueExists(LinkedList<String>* cmd_args_list, int index);
  103. bool inRange(int max, int index);
  104. bool apSelected();
  105. bool hasSSIDs();
  106. int argSearch(LinkedList<String>* cmd_args, String key);
  107. const char* ascii_art =
  108. "\r\n"
  109. " @@@@@@ \r\n"
  110. " @@@@@@@@ \r\n"
  111. " @@@@@@@@@@@ \r\n"
  112. " @@@@@@ @@@@@@ \r\n"
  113. " @@@@@@@ @@@@@@@ \r\n"
  114. " @@@@@@ @@@@@@ \r\n"
  115. " @@@@@@@ @@@@@@@ \r\n"
  116. " @@@@@@ @@@@@@ \r\n"
  117. "@@@@@@@ @@@@@@@@@@@@@@@@ \r\n"
  118. "@@@@@ @@@@@@@@@@@@@@@ \r\n"
  119. "@@@@@ @@@@@@@ \r\n"
  120. "@@@@@ @@@@@@ \r\n"
  121. "@@@@@@ @@@@@@@ \r\n"
  122. " @@@@@@ @@@@@@@@@@@@\r\n"
  123. " @@@@@@@ @@@@@@ \r\n"
  124. " @@@@@@ @@@@@@ \r\n"
  125. " @@@@@@@ @@@@@@ \r\n"
  126. " @@@@@@ @@@@@@ \r\n"
  127. " @@@@@@@ @@@@@@ \r\n"
  128. " @@@@@@ @@@@@@ \r\n"
  129. " @@@@@@@@@ \r\n"
  130. " @@@@@@ \r\n"
  131. " @@@@ \r\n"
  132. "\r\n";
  133. public:
  134. CommandLine();
  135. void RunSetup();
  136. void main(uint32_t currentTime);
  137. };
  138. #endif