Networking Basics
The internet is built on layers of abstraction. To exploit it, you must peel back these layers.
The OSI Model
The Open Systems Interconnection (OSI) model describes how computer systems communicate. Hackers use this to categorize attacks (e.g., "Layer 7 DDoS" vs "Layer 2 ARP Spoofing").
Memory Trick
| Layer | Name | Function | Protocols | Attack Examples |
|---|---|---|---|---|
| 7 | Application | End-user processes | HTTP, SSH, FTP, DNS, SMTP | SQLi, XSS, RCE |
| 6 | Presentation | Data formatting/encryption | SSL/TLS, JPEG, ASCII | SSL Stripping, Padding Oracle |
| 5 | Session | Connections between apps | NetBIOS, RPC, SMB | Session Hijacking |
| 4 | Transport | End-to-end connections | TCP, UDP | SYN Flood, Port Scanning |
| 3 | Network | Routing and addressing | IP, ICMP, IPSec | IP Spoofing, Smurf Attack |
| 2 | Data Link | Physical addressing | Ethernet, ARP, Wi-Fi | ARP Spoofing, MAC Flooding |
| 1 | Physical | Raw bit stream | Cables, Hubs, Radio | Wiretapping, Jamming |
IP Addressing (Layer 3)
An IP address is a logical identifier for a device on a network. Unlike MAC addresses, IPs can be changed and are used for routing across networks.
IPv4
32-bit address, written as 4 octets (0-255 each).
192.168.1.1 ~4.3 billion addresses (exhausted)
IPv6
128-bit address, hexadecimal notation.
2001:0db8:85a3::8a2e:0370:7334 340 undecillion addresses
Private IP Ranges (RFC 1918)
These addresses are NOT routable on the public internet. You'll see them on every internal network.
| Class | Range | CIDR | Hosts | Common Use |
|---|---|---|---|---|
| A | 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | 16M+ | Large enterprises |
| B | 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | 1M+ | Medium organizations |
| C | 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | 65K | Home/Small office |
Pentest Tip
10.x.x.x often means a large corporate network with many subnets to explore. 192.168.x.x is typically a smaller, flatter network.
MAC Addresses (Layer 2)
A Media Access Control (MAC) address is a hardware identifier burned into the network interface card (NIC). It is used for communication within the same local network segment (LAN).
Useful Commands
ip link show # Linux
ipconfig /all # Windows
ifconfig # macOS arp -a # All platforms
ip neigh show # Linux modern ip link set dev eth0 down
ip link set dev eth0 address XX:XX:XX:XX:XX:XX
ip link set dev eth0 up Hacker Note
ARP: The Bridge Between L2 and L3
Address Resolution Protocol (ARP) maps IP addresses to MAC addresses. When a device wants to communicate with another on the LAN, it asks: "Who has IP X.X.X.X? Tell me your MAC."
ARP Spoofing Attack (Man-in-the-Middle)
- Attacker sends fake ARP replies:
"192.168.1.1 is at AA:BB:CC:DD:EE:FF"(attacker's MAC) - Victim's ARP cache is poisoned - traffic intended for the gateway goes to the attacker
- Attacker forwards traffic to the real gateway (invisible interception)
- All victim traffic can now be sniffed, modified, or blocked
arpspoof -i eth0 -t 192.168.1.100 192.168.1.1