PHASE 1 · WEEK 1 · FOUNDATIONS
// BEGINNER → PRO ROADMAP

Phase 1, Week 1 —
Core Concepts & Environment

Seven focused days covering the cybersecurity landscape, Linux mastery, Windows fundamentals, virtualization, Python scripting, and your first CTF challenges.

7Days
35+Concepts
12+Lab Exercises
1CTF Challenge
01

The Cybersecurity Landscape

THEORY CIA Triad · Threat Actors · Attack Surfaces · CVE/CWE

WEEK PROGRESS — DAY 1 OF 7
🎯

Goal: Understand the full mental model of cybersecurity — what you are protecting, from whom, and how attackers think. This is the foundation every single technique you learn later will build upon.

What is the CIA Triad?

Every security decision in existence maps back to three principles. These aren't guidelines — they are the atomic definition of security. If you can't explain an attack in terms of CIA, you don't yet understand it.

🔒 Confidentiality

Only authorized entities can access data. Violations: data breaches, credential theft, eavesdropping, insecure storage. Example attack: a hacker intercepts unencrypted login credentials on public Wi-Fi (Man-in-the-Middle).

✅ Integrity

Data is only modified by authorized entities in authorized ways. Violations: SQL injection altering a database, malware corrupting files, DNS poisoning. Example: an attacker changes a bank transfer amount mid-transit.

⚡ Availability

Systems are accessible to authorized users when needed. Violations: DDoS attacks, ransomware, hardware failure, misconfigured firewalls. Example: a DDoS flood takes down an e-commerce site during Black Friday.

💡

Mental model: Ask of any attack — "What did it break?" Ransomware breaks Availability AND Confidentiality. A misconfigured S3 bucket breaks Confidentiality only. This maps directly to how you report and prioritize vulnerabilities later.

Who are the adversaries?

Understanding who attacks tells you how they attack. Motivation drives technique. A script kiddie uses existing tools blindly; a nation-state APT builds custom malware and operates for months undetected.

ACTOR TYPEMOTIVATIONSKILL LEVELTYPICAL ATTACK
Script KiddieFun, ego, disruptionLowOff-the-shelf exploit tools, DDoS stresser
HacktivistPolitical/ideologicalMediumWebsite defacement, data leaks, DDoS
CybercriminalFinancial gainMedium–HighRansomware, phishing, fraud, credential theft
Insider ThreatRevenge, money, accidentVariesData exfiltration, sabotage, accidental exposure
Nation-State APTEspionage, warfareEliteZero-days, supply chain attacks, long-term persistence
Pen Tester (YOU)Defense by offenseHighAuthorized simulation of all above
What can be attacked?

The attack surface is every point of entry that an attacker could exploit. Reducing attack surface is the most fundamental defensive strategy. You cannot protect what you don't know exists.

🌐 Network Surface

Open ports, exposed services, unencrypted protocols, firewall gaps. Every listening service is a potential door. Run nmap — you may find 50 open ports on a server that should have 3.

💻 Software Surface

Web apps, APIs, desktop applications, OS services. Every line of code is a potential vulnerability. Buffer overflows live here. SQL injection lives here.

👤 Human Surface

The most reliably exploitable surface. Social engineering, phishing, vishing, tailgating. "The human is the weakest link" isn't a cliché — it's statistically proven. 85%+ of breaches involve a human element.

🏢 Physical Surface

Unlocked server rooms, USB drops, dumpster diving, shoulder surfing. Air gaps are broken by physical access. Never underestimate this.

The Language of Vulnerabilities

You need to speak the industry's language. These identifiers are how the entire security industry communicates about flaws.

