Chrysolites Open Courses

Cybersecurity from the Ground Up · Course book

Chapter 4: Networks, Traffic and Intrusion Detection

Pairs with Lesson 4: Networks, Cryptography and Web Attacks in Practice

Almost every attack, from a phishing email to a ransomware outbreak, travels across a network at some point, and almost every defence depends on seeing and controlling that traffic. To protect a network you therefore need a working picture of how data moves through it: how messages are split into packets, how devices find one another, what ports and protocols are, and what normal traffic looks like. This chapter builds that picture, then explains how defenders watch traffic with packet analysers and intrusion detection systems, why such systems produce so many false alarms, and how attackers gather information about a target before striking, a stage known as reconnaissance or footprinting. Understanding that stage from the defender's side shows how much an organisation reveals about itself without meaning to.

How data crosses a network

When you load a web page, your request is not sent as one continuous stream. It is broken into small units called packets, each carrying a piece of the data plus addressing information, and the packets may take different routes before being reassembled at the destination. To manage this complexity, networking is described in layers, each handling one job and relying on the layer beneath it. The internet's own model, the TCP/IP model, has four layers; the older seven-layer OSI model is still widely used for teaching and troubleshooting.

ApplicationHTTP/HTTPS, DNS, email (SMTP, IMAP) TransportTCP (reliable) or UDP (fast); port numbers InternetIP addresses; routing between networks LinkEthernet, Wi-Fi; MAC addresses on the local network sending:each layer addsits own header receiving:headers removedin reverse order
Figure 4.1 — The four layers of the TCP/IP model. Each layer wraps the data from the layer above in its own header, a process called encapsulation.

Several kinds of address are involved. A MAC address identifies a network interface on the local network, such as your laptop's Wi-Fi card. An IP address identifies a device across networks, so routers can forward packets towards it. A port number identifies which program on that device should receive the data. Domain names such as a school's website address are translated into IP addresses by the Domain Name System (DNS), the internet's directory service.

At the transport layer, TCP sets up a connection with a three-step exchange, often called the handshake (SYN, SYN-ACK, ACK), numbers every piece of data and resends anything lost, so it suits web pages, email and file transfers. UDP simply sends data without checking, which is faster and suits video calls, online games and DNS lookups, where an occasional lost packet matters less than delay.

Ports, protocols and normal traffic

Many services listen on well-known port numbers, and defenders quickly learn to recognise them. Knowing which ports should be open on a system, and which should not, is one of the most basic security checks.

PortProtocolPurposeSecurity note
22SSHEncrypted remote loginConstantly probed for weak passwords; use keys
23TelnetUnencrypted remote loginSends passwords in clear text; should be disabled
25SMTPSending email between serversAbused for spam if left open to relay
53DNSName lookupsCan be abused to hide data in queries
80 / 443HTTP / HTTPSWeb traffic; 443 is encrypted with TLSMost allowed traffic, so attackers blend in here
3389RDPWindows remote desktopA frequent ransomware entry point when exposed

A packet analyser, such as the free tool Wireshark, captures traffic on a network interface and decodes each packet layer by layer, showing addresses, ports, protocol fields and, for unencrypted protocols, the contents. Network engineers use it to diagnose faults; security analysts use it to investigate suspicious activity and to learn what normal traffic looks like. A useful lesson from inspecting traffic is how much older protocols reveal: a login over Telnet or plain HTTP shows the username and password to anyone capturing packets on the path. Capturing other people's traffic without permission is illegal in most countries, so such practice belongs on your own equipment or in an authorised lab.

Defenders also build a baseline of normal activity: which devices talk to which servers, at what times and in what volumes. Deviations from the baseline, such as a reception computer suddenly sending gigabytes to an unfamiliar address at 3 a.m., are often the first sign of an intrusion.

Intrusion detection and the false-alarm problem

An intrusion detection system (IDS) monitors traffic or system activity and raises an alert when it sees signs of attack. A network IDS watches traffic at key points in the network; a host IDS runs on an individual computer and watches its files, processes and logs. An intrusion prevention system (IPS) does the same but sits in the traffic path and can block what it detects.

Detection uses two main methods. Signature-based detection compares activity with patterns of known attacks, much as anti-malware compares files with known samples; it is precise but blind to new attacks. Anomaly-based detection learns what normal looks like and flags deviations; it can catch new attacks but also flags unusual but innocent behaviour. Both face the same mathematical difficulty: genuine attacks are rare compared with the enormous volume of normal events.

