Network Security Exercises
Sixteen exercises across the whole course, in the order of its sections. Most are short analyses of the kind an assessor or defender does every week: read a scan, a ruleset, a configuration or a log, decide, and say what to fix. Try each before opening the answer. Two answers include a program you can edit and run.
| # | Exercise | Practises |
|---|---|---|
| 1 | Is this target in scope? | Scope and Authorization |
| 2 | Three sources, one inventory | Asset Inventory |
| 3 | Read the scan states | How Port Scanning Works |
| 4 | How long will it take? | Scan Noise, Timing, Ethics and Rate Limits |
| 5 | Baseline diff | Nmap Inventories |
| 6 | TLS and SSH review | Service Configuration Review |
| 7 | Name the weakness | Exposed Services … Remote Administration |
| 8 | A zone matrix | Zones, DMZs and Trust Boundaries, VLAN and ACL Design |
| 9 | Zero trust or not? | Zero Trust, Microsegmentation |
| 10 | The tunnel through the bastion | Bastion Hosts and SSH Tunnels |
| 11 | Stateful or not? | Stateless versus Stateful |
| 12 | Find the shadowed rule | Rule Order and Shadowing, nftables Rulesets |
| 13 | Egress and the drop log | Egress Filtering and Logging, Cloud Security Groups |
| 14 | VPN review | IPsec, WireGuard, OpenVPN |
| 15 | Write and tune a rule | Suricata and Snort Rules, Zeek Logs, Tuning |
| 16 | What do we patch first? | Vulnerability Scanners, Patch Prioritisation |
Exercise 1: Is this target in scope?
The scope is 10.10.0.0/24 and 203.0.113.10/32, excluding 10.10.0.40; window 18:00–22:00 UTC. Decide for each: (a) nmap 10.10.0.0/25 at 19:00; (b) nmap 10.10.0.128/25 at 21:30; (c) nmap 203.0.113.0/29 at 20:00; (d) nmap 10.10.0.10 at 22:15.
Answer
(a) No: the /25 contains the excluded 10.10.0.40; add --exclude 10.10.0.40. (b) Yes. (c) No: only 203.0.113.10 is in scope, the /29 covers seven other addresses. (d) No: outside the window, even though the target is fine.
Exercise 2: Three sources, one inventory
DHCP has 10.10.0.90 (printer-2F, MAC 02:00:00:0a:0a:5a); ARP has 10.10.0.90 with the same MAC and 10.10.0.91 with 00:1b:63:…; DNS has 10.10.0.95 nas.lab.test. The official list has none of them. What do you write?
Answer
Three inventory gaps: 10.10.0.90 (a printer by its DHCP name, unregistered); 10.10.0.91 (static address, an OUI to look up, no DHCP or DNS: identify by switch port and a version scan in scope); 10.10.0.95 (DNS only: a NAS that is off, or a stale record; confirm with the owner). Each gets an owner or is removed.
Exercise 3: Read the scan states
A SYN scan reports 22 open, 23 closed, 3389 filtered; a UDP scan reports 161 open|filtered, 123 open. What do you know, and what not?
Answer
22 answered SYN-ACK: something listens. 23 answered RST: reachable, nothing listens. 3389: no answer or ICMP unreachable: a filter in the way (the service may exist). 123/udp replied: NTP runs. 161/udp: silence; SNMP might be running and ignoring the probe, or a firewall drops it. Confirm with a protocol probe (-sU -sV or an SNMP query in scope).
Exercise 4: How long will it take?
At --max-rate 50, how long does a top-100 TCP scan of 120 live hosts take, assuming 90% of ports are silent and one retry each?
Answer
Probes ≈ 120 × 100 × (1 + 0.9) = 22,800; at 50 per second, 456 s, about 7.6 minutes.
Exercise 5: Baseline diff
Approved for db.lab.test: 5432/tcp (from the web server only), 22/tcp (from the bastion only). Last night's internal scan from the staff network shows 22, 5432, 6379 open. What are the findings?
Answer
6379/tcp (Redis) open and unapproved: a new service, often without authentication; identify and remove or bind to localhost. 22 and 5432 reachable from staff: approved services with over-broad reachability, a firewall/segmentation finding.
Exercise 6: TLS and SSH review
A server offers TLS 1.0, 1.2 and 1.3; its suites include TLS_RSA_WITH_3DES_EDE_CBC_SHA; its certificate expires in 9 days. Its sshd -T shows permitrootlogin yes, passwordauthentication yes, allowtcpforwarding yes. List the findings and fixes.
Answer
TLS 1.0 enabled (deprecated by RFC 8996): disable 1.0/1.1. 3DES with static RSA (SWEET32, no forward secrecy): ECDHE + AEAD suites only. Certificate about to expire: renew, automate with ACME, monitor 30 days ahead. SSH: PermitRootLogin no, PasswordAuthentication no (keys or certificates), AllowTcpForwarding no unless required.
Exercise 7: Name the weakness
For each observation, name the common weakness and the first fix: (a) a switch answers SNMP v2c community private; (b) Telnet on a core router; (c) iDRAC reachable from staff desks; (d) a Jenkins on 0.0.0.0:8080 on a developer's PC; (e) one VLAN for everything; (f) nginx 1.18 on Ubuntu 18.04; (g) the firewall's last rule is accept.
Answer
(a) weak authentication: SNMPv3 authPriv or off. (b) unencrypted protocol and insecure remote admin: SSH only, from the management network. (c) insecure remote administration: management network only. (d) unnecessary exposed service: bind to 127.0.0.1 or remove. (e) inadequate segmentation: zones with filtering. (f) outdated software (EOL OS): upgrade the OS. (g) misconfigured firewall: default deny.
Exercise 8: A zone matrix
Write the allowed flows for: public web server (DMZ), app server (app zone), database (data zone), admins (management). Users on the Internet use the website; the web server calls the app server's API on 8443; the app server uses the database on 5432; admins use SSH via a bastion.
Answer
Internet → DMZ: tcp 443. DMZ (web) → app: tcp 8443. App → data: tcp 5432. Management (bastion) → DMZ, app, data: tcp 22. Everything else denied, including DMZ → data and any zone → management. Replies via connection tracking; drops logged at each boundary.
Exercise 9: Zero trust or not?
A vendor sells "zero trust": a VPN client that puts users into the internal network after password login. Is it? What would you ask for?
Answer
No: it grants network-level access by location after one authentication. Ask for per-application access decided per session by a policy engine (identity with MFA, device posture, context), an enforcement point in front of each application, continuous re-evaluation and logging of every decision (NIST SP 800-207 tenets 3, 4 and 6).
Exercise 10: The tunnel through the bastion
On the bastion, ss -tlnp shows sshd listening on 0.0.0.0:3390. What is it, why is it dangerous, and which settings prevent it?
Answer
A remote port forward (ssh -R 3390:…) opened by a user, listening on all interfaces because GatewayPorts allows it: anyone who reaches the bastion on 3390 is relayed somewhere (probably an RDP host) through the user's tunnel. Prevent with GatewayPorts no, PermitListen none, AllowTcpForwarding local or no; detect new listeners against the baseline.
Exercise 11: Stateful or not?
A rule set has only tcp dport { 80, 443 } accept and policy drop, no conntrack rules. What happens to (a) replies to the server's outbound DNS queries; (b) a stray ACK to 443; (c) the server's own outbound HTTPS replies?
Answer
(a) Dropped: they arrive on high UDP ports with no rule. (b) Accepted: it matches port 443 although no connection exists. (c) Replies to the server's outbound connections arrive from port 443 to a high port and are dropped. Add ct state established,related accept and ct state invalid drop first.
Exercise 12: Find the shadowed rule
1 ip saddr 10.10.0.0/16 tcp dport 22 accept
2 ip saddr 10.10.9.0/24 tcp dport 22 drop # guests must not SSH
3 tcp dport 1-1023 drop
4 tcp dport 443 acceptWhich rules can never match? What is the effect? Check with the program.
Answer
Rule 2 is shadowed by rule 1 (guests are inside 10.10.0.0/16): guests can SSH. Rule 4 is shadowed by rule 3 (443 is in 1–1023): HTTPS is blocked. Fix: put rule 2 before rule 1, and either drop rule 3 (use policy drop) or put rule 4 before it.
import ipaddress
rules = [("10.10.0.0/16", (22, 22), "accept"), ("10.10.9.0/24", (22, 22), "drop"),
("0.0.0.0/0", (1, 1023), "drop"), ("0.0.0.0/0", (443, 443), "accept")]
def covers(a, b):
return (ipaddress.ip_network(b[0]).subnet_of(ipaddress.ip_network(a[0]))
and a[1][0] <= b[1][0] and b[1][1] <= a[1][1])
for j, rj in enumerate(rules):
for i in range(j):
if covers(rules[i], rj):
print(f"rule {j + 1} ({rj[2]}) shadowed by rule {i + 1} ({rules[i][2]})")
breakrule 2 (drop) shadowed by rule 1 (accept)
rule 4 (accept) shadowed by rule 3 (drop)
Exercise 13: Egress and the drop log
A server's egress drop log shows: 40 attempts to 198.51.100.53:53/udp per hour; 1 attempt per 300 s to 203.0.113.200:8443; 3 attempts to 192.0.2.80:443 after each package update. Classify each. Separately: an AWS security group allows 0.0.0.0/0 on 22, the NACL denies 22 from everywhere at rule 50. Is SSH reachable?
Answer
The DNS attempts: an application with a hard-coded public resolver (fix the configuration; keep blocking). The 300-second interval to 8443: beacon-like, investigate as a possible compromise. The 443 attempts after updates: an updater ignoring the proxy (configure the proxy). SSH: not reachable, because the NACL denies it before the security group is considered; but the security group is still a finding, since the next NACL change exposes it.
Exercise 14: VPN review
Grade: (a) IPsec IKE proposal aes128-sha1-modp1024; (b) WireGuard peer on the gateway with AllowedIPs = 0.0.0.0/0 for a laptop; (c) OpenVPN with duplicate-cn and no MFA; (d) WireGuard client with AllowedIPs = 10.10.0.0/16.
Answer
(a) Weak: SHA-1 and the 1024-bit MODP group; use AES-GCM, SHA-2 PRF and ECP/Curve25519 groups. (b) Finding: the laptop may send packets with any source address; use its /32. (c) Finding: no per-user identity or revocation, single factor; per-user certificates and MFA. (d) Fine as a split tunnel by design; decide and document the split-tunnel policy.
Exercise 15: Write and tune a rule
Write a Suricata-style rule that alerts on SMB connections from the staff network to other staff workstations (10.10.3.0/24 to 10.10.3.0/24, TCP 445). In a week it fired 900 times, all from 10.10.3.200, the IT team's deployment server. Tune it.
Answer
alert tcp 10.10.3.0/24 any -> 10.10.3.0/24 445 (msg:"LAB SMB between staff workstations"; flow:to_server; flags:S; sid:1000020; rev:1;). Tuning: suppress gen_id 1, sig_id 1000020, track by_src, ip 10.10.3.200 with an owner and a review date, or better, move the deployment server to the management zone so its traffic isn't staff-to-staff at all. A Zeek query on conn.log (id.resp_p == 445 with both ends in staff) shows the same pattern for hunting.
Exercise 16: What do we patch first?
Four findings: (A) CVSS 9.8, EPSS 0.002, internal test server; (B) CVSS 6.5, in KEV, Internet-facing file-transfer appliance; (C) CVSS 8.8, EPSS 0.3, staff browsers; (D) CVSS 7.5, banner-only check on an Ubuntu package. Order them and say what you do about D.
Answer
B first (known exploited, Internet-facing: emergency), then C (likely exploitation, reached by every user), then A (severe but unlikely and internal; normal cycle, or restrict access). D: verify with an authenticated check against the Ubuntu advisory before prioritising; it may be a backport false positive.
items = {"A": (9.8, 0.002, False, "internal"), "B": (6.5, None, True, "internet"),
"C": (8.8, 0.3, False, "user"), "D": (7.5, None, False, "unverified")}
def key(k):
cvss, epss, kev, exp = items[k]
if exp == "unverified": return (9, 0) # verify before ranking
return (0 if kev and exp == "internet" else 1 if (epss or 0) >= 0.1 else 2, -cvss)
print(" > ".join(sorted(items, key=key)), "(D: verify first)")B > C > A > D (D: verify first)
Practice problems for this course, with tests in 21 languages: Merge Port Ranges, Firewall First Match.
Test yourself
Exercise 12: why can guests SSH although rule 2 drops them?
- Rule 2 has a typo
- Rule 1 accepts 10.10.0.0/16, which contains the guest network, before rule 2 is reached
- The policy is accept
- SSH uses UDP
Exercise 13: is SSH reachable when the security group allows it but the NACL denies it?
- Yes
- No, the NACL drops it at the subnet
- Only over IPv6
- Only from the bastion
Exercise 16: which finding goes first?
- A, the highest CVSS
- B, known exploited and Internet-facing
- C
- D