☣ Malware & Threats

Botnets and Command-and-Control (C2) Explained

A botnet is a network of internet-connected devices infected with malware and controlled remotely by an attacker, while command-and-control (C2) is the infrastructure and communication channel the attacker uses to issue orders and receive data. Together they turn thousands or millions of compromised machines — the "bots" or "zombies" — into a coordinated platform for attacks. Understanding botnet and C2 mechanics is central to detecting active intrusions and disrupting large-scale abuse.

What a Botnet Is and How It Forms

A botnet begins when malware compromises a device and enrolls it as a bot under the control of an operator known as a bot herder. Suitable devices include desktops, servers, routers, and poorly secured IoT gadgets, many of which ship with weak default credentials. The malware is the bot; the collection of bots plus its control channel is the botnet. For background on the malicious code involved, see types of malware.

Once enrolled, each bot periodically contacts its C2 to fetch commands, a behavior called beaconing. This heartbeat is both the botnet's strength — enabling coordinated action — and a key weakness defenders can detect.

The Botnet Lifecycle

A botnet grows and operates through a repeating cycle:

  1. Infection — malware compromises a device through phishing, exploited vulnerabilities, or weak credentials.
  2. Enrollment — the new bot registers with the C2 and awaits instructions.
  3. Tasking — the bot herder issues commands to some or all of the fleet.
  4. Execution — bots carry out the assigned activity, from sending spam to flooding a target.
  5. Propagation and maintenance — the malware seeks new hosts and updates itself to evade detection and remove rival infections.

Because a botnet is only as durable as its C2 channel and its ability to recruit new hosts, defenders can weaken it by disrupting either.

What Botnets Are Used For

The pooled resources of many machines enable attacks no single host could manage:

  • Distributed denial-of-service (DDoS) attacks that overwhelm targets with traffic.
  • Spam and phishing distribution from countless addresses.
  • Credential stuffing and brute-force campaigns spread across many IP addresses.
  • Cryptomining that monetizes stolen computing power.
  • Proxy and anonymization services that relay other criminals' traffic.
  • Mass malware delivery, including acting as the distribution layer for ransomware.

Command-and-Control Architectures

How a botnet is controlled determines how resilient it is to takedown.

Centralized (Client-Server)

Bots connect to one or a few C2 servers, commonly over protocols such as IRC or HTTP/HTTPS. Centralized control is simple and responsive but creates a single point of failure: disrupt the server and the botnet goes dark.

Peer-to-Peer (P2P)

Bots relay commands among themselves with no central server, making the botnet far harder to dismantle because there is no single node to seize.

Hybrid and Resilient Techniques

Operators harden C2 against takedown with several techniques:

  • Domain generation algorithms (DGAs) that produce many pseudo-random rendezvous domains, of which the operator registers only a few.
  • Fast flux, rapidly rotating the IP addresses behind a domain across many bots.
  • Domain fronting and legitimate services, hiding C2 within trusted cloud platforms, messaging apps, or social media to blend with normal traffic.

How to Detect Botnet and C2 Activity

Because bots must communicate, network and endpoint telemetry reveal them:

  • Beaconing patterns — regular, periodic connections to the same destination, sometimes with added jitter to appear less regular.
  • DGA-like DNS queries — bursts of lookups for algorithmically random domain names, many returning failures.
  • Known-bad indicators — connections to reported C2 domains and IP addresses from threat intelligence.
  • Protocol anomalies — traffic that does not match the expected use of a port, or unusual TLS fingerprints.
  • Volume anomalies — a device suddenly sending large volumes of email or traffic.

A telltale sign is a host resolving many nonexistent domains in quick succession, characteristic of a DGA:

# Repeated NXDOMAIN responses to random-looking domains = possible DGA beaconing
kq3v9zt1x7.example  -> NXDOMAIN
b8f2m0waqp.example  -> NXDOMAIN
zr7hd4nls6.example  -> NXDOMAIN

How to Defend and Disrupt

  1. Harden devices by changing default credentials, disabling unnecessary services, and patching — especially routers and IoT.
  2. Filter and monitor DNS, using sinkholing and blocklists to break C2 rendezvous.
  3. Apply egress filtering so internal hosts cannot freely reach arbitrary internet destinations.
  4. Deploy IDS/IPS and network detection tuned for beaconing and known C2 indicators.
  5. Segment networks to contain infections and limit lateral spread.
  6. Feed threat intelligence into detection tools to recognize evolving infrastructure.

At a larger scale, coordinated takedowns — seizing servers, sinkholing DGA domains, and disrupting P2P layers — can dismantle botnets, though resilient architectures often require sustained effort. These behaviors map cleanly onto the command-and-control tactic in the MITRE ATT&CK framework.

Key Takeaways

  • A botnet is a fleet of compromised devices controlled through command-and-control (C2) channels.
  • Botnets power DDoS, spam, credential attacks, cryptomining, and malware distribution.
  • C2 architectures range from centralized to peer-to-peer, hardened with DGAs, fast flux, and traffic blending.
  • Beaconing and DGA-style DNS activity are among the most reliable detection signals.
  • Defense combines device hardening, DNS and egress controls, segmentation, and threat intelligence, with takedowns disrupting C2 at scale.
botnetcommand-and-controlddosnetwork-securityblue-team

Frequently asked questions

What is a botnet?

A botnet is a network of internet-connected devices infected with malware and controlled remotely by an attacker known as a bot herder. The compromised machines, called bots or zombies, can number in the thousands or millions and act together as a coordinated platform for attacks such as denial-of-service, spam, and credential stuffing.

What is command-and-control in a botnet?

Command-and-control, or C2, is the infrastructure and communication channel an attacker uses to issue orders to bots and receive stolen data. Each bot periodically contacts its C2 to fetch commands, a heartbeat called beaconing, which enables coordinated action but is also one of the most reliable signals defenders can detect.

What are botnets used for?

The pooled resources of many machines enable distributed denial-of-service attacks, mass spam and phishing distribution, credential stuffing and brute-force campaigns spread across many IP addresses, and cryptomining that monetizes stolen computing power. Botnets also serve as proxy networks and as the distribution layer for other malware, including ransomware.

How do you detect botnet and C2 activity?

Because bots must communicate, network and endpoint telemetry reveal them through beaconing patterns of regular periodic connections to the same destination, bursts of algorithmically random DNS queries characteristic of a domain generation algorithm, and connections to known-bad C2 indicators. Protocol and volume anomalies, such as a host suddenly sending large amounts of traffic, are additional signals.

How do you defend against botnets?

Harden devices by changing default credentials, disabling unnecessary services, and patching, especially routers and IoT gadgets. Filter and monitor DNS with sinkholing and blocklists, apply egress filtering so internal hosts cannot reach arbitrary destinations, deploy intrusion detection tuned for beaconing, segment networks, and feed threat intelligence into detection tools.

What is a domain generation algorithm?

A domain generation algorithm, or DGA, is a technique that produces many pseudo-random rendezvous domains, of which the botnet operator registers only a few, making command-and-control harder to block. A telltale detection sign is a host resolving many nonexistent domains in quick succession, producing repeated failed DNS lookups that defenders can flag.

Try it hands-on

K0G is an open toolkit of browser-based security utilities — hashing, encoding, JWT, certificates, crypto and more, all running locally in your browser.

Explore the tools →