Worked example. A company's IDS examines 1,000,000 network events a day, of which 10 are genuinely malicious. The IDS detects 99% of real attacks and wrongly flags 0.1% of normal events. Real alerts: 10 × 0.99 = 9.9. False alarms: 999,990 × 0.001 ≈ 1,000. Of about 1,010 alerts a day, only 9.9 are real, so the chance that any given alert is genuine is 9.9 ÷ 1,009.9 ≈ 0.98%, less than 1 in 100. Cutting the false-alarm rate tenfold, to 0.01%, gives about 100 false alarms, and the share of genuine alerts rises to 9.9 ÷ 109.9 ≈ 9.0%.
9%50%91% 0%50%100% 1%0.1%0.01%0.001%0.0001% false alarm rate (fraction of normal events flagged)share of alerts that are real
Figure 4.2 — Why rare attacks swamp detectors with false alarms. With 10 real attacks in a million events, even a detector that wrongly flags only 1 event in 1,000 produces alerts that are mostly false.

This base-rate effect explains why security operations centres invest so heavily in tuning rules, combining signals from several sources and automating the first stage of triage. An analyst who receives a thousand alerts a day, almost all false, will soon start ignoring them, a problem called alert fatigue. The goal is not just to detect attacks but to produce alerts that are worth a human's attention.

Reconnaissance: what attackers learn first

Before attacking, a skilled adversary studies the target, a phase called reconnaissance or footprinting. Passive reconnaissance gathers information without touching the target's systems: the company website, staff profiles on professional networking sites, job adverts that mention particular software, public DNS records, domain registration details and documents whose hidden metadata contains usernames. This kind of research from public sources is called open-source intelligence. Active reconnaissance interacts with the target, for example by scanning its internet-facing addresses to find which ports are open and which software versions are running.

Defenders use the same techniques on themselves, with permission, to see their organisation as an attacker would. Typical findings include forgotten test servers still online, remote desktop exposed to the internet, staff email addresses that follow an obvious pattern and job adverts revealing exactly which firewall the company uses. Reducing this exposure, by removing unneeded services, limiting what public pages reveal and training staff about what they share online, shrinks the attack surface before any attacker arrives. Scanning or probing systems you do not own, without written authorisation, is illegal in most countries even if nothing is damaged.

Seeing traffic in an encrypted world

Encryption creates a dilemma for defenders. Today most web traffic, and a growing share of all traffic, is protected by TLS. That is good for privacy, because nobody on the path can read the contents, but it also means a network IDS cannot read the contents of malicious traffic either. Attackers know this and increasingly hide their communications inside ordinary-looking encrypted connections to cloud services.

Defenders respond in several ways. Some organisations decrypt and inspect traffic at their own gateway, which requires installing a company certificate on managed devices and raises real privacy questions that need clear policies and legal advice. More commonly, analysts rely on information that encryption does not hide: which addresses are talking, how often, at what times and in what volumes. A laptop that contacts the same unfamiliar server every sixty seconds, all night, is suspicious whatever the contents, because that regular pattern, called beaconing, is typical of malware checking in with its controller. DNS lookups are another rich source, since a device must look up a name before connecting to it. Finally, host-based tools on each device can see data before it is encrypted, which is why modern defence combines network monitoring with endpoint detection and response software on laptops and servers. No single vantage point sees everything, so the strongest monitoring combines several and correlates their alerts.

Check your understanding

  1. Name the four layers of the TCP/IP model and give one protocol or address type that belongs to each.
  2. Explain why a video call is more likely to use UDP than TCP.
  3. A server should only offer a website. Which ports would you expect to be open, and why would an open port 3389 concern you?
  4. Explain the difference between signature-based and anomaly-based detection, with one strength and one weakness of each.
  5. Using the worked example's figures, calculate the share of genuine alerts if the false-alarm rate falls to 0.001%.
  6. List four pieces of information an attacker could learn about a company through passive reconnaissance, and one way to reduce each.

Install Chrysolites Open Courses

Android / Chrome / Edge: open the browser menu and choose Install app or Add to Home screen.

iPhone / iPad (Safari): tap the Share button, then Add to Home Screen.