Skip to main content

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
This knowledge also helps you write better pentest reports — you can tell defenders exactly what’s missing.

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.
Always run uname -r early and search for kernel exploits. Administrators frequently patch applications but forget to update the kernel manually on older systems.

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

TCP Wrappers only control access to services — not to ports. It’s not a firewall replacement. A service not using TCP Wrappers (like most modern daemons) is completely unaffected.

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.).
Pentest relevance: If fail2ban is active on SSH, slow down your brute force attempts or use a distributed approach. The default ban threshold is typically 5 failures.

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:
Key settings and their pentest implications:
Next: Terminal Shortcuts — keyboard shortcuts that save time and keep you moving fast in the terminal.