5 min read

Beginner

Network Security Fundamentals

Every attack crosses a network, and much of what decides whether it works is addressing, ports and prefixes. This section covers those, from the frame on the wire to the way a capture is read.

Why This Matters

Every exploit, every payload and every C2 callback travels over a network. A failure at Layer 2 and a failure at Layer 7 look nothing alike in a capture, and telling them apart is most of the diagnostic work.

OSI Attack Surface Map

OSI Model - Click layers to explore
7 LAYERS
7
Application
HTTP • HTTPS • SSH • FTP • DNS • SMTP
6
Presentation
SSL/TLS • JPEG • ASCII • MIME
5
Session
NetBIOS • RPC • SMB • SOCKS
4
Transport
TCP • UDP • SCTP
3
Network
IP • ICMP • IPSec • IGMP
2
Data Link
Ethernet • ARP • Wi-Fi • PPP
1
Physical
Cables • Hubs • Repeaters • Radio

The Two Models You Must Know

OSI Model (7 Layers)

The theoretical framework. Used for discussing attacks.

7ApplicationHTTP, SSH
6PresentationSSL/TLS
5SessionNetBIOS
4TransportTCP, UDP
3NetworkIP, ICMP
2Data LinkEthernet, ARP
1PhysicalCables, Hubs

TCP/IP Model (4 Layers)

The practical implementation. What actually runs.

4ApplicationHTTP, DNS, FTP
3TransportTCP, UDP
2InternetIP, ICMP, ARP
1Network AccessEthernet, Wi-Fi

Mnemonic: "All Traffic Is Not Perfect" (Application, Transport, Internet, Network Access). ARP sits at Data Link in OSI and at the Internet layer here; both describe the same frame.

Attack Surface by Layer

Every layer presents unique attack opportunities. Knowing where an attack occurs helps you understand how to execute and defend against it.

Layer Attack Type Example Techniques MITRE ATT&CK
L7 - Application Web/App Exploits SQL Injection, XSS, API Abuse, RCE T1190
L6 - Presentation Encryption Attacks SSL Stripping, Padding Oracle, Downgrade Attacks T1557
L5 - Session Session Hijacking Cookie Theft, Session Fixation, Token Replay T1539
L4 - Transport Connection Attacks SYN Flood, Port Scanning, TCP Sequence Prediction T1046
L3 - Network Routing Attacks IP Spoofing, ICMP Redirect, BGP Hijacking T1599
L2 - Data Link LAN Attacks ARP Spoofing, MAC Flooding, VLAN Hopping T1557.002
L1 - Physical Hardware Attacks Cable Tapping, Rogue Devices, Jamming T1200

Deep Dive Available

For detailed exploitation techniques per layer, see the Internal Pentest Guide which covers LLMNR poisoning, relay attacks, and more.

Quick Reference: Critical Ports

These are the ports most first-contact work runs into. The colour is a prompt: red is where to look first, yellow is cleartext, green is encrypted, blue is infrastructure.

21 | FTP
22 | SSH
23 | Telnet
25 | SMTP
53 | DNS
80 | HTTP
443 | HTTPS
445 | SMB
3306 | MySQL
3389 | RDP

The chips are a short list. Service names and risk notes for the wider set are in the Port Reference tool, and Protocols & Ports covers what actually answers on each one.

Learning Modules

Essential Recon Commands

Scanning a network you neither own nor hold written permission to test is unlawful in most jurisdictions, and a ping sweep or port scan is enough to qualify in several of them. The examples below assume a lab or a signed engagement scope.

Discover Live Hosts (Ping Sweep)

ping-sweep.sh
nmap -sn 192.168.1.0/24

Quick Port Scan (Top 1000)

quick-scan.sh
nmap -sT -T4 <target_ip>

View Your Network Interfaces

interfaces.sh
ip addr show          # Linux
ipconfig /all         # Windows
ifconfig              # macOS

Check ARP Table (Local Neighbors)

arp-table.sh
arp -a                # Windows and macOS
ip neigh show         # Linux

Trace the Route to a Target

traceroute.sh
traceroute <target>   # Linux/macOS
tracert <target>      # Windows

Full Service Scan with Scripts (all ports)

full-scan.sh
nmap -sC -sV -p- <target_ip>        # unprivileged; -p- is all 65,535 ports
sudo nmap -sC -sV -O -p- <target_ip>  # adds OS detection, which needs root