TERMWHAT IT ISEXAMPLE
CVE Common Vulnerabilities and Exposures — a unique ID for a specific, publicly known vulnerability in specific software CVE-2021-44228 = Log4Shell (critical RCE in Apache Log4j)
CWE Common Weakness Enumeration — a category of flaw types in code or design, not a specific bug CWE-79 = Cross-Site Scripting (XSS) as a class of flaw
CVSS Common Vulnerability Scoring System — a 0–10 score rating vulnerability severity CVSS 9.8 = Critical. CVSS 3.1 = Low.
Zero-Day A vulnerability unknown to the vendor — no patch exists. Extremely valuable; sold for millions. Stuxnet used 4 zero-days simultaneously (unprecedented)
Exploit Code or technique that takes advantage of a vulnerability A Python script that triggers a buffer overflow to get shell access
PoC Proof of Concept — a demonstration that a vulnerability is real and exploitable A PoC for Log4Shell was released within 24 hours of disclosure
⚠️

Critical: Unauthorized access to any system — even to "test" it — is illegal in virtually every jurisdiction. In the US: Computer Fraud and Abuse Act (CFAA). In UK: Computer Misuse Act. Always have written authorization before testing any system. "I was just testing" is not a legal defense. Ever.

The Hacker Spectrum

White Hat — Ethical hackers. Work with authorization. Report findings responsibly. Build defenses. This is where you're headed.

Grey Hat — Find vulnerabilities without authorization but don't exploit maliciously. Still illegal despite good intent.

Black Hat — Malicious actors. Exploit for personal gain, damage, or espionage. Criminal prosecution follows.

Bug Bounty — Authorized programs where companies pay you to find their vulnerabilities. Legal white-hat hacking for money.

1. A hospital's ransomware attack encrypts all patient records, making them inaccessible. Which CIA properties are violated?
A Confidentiality only
B Integrity only
C Availability and Integrity
D All three equally
2. You discover a critical vulnerability in a popular banking app. The right ethical action is:
A Post it publicly on Twitter immediately to warn users
B Notify the bank privately and give them time to patch before any public disclosure
C Exploit it once to prove it\'s real, then report it
D Ignore it since you didn\'t cause it
Practical Task

Research 3 Real-World Breaches

For each breach, identify: which CIA properties were violated, what threat actor type was responsible, what the attack vector was, and what the financial/reputational impact was.

  • Research the 2017 Equifax breach (147M records exposed)
  • Research the 2021 Colonial Pipeline ransomware attack
  • Research the 2020 SolarWinds supply chain attack
  • For each: write 3–5 sentences mapping to CIA Triad + threat actor type
  • Bookmark: nvd.nist.gov (National Vulnerability Database) — your home for CVE research
02

Linux Fundamentals

THEORY LAB Filesystem · Permissions · Processes · SSH · Users

WEEK PROGRESS — DAY 2 OF 7
🐧

Why Linux matters in cybersecurity: Kali Linux, Parrot OS, servers you'll attack, and most tools you'll use all run on Linux. You must be fluent — not just functional — in the command line. 90% of offensive security work happens in a terminal.

Linux Directory Structure

Linux has a single hierarchical tree rooted at /. No drive letters (C:, D:). Everything — files, devices, network sockets — is a file in this tree.

DIRECTORYWHAT LIVES HERESECURITY RELEVANCE
/etcSystem configuration filespasswd, shadow (password hashes), SSH config, cron jobs — goldmine for attackers
/homeUser home directoriesSSH keys, bash history, browser data, personal files
/rootRoot user's homeTarget for privilege escalation — getting here = full system compromise
/var/logSystem and application logsEvidence of attacks; blue teamers live here; attackers try to clear it
/tmpTemporary files, world-writableCommon place to drop exploit scripts; persists across logins unless cleared
/bin, /sbinEssential binariesSUID binaries here are a privesc target (explained Week 5)
/procVirtual FS for running processesReal-time process info, memory maps, used in forensics
Understanding rwx Permissions

Misconfigured permissions are one of the top causes of privilege escalation. You must read permission strings instantly.

