OS Fundamentals¶
Module Overview
This module covers essential operating system concepts crucial for understanding security, system administration, and penetration testing across different platforms.
Learning Objectives¶
By the end of this module, you will be able to:
- Understand operating system architecture and components
- Navigate and manage Linux and Windows file systems
- Comprehend process management and inter-process communication
- Configure and analyze network services and protocols
- Implement security hardening techniques
Operating System Architecture¶
graph TB
A[Applications] --> B[System Calls]
B --> C[Kernel]
C --> D[Hardware Abstraction Layer]
D --> E[Hardware]
C --> F[Process Management]
C --> G[Memory Management]
C --> H[File System]
C --> I[Network Stack]
C --> J[Device Drivers] Core OS Components¶
| Component | Function | Security Relevance |
|---|---|---|
| Kernel | Core OS functions, hardware abstraction | Kernel exploits, privilege escalation |
| Shell | User interface, command interpreter | Command injection, shell escapes |
| File System | Data storage and organization | File permissions, ACLs |
| Network Stack | Network communication protocols | Network attacks, packet analysis |
| Process Manager | Process creation and scheduling | Process injection, privilege escalation |
File Systems Deep Dive¶
Linux File System Hierarchy¶
# Extended attributes
lsattr file.txt # List attributes
chattr +i file.txt # Make immutable
chattr +a file.txt # Append-only
# Access Control Lists (ACLs)
getfacl file.txt # View ACL
setfacl -m u:user:rw file.txt # Modify ACL
# SELinux contexts
ls -Z file.txt # View SELinux context
chcon -t httpd_exec_t file.txt # Change context
Windows File System¶
# Registry hives
HKEY_LOCAL_MACHINE (HKLM) # Machine-wide settings
HKEY_CURRENT_USER (HKCU) # Current user settings
HKEY_CLASSES_ROOT (HKCR) # File associations
HKEY_USERS (HKU) # All user profiles
HKEY_CURRENT_CONFIG (HKCC) # Current hardware profile
# Registry operations
Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion"
Set-ItemProperty -Path "HKCU:\Software\Test" -Name "Value" -Value "Data"
Process Management¶
Linux Process Control¶
# Process listing and analysis
ps aux # All processes
ps -elf # Extended format
pstree # Process tree
top # Real-time process monitor
htop # Enhanced process monitor
# Process details
cat /proc/PID/status # Process status
cat /proc/PID/cmdline # Command line
cat /proc/PID/environ # Environment variables
lsof -p PID # Open files
Windows Process Management¶
Memory Management¶
Virtual Memory Concepts¶
The relationship between virtual and physical memory can be expressed as:
Where the Memory Management Unit (MMU) translates virtual addresses to physical addresses using page tables.
Linux Memory Analysis¶
Windows Memory Management¶
# Memory information
Get-WmiObject Win32_PhysicalMemory | Select Capacity, Speed
Get-Counter "\Memory\Available MBytes"
# Process memory usage
Get-Process | Sort-Object WorkingSet -Descending | Select -First 10
# Virtual memory
Get-WmiObject Win32_PageFileUsage
Network Fundamentals¶
TCP/IP Stack Analysis¶
graph TB
A[Application Layer] --> B[Transport Layer]
B --> C[Network Layer]
C --> D[Data Link Layer]
D --> E[Physical Layer]
A --> F[HTTP, HTTPS, SSH, FTP]
B --> G[TCP, UDP]
C --> H[IP, ICMP, ARP]
D --> I[Ethernet, WiFi]
E --> J[Physical Hardware] Network Configuration¶
# Interface configuration
ip addr show # Show interfaces
ip route show # Show routing table
ip neigh show # Show ARP table
# Network statistics
ss -tuln # Socket statistics
netstat -rn # Routing table
iptables -L -n # Firewall rules
# DNS configuration
cat /etc/resolv.conf # DNS servers
systemd-resolve --status # Systemd DNS info
# Network configuration
Get-NetAdapter # Network adapters
Get-NetIPConfiguration # IP configuration
Get-NetRoute # Routing table
# Network connections
Get-NetTCPConnection # TCP connections
Get-NetUDPEndpoint # UDP endpoints
# Firewall
Get-NetFirewallRule # Firewall rules
Get-NetFirewallProfile # Firewall profiles
Protocol Analysis¶
Security Hardening¶
Linux Hardening Checklist¶
| Category | Hardening Measure | Implementation |
|---|---|---|
| Updates | Keep system updated | apt update && apt upgrade |
| Users | Disable root login | PermitRootLogin no in sshd_config |
| Firewall | Enable iptables/ufw | ufw enable |
| Services | Disable unnecessary services | systemctl disable service |
| Permissions | Fix file permissions | chmod, chown appropriately |
| Logging | Enable comprehensive logging | Configure rsyslog/journald |
Windows Hardening¶
Practical Exercises¶
Exercise 1: File System Analysis¶
Challenge
Analyze a compromised system's file system for evidence of intrusion.
Investigation Steps
# 1. Check recently modified files
find / -mtime -1 -type f 2>/dev/null
# 2. Look for unusual SUID binaries
find / -perm -4000 -type f 2>/dev/null | sort
# 3. Examine log files
tail -f /var/log/auth.log
grep -i "failed\|error" /var/log/syslog
# 4. Check for hidden files
find / -name ".*" -type f 2>/dev/null
Exercise 2: Process Forensics¶
Challenge
Identify and analyze suspicious processes on a Windows system.
Analysis Approach
flowchart TD
A[List All Processes] --> B[Check Process Trees]
B --> C[Analyze Network Connections]
C --> D[Examine Process Details]
D --> E[Check File Signatures]
E --> F[Correlate with Logs] Performance Monitoring¶
System Resource Monitoring¶
Performance Tuning¶
The performance optimization formula:
Where efficiency factors include CPU scheduling, memory allocation, and I/O optimization.
Key Takeaways¶
Core Concepts
- Understanding OS internals is crucial for effective security assessment
- File systems store critical security information and potential attack vectors
- Process management knowledge enables detection of malicious activities
- Network stack comprehension aids in traffic analysis and incident response
- Security hardening requires systematic approach across all OS components
Additional Resources¶
- Linux System Administrator's Guide - Comprehensive Linux administration
- Windows Internals - Deep Windows system knowledge
- SANS Linux Cheat Sheet - Quick reference
- PowerShell Documentation - Windows automation
- Sysadmin Toolkit - System administration resources
This module establishes the foundational operating system knowledge necessary for advanced security topics and practical system administration tasks.