From c3b99df788db6ce1b24f7dd42786976744b21eb2 Mon Sep 17 00:00:00 2001 From: Frederic Jung Date: Sun, 25 Oct 2026 06:18:51 +0000 Subject: [PATCH] Shape DDoS attacks and add a mitigation toolbox (1.17.0) DDoS was one flat random event. Now each attack has a vector (DNS, NTP, CLDAP, SYN, HTTP), a size from a few Gbps to a multi-terabit monster, a target POP, a duration and an entry point among that city's uplinks. The NOC grows a live attack panel and a toolbox: RTBH (free, instant, but the victim goes dark too), a one-time Flowspec licence that drops known UDP floods at the edge but cannot touch an HTTP flood, the existing scrubbing center, and HackBack 3000, which sometimes ends the attack and often flattens an innocent for a fine. New Vigilante and Collateral Damage badges, Italian translations, and tests for the attack, each tool and old saves. --- CHANGELOG.md | 20 +++++++++++ package-lock.json | 4 +-- package.json | 2 +- site/i18n/it.js | 47 +++++++++++++++++++++++--- site/index.html | 84 +++++++++++++++++++++++++++++++++++++++++----- tests/game.test.js | 48 ++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99dacee..d85566c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,26 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +## [1.17.0] — 2026-10-25 + +- DDoS attacks now have a shape: a vector (DNS reflection, NTP or CLDAP + amplification, SYN or HTTP flood), a size from a few Gbps up to a + multi-terabit "botnet of toasters" monster, a target POP, a duration, and + an entry point among that city's uplinks. Most are modest spikes; the big + ones are rare. +- A DDoS toolbox in the NOC. A live attack panel shows the vector, size, + entry and what each mitigation is doing right now: + - **RTBH** — free and instant, but it blackholes the victim, so the + attack and the customer both go dark. Earns the Collateral Damage badge. + - **Flowspec** — a one-time licence that drops known UDP floods (DNS, NTP, + CLDAP, SYN) at your edge. Precise, but useless against an HTTP flood, and + the junk still fills the port it enters. + - **Scrubbing center** — cleans attacks network-wide, as before, and still + risks the GRE/MSS black hole. + - **HackBack 3000™ by Skynot AI** — a tempting red button. Sometimes it + ends the attack; more often it flattens an innocent and earns you a + regulator fine and the Vigilante badge. Hack-back is illegal in reality. + ## [1.16.0] — 2026-10-25 - Customers on interconnection fabrics. Companies already on Megapork, diff --git a/package-lock.json b/package-lock.json index 78df2f9..408a2a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seriesoftubes", - "version": "1.16.0", + "version": "1.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seriesoftubes", - "version": "1.16.0", + "version": "1.17.0", "devDependencies": { "jsdom": "24.1.3" }, diff --git a/package.json b/package.json index eb64b5c..10da1a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seriesoftubes", - "version": "1.16.0", + "version": "1.17.0", "description": "A cartoon browser game about building the internet.", "private": true, "license": "MIT", diff --git a/site/i18n/it.js b/site/i18n/it.js index 3f6b40d..86e134b 100644 --- a/site/i18n/it.js +++ b/site/i18n/it.js @@ -914,10 +914,49 @@ "Someone plugged a loop into the {ix} fabric. Broadcast storm! All peering there is down.":"Qualcuno ha collegato un loop al fabric di {ix}. Broadcast storm! Tutto il peering lì è giù.", "BGP route leak: a small ISP is announcing {net}'s prefixes. Traffic to them over transit is black-holed. Direct peering still works.":"Route leak BGP: un piccolo ISP sta annunciando i prefissi di {net}. Il traffico verso di loro via transit finisce in un buco nero. Il peering diretto funziona ancora.", "{fabric} is having a bad day. Every virtual circuit on their fabric is down.":"{fabric} sta avendo una brutta giornata. Tutti i circuiti virtuali sul loro fabric sono giù.", -"DDoS on {city}
A botnet of smart toasters tried. Your scrubbing center in {scrub} ate most of it.":"DDoS su {city}
Una botnet di tostapane smart ci ha provato. Il tuo centro di scrubbing a {scrub} se n’è mangiato quasi tutto.", -"Mostly absorbed by scrubbing.":"Assorbito quasi tutto dallo scrubbing.", -"A botnet of smart toasters is DDoSing {city}. Junk traffic is eating your capacity.":"Una botnet di tostapane smart sta facendo DDoS su {city}. Il traffico spazzatura si sta mangiando la tua capacità.", -"Buy scrubbing":"Compra lo scrubbing", +"DNS reflection":"riflessione DNS", +"NTP amplification":"amplificazione NTP", +"CLDAP flood":"flood CLDAP", +"SYN flood":"flood SYN", +"HTTP flood":"flood HTTP", +"A {size} {vec} attack is hitting {city}{how}.":"Un attacco {vec} da {size} sta colpendo {city}{how}.", +", in via {e}":", entra da {e}", +"Your mitigation is eating most of it.":"La tua mitigazione se ne sta mangiando quasi tutto.", +"Junk traffic is eating your capacity. Open the NOC to fight back.":"Il traffico spazzatura si sta mangiando la tua capacità. Apri il NOC per difenderti.", +"Open NOC":"Apri il NOC", +"Live attack: {city}":"Attacco in corso: {city}", +"{size} · {vec}{entry} · {n}d left":"{size} · {vec}{entry} · {n}g rimasti", +"Blackholed: the junk is gone, and so is {city}. The attack got what it wanted.":"In buco nero: la spazzatura è sparita, e anche {city}. L’attacco ha ottenuto ciò che voleva.", +"Reaching your network: {g}":"Arriva alla tua rete: {g}", +"Scrubbing in {city} is cleaning it":"Lo scrubbing a {city} lo sta pulendo", +"No scrubbing center":"Nessun centro di scrubbing", +"Flowspec is dropping {vec} at your edge":"Flowspec sta scartando {vec} al tuo edge", +"Flowspec cannot catch an {vec} (application layer)":"Flowspec non può fermare un {vec} (livello applicativo)", +"No Flowspec licence":"Nessuna licenza Flowspec", +"Stop blackholing":"Togli il buco nero", +"Blackhole the target (RTBH)":"Metti il bersaglio in buco nero (RTBH)", +"HackBack 3000™ $20k":"HackBack 3000™ $20k", +"Buy Flowspec {cost}":"Compra Flowspec {cost}", +"RTBH is free and instant, but it drops everything to the victim, attack and customer alike. HackBack 3000™ by Skynot AI sometimes ends it, and sometimes flattens an innocent and earns you a fine.":"L’RTBH è gratis e immediato, ma scarta tutto ciò che va alla vittima: attacco e cliente insieme. HackBack 3000™ di Skynot AI a volte lo ferma, e a volte travolge un innocente e ti becca una multa.", +"Flowspec filtering":"Filtro Flowspec", +"Licensed":"Con licenza", +"Not licensed":"Senza licenza", +"Push drop rules to your edge to stop known UDP floods (DNS, NTP, CLDAP, SYN). Precise, but it cannot touch an HTTP flood and the junk still fills the port it enters.":"Spingi regole di scarto al tuo edge per fermare i flood UDP noti (DNS, NTP, CLDAP, SYN). Preciso, ma non tocca un flood HTTP e la spazzatura riempie comunque la porta da cui entra.", +"Buy Flowspec licence {cost}":"Compra la licenza Flowspec {cost}", +"Flowspec licensed.
Your edge now drops DNS, NTP, CLDAP and SYN floods automatically. HTTP floods still need scrubbing.":"Flowspec attivo.
Il tuo edge ora scarta da solo i flood DNS, NTP, CLDAP e SYN. I flood HTTP servono ancora lo scrubbing.", +"No attack to blackhole right now.":"Nessun attacco da mettere in buco nero adesso.", +"RTBH announced.
You blackholed the target in {city}. The flood stops, and so does everyone there.":"RTBH annunciato.
Hai messo il bersaglio a {city} in buco nero. Il flood si ferma, e con lui tutti quelli lì.", +"Blackhole withdrawn.
{city} is reachable again. Brace for the junk.":"Buco nero ritirato.
{city} è di nuovo raggiungibile. Preparati alla spazzatura.", +"Nothing to hack back right now.":"Niente da contrattaccare adesso.", +"HackBack 3000™ strikes back!
Skynot AI traced the botnet and politely bricked it. The attack on {city} stops cold.":"HackBack 3000™ colpisce ancora!
Skynot AI ha tracciato la botnet e l’ha gentilmente spenta. L’attacco su {city} si ferma di colpo.", +"HackBack 3000™ hit the wrong target.
{who} A regulator sends you a {fine} fine, and the attack rolls on.":"HackBack 3000™ ha colpito il bersaglio sbagliato.
{who} Un’autorità ti manda una multa da {fine}, e l’attacco continua.", +"Skynot AI flattened a grandma's internet-connected fridge.":"Skynot AI ha steso il frigo connesso di una nonna.", +"You counter-flooded a hospital in a country you cannot pronounce.":"Hai contro-floodato un ospedale in un paese che non sai pronunciare.", +"The botnet was already someone else’s botnet. They are furious.":"La botnet era già la botnet di qualcun altro. Sono furiosi.", +"Vigilante":"Giustiziere", +"Fire the HackBack 3000™ and flatten an innocent.":"Spara con l’HackBack 3000™ e travolgi un innocente.", +"Collateral Damage":"Danni collaterali", +"Blackhole one of your own cities to stop a DDoS.":"Metti in buco nero una tua città per fermare un DDoS.", "Traffic rerouted, customers barely noticed.":"Traffico reinstradato, i clienti se ne sono accorti appena.", "Rush repair":"Riparazione urgente", "Metro ring cut":"Anello metro tagliato", diff --git a/site/index.html b/site/index.html index d90ab3b..2eb6488 100644 --- a/site/index.html +++ b/site/index.html @@ -582,6 +582,16 @@ const SITE2_N=[tr('The Other Building'),tr('Campus B (the one with parking)'),tr const siteName=(c,s)=>s==='b'?SITE2_N[hstr(c)%SITE2_N.length]:CITY[c].dc; const popCost=c=>POP_COST+(c&&CITY[c]&&CITY[c].ru?RU_BOX:0)+(c&&CITY[c]&&CITY[c].uae?UAE_LIC:0)+(c&&CITY[c]&&CITY[c].saudi?KSA_LIC:0); const CN_LIC=150000, CN_JV_MO=6000, SCRUB_COST=60000, SCRUB_MO=5000; +// DDoS has a shape now: a vector, a size and an entry point. `fs` is whether Flowspec can drop it at the +// edge — it catches the known volumetric UDP floods, but an application-layer HTTP flood sails right through. +const FLOWSPEC_LIC=40000; +const DDOS_VEC={ + dns:{n:tr('DNS reflection'),fs:true}, + ntp:{n:tr('NTP amplification'),fs:true}, + cldap:{n:tr('CLDAP flood'),fs:true}, + syn:{n:tr('SYN flood'),fs:true}, + http:{n:tr('HTTP flood'),fs:false}, +}; const MYIX_COST=80000, MYIX_MO=3000, MYIX_FEE=1500, START_CASH=200000; // Your own exchange's switching fabric. Bigger fabrics carry more and attract more members. const MYIX_FAB=[{n:'400G',g:400,cost:0,mo:3000,max:12},{n:'1.6T',g:1600,cost:60000,mo:6000,max:20,lvl:2},{n:'6.4T',g:6400,cost:200000,mo:12000,max:30,lvl:3},{n:'25.6T',g:25600,cost:600000,mo:25000,max:45,lvl:4}]; @@ -1370,7 +1380,7 @@ function scenarioModal(){const wk=weekly(),h=scnHof();let best=null;try{best=JSO function newGame(name,home){ S={v:1,name,asn:200000+Math.floor(_rand()*15000),home,day:0,cash:START_CASH, ltv:2,t1v:2,pops:{[home]:{day:0,bb:null,boost:0,down:0,routers:1,gen:false}},links:[],nni:[],transit:[],ixp:{},rs:{},peers:{},pni:[],caches:[],biz:[],offers:[],myIx:{}, - done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubAt:null,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0}; + done:{},inc:[],ev:{},priceMul:1,nextFail:45,nextEvent:40,usedNames:[],stats:{survived:0,incidents:0,peak:0},cnLic:{state:'none'},scrubAt:null,ddosFs:false,won:false,lost:false,neg:0,loans:[],loanOffers:[],loanStrikes:0}; } /* ================= HELPERS ================= */ @@ -1585,11 +1595,19 @@ function compute(){ R2.cityEye[c]=eye;R2.cityDem[c]=d;R2.citySrv[c]=0;R2.demand+=d; for(const n of NETS)R2.demTo[n.id]=(R2.demTo[n.id]||0)+d*(SH[n.id]||0); if(!popUp(c))continue; - const dd=ev.ddos&&ev.ddos.city===c&&ev.ddos.until>day?d*0.7*(S.scrubAt?0.15:1):0; - const bh=dd&&TRX&&TRX.blackhole;if(dd&&!bh)for(const n of NETS)flows.push({c,n:n.id,rem:dd*NSH[n.id],junk:true});if(bh)R2.teBlack+=dd+d*0.1; + // A shaped attack: `rtbh` is the player pulling the plug on the victim IP (junk gone, customer dark too); + // `edge` is the crude RouteScript `blackhole ddos` filter (junk gone, 10% of real traffic with it). Flowspec + // (a standing licence) and a scrubbing center each knock the flood down before it reaches the sim. + const atk=ev.ddos&&ev.ddos.city===c&&ev.ddos.until>day?ev.ddos:null; + const rtbh=!!(atk&&atk.bh), edge=!!(atk&&TRX&&TRX.blackhole&&!rtbh); + let dd=0; + if(atk&&!rtbh){let mult=1;if(DDOS_VEC[atk.vec]&&DDOS_VEC[atk.vec].fs&&S.ddosFs)mult=Math.min(mult,0.25);if(S.scrubAt)mult=Math.min(mult,0.15);if(edge)mult=0;dd=atk.gbps*mult;} + const bh=rtbh||edge; + if(dd>0)for(const n of NETS)flows.push({c,n:n.id,rem:dd*NSH[n.id],junk:true}); + if(edge)R2.teBlack+=atk.gbps*0.15+d*0.1;if(rtbh)R2.teBlack+=atk.gbps+d; R2.cityBlocked=R2.cityBlocked||{}; const mtuH=ev.pmtud&&ev.pmtud.until>day?ev.pmtud:null,kr=CITY[c].kr; - for(const n of NETS){const a=d*(SH[n.id]||0)*(bh?0.9:1)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue; + for(const n of NETS){const a=d*(SH[n.id]||0)*(rtbh?0:edge?0.9:1)*(mtuH&&mtuH.net===n.id?mtuH.f:1)*(kr&&ev.krroute>day&&n.id==='fbk'?0.8:1);if(a<=0)continue; if(cacheNets.has(n.id)){flows.push({c,n:n.id,rem:a*0.85,cache:true});flows.push({c,n:n.id,rem:a*0.15});} else flows.push({c,n:n.id,rem:a});} } @@ -1737,6 +1755,11 @@ function sanitize(s){ s.loans=s.loans.filter(l=>l&&own(BANKS,l.bank));s.loanOffers=s.loanOffers.filter(l=>l&&own(BANKS,l.bank)); s.usedNames=s.usedNames.filter(x=>typeof x==='string');s.log=s.log.filter(e=>e&&typeof e.t==='string').slice(0,30); if(s.scrubAt&&!isCity(s.scrubAt))s.scrubAt=null; + s.ddosFs=!!s.ddosFs; + if(s.ev&&s.ev.ddos){const a=s.ev.ddos; + if(!a||typeof a!=='object'||!isCity(a.city)||!own(DDOS_VEC,a.vec))delete s.ev.ddos; + else{a.gbps=num(a.gbps,2);a.until=num(a.until,s.day);a.bh=!!a.bh;a.start=num(a.start,s.day); + if(!a.entry||typeof a.entry!=='object')a.entry={k:'edge',lab:''};else a.entry.lab=String(a.entry.lab||'').slice(0,60);}} if(s.te){if(typeof s.te!=='object')s.te=null;else{s.te.on=!!s.te.on;s.te.script=typeof s.te.script==='string'?s.te.script.slice(0,4000):'';}} return s;} function migrate(s){sanitize(s);for(const b of [...s.biz,...s.offers])if(Array.isArray(b.reqs))b.reqs=b.reqs.filter(k=>!REQS[k]||!REQS[k].can||(isCity(b.city)&&(!b.city2||isCity(b.city2))&&REQS[k].can(b)));if(s.ltv!==2){for(const l of s.links)if(l.kind==='wave'&&l.tier>=3)l.tier=Math.min(LT.length-1,l.tier+1);s.ltv=2;}if(s.dk){s.dk.m=s.dk.m||{};s.dk.add=s.dk.add||{};s.dk.ret=s.dk.ret||{};s.dk.retUsed=s.dk.retUsed||{};}s.hist=s.hist||[];s.loans=s.loans||[];s.loanOffers=s.loanOffers||[];s.loanStrikes=s.loanStrikes||0;for(const l of s.links||[])if(!l.kind)l.kind='wave'; @@ -1895,6 +1918,27 @@ const HARMLESS=[ function lagsN(){const o=[];for(const t of S.transit)if((t.n||1)>=2&&!(t.down>S.day))o.push({k:'t',id:t.id,o:t,n:t.n,lab:tr('{name} transit LAG in {city}',{name:NET[t.net].name,city:CITY[t.city].name})}); for(const p of S.pni)if((p.n||1)>=2)o.push({k:'p',id:p.id,o:p,n:p.n,lab:tr('PNI LAG with {name} in {city}',{name:NET[p.net].name,city:CITY[p.city].name})}); for(const x in S.ixp){const n=(S.ixn||{})[x]||1;if(n>=2&&!S.myIx[x])o.push({k:'ix',id:x,n,lab:tr('{ix} LAG in {city}',{ix:ixName(x),city:CITY[ixCity(x)].name})});}return o;} +// Where the junk comes in: one of the city's live uplinks, or just "the edge" if it has none yet. +function ddosEntry(c){const o=[]; + for(const t of S.transit)if(t.city===c&&!(t.down>S.day))o.push({k:'t',lab:tr('{net} transit',{net:NET[t.net].name})}); + for(const x of ixIdsIn(c))if(S.ixp[x]!==undefined)o.push({k:'ix',lab:tr('{ix} peering',{ix:ixName(x)})}); + for(const p of S.pni)if(p.city===c)o.push({k:'p',lab:tr('PNI with {net}',{net:NET[p.net].name})}); + return o.length?pick(o):{k:'edge',lab:''};} +// The NOC's live attack view: what is hitting you, what each tool would do about it right now, and the buttons. +function ddosPanel(){ + const a=S&&S.ev&&S.ev.ddos;if(!a||a.until<=S.day||!S.pops[a.city])return ''; + const V=DDOS_VEC[a.vec]||{n:'?',fs:false},fsOn=V.fs&&S.ddosFs,scrOn=!!S.scrubAt; + let mult=1;if(fsOn)mult=Math.min(mult,0.25);if(scrOn)mult=Math.min(mult,0.15); + const land=a.bh?0:Math.round(a.gbps*mult); + let h=`
+
🚨 ${tr('Live attack: {city}',{city:esc(CITY[a.city].name)})}
+
${tr('{size} · {vec}{entry} · {n}d left',{size:fmtG(a.gbps),vec:esc(V.n),entry:a.entry&&a.entry.lab?' · '+esc(a.entry.lab):'',n:a.until-S.day})}
+
${a.bh?tr('Blackholed: the junk is gone, and so is {city}. The attack got what it wanted.',{city:esc(CITY[a.city].name)}):tr('Reaching your network: {g}',{g:fmtG(land)})}
+
${scrOn?'✓ '+tr('Scrubbing in {city} is cleaning it',{city:esc(CITY[S.scrubAt].name)}):'— '+tr('No scrubbing center')}
+
${S.ddosFs?(V.fs?'✓ '+tr('Flowspec is dropping {vec} at your edge',{vec:esc(V.n)}):'— '+tr('Flowspec cannot catch an {vec} (application layer)',{vec:esc(V.n)})):'— '+tr('No Flowspec licence')}
+
${a.bh?btn(tr('Stop blackholing'),'unrtbh',{},'ghost sm'):btn(tr('Blackhole the target (RTBH)'),'rtbh',{},'red sm')}${btn(tr('HackBack 3000™ $20k'),'hackback',{},'sm',S.cash<20000)}${!S.ddosFs?btn(tr('Buy Flowspec {cost}',{cost:fmt$(FLOWSPEC_LIC)}),'buyFs',{},'pink sm',S.cash +

${tr('RTBH is free and instant, but it drops everything to the victim, attack and customer alike. HackBack 3000™ by Skynot AI sometimes ends it, and sometimes flattens an innocent and earns you a fine.')}

`; + return h;} function fireFailure(){ const opts=[]; const live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))]; @@ -2000,9 +2044,20 @@ function fireFailure(){ const f=pick(fabsUsed);S.ev.fab=S.ev.fab||{};S.ev.fab[f]=S.day+2+Math.floor(Math.random()*3); addInc({type,ref:f,until:S.ev.fab[f],msg:tr('{fabric} is having a bad day. Every virtual circuit on their fabric is down.',{fabric:FAB[f].name}),cost:0}); }else if(type==='ddos'){ - const c=pick(Object.keys(S.pops));S.ev.ddos={city:c,until:S.day+4}; - if(S.scrubAt){S.stats.survived++;toast(tr('DDoS on {city}
A botnet of smart toasters tried. Your scrubbing center in {scrub} ate most of it.',{city:CITY[c].name,scrub:CITY[S.scrubAt].name}),'good');sfx('alert');addInc({type,ref:c,until:S.day+4,msg:tr('Mostly absorbed by scrubbing.'),cost:0});return;} - addInc({type,ref:c,until:S.day+4,msg:tr('A botnet of smart toasters is DDoSing {city}. Junk traffic is eating your capacity.',{city:CITY[c].name}),cost:6000,fix:tr('Buy scrubbing')}); + const c=pick(Object.keys(S.pops)),vec=pick(Object.keys(DDOS_VEC)),V=DDOS_VEC[vec]; + // Mostly short, modest spikes; now and then a "botnet of toasters" monster into the terabits. + const monster=Math.random()<0.15,base=Math.max(R.cityDem[c]||0,4); + const gbps=monster?Math.round(800+Math.random()*2600):Math.round(2+Math.random()*Math.max(18,base*0.9)); + const dur=2+Math.floor(Math.random()*4),entry=ddosEntry(c); + S.ev.ddos={city:c,vec,gbps,until:S.day+dur,entry,bh:false,start:S.day}; + const soaked=(V.fs&&S.ddosFs)||S.scrubAt; + const how=entry&&entry.lab?tr(', in via {e}',{e:entry.lab}):''; + const msg=tr('A {size} {vec} attack is hitting {city}{how}.',{size:fmtG(gbps),vec:V.n,city:CITY[c].name,how})+' '+(soaked?tr('Your mitigation is eating most of it.'):tr('Junk traffic is eating your capacity. Open the NOC to fight back.')); + addInc({type,ref:c,until:S.day+dur,msg,cost:0}); + if(soaked)S.stats.survived++; + compute(); + toast(`${incTitle('ddos')}: ${esc(CITY[c].name)}
${esc(msg)}`,soaked?'goal':'bad',[{l:tr('Open NOC'),act:'leftTab',args:{t:'noc'}}]); + sfx('alert');return; } compute(); const last=S.inc[S.inc.length-1]; @@ -2242,6 +2297,8 @@ const BADGES=[ {id:'scen3',i:'🏅',t:tr('Scenario Specialist'),d:tr('Complete three different scenarios.'),r:'e',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id!=='weekly')&&Object.keys(scnHof()).filter(k=>k!=='weekly').length>=3}, {id:'scenall',i:'🏆',t:tr('Scenario Grandmaster'),d:tr('Complete every scenario.'),r:'l',ok:()=>!!(S.scn&&S.scn.done&&S.scn.id!=='weekly')&&SCN.every(x=>scnHof()[x.id])}, {id:'elephant',i:'🐘',t:tr('I Survived the Elephant'),d:tr('Live through the day half the internet went down.'),r:'l',secret:true,ok:()=>!!S.phpDone&&!(S.ev.php>S.day)}, + {id:'vigil',i:'⚖️',t:tr('Vigilante'),d:tr('Fire the HackBack 3000™ and flatten an innocent.'),r:'e',secret:true,ok:()=>(st().vigilante||0)>=1}, + {id:'nullroute',i:'💥',t:tr('Collateral Damage'),d:tr('Blackhole one of your own cities to stop a DDoS.'),r:'r',ok:()=>(st().rtbh||0)>=1}, {id:'zero',i:'🕳️',t:tr('Zero Peers Given'),d:tr('Reach Tier 2 with every single session over the route server.'),r:'l',secret:true,ok:()=>isTier2()&&!Object.keys(S.peers).length&&!S.pni.length}, ]; function hof(){try{return JSON.parse(localStorage.getItem('sot-badges')||'{}')||{};}catch(e){return {};}} @@ -2397,6 +2454,14 @@ const ACT={ applyCn:()=>{if(S.cnLic.state!=='none')return;if(!spend(CN_LIC))return;S.cnLic={state:'pending',ready:S.day+45};toast(tr('Application filed.
Your local partner says about 45 days. Probably.'),'goal');after();}, togglePrem:({id})=>{const t=S.transit.find(x=>x.id===id);if(!t)return;t.premium=!t.premium;sfx('click');after();}, scrub:({city})=>{if(S.scrubAt){if(UI.confirm!=='scrub'){UI.confirm='scrub';renderAll();return;}S.scrubAt=null;UI.confirm=null;after();return;}if(!spend(SCRUB_COST))return;S.scrubAt=city;toast(tr('Scrubbing center online in {city}.
DDoS attacks are now absorbed, and you can sell DDoS protection to businesses.',{city:CITY[city].name}),'good');after();}, + buyFs:()=>{if(S.ddosFs)return;if(!spend(FLOWSPEC_LIC))return;S.ddosFs=true;toast(tr('Flowspec licensed.
Your edge now drops DNS, NTP, CLDAP and SYN floods automatically. HTTP floods still need scrubbing.'),'good');after();}, + rtbh:()=>{const a=S.ev.ddos;if(!a){toast(tr('No attack to blackhole right now.'),'');return;}a.bh=true;S.stats.rtbh=(S.stats.rtbh||0)+1;toast(tr('RTBH announced.
You blackholed the target in {city}. The flood stops, and so does everyone there.',{city:CITY[a.city].name}),'bad');sfx('alert');after();}, + unrtbh:()=>{const a=S.ev.ddos;if(!a||!a.bh)return;a.bh=false;toast(tr('Blackhole withdrawn.
{city} is reachable again. Brace for the junk.',{city:CITY[a.city].name}),'');after();}, + hackback:()=>{const a=S.ev.ddos;if(!a||a.until<=S.day){toast(tr('Nothing to hack back right now.'),'');return;}if(!spend(20000))return;S.stats.hackback=(S.stats.hackback||0)+1; + if(Math.random()<0.35){a.until=S.day;a.bh=false;toast(tr('HackBack 3000™ strikes back!
Skynot AI traced the botnet and politely bricked it. The attack on {city} stops cold.',{city:CITY[a.city].name}),'goal');sfx('coin');} + else{const fine=15000+Math.floor(Math.random()*35000);S.cash-=fine;S.stats.vigilante=(S.stats.vigilante||0)+1; + toast(tr('HackBack 3000™ hit the wrong target.
{who} A regulator sends you a {fine} fine, and the attack rolls on.',{who:pick([tr("Skynot AI flattened a grandma's internet-connected fridge."),tr('You counter-flooded a hospital in a country you cannot pronounce.'),tr('The botnet was already someone else’s botnet. They are furious.')]),fine:fmt$(fine)}),'bad');sfx('err');} + after();}, cnPrem:({v})=>{UI.cnPrem=!!+v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);}, via:({v})=>{UI.via=v;if(UI.pending)openLinkModal(UI.pending.a,UI.pending.b);}, setRoute:({id,m})=>{if(!own(RT,m))return;const b=S.biz.find(x=>x.id===id);if(b){b.route=m;sfx('click');after();}}, @@ -2595,6 +2660,9 @@ function renderLeft(){ h+=`
${btn(tr('Open NOC dashboard'),'dash',{},'pink')}${btn(tr('Traceroute'),'trace',{},'')}
`; h+=`

${tr('Your Network Operations Center. Every notification also lands here. Things fail all the time on the internet. Redundant links and multiple upstreams let traffic reroute by itself.')}

`; h+=`
${tr('DDoS scrubbing')}${S.scrubAt?tr('On · {city}',{city:CITY[S.scrubAt].name}):tr('None (build one from a POP\'s Infra tab)')}
`; + h+=`
${tr('Flowspec filtering')}${S.ddosFs?tr('Licensed'):tr('Not licensed')}
`; + if(!S.ddosFs)h+=`

${tr('Push drop rules to your edge to stop known UDP floods (DNS, NTP, CLDAP, SYN). Precise, but it cannot touch an HTTP flood and the junk still fills the port it enters.')}

${btn(tr('Buy Flowspec licence {cost}',{cost:fmt$(FLOWSPEC_LIC)}),'buyFs',{},'pink sm',S.cash`; + h+=ddosPanel(); h+=S.te?`
Auto-TE${S.te.on?tr('On · moving {g} onto alternate paths',{g:fmtG(R.teMoved||0)}):tr('Off')}
${btn(S.te.on?tr('Turn Auto-TE off'):tr('Turn Auto-TE on'),'teToggle',{},'ghost sm')}${btn(S.te.script?tr('Edit RouteScript'):tr('Write a RouteScript'),'teEdit',{},'pink sm')}
${S.te.script?`

RouteScript: ${teRules()?tr('{n} rules live',{n:teRules().n}):S.te.on?tr('has errors, not running'):tr('controller off')}${R.teBlack?` · ${tr('blackholing {g}',{g:fmtG(R.teBlack)})}`:''}

`:''}` :`
Auto-TE${lvl()<3?tr('Unlocks at customer level 3'):tr('Not installed')}

${tr('Traffic takes the shortest path, even when it is full. A traffic-engineering controller spills the overflow onto the next-best paths with room.')}

${btn(tr('Install Auto-TE {cost} + {mo}/mo',{cost:fmt$(TE_COST),mo:fmt$(TE_MO)}),'buyTE',{},'pink sm',lvl()<3||S.cash`; const hot=S.links.filter(l=>!linkDown(l)&&capOf(l)>0&&(R.load[l.id]||0)/capOf(l)>=0.85).sort((a,b)=>(R.load[b.id]/capOf(b))-(R.load[a.id]/capOf(a))); @@ -2602,7 +2670,7 @@ function renderLeft(){ const hotR=hotPorts(); if(hotR.length)h+=`

${tr('Ports, caches and routers running hot')}

`+hotR.map(x=>`
${HOTL[x.k]}
${CITY[x.city].name} · ${esc(x.lab)}
${tr('{p} full',{p:pct(Math.min(1,x.u))})}${x.u>=0.995?' · '+tr('dropping or overflowing'):''} · ${esc(x.tip)}
${btn(tr('Inspect'),'focusCity',{city:x.city},'pink sm')}
`).join(''); if(!S.inc.length&&!hot.length&&!hotR.length)h+=`

${tr('All systems green. Enjoy it while it lasts.')}

`; - for(const i of S.inc){h+=`
${incTitle(i.type)}
${esc(i.msg)}
${trn('Auto-fix in {n} day','Auto-fix in {n} days',i.until-S.day)}${i.impact?` · ${tr('{g} lost',{g:fmtG(i.impact)})}`:''}
${i.cost?`
${btn(`${esc(i.fix||tr('Rush repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash`:''}
`;} + for(const i of S.inc){if(i.type==='ddos')continue;h+=`
${incTitle(i.type)}
${esc(i.msg)}
${trn('Auto-fix in {n} day','Auto-fix in {n} days',i.until-S.day)}${i.impact?` · ${tr('{g} lost',{g:fmtG(i.impact)})}`:''}
${i.cost?`
${btn(`${esc(i.fix||tr('Rush repair'))} ${fmt$(i.cost)}`,'fixInc',{id:i.id},'red sm',S.cash`:''}
`;} if(S.log&&S.log.length){h+=`

${tr('Recent events')}

`+S.log.slice(0,15).map(e=>`
${dateStr(e.d)} ${esc(e.t)}
`).join('');} h+=`
${tr('Incidents so far')}${S.stats.incidents}
${tr('Survived with no impact')}${S.stats.survived}
`; }else{ diff --git a/tests/game.test.js b/tests/game.test.js index f211802..d904d6f 100644 --- a/tests/game.test.js +++ b/tests/game.test.js @@ -170,3 +170,51 @@ test('bank: the venture vultures take a share of revenue instead of payments', ( assert.equal(ev('R.cost.loans'), 0); assert.ok(Math.abs(ev('R.cost.revshare') - ev('R.revMo') * 0.1) < 1); }); + +test('a shaped DDoS eats capacity, and each tool answers it differently', () => { + const { ev, errors } = load(); + ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=200;ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()"); + const clean = ev('R.served'); + assert.ok(clean > 20, 'traffic flows before the attack'); + // A 300 Gbps DNS flood on fra, no mitigation: junk starves the exit and node. + ev("S.ev.ddos={city:'fra',vec:'dns',gbps:300,until:S.day+3,entry:{k:'t',lab:'x'},bh:false,start:S.day};compute()"); + const attacked = ev('R.served'); + assert.ok(attacked < clean, 'the flood displaces real traffic'); + // Flowspec is a standing licence: it drops the known UDP vector at the edge. + ev("ACT.buyFs();compute()"); + assert.equal(ev('S.ddosFs'), true); + assert.ok(ev('R.served') > attacked, 'flowspec recovers a DNS flood'); + // It cannot touch an application-layer HTTP flood. + const withFs = ev("S.ev.ddos.vec='http';compute();R.served"); + ev("S.ddosFs=false;compute()"); + assert.ok(Math.abs(withFs - ev('R.served')) < 1, 'flowspec is useless against HTTP'); + // Scrubbing cleans any vector network-wide. + ev("S.ev.ddos.vec='dns';S.scrubAt='fra';compute()"); + assert.ok(ev('R.served') > attacked, 'scrubbing recovers real traffic'); + assert.deepEqual(errors, []); +}); + +test('RTBH blackholes the victim, and HackBack 3000 is a gamble', () => { + const { ev } = load(); + ev("ACT.start({});S.cash=1e8;ACT.launchBB({city:'fra'});S.pops.fra.bb.d=120;ACT.buyTransit({city:'fra',net:'cog',tier:1});compute()"); + ev("S.ev.ddos={city:'fra',vec:'syn',gbps:200,until:S.day+3,entry:{k:'edge',lab:''},bh:false,start:S.day};ACT.rtbh();compute()"); + assert.equal(ev('S.ev.ddos.bh'), true); + assert.equal(ev('S.stats.rtbh'), 1); + assert.ok(ev("R.citySrv.fra") < 1, 'the blackholed city serves nothing'); + // HackBack: a forced win ends the attack early. + ev("S.ev.ddos.bh=false;S.ev.ddos.until=S.day+3;const _r=Math.random;Math.random=()=>0.1;ACT.hackback();Math.random=_r"); + assert.ok(ev('S.ev.ddos.until') <= ev('S.day'), 'a lucky hack-back ends it'); + // A forced miss fines you and marks you a vigilante. + ev("S.ev.ddos={city:'fra',vec:'dns',gbps:50,until:S.day+3,entry:{k:'edge',lab:''},bh:false,start:S.day};const c=S.cash;const _r=Math.random;Math.random=()=>0.9;ACT.hackback();Math.random=_r;window.__fined=c-S.cash"); + assert.ok(ev('window.__fined') > 20000, 'a bad hack-back costs the fee plus a fine'); + assert.equal(ev('S.stats.vigilante'), 1); +}); + +test('old saves without DDoS fields load, and a junk attack object is repaired', () => { + const { ev } = load(); + ev("ACT.start({})"); + // An old save: no ddosFs, and a stale flat attack with no vector. + const loaded = ev("const s=JSON.parse(JSON.stringify(S));delete s.ddosFs;s.ev={ddos:{city:'fra',until:9}};sanitize(s);JSON.stringify([s.ddosFs, s.ev.ddos===undefined])"); + assert.equal(JSON.parse(loaded)[0], false, 'ddosFs defaults to false'); + assert.equal(JSON.parse(loaded)[1], true, 'a vectorless attack is dropped'); +});