kali@machine:~$
$ ls -la /etc/passwd -rw-r--r-- 1 root root 2847 Jan 15 09:22 /etc/passwd Breaking down: -rw-r--r-- - rw- r-- r-- │ │ │ │ │ │ │ └── Others: read only │ │ └────────── Group: read only │ └─────────────────── Owner: read + write └───────────────────────────── Type: - = file, d = dir, l = symlink $ ls -la /etc/shadow -rw-r----- 1 root shadow 1547 Jan 15 09:22 /etc/shadow # shadow = password hashes. Only root + shadow group can read. This is why you need privesc to crack passwords. $ chmod 755 script.sh # 7=rwx(owner) 5=r-x(group) 5=r-x(others) $ chmod +x script.sh # adds execute for all $ chown root:root file # change owner to root
FILE NAVIGATION & MANIPULATION
$ pwd # Print Working Directory $ ls -la # List all files with permissions + hidden files $ cd /etc # Change directory $ cat /etc/passwd # Display file contents $ less /var/log/auth.log # Paginate through large files $ find / -name "*.conf" 2>/dev/null # Find all .conf files (suppress errors) $ grep -r "password" /etc/ # Search recursively for "password" string $ cp file.txt /tmp/backup.txt # Copy file $ mv old.txt new.txt # Move / rename file $ rm -rf /tmp/testdir # Remove dir recursively (CAREFUL: irreversible)
User Management — Security Critical

Every privilege escalation attack targets this: becoming a higher-privileged user. Understanding how users and sudo work is the precursor to breaking them.

USER & PROCESS COMMANDS
$ whoami # Current user $ id # uid=1000(user) gid=1000(user) groups=... $ cat /etc/passwd # All system users (username:x:uid:gid:info:home:shell) $ cat /etc/shadow # Password hashes — needs root to read $ sudo -l # What can THIS user run as root? (key privesc check) $ su - root # Switch to root (needs root password) $ ps aux # All running processes — look for interesting services $ ps aux | grep apache # Filter processes $ kill -9 1234 # Force-kill process with PID 1234 $ netstat -tulpn # What's listening on which ports?
SSH — Your Primary Remote Access Tool

SSH is how you access remote machines, both legitimately and as part of post-exploitation. You'll use SSH keys constantly in CTFs and real engagements.

SSH COMMANDS
$ ssh user@192.168.1.10 # Connect to remote host $ ssh -p 2222 user@target.com # Non-standard port $ ssh-keygen -t ed25519 # Generate SSH key pair (stronger than RSA) $ ssh-copy-id user@remote # Copy public key to remote (passwordless auth) $ cat ~/.ssh/id_ed25519 # PRIVATE KEY — never share this! $ cat ~/.ssh/id_ed25519.pub # PUBLIC KEY — safe to share/upload # In CTFs: you'll often find SSH private keys in files like /home/user/.ssh/id_rsa # Finding one = instant SSH access as that user $ chmod 600 found_key.pem # Keys must be 600 or SSH refuses them $ ssh -i found_key.pem user@target
A file shows permissions -rwsr-xr-x root root. The 's' in the owner execute position is called a SUID bit. What does this mean for a regular user who runs this file?
A The file runs with the permissions of the user who invokes it
B The file runs with root permissions regardless of who runs it
C Only root can execute this file
D The 's' has no practical effect on execution
Lab: Linux Filesystem Exploration (on your Kali VM)
  • Open terminal. Run cat /etc/passwd — identify the format: username:x:UID:GID:comment:home:shell
  • Find all SUID binaries on the system: find / -perm -4000 2>/dev/null — note what you find
  • Check what sudo permissions your user has: sudo -l
  • Examine running processes: ps aux | sort -k3 -rn | head -20 (top 20 by CPU)
  • Check open network ports: ss -tulpn (modern replacement for netstat)
  • Generate an SSH key pair. Find where it's stored. Read both files.
  • Create a file, set permissions to 600, verify with ls -la
03

Linux Deep Dive

TOOL LAB grep · awk · sed · Pipes · Cron · Scripting

WEEK PROGRESS — DAY 3 OF 7
⚙️

