Hello! Welcome to your first lesson in the "Teach me Kali Linux" course. I'm excited to start this journey with you.
Given your goal of becoming a professional penetration tester, we're beginning with the absolute bedrock of the field: networking. You can't ethically hack what you don't understand. This first module is designed to give you that deep, theoretical foundation you asked for, focusing on the "how and why" before we ever touch a tool.
Today's lesson addresses the first learning outcome: Explain the purpose and layers of the OSI model. We will explore why a standardized model for networking is necessary, and then we'll break down its seven layers. Crucially, we'll look at each layer not just as an abstract concept, but as a potential "attack surface"—a perspective that is fundamental to security analysis.
The Problem: Why Do We Need a Model?
Imagine the early days of computing in the 1960s and 70s. You have computers from different manufacturers, like IBM and HP. They are brilliant machines, but they can't talk to each other. Each company developed its own proprietary networking technology, its own "language." It was like trying to plug a modern Android charger into an iPhone—they're fundamentally incompatible.
This created a huge barrier. For the internet to become the global network it is today, a common set of rules—a standard—was needed. To understand this historical context and the solution that emerged, please watch the beginning of the following video.
what is TCP/IP and OSI? // FREE CCNA // EP 3
This video from NetworkChuck explains the historical problem of incompatible networks and introduces why standardized models like TCP/IP and OSI were created to solve it.
Watch the section from the beginning until 03:50. Focus on understanding the problem that networking models were designed to solve.
The key takeaway is that networking models provide a universal blueprint. They ensure that a device made by Apple can successfully exchange data with a server running on a Linux system built with custom hardware. This interoperability is achieved by breaking down the incredibly complex task of network communication into smaller, distinct parts. This is the core purpose of the OSI model.
The OSI Model: A Conceptual Framework
The Open Systems Interconnection (OSI) model is a conceptual framework that standardizes the functions of a telecommunication or computing system into seven distinct layers. Think of it as a recipe for network communication. Each layer handles a specific part of the job, and they all work together in a specific order.
Here is a high-level look at the seven layers. We will explore each one in detail shortly.
:max_bytes(150000):strip_icc()/Osi-model-jb.svg-57f7b9af3df78c690f6305e8.png)
How Data Moves: Encapsulation and De-encapsulation
When you send data—for example, by loading a webpage—it doesn't just go out as one big chunk. It starts at the top of the OSI model (Layer 7) on your computer and moves down through each layer.
At each layer, a piece of information, called a header, is added. This process is called encapsulation. The header contains instructions that are relevant to that specific layer. For instance, the Network Layer adds a header with the IP address, while the Data Link Layer adds a header with the MAC address.
Once the data reaches the bottom layer (Layer 1), it is sent over the network. The receiving computer then does the reverse process, known as de-encapsulation. The data moves up the stack from Layer 1 to Layer 7. At each layer, the corresponding header is read, acted upon, and stripped away, until the original data is delivered to the application.
To see a detailed walkthrough of this process, please read the following excerpt.
The OSI Model: Understanding the Layered Approach to Network ...
This article from Splunk provides a clear, practical example of how data travels through the OSI layers when you request a webpage.
Read the section titled 'How data is transmitted in the OSI model: The bi-directional journey'. Focus on understanding the concepts of encapsulation (data moving down the layers) and de-encapsulation (data moving up the layers).
The Seven Layers: A Map of Attack Surfaces
Now, let's dive into the function of each layer. As a future penetration tester, it's vital to see these layers as more than just theoretical constructs. Each one uses different protocols and technologies, and therefore, each one has unique vulnerabilities. Understanding the layers helps you map out where and how a system might be attacked.
The following video provides an excellent overview of all seven layers from a hacker's perspective. It will introduce each layer's function and, more importantly, an example of an attack that targets that layer.
TCP/IP and the OSI Model Explained! (Advanced Hacking Course)
This video from Hacker Joe frames the OSI model as a 'map of attack surfaces,' explaining each layer's function and a corresponding exploit. This aligns perfectly with an ethical hacking mindset.
Watch from timestamp 06:23 to 16:03. Pay close attention to the specific function of each layer and the type of attack that can be performed against it.
To reinforce what you just watched, here is a summary of the seven layers and their functions, keeping the security context in mind.
| Layer | Name | Primary Function | Data Unit | Security Perspective (Attack Examples) |
|---|---|---|---|---|
| 7 | Application | Provides a network interface for applications. What the user sees. | Data | SQL Injection, Cross-Site Scripting (XSS), Phishing. Attacks target software logic and user trust. |
| 6 | Presentation | Translates, formats, encrypts, and compresses data. | Data | Man-in-the-Middle (MITM) attacks like SSL Stripping, which downgrade encryption. |
| 5 | Session | Establishes, manages, and terminates connections (sessions). | Data | Session Hijacking, where an attacker steals a session cookie to impersonate a user. |
| 4 | Transport | Provides end-to-end data transport services with TCP & UDP. Manages flow control and error checking. | Segment (TCP) / Datagram (UDP) | Port scanning, SYN floods (DoS), and firewall evasion using packet fragmentation. |
| 3 | Network | Handles logical addressing (IP addresses) and routing of packets across networks. | Packet | IP Spoofing, Denial-of-Service (DoS) attacks, and interfering with routing tables. |
| 2 | Data Link | Manages communication on the local network using physical addresses (MAC addresses). | Frame | ARP Spoofing/Poisoning to conduct MITM attacks on a local network. |
| 1 | Physical | Defines the physical and electrical specifications for devices. Transmits raw bits over a medium. | Bit | Physical access, wiretapping, and hardware-based attacks like a USB Rubber Ducky or Wi-Fi Pineapple. |
This detailed chart provides another excellent summary for your reference.
OSI vs. TCP/IP
You will often hear the OSI model mentioned alongside another model: TCP/IP. While the OSI model is the standard conceptual and educational tool (we always refer to layers by their OSI number, e.g., a "Layer 7 firewall"), the TCP/IP model is a more practical model that the internet is actually built upon. It has fewer layers, condensing some of the OSI layers' functions.
For a network professional, it's important to know both and how they relate. Most of the protocols you'll encounter, like HTTP, TCP, and IP, are from the TCP/IP suite.
Here is a simple mapping:
| OSI Model Layer | TCP/IP Model Layer |
|---|---|
| 7. Application | \multirow{3}{*}{Application} |
| 6. Presentation | |
| 5. Session | |
| 4. Transport | Transport |
| 3. Network | Internet |
| 2. Data Link | \multirow{2}{*}{Network Access} |
| 1. Physical |
Understanding this relationship helps bridge the gap between theory (OSI) and practice (TCP/IP).
Conclusion
In this lesson, we established the foundational "map" for all our future explorations in networking and security.
Key Takeaways:
- The OSI model was created to standardize network communication, allowing devices from different manufacturers to interoperate.
- It is a 7-layer conceptual framework that breaks down the complex process of networking into smaller, manageable functions.
- Data is encapsulated as it travels down the layers on the sending device and de-encapsulated as it travels up the layers on the receiving device.
- From a security perspective, each layer is an attack surface with unique vulnerabilities that can be exploited.
This layered model is the key to troubleshooting network issues and, for our purposes, to identifying weaknesses in a system. When a penetration tester analyzes a target, they are mentally breaking it down along these layers: can I attack the physical hardware (Layer 1)? Can I interfere with local traffic (Layer 2)? Can I fool the application logic (Layer 7)?
In our next lesson, we will dive deeper into Layer 4, the Transport Layer, and explore the critical differences between its two main protocols: TCP and UDP. Understanding them is essential for learning how tools like the port scanner Nmap work and how different types of data are transmitted across the internet.