Build your cybersecurity foundation with these essential hands-on labs designed for CompTIA Security+ certification preparation.
Lab 1: Linux Security Hardening
Beginner
Scenario: Secure the Web Server
You've been hired as a junior security analyst at StartupTech Inc. The company's web server running Ubuntu 20.04 has never been properly secured. Your manager has asked you to perform basic security hardening to protect against common attacks. The server is currently running with default configurations and needs immediate attention.
Learning Objectives:
User Account Security: Create secure user accounts and disable unnecessary ones
SSH Hardening: Configure SSH for key-based authentication and disable root login
Firewall Configuration: Set up UFW (Uncomplicated Firewall) with proper rules
System Updates: Update system packages and configure automatic security updates
📋 Step-by-Step Instructions
Check Current User Accounts:cat /etc/passwd | grep -v nologin
Why: Attackers often create backdoor accounts. Identifying all login-enabled accounts helps you spot unauthorized access. Security Impact: Reduces attack surface by eliminating unnecessary user accounts that could be exploited.
Create a New Secure Admin User:sudo adduser secadmin
Why: Using generic 'admin' or 'ubuntu' accounts makes you vulnerable to brute-force attacks. A uniquely named admin account with a strong password is harder to compromise. Security Impact: Implements principle of least privilege and accountability through distinct administrative accounts.
Add User to Sudo Group:sudo usermod -aG sudo secadmin
Why: Instead of using root directly, sudo provides accountability through logging and time-limited privilege escalation. Security Impact: All administrative actions are logged with timestamps and user attribution for audit trails.
Why: Root is the most targeted account in SSH brute-force attacks. Disabling root SSH login forces attackers to compromise two accounts (user + privilege escalation). Security Impact: Prevents 90% of automated SSH attacks that target the root account. Edit 'PermitRootLogin' to 'no'.
Restart SSH Service:sudo systemctl restart sshd
Why: SSH configuration changes only take effect after service restart. Without this, your security changes won't be active. Security Impact: Applies the root login restriction immediately, closing the vulnerability window.
Enable UFW Firewall:sudo ufw enable
Why: Without a firewall, all network services are exposed. UFW provides a simple defense-in-depth layer to control network access. Security Impact: Blocks all incoming connections by default, forcing explicit allow rules for required services only.
Why: Principle of least privilege - only expose ports that are absolutely necessary. Port 22 (SSH), 80 (HTTP), and 443 (HTTPS) are required for web server management. Security Impact: Reduces attack surface by 99% - only 3 ports open instead of 65,535. Blocks vulnerability scanners and exploit attempts on unused services.
Update System Packages:sudo apt update && sudo apt upgrade -y
Why: 60% of breaches exploit known vulnerabilities that have available patches. Keeping systems updated closes these security holes. Security Impact: Patches critical CVEs (Common Vulnerabilities and Exposures) including remote code execution, privilege escalation, and data exposure flaws.
Why: Manual patching creates gaps where critical security updates are delayed. Automated updates ensure zero-day exploits are patched immediately when fixes are available. Security Impact: Reduces vulnerability window from days/weeks to hours. Protects against wormable exploits that spread automatically across networks.
Verify Security Status:sudo ufw status && sudo systemctl status ssh
Why: Verification is critical - security configurations don't matter if they're not actually active. Always validate your hardening work. Security Impact: Confirms defense-in-depth layers are operational. Provides audit evidence that security controls are functioning as intended.
Ubuntu 20.04 LTS - Security Hardening Lab
Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-74-generic x86_64)
*** System Security Hardening Lab Environment ***
⚠️ WARNING: This system has default security settings and needs hardening!
Last login: Mon Jun 15 14:30:15 2025 from 192.168.1.100
student@webserver:~$
Progress:0/10 tasks completed
Score: 0/100
0%
Lab Completed!
Great job completing the Linux Security Hardening lab!
Lab 2: Windows Active Directory Security
Intermediate
Scenario: Secure the Domain Controller
MegaCorp has just experienced a security breach where an attacker gained access to several user accounts. As the security administrator, you need to implement proper Active Directory security policies, create secure organizational units (OUs), configure group policies, and set up proper password policies to prevent future attacks. The domain controller is running Windows Server 2019.
Learning Objectives:
OU Structure: Create a secure organizational unit structure for users and computers
Group Policy: Configure GPOs for security hardening and password policies
User Security: Implement principle of least privilege for user accounts
Audit Policies: Enable security auditing for critical events
📋 Step-by-Step Instructions
Open Active Directory Users and Computers
Navigate to Server Manager > Tools > Active Directory Users and Computers Why: ADUC is the central management tool for organizing and securing your domain users, groups, and computers. Security Impact: Proper AD organization prevents lateral movement during breaches by implementing security boundaries.
Why: OUs enable role-based access control (RBAC) and different security policies for different user types. A flat AD structure is a security nightmare. Security Impact: Allows granular GPO application - finance users can have strict data protection while IT has necessary admin access. Limits breach blast radius.
Open Group Policy Management
Navigate to Server Manager > Tools > Group Policy Management. Use the tree navigation on the left to explore Domain > Group Policy Objects. Why: Group Policy is how you enforce security settings across thousands of machines from one central location using a hierarchical tree structure. Security Impact: Ensures consistent security configuration domain-wide. Prevents users from weakening security on their local machines.
Create Password Policy GPO
Right-click domain > Create GPO > Name: Secure Password Policy Why: 81% of breaches involve weak or stolen passwords (Verizon DBIR). Strong password policies are your first line of defense. Security Impact: Prevents dictionary attacks, brute force, and credential stuffing. Forces attackers to use more sophisticated techniques.
Configure Password Requirements
Set: Min length: 12, Complexity: Enabled, History: 24, Max age: 90 days Why: 12+ character passwords resist brute force for years vs hours for 8-character passwords. Complexity requirements force mixing of character types. Security Impact: NIST recommends 12+ characters. Password history prevents reuse. Rotation limits exposure from compromised credentials.
Configure Account Lockout Policy
Set: Threshold: 5 attempts, Duration: 30 minutes, Reset: 30 minutes Why: Account lockout defeats automated password guessing. 5 attempts is enough for legitimate typos but blocks brute force. Security Impact: Makes password cracking impractical - even with 1000 accounts to target, attackers get only 5000 attempts before mass lockouts trigger alerts.
Enable Audit Policies
Configure: Audit account logon events, Audit account management, Audit policy change Why: You can't detect what you don't log. Audit policies create forensic evidence and enable threat detection. Security Impact: Detects privilege escalation, unauthorized account creation, and policy tampering. Required for compliance (PCI-DSS, HIPAA, SOC 2).
Why: Groups enable least privilege access control. Never assign permissions to individual users - always use groups for scalability. Security Impact: Limits data exposure during breaches. Finance users can't access HR data and vice versa. Simplified access reviews for compliance.
Apply GPOs to OUs
Link security GPOs to appropriate organizational units Why: GPOs don't do anything until they're linked to OUs. This step activates your security policies. Security Impact: Enforces security settings on all computers/users in the OU. Policies update automatically without touching each machine.
Test and Verify Settings
Run gpupdate /force and verify policies are applied correctly Why: GPOs may take up to 90 minutes to apply naturally. Force update ensures immediate application for testing. Security Impact: Confirms security controls are operational. Identifies misconfiguration before attackers can exploit gaps.
⚠️ No custom OUs configured - requires organization
⚠️ Audit policies not configured - requires logging setup
Active Directory Users and Computers
megacorp.local
Computers
Users
Select an OU to view contents
Group Policy Management
megacorp.local
Domain
Domain Controllers
Group Policy Objects
Default Domain Policy
Select a Group Policy Object from the tree to view or edit its settings
Progress:0/10 tasks completed
Score: 0/100
0%
Lab Completed!
Excellent work securing the Active Directory environment!
Lab 3: Firewall Configuration with pfSense
Intermediate
Scenario: Network Perimeter Defense
TechStartup Inc. has grown rapidly and needs proper network segmentation and firewall rules. You're tasked with configuring a pfSense firewall to protect the internal network, create a DMZ for public-facing servers, and implement proper NAT and firewall rules. The company has web servers that need to be accessible from the internet while keeping the internal network secure.
Learning Objectives:
Network Segmentation: Configure VLANs and network interfaces for proper segmentation
Firewall Rules: Create and order firewall rules following security best practices
NAT Configuration: Set up port forwarding and outbound NAT rules
Security Features: Enable IDS/IPS and configure logging
📋 Step-by-Step Instructions
Access pfSense Dashboard
Click on the Dashboard tab to view the pfSense system information and interface status. Why: The dashboard provides an overview of all network interfaces and system health. It's the starting point for firewall configuration. Security Impact: Monitoring dashboard alerts helps detect misconfigurations or security issues before they become critical vulnerabilities.
Review and Configure Network Interfaces
Go to the Interfaces tab and review WAN and LAN (already configured). Click Configure button on the DMZ interface to set it up:
DMZ Configuration Values (select and copy):
IP Address: 192.168.100.1
Subnet Mask: /24
Note: WAN (203.0.113.5/24) and LAN (192.168.10.1/24) interfaces are pre-configured. You can click Edit to review their settings, but focus on configuring the DMZ interface. Why: Network segmentation is the #1 defense against lateral movement. Breached web server shouldn't reach internal databases. Security Impact: DMZ isolation limits blast radius. If attacker compromises web server in DMZ, they can't pivot to internal network without breaking through another firewall layer.
Create Firewall Aliases
Go to the Firewall tab and click on the Aliases subtab. Create the following 3 aliases:
Why: Aliases make rules readable and maintainable. "Allow Management_IPs" is clearer than "Allow 192.168.10.5". Change alias once, updates all rules. Security Impact: Reduces configuration errors. Mistyped IP in 20 rules = security holes. Aliases ensure consistency across your ruleset.
Configure DMZ Firewall Rules
Go to the Firewall tab, click on the Rules subtab, then select DMZ from the interface dropdown menu. Click Add Rule button to create a new firewall rule:
Rule Configuration (copy these exact values):
Action: Pass
Protocol: TCP
Source: WAN
Destination: DMZ
Ports: 80,443
Description: Allow web traffic to DMZ
Why: Public-facing services must be accessible from internet, but ONLY on required ports. Attackers scan all 65,535 ports looking for weaknesses. Security Impact: Allows legitimate web traffic while blocking SSH, RDP, database ports. Prevents attackers from accessing management interfaces or exploiting unpatched services.
Configure LAN Firewall Rules
Go to the Firewall tab, click on the Rules subtab, then select LAN from the interface dropdown. Add the following 3 rules in order:
1. Allow LAN to Internet: Action=Pass, Protocol=Any, Source=LAN, Destination=WAN
2. Allow Admin SSH to DMZ: Action=Pass, Protocol=TCP, Source=Management_IPs, Destination=DMZ, Port=22
3. Block LAN to DMZ: Action=Block, Protocol=Any, Source=LAN, Destination=DMZ (implicit deny all other traffic)
Why: Internal users need internet but shouldn't directly access DMZ servers. Only designated admins need SSH to DMZ for maintenance. Security Impact: Prevents compromised employee workstation from attacking DMZ servers. Limits admin access to specific IP addresses for accountability.
Set Up NAT Port Forwarding
Go to the Firewall tab, then navigate to NAT > Port Forward. Click Add to create a new port forwarding rule with these settings:
Why: Your web server has private IP (192.168.100.10) but internet users connect to your public IP. NAT translates public IP:80 → private IP:80. Security Impact: Hides internal network topology. Attackers see only your public IP, not the real server addresses. Makes reconnaissance harder.
Configure Outbound NAT
Go to the Firewall tab, then navigate to NAT > Outbound. Set the mode to Hybrid or Manual. Add outbound NAT rules for both networks:
Why: Internal devices use private IPs (RFC 1918) which aren't routable on internet. Outbound NAT rewrites source IPs to your public IP. Security Impact: Enables connection tracking (stateful firewall). Return traffic is automatically allowed. Prevents IP spoofing attacks by validating source addresses.
Configure DNS Resolver Service
Go to the Services tab and click the Configure button on DNS Resolver (Unbound). Configure the following settings:
DNS Configuration (copy these values):
• Enable DNS Resolver: Enabled
• Listen Port: 53
• Network Interfaces: LAN (check LAN checkbox)
• DNSSEC: Disabled
• Forwarding Mode: DNS Resolver (Recursive)
Why: DNS Resolver (Unbound) performs recursive DNS queries directly to authoritative servers, providing better privacy than forwarding to external DNS servers like Google or Cloudflare. Security Impact: Prevents DNS poisoning, enables internal name resolution for network devices, and protects against DNS-based data exfiltration. Port 53 is the standard DNS port.
Configure NTP Time Synchronization
Go to the Services tab and click the Configure button on NTP Server. Configure the following settings:
NTP Configuration (copy these values):
• Enable NTP Server: Enabled
• Time Server 1: 0.pfsense.pool.ntp.org
• Time Server 2: 1.pfsense.pool.ntp.org
• Interface: All Interfaces
• Timezone: UTC
Why: Accurate time synchronization is critical for security. Log correlation across systems requires synchronized clocks. SSL/TLS certificates fail if time is wrong. Kerberos authentication breaks with >5 minute time drift. Security Impact: Enables accurate forensic analysis after incidents. Prevents attackers from manipulating timestamps to hide their tracks. Required for compliance (PCI-DSS requires time sync).
Configure DHCP Server for LAN
Go to the Services tab and click the Configure button on DHCP Server. Configure the following settings:
DHCP Configuration (copy these values):
• Enable DHCP Server: Enabled
• Range From: 192.168.10.100
• Range To: 192.168.10.200
• Gateway: 192.168.10.1
• DNS Servers: 192.168.10.1, 8.8.8.8
• Lease Time: 7200 seconds (2 hours)
Why: DHCP automates IP address assignment for client devices, preventing IP conflicts. Reserve .1-.99 for static assignments (servers, printers). Use .100-.200 for dynamic client allocation. Security Impact: Centralized IP management enables better network visibility and access control. Prevents rogue DHCP servers (DHCP snooping). DNS setting points clients to your secure DNS resolver, not potentially malicious external DNS.
Enable Snort IDS/IPS
Go to the Services tab and click the Configure button on Snort IDS/IPS. Enable it on WAN and DMZ interfaces, and select rulesets (ET Open, Snort VRT). Why: Firewalls block ports but can't detect application-layer attacks like SQL injection, XSS, or zero-day exploits in allowed traffic. Security Impact: IDS detects attack patterns in real-time. IPS actively blocks malicious packets. Protects against OWASP Top 10 web attacks even when port 80/443 must be open.
Configure Logging
Go to the Status tab, then navigate to System Logs > Settings. Enable logging for firewall (deny rules), IDS alerts, and NAT events. Send logs to a remote syslog server if available. Why: Logs are forensic evidence. When breach occurs, logs tell you what happened, when, and from where. Required for compliance (PCI-DSS, HIPAA). Security Impact: Enables threat hunting and incident response. Detect port scans, brute force attempts, and policy violations. Average breach detection time: 207 days (IBM). Logs reduce this dramatically.
Test and Verify Configuration
Click the Test Connectivity button below to verify your configuration. Ensure that: WAN is accessible, LAN can reach the internet, DMZ web server is reachable from WAN, and LAN traffic is blocked from accessing DMZ. Why: Firewalls can look perfect in config but fail in practice due to rule ordering, typos, or misunderstood requirements. Always test! Security Impact: Prevents false sense of security. Misconfigured firewall = no security. Testing confirms defense-in-depth layers work as designed before going production.
pfSense 2.6.0 - Firewall Configuration
pfSense
admin@192.168.1.1
System Information
WAN Interface
IP: 203.0.113.5
Status: Up
LAN Interface
IP: 192.168.10.1
Status: Up
DMZ Interface
Not Configured
Status: Down
Firewall Rules
Action
Protocol
Source
Destination
Port
Description
Block
Any
Any
Any
Any
Default deny all
Firewall Aliases
Name
Type
Value
Description
No aliases configured yet
Network Interfaces
Interface
Status
IP Address
Subnet
Gateway
Actions
WAN (em0)
● Up
203.0.113.5
/24
203.0.113.1
LAN (em1)
● Up
192.168.10.1
/24
-
DMZ (em2)
● Down
Not configured
-
-
Services
Snort IDS/IPS
● Stopped
Intrusion Detection & Prevention System
DNS Resolver
● Running
Unbound DNS service
NTP Server
● Running
Network Time Protocol service
DHCP Server
● Running
DHCP service for LAN interface
System Logs
Log Settings
Configure logging for security events, firewall activity, and intrusion detection.
Recent Log Entries
[2024-12-07 15:05:23] Firewall: Allow WAN TCP 80 from 203.0.113.100 to DMZ
[2024-12-07 15:05:15] Firewall: Allow LAN TCP 443 to Internet
[2024-12-07 15:04:58] Firewall: Block LAN to DMZ port 3389
[2024-12-07 15:04:42] Snort: No threats detected in last scan