Today's goal: Master the power tools that make Linux lethal. grep, awk, and sed are not "nice to know" — they are how you process massive log files, extract credentials from dumps, and automate repetitive security tasks. A pentester who can't pipe commands is severely limited.

grep MASTERY
# Basic: search for pattern in file $ grep "failed" /var/log/auth.log # Case-insensitive search $ grep -i "password" config.txt # Recursive search in all files in directory $ grep -r "api_key" /var/www/ # Show line numbers $ grep -n "root" /etc/passwd # Invert match (lines NOT containing pattern) $ grep -v "#" /etc/ssh/sshd_config # Strip comment lines # Count occurrences $ grep -c "Failed password" /var/log/auth.log # Extended regex — find IPs in a file $ grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" access.log # REAL PENTEST USE: Find hardcoded credentials in web app source $ grep -rn "password\|passwd\|secret\|api_key\|token" /var/www/ --include="*.php"
The Pipe | — Linux's Superpower

Pipe | sends the output of one command as input to the next. This lets you build powerful one-line processing pipelines. The best security analysts think in pipelines.

PIPES IN ACTION
# Count failed SSH logins by IP address (real log analysis) $ grep "Failed password" /var/log/auth.log | awk '{print $11}' | sort | uniq -c | sort -rn | head -20 847 192.168.1.105 ← brute-force attack from this IP 312 10.0.0.23 45 172.16.0.5 # Extract usernames from /etc/passwd $ cat /etc/passwd | cut -d: -f1 root daemon www-data user1 ... # Find the 10 largest files in /var $ find /var -type f -exec du -sh {} \; 2>/dev/null | sort -rh | head -10 # Live monitoring: show new SSH failed logins in real-time $ tail -f /var/log/auth.log | grep "Failed password"
Cron — Scheduled Tasks in Linux

Cron runs commands automatically on a schedule. Misconfigured cron jobs running as root are one of the most common Linux privilege escalation techniques. If a cron job runs a script that's world-writable, you can modify that script to run your own commands as root.

CRON
# Cron syntax: minute hour day month weekday command * * * * * /path/to/command │ │ │ │ │ │ │ │ │ └── Day of week (0=Sunday) │ │ │ └───── Month (1-12) │ │ └──────── Day of month (1-31) │ └─────────── Hour (0-23) └────────────── Minute (0-59) # View current user's cron jobs $ crontab -l # View system-wide cron jobs (check these for privesc) $ cat /etc/crontab $ ls -la /etc/cron.d/ /etc/cron.daily/ # Classic privesc scenario: # /etc/crontab shows: * * * * * root /opt/backup.sh # ls -la /opt/backup.sh shows: -rwxrwxrwx (world writable!) # You add: echo 'chmod +s /bin/bash' >> /opt/backup.sh # Wait 1 minute... then: /bin/bash -p → YOU ARE ROOT
#!/bin/bash # Recon script — automates initial enumeration of a target TARGET=$1 # First argument: IP address echo "[*] Starting recon on $TARGET" # Check if target is alive ping -c 1 $TARGET > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "[+] Host is UP" else echo "[-] Host appears DOWN" exit 1 fi # Quick port scan echo "[*] Scanning common ports..." nmap -sV --top-ports 1000 $TARGET -o /tmp/scan_$TARGET.txt echo "[+] Done. Results in /tmp/scan_$TARGET.txt"
RUN YOUR SCRIPT
$ chmod +x recon.sh $ ./recon.sh 192.168.1.100 [*] Starting recon on 192.168.1.100 [+] Host is UP [*] Scanning common ports... [+] Done. Results in /tmp/scan_192.168.1.100.txt
Lab: Log Analysis + Bash Script
  • Download a sample auth.log from the internet. Use grep to find all failed SSH attempts.
  • Build a pipeline to extract attacker IPs and count how many attempts each made (see example above).
  • Write a bash script that accepts an IP as argument, pings it, and prints "UP" or "DOWN".
  • Check your own cron jobs with crontab -l and inspect /etc/cron.d/ on your Kali VM.
  • Use find / -writable -type f 2>/dev/null | grep -v proc — what writable files exist?
