WiFiScan.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_ATTACK_BEACON_SPAM 6
  20. #define WIFI_ATTACK_RICK_ROLL 7
  21. #define BT_SCAN_ALL 8
  22. #define BT_SCAN_SKIMMERS 9
  23. extern Display display_obj;
  24. esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
  25. class WiFiScan
  26. {
  27. private:
  28. uint32_t initTime = 0;
  29. bool run_setup = true;
  30. int set_channel = 1;
  31. int bluetoothScanTime = 5;
  32. int packets_sent = 0;
  33. const wifi_promiscuous_filter_t filt = {.filter_mask=WIFI_PROMIS_FILTER_MASK_MGMT | WIFI_PROMIS_FILTER_MASK_DATA};
  34. BLEScan* pBLEScan;
  35. String alfa = "1234567890qwertyuiopasdfghjkklzxcvbnm QWERTYUIOPASDFGHJKLZXCVBNM_";
  36. char* rick_roll[8] = {
  37. "01 Never gonna give you up",
  38. "02 Never gonna let you down",
  39. "03 Never gonna run around",
  40. "04 and desert you",
  41. "05 Never gonna make you cry",
  42. "06 Never gonna say goodbye",
  43. "07 Never gonna tell a lie",
  44. "08 and hurt you"
  45. };
  46. char* prefix = "G";
  47. typedef struct
  48. {
  49. int16_t fctl;
  50. int16_t duration;
  51. uint8_t da;
  52. uint8_t sa;
  53. uint8_t bssid;
  54. int16_t seqctl;
  55. unsigned char payload[];
  56. } __attribute__((packed)) WifiMgmtHdr;
  57. typedef struct {
  58. WifiMgmtHdr hdr;
  59. uint8_t payload[0];
  60. } wifi_ieee80211_packet_t;
  61. // barebones packet
  62. uint8_t packet[128] = { 0x80, 0x00, 0x00, 0x00, //Frame Control, Duration
  63. /*4*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, //Destination address
  64. /*10*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //Source address - overwritten later
  65. /*16*/ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, //BSSID - overwritten to the same as the source address
  66. /*22*/ 0xc0, 0x6c, //Seq-ctl
  67. /*24*/ 0x83, 0x51, 0xf7, 0x8f, 0x0f, 0x00, 0x00, 0x00, //timestamp - the number of microseconds the AP has been active
  68. /*32*/ 0x64, 0x00, //Beacon interval
  69. /*34*/ 0x01, 0x04, //Capability info
  70. /* SSID */
  71. /*36*/ 0x00
  72. };
  73. void broadcastRandomSSID(uint32_t currentTime);
  74. void broadcastSetSSID(uint32_t current_time, char* ESSID);
  75. void RunRickRoll(uint8_t scan_mode, uint16_t color);
  76. void RunBeaconSpam(uint8_t scan_mode, uint16_t color);
  77. void RunBeaconScan(uint8_t scan_mode, uint16_t color);
  78. void RunDeauthScan(uint8_t scan_mode, uint16_t color);
  79. void RunProbeScan(uint8_t scan_mode, uint16_t color);
  80. void RunBluetoothScan(uint8_t scan_mode, uint16_t color);
  81. static void scanCompleteCB(BLEScanResults scanResults);
  82. public:
  83. WiFiScan();
  84. void channelHop();
  85. uint8_t currentScanMode = 0;
  86. void main(uint32_t currentTime);
  87. void StartScan(uint8_t scan_mode, uint16_t color = 0);
  88. void StopScan(uint8_t scan_mode);
  89. static void getMAC(char *addr, uint8_t* data, uint16_t offset);
  90. static void beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  91. static void deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  92. static void probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type);
  93. };
  94. #endif