**Networking Basics and Linux Fundamentals
This lesson introduces fundamental networking concepts and Linux basics crucial for red team pentesting. You'll learn about IP addresses, ports, common network protocols, and how to navigate and interact with Linux systems. This will lay the groundwork for understanding how systems communicate and how to begin assessing their security.
Learning Objectives
- Define and differentiate between IP addresses, subnets, and gateways.
- Identify common network ports and the services associated with them.
- Understand basic Linux commands for navigation, file manipulation, and process management.
- Explain the role of the command line interface (CLI) and its importance in pentesting.
Text-to-Speech
Listen to the lesson content
Lesson Content
Networking Fundamentals
Networks connect devices together to share resources. The Internet Protocol (IP) is the language networks use to talk. Let's explore some key concepts:
- IP Addresses: Think of them as unique addresses for devices on a network (like your home address). There are two main types: IPv4 (e.g., 192.168.1.1) and IPv6 (a newer, more complex type).
- Subnets: Networks can be divided into smaller groups called subnets. This helps organize and manage devices.
- Gateways: The gateway is like a door that lets your network connect to other networks, including the Internet.
- Ports: Think of ports as virtual doors on a computer that let different services communicate. Each port has a number (e.g., port 80 for HTTP, port 443 for HTTPS).
- Protocols: Protocols are sets of rules that govern communication. Examples include:
- TCP (Transmission Control Protocol): Reliable, connection-oriented (like a phone call).
- UDP (User Datagram Protocol): Unreliable, connectionless (like sending a postcard).
- HTTP/HTTPS (Hypertext Transfer Protocol/Secure): Used for web browsing.
- DNS (Domain Name System): Translates domain names (like google.com) to IP addresses.
Example: When you type "google.com" in your browser:
1. Your computer asks a DNS server for the IP address of google.com.
2. The DNS server replies with something like 142.250.186.142.
3. Your computer sends an HTTP request (over port 80) or HTTPS request (over port 443) to that IP address.
Linux Fundamentals
Linux is a popular operating system used in cybersecurity. The command-line interface (CLI) is how you interact with it.
Here are some basic commands:
pwd(Print Working Directory): Shows your current location.ls(List): Lists files and directories in your current location.cd(Change Directory): Moves you to a different directory. Example:cd Documents.mkdir(Make Directory): Creates a new directory. Example:mkdir new_folder.rmdir(Remove Directory): Removes an empty directory. Example:rmdir new_folder.rm -r(Remove Recursively): Removes a directory and all its contents. Use with caution! Example:rm -r directory_to_remove.touch(Create File): Creates a new, empty file. Example:touch new_file.txt.cat(Concatenate): Displays the contents of a file. Example:cat new_file.txt.nanoorvim(Text Editors): Opens a text editor to modify files.ifconfigorip addr: (Network Interface Configuration) Displays information about your network interfaces and IP addresses (used on some distributions,ip addris increasingly common).ping: Sends packets to a host to test network connectivity. Example:ping google.com.whoami: Displays your current username.sudo: Executes a command with elevated privileges (requires a password, typically).ps: Lists running processes. Example:ps auxwill show all processes.kill: Terminates a process. Requires the process ID (PID) fromps. Example:kill 1234(where 1234 is the PID).
Deep Dive
Explore advanced insights, examples, and bonus exercises to deepen understanding.
Day 2: Red Team Pentesting - Extended Learning
Building on our foundational knowledge of networking and Linux, let's explore deeper concepts and practical applications relevant to red team pentesting. We'll enhance your understanding of how systems connect and how you can leverage these insights to assess and exploit vulnerabilities.
Deep Dive: Understanding Network Addressing & Linux File Systems
Let's go beyond the basics. We'll explore more nuanced concepts and alternative ways to think about networking and Linux.
Network Addressing: Subnetting & CIDR Notation
Recall that IP addresses are used to identify devices on a network. But how does a device determine if another device is on the same network? Subnets are crucial. They divide a network into smaller, manageable parts. Instead of using classful addressing (A,B,C), we now use CIDR (Classless Inter-Domain Routing). CIDR uses a notation like 192.168.1.0/24. The /24 indicates the "subnet mask" (255.255.255.0). This mask specifies which part of the IP address is the network address and which part is the host address. In a /24 network, the first three octets (192.168.1) identify the network, and the last octet (0-255) is for host addresses within that subnet. Understanding subnetting is critical for network reconnaissance and identifying targets.
Linux File Systems: Beyond Navigation
Understanding the Linux file system is vital for data exfiltration, privilege escalation, and lateral movement. Remember the file system starts at the root (/). Important directories include: /home (user home directories), /etc (configuration files), /var (variable data like logs), /tmp (temporary files), /proc (process information), and /root (root user's home directory). Consider the implications of each during a pentest: What information can be found in each directory? How could you manipulate files within them for malicious purposes? Familiarize yourself with commands like `find`, `grep`, and `chmod` for file manipulation and information gathering.
Bonus Exercises
Put your new knowledge to the test!
Exercise 1: Subnetting Practice
Determine the subnet mask and the usable host range for the following CIDR notations: 10.0.0.0/20, 172.16.0.0/16, 192.168.10.0/28. Use online subnet calculators to verify your answers. What implications do different subnet sizes have for network security?
Exercise 2: File System Exploration
Using a Linux virtual machine or a live CD, explore the file system. Use the `ls -l` command to view file permissions. Create a file in `/tmp`. Identify the owner and group of files in `/etc/passwd`. Try to find and list all files ending in `.log` within the `/var/log` directory. Explain what you've found and its implications.
Real-World Connections
How does this apply to the real world?
Penetration Testing Scenario
Imagine you're tasked with testing the network security of a company. You perform a network scan and discover a host with the IP address 192.168.1.100 on a 192.168.1.0/24 subnet. How does understanding the subnet mask and host range help you plan your next steps? What information can you gather to better understand the company's network infrastructure and how to get access?
Daily Life: Home Network Security
Knowing about subnets and port numbers can help you secure your home network. By understanding your router's configuration (subnet, DHCP range) and the ports used by your devices, you can create more effective firewall rules. Also, knowing what programs are using what ports can help you diagnose and fix problems with your connectivity.
Challenge Yourself
Want to go further? Try this:
Network Reconnaissance Tool Development (Simplified)
Write a simple Python script (using the `socket` module) that scans a specified IP address range and identifies open ports. The script should at least check for ports 21 (FTP), 22 (SSH), and 80 (HTTP). This is an extremely simplified version of a port scanner and useful to get a deeper understanding of how the network works.
Further Learning
Continue your exploration with these topics and resources:
- Online Networking Courses: Explore resources like Cisco's free courses on networking fundamentals or the CompTIA Network+ certification.
- Linux Command Reference: Study the man pages (e.g., `man ls`, `man find`) for a deeper understanding of Linux commands.
- Network Protocols: Dive into specific protocols like TCP, UDP, and ICMP to understand their inner workings.
- Wireshark: Learn to use Wireshark (a network packet analyzer) to capture and analyze network traffic.
Interactive Exercises
Network Troubleshooting with Ping
Open your terminal. Try to 'ping' a few different websites (e.g., google.com, amazon.com, your local router address). What do the results tell you about your network connection?
Navigating the File System
Using `cd`, `ls`, `mkdir`, and `rmdir` commands, create a directory called 'test', then create a file called 'hello.txt' inside it. Then remove the 'test' directory and its contents (if you want to test the `rm -r` command).
Identifying Network Interfaces
Use the `ifconfig` or `ip addr` command (depending on your Linux distribution) to identify your network interfaces. What is the IP address assigned to your primary interface? What is the subnet mask?
Reflection: The Command Line's Power
Consider why the command line is so valuable to penetration testers. What tasks are easier using the CLI than with a graphical user interface (GUI)? Write a short paragraph explaining your thoughts.
Practical Application
Imagine you've been hired to audit a small company's network security. Start by using ping and traceroute (if available on your system) to map out their network. Try to identify the active IP addresses and the path traffic takes to get to their main server. Document your findings.
Key Takeaways
IP addresses and ports are fundamental to network communication.
Linux CLI provides powerful tools for system interaction and pentesting.
Understanding protocols like TCP/UDP, HTTP/HTTPS, and DNS is critical for network analysis.
The `ping` command is a basic but important tool for network troubleshooting and reconnaissance.
Next Steps
Prepare for the next lesson by researching network scanning tools like `nmap` and learning about the different scan types (e.
g.
, TCP connect scan, SYN scan).
Consider installing a Linux distribution or setting up a virtual machine environment (e.
g.
, VirtualBox, VMware) for hands-on practice.
Your Progress is Being Saved!
We're automatically tracking your progress. Sign up for free to keep your learning paths forever and unlock advanced features like detailed analytics and personalized recommendations.
Extended Learning Content
Extended Resources
Extended Resources
Additional learning materials and resources will be available here in future updates.