04

Windows Fundamentals

THEORY LAB Registry · Active Directory · PowerShell · Services

WEEK PROGRESS — DAY 4 OF 7
🪟

Why Windows? Over 70% of enterprise environments run Windows. Most high-value targets (domain controllers, file servers, workstations) are Windows. Active Directory is the authentication backbone of almost every large organization — and it's riddled with attackable design decisions.

The Registry — Windows's Configuration Database

The Windows Registry is a hierarchical database storing OS and application settings. Attackers love it for persistence (making malware survive reboots) and credential storage.

HIVECONTAINSSECURITY RELEVANCE
HKLM\SOFTWAREInstalled applications settings (all users)Find installed software, versions → look for vulnerable versions
HKLM\SYSTEMHardware config, services, network settingsSAM database location, service configs, sometimes credentials
HKCU\SOFTWAREPer-user application settingsPutty saved sessions (often contain SSH credentials!)
HKLM\SAMLocal user accounts and password hashesExtract with mimikatz or reg save — crack with hashcat
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunPrograms that run on startupClassic persistence location for malware — check this in forensics
Active Directory — The Crown Jewel Target

Active Directory is Microsoft's centralized authentication and authorization system used in virtually every enterprise network. Compromising AD = compromising the entire organization. The Domain Controller (DC) is the most valuable target in any network.

🏰 Domain

A logical grouping of computers sharing a common authentication database. All managed by a Domain Controller. E.g., CORP.LOCAL

👑 Domain Controller (DC)

The server running AD. Handles all authentication (Kerberos/NTLM), stores all user/computer accounts, enforces Group Policy. Owning this = owning everything.

🎫 Kerberos

AD's primary authentication protocol. Uses tickets (TGT, TGS). Attacks like Kerberoasting, Pass-the-Ticket, and Golden Ticket attacks all target this. You'll learn these in Week 5.

📋 Group Policy (GPO)

Centralized configuration rules pushed to all domain machines. Can set password policies, install software, configure firewalls. Misconfigured GPOs = attack vector.

PowerShell — The Swiss Army Knife

PowerShell is to Windows what bash is to Linux — but more powerful for security work. Modern malware and red teams use PowerShell extensively because it's built-in, trusted, and can do almost anything.

PowerShell — Windows Security Commands
# System information Get-ComputerInfo systeminfo # Running processes (like ps aux on Linux) Get-Process Get-Process | Sort-Object CPU -Descending | Select -First 10 # Network connections (like netstat) Get-NetTCPConnection | Where-Object State -eq "Listen" # Find users and their privileges Get-LocalUser Get-LocalGroupMember -Group "Administrators" # Services — look for vulnerable/unusual services Get-Service | Where-Object Status -eq "Running" # Scheduled Tasks (Windows equivalent of cron) Get-ScheduledTask | Where-Object State -eq "Ready" # Firewall rules Get-NetFirewallRule | Where-Object Enabled -eq True # Download and run in memory (fileless malware technique) # Never run untrusted content — shown for EDUCATIONAL awareness only # IEX (Invoke-Expression) + download = common attack pattern # Defenders watch for this in PowerShell logs
LOCATIONWHAT'S THEREWHY IT MATTERS
C:\Windows\System32\config\SAMLocal password hashesExtract and crack to get local admin passwords
C:\Windows\System32\drivers\etc\hostsLocal DNS overridesAttackers modify to redirect domains
C:\Users\[user]\AppData\RoamingUser app data, browser dataBrowser credentials, saved passwords
C:\Windows\PrefetchProgram execution cacheForensics: proves what programs ran and when
C:\Windows\System32\winevt\LogsEvent logsSecurity.evtx, System.evtx — evidence of attacks
%TEMP%Temporary filesMalware often drops here; check in IR
Lab: Windows Exploration (Windows VM)
  • Open regedit.exe. Navigate to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run — what's there?
  • Open PowerShell as admin. Run Get-LocalGroupMember -Group "Administrators"
  • Run Get-NetTCPConnection | Where-Object State -eq "Listen" — what ports are open?
  • Open Event Viewer → Windows Logs → Security. Find event ID 4624 (successful logon) and 4625 (failed logon)
  • Run Get-ScheduledTask — identify any suspicious scheduled tasks
