The Mindset
Security hardening is what defenders put in place to stop you. As a pentester you need to:- Identify what’s running — SELinux? AppArmor? Fail2ban? Each changes your approach
- Understand the restrictions — What can’t you do, and why?
- Find the gaps — Hardening is only as strong as its configuration. Misconfigured defenses are often worse than none at all
System Updates & Patch Level
The most basic security control — and the most commonly neglected. An unpatched kernel or service is often a direct path to root.SELinux — Security-Enhanced Linux
SELinux is a Mandatory Access Control (MAC) system built into the Linux kernel. It enforces security policies that define exactly what every process can and cannot do — regardless of file permissions.How It Works
Every process, file, and system object gets a security label. Policy rules define which labels can interact with which. Even root is constrained by SELinux policy.Check SELinux Status
SELinux Modes
SELinux Contexts
Temporarily Disable SELinux (Requires Root)
Common SELinux Bypass Techniques
AppArmor
AppArmor is also a MAC system but operates differently from SELinux. It uses application profiles that define what files and capabilities each application can access. Simpler to configure than SELinux, and common on Ubuntu/Debian systems.Check AppArmor Status
AppArmor Modes
Check Profiles for a Process
Disable AppArmor for a Profile (Requires Root)
TCP Wrappers
TCP Wrappers control access to network services based on the client’s IP address. Simple but effective for basic network-level access control.How It Works
Two files control access:
Rule order:
hosts.allow is checked first. If a match is found, access is granted. If not, hosts.deny is checked. If no match in either, access is granted by default.
Reading the Config Files
Format
Firewall — iptables & nftables
iptables
nftables (Modern Replacement)
UFW (Uncomplicated Firewall — Ubuntu)
Fail2ban
Fail2ban monitors logs and bans IPs that show malicious behavior (too many failed logins, etc.).Other Security Tools
SSH Hardening (Know What You’re Up Against)
SSH config reveals what authentication methods are allowed and what restrictions are in place:Next: Terminal Shortcuts — keyboard shortcuts that save time and keep you moving fast in the terminal.