WiFiScan.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef WiFiScan_h
  2. #define WiFiScan_h
  3. #include <BLEDevice.h>
  4. #include <BLEUtils.h>
  5. #include <BLEScan.h>
  6. #include <BLEAdvertisedDevice.h>
  7. #include <WiFi.h>
  8. #include "esp_wifi.h"
  9. #include "esp_wifi_types.h"
  10. #include "Display.h"
  11. //#include "MenuFunctions.h"
  12. #define bad_list_length 3
  13. #define WIFI_SCAN_OFF 0
  14. #define WIFI_SCAN_PROBE 1
  15. #define WIFI_SCAN_AP 2
  16. #define WIFI_SCAN_ST 3
  17. #define WIFI_SCAN_DEAUTH 4
  18. #define WIFI_SCAN_ALL 5
  19. #define WIFI_PACKET_MONITOR 6
  20. #define WIFI_ATTACK_BEACON_SPAM 7
  21. #define WIFI_ATTACK_RICK_ROLL 8
  22. #define BT_SCAN_ALL 9
  23. #define BT_SCAN_SKIMMERS 10
  24. #define MAX_CHANNEL 14
  25. extern Display display_obj;
  26. esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
  27. class WiFiScan
  28. {
  29. private:
  30. int x_pos; //position along the graph x axis
  31. float y_pos_x; //current graph y axis position of X value
  32. float y_pos_x_old = 120; //old y axis position of X value
  33. float y_pos_y; //current graph y axis position of Y value
  34. float y_pos_y_old = 120; //old y axis position of Y value
  35. float y_pos_z; //current graph y axis position of Z value
  36. float y_pos_z_old = 120; //old y axis position of Z value
  37. int midway = 0;
  38. byte x_scale = 1; //scale of graph x axis, controlled by touchscreen buttons
  39. byte y_scale = 1;
  40. bool do_break = false;
  41. //int num_beacon = 0; // GREEN
  42. //int num_probe = 0; // BLUE
  43. //int num_deauth = 0; // RED
  44. uint32_t initTime = 0;
  45. bool run_setup = true;
  46. int set_channel = 1;
  47. int bluetoothScanTime = 5;
  48. int packets_sent = 0;
  49. const wifi_promiscuous_filter_t filt = {.filter_mask=WIFI_PROMIS_FILTER_MASK_MGMT | WIFI_PROMIS_FILTER_MASK_DATA};
  50. BLEScan* pBLEScan;
  51. String alfa = "1234567890qwertyuiopasdfghjkklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM_";
  52. char* rick_roll[8] = {
  53. "01 Never gonna give you up",
  54. "02 Never gonna let you down",
  55. "03 Never gonna run around",
  56. "04 and desert you",
  57. "05 Never gonna make you cry",
  58. "06 Never gonna say goodbye",
  59. "07 Never gonna tell a lie",
  60. "08 and hurt you"
  61. };
  62. char* prefix = "G";
  63. typedef struct
  64. {
  65. int16_t fctl;
  66. int16_t duration;
  67. uint8_t da;
  68. uint8_t sa;
  69. uint8_t bssid;
  70. int16_t seqctl;
  71. unsigned char payload[];
  72. } __attribute__((packed)) WifiMgmtHdr;
  73. typedef struct {
  74. WifiMgmtHdr hdr;
  75. uint8_t payload[0];
  76. } wifi_ieee80211_packet_t;
  77. // barebones packet
  78. uint8_t packet[128] = { 0x80, 0x00, 0x00, 0x00, //Frame Control, Duration
  79. /*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Destination address
  80. /*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //Source address - overwritten later
  81. /*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //BSSID - overwritten to the same as the source address
  82. /*22*/ 0xc0, 0x6c, //Seq-ctl
  83. /*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, //timestamp - the number of microseconds the AP has been active
  84. /*32*/ 0x64, 0x00, //Beacon interval
  85. /*34*/ 0x01, 0x04, //Capability info
  86. /* SSID */
  87. /*36*/ 0x00
  88. };
  89. void packetMonitorMain();
  90. void changeChannel();
  91. void updateMidway();
  92. void tftDrawXScalButtons();
  93. void tftDrawYScaleButtons();
  94. void tftDrawChannelScaleButtons();
  95. void tftDrawColorKey();
  96. void tftDrawGraphObjects();
  97. void broadcastRandomSSID(uint32_t currentTime);
  98. void broadcastSetSSID(uint32_t current_time, char* ESSID);
  99. void RunRickRoll(uint8_t scan_mode, uint16_t color);
  100. void RunBeaconSpam(uint8_t scan_mode, uint16_t color);
  101. void RunBeaconScan(uint8_t scan_mode, uint16_t color);
  102. void RunDeauthScan(uint8_t scan_mode, uint16_t color);
  103. void RunProbeScan(uint8_t scan_mode, uint16_t color);
  104. void RunPacketMonitor(uint8_t scan_mode, uint16_t color);
  105. void RunBluetoothScan(uint8_t scan_mode, uint16_t color);
  106. static void scanCompleteCB(BLEScanResults scanResults);
  107. public:
  108. WiFiScan();
  109. bool orient_display = false;
  110. void channelHop();
  111. uint8_t currentScanMode = 0;
  112. void main(uint32_t currentTime);
  113. void StartScan(uint8_t scan_mode, uint16_t color = 0);
  114. void StopScan(uint8_t scan_mode);
  115. static void getMAC(char *addr, uint8_t* data, uint16_t offset);
  116. static void beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  117. static void deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  118. static void probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  119. static void wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  120. };
  121. #endif