05

Virtualization Lab Setup

LAB TOOL VirtualBox · Kali Linux · Metasploitable · Isolated Network

WEEK PROGRESS — DAY 5 OF 7
⚠️

Critical: Your lab must be isolated from the internet. Machines like Metasploitable are intentionally vulnerable — they will be compromised within minutes if exposed publicly. Use Host-Only or Internal Network mode in VirtualBox.

Target Lab Architecture

You need at minimum three virtual machines communicating on an isolated network:

🗡️ Kali Linux (Attacker)

Your primary attack machine. Pre-loaded with 600+ security tools. Download from kali.org/get-kali. Use the pre-built VM image.

🎯 Metasploitable 2 (Linux Target)

An intentionally vulnerable Linux server. Contains dozens of exploitable services. Download from SourceForge. Never expose to internet.

🪟 Windows 10/11 (Windows Target)

Get a free evaluation copy from Microsoft. Needed for Windows-specific attacks, Active Directory labs later.

MODEVM → InternetVM → VMUSE WHEN
NATYes (via host)NoDefault. VMs can access internet but not each other
Host-OnlyNoYesIsolated lab between VMs and host only. SAFE.
Internal NetworkNoYesVMs talk to each other only — host excluded. SAFEST.
BridgedYes (own IP)YesVM acts like a real device on your LAN. DANGEROUS with vuln VMs
Lab Setup Procedure
  • Step 1: Download VirtualBox from virtualbox.org and install. Also install the Extension Pack.
  • Step 2: Download Kali Linux pre-built VM from kali.org/get-kali → Virtual Machines. Import the OVA file into VirtualBox.
  • Step 3: Download Metasploitable 2. Unzip, create a new VM in VirtualBox pointing to the .vmdk file. Set type: Linux / Ubuntu.
  • Step 4: In VirtualBox → File → Host Network Manager → Create a Host-Only network (e.g., 192.168.56.0/24).
  • Step 5: For BOTH Kali and Metasploitable: Settings → Network → Adapter 1 → Host-Only Adapter (select your Host-Only network).
  • Step 6: Boot Kali. Default credentials: kali / kali. Run ip addr — you should see a 192.168.56.x address.
  • Step 7: Boot Metasploitable. Default credentials: msfadmin / msfadmin. Run ifconfig to find its IP.
  • Step 8: From Kali, ping Metasploitable: ping 192.168.56.101. If you get replies — your lab works!
KALI ATTACKING METASPLOITABLE — FIRST SCAN
kali$ nmap -sV 192.168.56.101 Starting Nmap 7.94 at 2024-01-15 10:00 Nmap scan report for 192.168.56.101 Host is up (0.00045s latency). PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 2.3.4 ← known backdoor (CVE-2011-2523) 22/tcp open ssh OpenSSH 4.7p1 23/tcp open telnet Linux telnetd 25/tcp open smtp Postfix smtpd 80/tcp open http Apache httpd 2.2.8 139/tcp open netbios-ssn Samba smbd 3.X 445/tcp open microsoft-ds Samba smbd 3.X ← EternalBlue-style attacks 3306/tcp open mysql MySQL 5.0.51a ← no root password! 5432/tcp open postgresql PostgreSQL 8.3.0 6667/tcp open irc UnrealIRCd ← known backdoor 8180/tcp open http Apache Tomcat 5.5 # This single scan reveals MASSIVE attack surface # Every one of these services has known critical vulnerabilities # You'll exploit them starting Week 3
🎉

If you see output like above: Your lab is working perfectly. You've just done your first security reconnaissance. Save this IP and output — you'll return to this machine many times in the coming weeks.

