WiFiScan.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  1. #include "WiFiScan.h"
  2. //esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
  3. //int num_beacon = 0;
  4. int num_beacon = 0;
  5. int num_deauth = 0;
  6. int num_probe = 0;
  7. class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
  8. void onResult(BLEAdvertisedDevice advertisedDevice) {
  9. String display_string = "";
  10. if (display_obj.display_buffer->size() >= 0)
  11. {
  12. display_string.concat(" RSSI: ");
  13. display_string.concat(advertisedDevice.getRSSI());
  14. Serial.print(" RSSI: ");
  15. Serial.print(advertisedDevice.getRSSI());
  16. display_string.concat(" ");
  17. Serial.print(" ");
  18. Serial.print("Device: ");
  19. if(advertisedDevice.getName().length() != 0)
  20. {
  21. display_string.concat(advertisedDevice.getName().c_str());
  22. Serial.print(advertisedDevice.getName().c_str());
  23. }
  24. else
  25. {
  26. display_string.concat(advertisedDevice.getAddress().toString().c_str());
  27. Serial.print(advertisedDevice.getAddress().toString().c_str());
  28. }
  29. int temp_len = display_string.length();
  30. for (int i = 0; i < 40 - temp_len; i++)
  31. {
  32. display_string.concat(" ");
  33. }
  34. Serial.println();
  35. while (display_obj.printing)
  36. delay(1);
  37. display_obj.loading = true;
  38. display_obj.display_buffer->add(display_string);
  39. display_obj.loading = false;
  40. }
  41. }
  42. };
  43. class bluetoothScanSkimmersCallback: public BLEAdvertisedDeviceCallbacks {
  44. void onResult(BLEAdvertisedDevice advertisedDevice) {
  45. String bad_list[bad_list_length] = {"HC-03", "HC-05", "HC-06"};
  46. if (display_obj.display_buffer->size() >= 0)
  47. {
  48. Serial.print("Device: ");
  49. String display_string = "";
  50. //display_string.concat(" RSSI: ");
  51. //display_string.concat(advertisedDevice.getRSSI());
  52. //display_string.concat(" ");
  53. if(advertisedDevice.getName().length() != 0)
  54. {
  55. //display_string.concat(advertisedDevice.getName().c_str());
  56. Serial.print(advertisedDevice.getName().c_str());
  57. for(int i = 0; i < bad_list_length; i++)
  58. {
  59. if(strcmp(advertisedDevice.getName().c_str(), bad_list[i].c_str()) == 0)
  60. {
  61. display_string.concat("Potential Skimmer: ");
  62. display_string.concat(" ");
  63. display_string.concat(advertisedDevice.getName().c_str());
  64. int temp_len = display_string.length();
  65. for (int i = 0; i < 40 - temp_len; i++)
  66. {
  67. display_string.concat(" ");
  68. }
  69. while (display_obj.printing)
  70. delay(1);
  71. display_obj.loading = true;
  72. display_obj.display_buffer->add(display_string);
  73. display_obj.loading = false;
  74. }
  75. }
  76. }
  77. else
  78. {
  79. Serial.print(advertisedDevice.getAddress().toString().c_str());
  80. //display_string.concat(advertisedDevice.getAddress().toString().c_str());
  81. }
  82. /*
  83. int temp_len = display_string.length();
  84. for (int i = 0; i < 40 - temp_len; i++)
  85. {
  86. display_string.concat(" ");
  87. }
  88. */
  89. Serial.print(" RSSI: ");
  90. Serial.println(advertisedDevice.getRSSI());
  91. /*
  92. while (display_obj.printing)
  93. delay(1);
  94. display_obj.loading = true;
  95. display_obj.display_buffer->add(display_string);
  96. display_obj.loading = false;
  97. */
  98. }
  99. }
  100. };
  101. WiFiScan::WiFiScan()
  102. {
  103. }
  104. // Function to prepare to run a specific scan
  105. void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
  106. {
  107. //Serial.println("Starting Scan...");
  108. if (scan_mode == WIFI_SCAN_OFF)
  109. StopScan(scan_mode);
  110. else if (scan_mode == WIFI_SCAN_PROBE)
  111. RunProbeScan(scan_mode, color);
  112. else if (scan_mode == WIFI_SCAN_AP)
  113. RunBeaconScan(scan_mode, color);
  114. else if (scan_mode == WIFI_SCAN_DEAUTH)
  115. RunDeauthScan(scan_mode, color);
  116. else if (scan_mode == WIFI_PACKET_MONITOR)
  117. RunPacketMonitor(scan_mode, color);
  118. else if (scan_mode == WIFI_ATTACK_BEACON_SPAM)
  119. RunBeaconSpam(scan_mode, color);
  120. else if (scan_mode == WIFI_ATTACK_RICK_ROLL)
  121. RunRickRoll(scan_mode, color);
  122. else if (scan_mode == BT_SCAN_ALL)
  123. RunBluetoothScan(scan_mode, color);
  124. else if (scan_mode == BT_SCAN_SKIMMERS)
  125. RunBluetoothScan(scan_mode, color);
  126. WiFiScan::currentScanMode = scan_mode;
  127. }
  128. // Function to stop all wifi scans
  129. void WiFiScan::StopScan(uint8_t scan_mode)
  130. {
  131. if ((currentScanMode == WIFI_SCAN_PROBE) ||
  132. (currentScanMode == WIFI_SCAN_AP) ||
  133. (currentScanMode == WIFI_SCAN_ST) ||
  134. (currentScanMode == WIFI_SCAN_ALL) ||
  135. (currentScanMode == WIFI_SCAN_DEAUTH) ||
  136. (currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
  137. (currentScanMode == WIFI_ATTACK_RICK_ROLL))
  138. {
  139. esp_wifi_set_promiscuous(false);
  140. WiFi.mode(WIFI_OFF);
  141. }
  142. else if ((currentScanMode == BT_SCAN_ALL) ||
  143. (currentScanMode == BT_SCAN_SKIMMERS))
  144. {
  145. Serial.println("Stopping BLE scan...");
  146. pBLEScan->stop();
  147. Serial.println("BLE Scan Stopped");
  148. }
  149. display_obj.display_buffer->clear();
  150. Serial.print("display_buffer->size(): ");
  151. Serial.println(display_obj.display_buffer->size());
  152. display_obj.tteBar = false;
  153. }
  154. String WiFiScan::getStaMAC()
  155. {
  156. char *buf;
  157. uint8_t mac[6];
  158. char macAddrChr[18] = {0};
  159. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  160. esp_wifi_init(&cfg);
  161. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  162. esp_wifi_set_mode(WIFI_MODE_NULL);
  163. esp_wifi_start();
  164. esp_err_t mac_status = esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
  165. sprintf(macAddrChr,
  166. "%02X:%02X:%02X:%02X:%02X:%02X",
  167. mac[0],
  168. mac[1],
  169. mac[2],
  170. mac[3],
  171. mac[4],
  172. mac[5]);
  173. return String(macAddrChr);
  174. }
  175. String WiFiScan::getApMAC()
  176. {
  177. char *buf;
  178. uint8_t mac[6];
  179. char macAddrChr[18] = {0};
  180. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  181. esp_wifi_init(&cfg);
  182. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  183. esp_wifi_set_mode(WIFI_MODE_NULL);
  184. esp_wifi_start();
  185. esp_err_t mac_status = esp_wifi_get_mac(ESP_IF_WIFI_AP, mac);
  186. sprintf(macAddrChr,
  187. "%02X:%02X:%02X:%02X:%02X:%02X",
  188. mac[0],
  189. mac[1],
  190. mac[2],
  191. mac[3],
  192. mac[4],
  193. mac[5]);
  194. return String(macAddrChr);
  195. }
  196. String WiFiScan::freeRAM()
  197. {
  198. char s[150];
  199. sprintf(s, "RAM Free: %u bytes", system_get_free_heap_size());
  200. return String(s);
  201. }
  202. void WiFiScan::RunInfo()
  203. {
  204. String sta_mac = this->getStaMAC();
  205. String ap_mac = this->getApMAC();
  206. String free_ram = this->freeRAM();
  207. Serial.print("STA MAC: ");
  208. Serial.println(sta_mac);
  209. Serial.print("AP MAC: ");
  210. Serial.println(ap_mac);
  211. Serial.println(free_ram);
  212. display_obj.tft.setTextWrap(false);
  213. display_obj.tft.setFreeFont(NULL);
  214. display_obj.tft.setCursor(0, 100);
  215. display_obj.tft.setTextSize(1);
  216. display_obj.tft.setTextColor(TFT_CYAN);
  217. display_obj.tft.println(" Station MAC: " + sta_mac);
  218. display_obj.tft.println(" AP MAC: " + ap_mac);
  219. display_obj.tft.println(" " + free_ram);
  220. }
  221. void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
  222. {
  223. display_obj.tft.init();
  224. display_obj.tft.setRotation(1);
  225. display_obj.tft.fillScreen(TFT_BLACK);
  226. uint16_t calData[5] = { 391, 3491, 266, 3505, 7 };
  227. display_obj.tft.setTouch(calData);
  228. //display_obj.tft.setFreeFont(1);
  229. display_obj.tft.setFreeFont(NULL);
  230. display_obj.tft.setTextSize(1);
  231. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons
  232. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key
  233. delay(10);
  234. display_obj.tftDrawGraphObjects(x_scale); //draw graph objects
  235. display_obj.tftDrawColorKey();
  236. display_obj.tftDrawXScaleButtons(x_scale);
  237. display_obj.tftDrawYScaleButtons(y_scale);
  238. display_obj.tftDrawChannelScaleButtons(set_channel);
  239. display_obj.tftDrawExitScaleButtons();
  240. Serial.println("Running packet scan...");
  241. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  242. esp_wifi_init(&cfg);
  243. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  244. esp_wifi_set_mode(WIFI_MODE_NULL);
  245. esp_wifi_start();
  246. esp_wifi_set_promiscuous(true);
  247. esp_wifi_set_promiscuous_filter(&filt);
  248. esp_wifi_set_promiscuous_rx_cb(&wifiSnifferCallback);
  249. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  250. uint32_t initTime = millis();
  251. }
  252. void WiFiScan::RunRickRoll(uint8_t scan_mode, uint16_t color)
  253. {
  254. //Serial.println("Rick Roll...");
  255. display_obj.TOP_FIXED_AREA_2 = 32;
  256. display_obj.tteBar = true;
  257. display_obj.print_delay_1 = 15;
  258. display_obj.print_delay_2 = 10;
  259. display_obj.clearScreen();
  260. display_obj.initScrollValues(true);
  261. display_obj.tft.setTextWrap(false);
  262. display_obj.tft.setTextColor(TFT_BLACK, color);
  263. display_obj.tft.fillRect(0,0,240,16, color);
  264. display_obj.tft.drawCentreString(" Rick Roll Beacon ",120,0,2);
  265. display_obj.touchToExit();
  266. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  267. packets_sent = 0;
  268. //esp_wifi_set_mode(WIFI_MODE_STA);
  269. WiFi.mode(WIFI_AP_STA);
  270. esp_wifi_start();
  271. esp_wifi_set_promiscuous_filter(NULL);
  272. esp_wifi_set_promiscuous(true);
  273. esp_wifi_set_max_tx_power(78);
  274. initTime = millis();
  275. //display_obj.clearScreen();
  276. //Serial.println("End of func");
  277. }
  278. // Function to prepare for beacon spam
  279. void WiFiScan::RunBeaconSpam(uint8_t scan_mode, uint16_t color)
  280. {
  281. //Serial.println("Beacon Spam...");
  282. display_obj.TOP_FIXED_AREA_2 = 32;
  283. display_obj.tteBar = true;
  284. display_obj.print_delay_1 = 15;
  285. display_obj.print_delay_2 = 10;
  286. display_obj.clearScreen();
  287. display_obj.initScrollValues(true);
  288. display_obj.tft.setTextWrap(false);
  289. display_obj.tft.setTextColor(TFT_BLACK, color);
  290. display_obj.tft.fillRect(0,0,240,16, color);
  291. display_obj.tft.drawCentreString(" Beacon Spam Random ",120,0,2);
  292. display_obj.touchToExit();
  293. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  294. packets_sent = 0;
  295. //esp_wifi_set_mode(WIFI_MODE_STA);
  296. WiFi.mode(WIFI_AP_STA);
  297. esp_wifi_start();
  298. esp_wifi_set_promiscuous_filter(NULL);
  299. esp_wifi_set_promiscuous(true);
  300. esp_wifi_set_max_tx_power(78);
  301. initTime = millis();
  302. //display_obj.clearScreen();
  303. //Serial.println("End of func");
  304. }
  305. // Function to start running a beacon scan
  306. void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
  307. {
  308. display_obj.TOP_FIXED_AREA_2 = 32;
  309. display_obj.tteBar = true;
  310. display_obj.print_delay_1 = 15;
  311. display_obj.print_delay_2 = 10;
  312. display_obj.clearScreen();
  313. display_obj.initScrollValues(true);
  314. display_obj.tft.setTextWrap(false);
  315. display_obj.tft.setTextColor(TFT_WHITE, color);
  316. display_obj.tft.fillRect(0,0,240,16, color);
  317. display_obj.tft.drawCentreString(" Beacon Sniffer ",120,0,2);
  318. display_obj.touchToExit();
  319. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  320. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  321. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  322. esp_wifi_init(&cfg);
  323. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  324. esp_wifi_set_mode(WIFI_MODE_NULL);
  325. esp_wifi_start();
  326. esp_wifi_set_promiscuous(true);
  327. esp_wifi_set_promiscuous_filter(&filt);
  328. esp_wifi_set_promiscuous_rx_cb(&beaconSnifferCallback);
  329. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  330. initTime = millis();
  331. }
  332. void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color)
  333. {
  334. display_obj.TOP_FIXED_AREA_2 = 32;
  335. display_obj.tteBar = true;
  336. display_obj.print_delay_1 = 15;
  337. display_obj.print_delay_2 = 10;
  338. display_obj.clearScreen();
  339. display_obj.initScrollValues(true);
  340. display_obj.tft.setTextWrap(false);
  341. display_obj.tft.setTextColor(TFT_BLACK, color);
  342. display_obj.tft.fillRect(0,0,240,16, color);
  343. display_obj.tft.drawCentreString(" Deauthentication Sniffer ",120,0,2);
  344. display_obj.touchToExit();
  345. display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
  346. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  347. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  348. esp_wifi_init(&cfg);
  349. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  350. esp_wifi_set_mode(WIFI_MODE_NULL);
  351. esp_wifi_start();
  352. esp_wifi_set_promiscuous(true);
  353. esp_wifi_set_promiscuous_filter(&filt);
  354. esp_wifi_set_promiscuous_rx_cb(&deauthSnifferCallback);
  355. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  356. initTime = millis();
  357. }
  358. // Function for running probe request scan
  359. void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
  360. {
  361. display_obj.TOP_FIXED_AREA_2 = 32;
  362. display_obj.tteBar = true;
  363. display_obj.print_delay_1 = 15;
  364. display_obj.print_delay_2 = 10;
  365. display_obj.clearScreen();
  366. display_obj.initScrollValues(true);
  367. display_obj.tft.setTextWrap(false);
  368. display_obj.tft.setTextColor(TFT_BLACK, color);
  369. display_obj.tft.fillRect(0,0,240,16, color);
  370. display_obj.tft.drawCentreString(" Probe Request Sniffer ",120,0,2);
  371. display_obj.touchToExit();
  372. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  373. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  374. wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
  375. esp_wifi_init(&cfg);
  376. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  377. esp_wifi_set_mode(WIFI_MODE_NULL);
  378. esp_wifi_start();
  379. esp_wifi_set_promiscuous(true);
  380. esp_wifi_set_promiscuous_filter(&filt);
  381. esp_wifi_set_promiscuous_rx_cb(&probeSnifferCallback);
  382. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  383. initTime = millis();
  384. }
  385. // Function to start running any BLE scan
  386. void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
  387. {
  388. display_obj.print_delay_1 = 50;
  389. display_obj.print_delay_2 = 20;
  390. BLEDevice::init("");
  391. pBLEScan = BLEDevice::getScan(); //create new scan
  392. if (scan_mode == BT_SCAN_ALL)
  393. {
  394. display_obj.TOP_FIXED_AREA_2 = 32;
  395. display_obj.tteBar = true;
  396. display_obj.clearScreen();
  397. display_obj.initScrollValues(true);
  398. display_obj.tft.setTextWrap(false);
  399. display_obj.tft.setTextColor(TFT_BLACK, color);
  400. display_obj.tft.fillRect(0,0,240,16, color);
  401. display_obj.tft.drawCentreString(" Bluetooth Sniff ",120,0,2);
  402. display_obj.touchToExit();
  403. display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
  404. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  405. pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback());
  406. }
  407. else if (scan_mode == BT_SCAN_SKIMMERS)
  408. {
  409. display_obj.TOP_FIXED_AREA_2 = 160;
  410. display_obj.tteBar = true;
  411. display_obj.clearScreen();
  412. display_obj.tft.fillScreen(TFT_DARKGREY);
  413. display_obj.initScrollValues(true);
  414. display_obj.tft.setTextWrap(false);
  415. display_obj.tft.setTextColor(TFT_BLACK, color);
  416. display_obj.tft.fillRect(0,0,240,16, color);
  417. display_obj.tft.drawCentreString(" Detect Card Skimmers ",120,0,2);
  418. display_obj.twoPartDisplay("Scanning for\nBluetooth-enabled skimmers\nHC-03, HC-05, and HC-06...");
  419. display_obj.tft.setTextColor(TFT_BLACK, TFT_DARKGREY);
  420. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  421. pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanSkimmersCallback());
  422. }
  423. pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  424. pBLEScan->setInterval(100);
  425. pBLEScan->setWindow(99); // less or equal setInterval value
  426. pBLEScan->start(0, scanCompleteCB);
  427. Serial.println("Started BLE Scan");
  428. initTime = millis();
  429. }
  430. // Function that is called when BLE scan is completed
  431. void WiFiScan::scanCompleteCB(BLEScanResults scanResults) {
  432. printf("Scan complete!\n");
  433. printf("Found %d devices\n", scanResults.getCount());
  434. scanResults.dump();
  435. } // scanCompleteCB
  436. // Function to extract MAC addr from a packet at given offset
  437. void WiFiScan::getMAC(char *addr, uint8_t* data, uint16_t offset) {
  438. sprintf(addr, "%02x:%02x:%02x:%02x:%02x:%02x", data[offset+0], data[offset+1], data[offset+2], data[offset+3], data[offset+4], data[offset+5]);
  439. }
  440. void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  441. {
  442. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  443. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  444. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  445. int len = snifferPacket->rx_ctrl.sig_len;
  446. String display_string = "";
  447. if (type == WIFI_PKT_MGMT)
  448. {
  449. int fctl = ntohs(frameControl->fctl);
  450. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  451. const WifiMgmtHdr *hdr = &ipkt->hdr;
  452. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  453. if ((snifferPacket->payload[0] == 0x80) && (display_obj.display_buffer->size() == 0))
  454. {
  455. delay(random(0, 10));
  456. Serial.print("RSSI: ");
  457. Serial.print(snifferPacket->rx_ctrl.rssi);
  458. Serial.print(" Ch: ");
  459. Serial.print(snifferPacket->rx_ctrl.channel);
  460. Serial.print(" BSSID: ");
  461. char addr[] = "00:00:00:00:00:00";
  462. getMAC(addr, snifferPacket->payload, 10);
  463. Serial.print(addr);
  464. display_string.concat(addr);
  465. Serial.print(" ESSID: ");
  466. display_string.concat(" -> ");
  467. for (int i = 0; i < snifferPacket->payload[37]; i++)
  468. {
  469. Serial.print((char)snifferPacket->payload[i + 38]);
  470. display_string.concat((char)snifferPacket->payload[i + 38]);
  471. }
  472. int temp_len = display_string.length();
  473. for (int i = 0; i < 40 - temp_len; i++)
  474. {
  475. display_string.concat(" ");
  476. }
  477. Serial.print(" ");
  478. if (display_obj.display_buffer->size() == 0)
  479. {
  480. display_obj.loading = true;
  481. display_obj.display_buffer->add(display_string);
  482. display_obj.loading = false;
  483. }
  484. Serial.println();
  485. }
  486. }
  487. }
  488. void WiFiScan::deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  489. {
  490. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  491. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  492. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  493. int len = snifferPacket->rx_ctrl.sig_len;
  494. String display_string = "";
  495. if (type == WIFI_PKT_MGMT)
  496. {
  497. int fctl = ntohs(frameControl->fctl);
  498. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  499. const WifiMgmtHdr *hdr = &ipkt->hdr;
  500. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  501. if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ) && (display_obj.display_buffer->size() == 0))
  502. {
  503. delay(random(0, 10));
  504. Serial.print("RSSI: ");
  505. Serial.print(snifferPacket->rx_ctrl.rssi);
  506. Serial.print(" Ch: ");
  507. Serial.print(snifferPacket->rx_ctrl.channel);
  508. Serial.print(" BSSID: ");
  509. char addr[] = "00:00:00:00:00:00";
  510. getMAC(addr, snifferPacket->payload, 10);
  511. Serial.print(addr);
  512. display_string.concat(" RSSI: ");
  513. display_string.concat(snifferPacket->rx_ctrl.rssi);
  514. display_string.concat(" ");
  515. display_string.concat(addr);
  516. for (int i = 0; i < 19 - snifferPacket->payload[37]; i++)
  517. {
  518. display_string.concat(" ");
  519. }
  520. Serial.print(" ");
  521. if (display_obj.display_buffer->size() == 0)
  522. {
  523. display_obj.loading = true;
  524. display_obj.display_buffer->add(display_string);
  525. display_obj.loading = false;
  526. }
  527. Serial.println();
  528. }
  529. }
  530. }
  531. void WiFiScan::probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type) {
  532. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  533. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  534. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  535. int len = snifferPacket->rx_ctrl.sig_len;
  536. String display_string = "";
  537. if (type == WIFI_PKT_MGMT)
  538. {
  539. int fctl = ntohs(frameControl->fctl);
  540. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  541. const WifiMgmtHdr *hdr = &ipkt->hdr;
  542. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  543. if ((snifferPacket->payload[0] == 0x40) && (display_obj.display_buffer->size() == 0))
  544. {
  545. delay(random(0, 10));
  546. Serial.print("RSSI: ");
  547. Serial.print(snifferPacket->rx_ctrl.rssi);
  548. Serial.print(" Ch: ");
  549. Serial.print(snifferPacket->rx_ctrl.channel);
  550. Serial.print(" Client: ");
  551. char addr[] = "00:00:00:00:00:00";
  552. getMAC(addr, snifferPacket->payload, 10);
  553. Serial.print(addr);
  554. display_string.concat(addr);
  555. Serial.print(" Requesting: ");
  556. display_string.concat(" -> ");
  557. for (int i = 0; i < snifferPacket->payload[25]; i++)
  558. {
  559. Serial.print((char)snifferPacket->payload[26 + i]);
  560. display_string.concat((char)snifferPacket->payload[26 + i]);
  561. }
  562. // Print spaces because of the rotating lines of the hardware scroll.
  563. // The same characters print from previous lines so I just overwrite them
  564. // with spaces.
  565. for (int i = 0; i < 19 - snifferPacket->payload[25]; i++)
  566. {
  567. display_string.concat(" ");
  568. }
  569. if (display_obj.display_buffer->size() == 0)
  570. {
  571. //while (display_obj.printing)
  572. // delay(1);
  573. display_obj.loading = true;
  574. display_obj.display_buffer->add(display_string);
  575. display_obj.loading = false;
  576. }
  577. Serial.println();
  578. }
  579. }
  580. }
  581. // Function to send beacons with random ESSID length
  582. void WiFiScan::broadcastSetSSID(uint32_t current_time, char* ESSID) {
  583. set_channel = random(1,12);
  584. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  585. delay(1);
  586. // Randomize SRC MAC
  587. packet[10] = packet[16] = random(256);
  588. packet[11] = packet[17] = random(256);
  589. packet[12] = packet[18] = random(256);
  590. packet[13] = packet[19] = random(256);
  591. packet[14] = packet[20] = random(256);
  592. packet[15] = packet[21] = random(256);
  593. /////////////////////////////
  594. //int essid_len = random(6, 10);
  595. // random prefix to beacon essid
  596. //uint8_t rand_reg[essid_len] = {};
  597. //for (int i = 0; i < essid_len; i++)
  598. // rand_reg[i] = alfa[random(65)];
  599. int ssidLen = strlen(ESSID);
  600. //int rand_len = sizeof(rand_reg);
  601. int fullLen = ssidLen;
  602. packet[37] = fullLen;
  603. // Insert random prefix
  604. //for (int i = 0; i < rand_len; i++)
  605. // packet[38+i] = rand_reg[i];
  606. // Insert my tag
  607. for(int i = 0; i < ssidLen; i++)
  608. packet[38 + i] = ESSID[i];
  609. /////////////////////////////
  610. packet[50 + fullLen] = set_channel;
  611. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  612. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  613. // Add everything that goes after the SSID
  614. for(int i = 0; i < 12; i++)
  615. packet[38 + fullLen + i] = postSSID[i];
  616. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  617. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  618. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  619. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  620. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  621. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  622. packets_sent = packets_sent + 3;
  623. }
  624. // Function for sending crafted beacon frames
  625. void WiFiScan::broadcastRandomSSID(uint32_t currentTime) {
  626. set_channel = random(1,12);
  627. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  628. delay(1);
  629. // Randomize SRC MAC
  630. packet[10] = packet[16] = random(256);
  631. packet[11] = packet[17] = random(256);
  632. packet[12] = packet[18] = random(256);
  633. packet[13] = packet[19] = random(256);
  634. packet[14] = packet[20] = random(256);
  635. packet[15] = packet[21] = random(256);
  636. packet[37] = 6;
  637. // Randomize SSID (Fixed size 6. Lazy right?)
  638. packet[38] = alfa[random(65)];
  639. packet[39] = alfa[random(65)];
  640. packet[40] = alfa[random(65)];
  641. packet[41] = alfa[random(65)];
  642. packet[42] = alfa[random(65)];
  643. packet[43] = alfa[random(65)];
  644. packet[56] = set_channel;
  645. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  646. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  647. // Add everything that goes after the SSID
  648. for(int i = 0; i < 12; i++)
  649. packet[38 + 6 + i] = postSSID[i];
  650. //Serial.println("About to send packets...");
  651. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  652. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  653. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  654. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  655. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  656. //esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  657. packets_sent = packets_sent + 3;
  658. //Serial.print("Packets sent: ");
  659. //Serial.println(packets_sent);
  660. //Serial.println("Sent packets");
  661. }
  662. void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  663. {
  664. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  665. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  666. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  667. int len = snifferPacket->rx_ctrl.sig_len;
  668. if (type == WIFI_PKT_MGMT)
  669. {
  670. int fctl = ntohs(frameControl->fctl);
  671. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  672. const WifiMgmtHdr *hdr = &ipkt->hdr;
  673. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  674. if (snifferPacket->payload[0] == 0x80)
  675. {
  676. num_beacon++;
  677. }
  678. else if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ))
  679. {
  680. num_deauth++;
  681. }
  682. else if (snifferPacket->payload[0] == 0x40)
  683. {
  684. num_probe++;
  685. }
  686. }
  687. }
  688. void WiFiScan::packetMonitorMain()
  689. {
  690. //---------MAIN 'FOR' LOOP! THIS IS WHERE ALL THE ACTION HAPPENS! HAS TO BE FAST!!!!!---------\\
  691. for (x_pos = (11 + x_scale); x_pos <= 320; x_pos += x_scale) //go along every point on the x axis and do something, start over when finished
  692. {
  693. do_break = false;
  694. y_pos_x = 0;
  695. y_pos_y = 0;
  696. y_pos_z = 0;
  697. boolean pressed = false;
  698. uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
  699. // Do the touch stuff
  700. pressed = display_obj.tft.getTouch(&t_x, &t_y);
  701. if (pressed) {
  702. Serial.print("Got touch | X: ");
  703. Serial.print(t_x);
  704. Serial.print(" Y: ");
  705. Serial.println(t_y);
  706. }
  707. // Check buttons for presses
  708. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  709. {
  710. if (pressed && display_obj.key[b].contains(t_x, t_y))
  711. {
  712. display_obj.key[b].press(true);
  713. } else {
  714. display_obj.key[b].press(false);
  715. }
  716. }
  717. // Which buttons pressed
  718. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  719. {
  720. if (display_obj.key[b].justPressed())
  721. {
  722. Serial.println("Bro, key pressed");
  723. //do_break = true;
  724. }
  725. if (display_obj.key[b].justReleased())
  726. {
  727. do_break = true;
  728. // X - button pressed
  729. if (b == 0) {
  730. if (x_scale > 1) {
  731. x_scale--;
  732. delay(70);
  733. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  734. display_obj.tftDrawXScaleButtons(x_scale);
  735. display_obj.tftDrawYScaleButtons(y_scale);
  736. display_obj.tftDrawChannelScaleButtons(set_channel);
  737. display_obj.tftDrawExitScaleButtons();
  738. break;
  739. }
  740. }
  741. // X + button pressed
  742. else if (b == 1) {
  743. if (x_scale < 6) {
  744. x_scale++;
  745. delay(70);
  746. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  747. display_obj.tftDrawXScaleButtons(x_scale);
  748. display_obj.tftDrawYScaleButtons(y_scale);
  749. display_obj.tftDrawChannelScaleButtons(set_channel);
  750. display_obj.tftDrawExitScaleButtons();
  751. break;
  752. }
  753. }
  754. // Y - button pressed
  755. else if (b == 2) {
  756. if (y_scale > 1) {
  757. y_scale--;
  758. delay(70);
  759. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  760. display_obj.tftDrawXScaleButtons(x_scale);
  761. display_obj.tftDrawYScaleButtons(y_scale);
  762. display_obj.tftDrawChannelScaleButtons(set_channel);
  763. display_obj.tftDrawExitScaleButtons();
  764. //updateMidway();
  765. break;
  766. }
  767. }
  768. // Y + button pressed
  769. else if (b == 3) {
  770. if (y_scale < 6) {
  771. y_scale++;
  772. delay(70);
  773. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  774. display_obj.tftDrawXScaleButtons(x_scale);
  775. display_obj.tftDrawYScaleButtons(y_scale);
  776. display_obj.tftDrawChannelScaleButtons(set_channel);
  777. display_obj.tftDrawExitScaleButtons();
  778. //updateMidway();
  779. break;
  780. }
  781. }
  782. // Channel - button pressed
  783. else if (b == 4) {
  784. if (set_channel > 1) {
  785. Serial.println("Shit channel down");
  786. set_channel--;
  787. delay(70);
  788. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  789. display_obj.tftDrawXScaleButtons(x_scale);
  790. display_obj.tftDrawYScaleButtons(y_scale);
  791. display_obj.tftDrawChannelScaleButtons(set_channel);
  792. display_obj.tftDrawExitScaleButtons();
  793. changeChannel();
  794. break;
  795. }
  796. }
  797. // Channel + button pressed
  798. else if (b == 5) {
  799. if (set_channel < MAX_CHANNEL) {
  800. Serial.println("Shit channel up");
  801. set_channel++;
  802. delay(70);
  803. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  804. display_obj.tftDrawXScaleButtons(x_scale);
  805. display_obj.tftDrawYScaleButtons(y_scale);
  806. display_obj.tftDrawChannelScaleButtons(set_channel);
  807. display_obj.tftDrawExitScaleButtons();
  808. changeChannel();
  809. break;
  810. }
  811. }
  812. else if (b == 6) {
  813. Serial.println("Exiting packet monitor...");
  814. this->StartScan(WIFI_SCAN_OFF);
  815. //display_obj.tft.init();
  816. this->orient_display = true;
  817. return;
  818. }
  819. }
  820. }
  821. y_pos_x = ((-num_beacon * (y_scale * 10)) + (HEIGHT_1 - 2)); // GREEN
  822. y_pos_y = ((-num_deauth * (y_scale * 10)) + (HEIGHT_1 - 2)); // RED
  823. y_pos_z = ((-num_probe * (y_scale * 10)) + (HEIGHT_1 - 2)); // BLUE
  824. num_beacon = 0;
  825. num_probe = 0;
  826. num_deauth = 0;
  827. //CODE FOR PLOTTING CONTINUOUS LINES!!!!!!!!!!!!
  828. //Plot "X" value
  829. display_obj.tft.drawLine(x_pos - x_scale, y_pos_x_old, x_pos, y_pos_x, TFT_GREEN);
  830. //Plot "Z" value
  831. display_obj.tft.drawLine(x_pos - x_scale, y_pos_z_old, x_pos, y_pos_z, TFT_BLUE);
  832. //Plot "Y" value
  833. display_obj.tft.drawLine(x_pos - x_scale, y_pos_y_old, x_pos, y_pos_y, TFT_RED);
  834. //Draw preceding black 'boxes' to erase old plot lines, !!!WEIRD CODE TO COMPENSATE FOR BUTTONS AND COLOR KEY SO 'ERASER' DOESN'T ERASE BUTTONS AND COLOR KEY!!!
  835. //if ((x_pos <= 90) || ((x_pos >= 198) && (x_pos <= 320))) //above x axis
  836. if ((x_pos <= 90) || ((x_pos >= 117) && (x_pos <= 320))) //above x axis
  837. {
  838. display_obj.tft.fillRect(x_pos+1, 28, 10, 93, TFT_BLACK); //compensate for buttons!
  839. }
  840. else
  841. {
  842. display_obj.tft.fillRect(x_pos+1, 0, 10, 121, TFT_BLACK); //don't compensate for buttons!
  843. }
  844. //if ((x_pos >= 254) && (x_pos <= 320)) //below x axis
  845. //if (x_pos <= 90)
  846. if (x_pos < 0) // below x axis
  847. {
  848. //tft.fillRect(x_pos+1, 121, 10, 88, TFT_BLACK);
  849. display_obj.tft.fillRect(x_pos+1, 121, 10, 88, TFT_CYAN);
  850. }
  851. else
  852. {
  853. //tft.fillRect(x_pos+1, 121, 10, 119, TFT_BLACK);
  854. display_obj.tft.fillRect(x_pos+1, 121, 10, 118, TFT_BLACK);
  855. }
  856. //tftDisplayTime();
  857. if ( (y_pos_x == 120) || (y_pos_y == 120) || (y_pos_z == 120) )
  858. {
  859. display_obj.tft.drawFastHLine(10, 120, 310, TFT_WHITE); // x axis
  860. }
  861. y_pos_x_old = y_pos_x; //set old y pos values to current y pos values
  862. y_pos_y_old = y_pos_y;
  863. y_pos_z_old = y_pos_z;
  864. //delay(50);
  865. }
  866. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); //erase XY buttons and any lines behind them
  867. //tft.fillRect(56, 0, 66, 32, TFT_ORANGE); //erase time and color key and any stray lines behind them
  868. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // key
  869. display_obj.tftDrawXScaleButtons(x_scale); //redraw stuff
  870. display_obj.tftDrawYScaleButtons(y_scale);
  871. display_obj.tftDrawChannelScaleButtons(set_channel);
  872. display_obj.tftDrawExitScaleButtons();
  873. display_obj.tftDrawColorKey();
  874. display_obj.tftDrawGraphObjects(x_scale);
  875. }
  876. //void WiFiScan::sniffer_callback(void* buf, wifi_promiscuous_pkt_type_t type) {
  877. // wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  878. // showMetadata(snifferPacket, type);
  879. //}
  880. void WiFiScan::changeChannel()
  881. {
  882. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  883. delay(1);
  884. }
  885. // Function to cycle to the next channel
  886. void WiFiScan::channelHop()
  887. {
  888. set_channel = set_channel + 1;
  889. if (set_channel > 13) {
  890. set_channel = 1;
  891. }
  892. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  893. delay(1);
  894. }
  895. // Function for updating scan status
  896. void WiFiScan::main(uint32_t currentTime)
  897. {
  898. // WiFi operations
  899. if ((currentScanMode == WIFI_SCAN_PROBE) ||
  900. (currentScanMode == WIFI_SCAN_AP) ||
  901. (currentScanMode == WIFI_SCAN_ST) ||
  902. (currentScanMode == WIFI_SCAN_DEAUTH) ||
  903. (currentScanMode == WIFI_SCAN_ALL))
  904. {
  905. if (currentTime - initTime >= 1000)
  906. {
  907. initTime = millis();
  908. channelHop();
  909. }
  910. }
  911. else if (currentScanMode == WIFI_PACKET_MONITOR)
  912. {
  913. packetMonitorMain();
  914. }
  915. else if ((currentScanMode == WIFI_ATTACK_BEACON_SPAM))
  916. {
  917. // Need this for loop because getTouch causes ~10ms delay
  918. // which makes beacon spam less effective
  919. for (int i = 0; i < 55; i++)
  920. broadcastRandomSSID(currentTime);
  921. if (currentTime - initTime >= 1000)
  922. {
  923. initTime = millis();
  924. //Serial.print("packets/sec: ");
  925. //Serial.println(packets_sent);
  926. String displayString = "";
  927. String displayString2 = "";
  928. displayString.concat("packets/sec: ");
  929. displayString.concat(packets_sent);
  930. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  931. displayString2.concat(" ");
  932. display_obj.showCenterText(displayString2, 160);
  933. display_obj.showCenterText(displayString, 160);
  934. packets_sent = 0;
  935. }
  936. }
  937. else if ((currentScanMode == WIFI_ATTACK_RICK_ROLL))
  938. {
  939. // Need this for loop because getTouch causes ~10ms delay
  940. // which makes beacon spam less effective
  941. for (int i = 0; i < 7; i++)
  942. {
  943. for (int x = 0; x < (sizeof(rick_roll)/sizeof(char *)); x++)
  944. {
  945. broadcastSetSSID(currentTime, rick_roll[x]);
  946. }
  947. }
  948. if (currentTime - initTime >= 1000)
  949. {
  950. initTime = millis();
  951. //Serial.print("packets/sec: ");
  952. //Serial.println(packets_sent);
  953. String displayString = "";
  954. String displayString2 = "";
  955. displayString.concat("packets/sec: ");
  956. displayString.concat(packets_sent);
  957. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  958. displayString2.concat(" ");
  959. display_obj.showCenterText(displayString2, 160);
  960. display_obj.showCenterText(displayString, 160);
  961. packets_sent = 0;
  962. }
  963. }
  964. }