CommandLine.h 5.5 KB

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