06

Python for Security

THEORY LAB Sockets · File I/O · Build a Port Scanner

WEEK PROGRESS — DAY 6 OF 7
🐍

Why Python: Python is the de facto language of security tools. Metasploit modules, exploit scripts, automation, custom C2 tools — all Python. You don't need to be a developer. You need to read, modify, and write scripts that interact with networks and files.

# ── Variables & Data Types ────────────────────────────── target_ip = "192.168.56.101" port = 80 ports = [21, 22, 80, 443, 8080] service_map = {21: "FTP", 22: "SSH", 80: "HTTP", 443: "HTTPS"} # ── Conditionals ───────────────────────────────────────── if port in service_map: print(f"Port {port} → {service_map[port]}") else: print(f"Port {port} → Unknown service") # ── Loops ──────────────────────────────────────────────── for p in ports: print(f"Checking port {p}...") # ── Functions ──────────────────────────────────────────── def banner(target): print(f"="*40) print(f" TARGET: {target}") print(f"="*40) banner(target_ip) # ── File Operations (reading configs, logs, wordlists) ── with open("/usr/share/wordlists/rockyou.txt", "r", encoding="latin-1") as f: passwords = f.readlines() print(f"Loaded {len(passwords)} passwords")
Sockets — How Programs Communicate Over Networks

A socket is a software endpoint for sending/receiving data. Every network tool — scanners, exploits, C2 frameworks — uses sockets under the hood. Understanding this is the difference between using tools blindly and understanding what they do.

# How a TCP connection works in Python import socket # Create a TCP socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1) # Don't wait more than 1 second # Try to connect — if we can, port is open result = s.connect_ex(("192.168.56.101", 80)) # connect_ex returns 0 on success, error code on failure if result == 0: print("Port 80: OPEN") # Try to grab the banner (what service says hello) s.send(b"HEAD / HTTP/1.0\r\n\r\n") banner = s.recv(1024).decode("utf-8", errors="ignore") print(f"Banner: {banner[:100]}") else: print("Port 80: CLOSED") s.close()
#!/usr/bin/env python3 """ Simple Port Scanner — Your First Security Tool Usage: python3 scanner.py 192.168.56.101 """ import socket import sys from datetime import datetime def scan_port(host, port, timeout=0.5): """Returns True if port is open, False if closed""" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(timeout) result = s.connect_ex((host, port)) s.close() return result == 0 except socket.error: return False def get_banner(host, port): """Try to grab service banner""" try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1) s.connect((host, port)) s.send(b"HEAD / HTTP/1.0\r\n\r\n") banner = s.recv(100).decode("utf-8", errors="ignore").strip() s.close() return banner.split("\n")[0] except: return "(no banner)" def main(): if len(sys.argv) != 2: print("Usage: python3 scanner.py <target_ip>") sys.exit(1) target = sys.argv[1] common_ports = [21,22,23,25,53,80,110,139,143,443,445, 3306,3389,5432,5900,6379,6667,8080,8443] print(f"\n{'='*50}") print(f" PORT SCANNER — Target: {target}") print(f" Scan started: {datetime.now().strftime('%H:%M:%S')}") print(f"{'='*50}\n") open_ports = [] for port in common_ports: if scan_port(target, port): banner = get_banner(target, port) open_ports.append(port) print(f" [OPEN] Port {port:5d} → {banner}") print(f"\n[+] {len(open_ports)} open ports found") if __name__ == "__main__": main()
RUNNING YOUR SCANNER
kali$ python3 scanner.py 192.168.56.101 ================================================== PORT SCANNER — Target: 192.168.56.101 Scan started: 14:32:11 ================================================== [OPEN] Port 21 → 220 (vsFTPd 2.3.4) [OPEN] Port 22 → SSH-2.0-OpenSSH_4.7p1 [OPEN] Port 23 → (no banner) [OPEN] Port 80 → HTTP/1.1 200 OK [OPEN] Port 139 → (no banner) [OPEN] Port 445 → (no banner) [OPEN] Port 3306 → (no banner) [OPEN] Port 5432 → (no banner) [+] 8 open ports found # You just built a working security tool from scratch. # Nmap does this + 1000x more. Now you understand HOW it works.
07

Review + First CTF Challenge

LAB PicoCTF · TryHackMe · Week 1 Consolidation

WEEK PROGRESS — DAY 7 OF 7 — WEEK COMPLETE
🏁

CTF = Capture The Flag. Security competitions where you solve challenges to find hidden "flags" (text strings like flag{y0u_f0und_1t}). This is how you build real skills — reading about security is theory; CTFs make it real.

TOPICKEY TAKEAWAYSTATUS
CIA TriadEvery attack breaks Confidentiality, Integrity, and/or AvailabilityDay 1 ✓
Threat ActorsMotivation drives technique — know who you're defending againstDay 1 ✓
Linux Permissionsrwx notation, SUID bits, chmod, chown — misconfigs = privescDay 2 ✓
Linux Commandsgrep, awk, pipes, find, process management, SSHDay 3 ✓
Windows / ADRegistry, Kerberos, PowerShell, Event Logs — enterprise fundamentalsDay 4 ✓
Lab SetupIsolated VirtualBox environment: Kali + Metasploitable + WindowsDay 5 ✓
Python ScriptingSockets, file I/O, loops — built a working port scannerDay 6 ✓
1. You find a file: -rwsr-xr-x root root /usr/bin/find. What can a low-privilege user potentially do with this?
A Read files owned by root
B Execute commands as root using find's -exec flag
C Delete system files
D Nothing special — SUID on find is harmless
2. A pipeline shows: grep "Failed password" auth.log | awk '{print $11}' | sort | uniq -c | sort -rn. What is the purpose of uniq -c?
A Remove duplicate lines
B Count occurrences of each unique line and prefix each with its count
C Sort lines alphabetically
D Show only the first occurrence of each line
Mission 1: PicoCTF (picoctf.org)
  • Create a free account at picoctf.org
  • Complete: Obedient Cat (General Skills) — learn to find flags in files
  • Complete: Python Wrangling — run a Python script to decode a flag
  • Complete: Wave a Flag — use --help flags and command arguments
  • Complete: Nice netcat — use netcat (nc) to connect to a server
Mission 2: TryHackMe (tryhackme.com)
  • Create a free account at tryhackme.com
  • Complete the room: "Pre-Security" path (free) — perfect Week 1 review
  • Complete the room: "Linux Fundamentals Part 1"
  • Complete the room: "Introductory Networking" (preview for Week 2)
Mission 3: Metasploitable Exploration
  • From your Kali VM, run your Python port scanner against Metasploitable.
  • Navigate to http://192.168.56.101 in a browser — explore the Metasploitable web interface (DVWA, Mutillidae — these are vulnerable web apps for practice)
  • From Kali: ftp 192.168.56.101 — log in with anonymous / anonymous. What files can you see?
  • Document everything in a notes file. This is your first reconnaissance report.
Before You Move to Week 2 — Verify You Can:
  • Explain the CIA Triad and map any attack to it
  • Navigate the Linux filesystem, read permissions, find SUID files
  • Write a grep pipeline to analyze a log file and count attacker IPs
  • Use PowerShell to enumerate users, services, and network connections
  • Have a working VirtualBox lab: Kali ↔ Metasploitable on an isolated network
  • Run your Python port scanner and understand every line of code
  • Complete at least 3 PicoCTF or TryHackMe challenges
  • Have a notes system set up (Obsidian, Notion, or even a text file)
🚀

Coming in Week 2: Networking & Protocols — OSI model, TCP/IP in depth, Wireshark packet analysis, DNS/HTTP/ARP internals, and understanding the attack surface at the network layer. Everything you'll do in offensive and defensive security requires this.

← Previous Week ⌂ Lesson Hub Next Week →