nmap
Stealth SYN Port Scan Network Recon (Nmap/Netcat) Performs a TCP SYN stealth scan without completing full 3-way handshakes, skipping ICMP ping probe (-Pn).
nmap -sS -Pn -T4 target.comCommand Flags Breakdown:
-sS TCP SYN scan (half-open, doesn't complete TCP connection)
-Pn Treat all hosts as online (skips initial ICMP ping discovery)
-T4 Aggressive timing template for faster execution
Hardening & Defense: Configure firewall (e.g. iptables / UFW) with SYN flood protection and drop unsolicited SYN packets.
nmap
Full 65k Port & Service Version Audit Network Recon (Nmap/Netcat) Probes all 65,535 TCP ports to determine service versions, daemon banners, and operating system fingerprints.
nmap -sV -O -p- -T4 target.comCommand Flags Breakdown:
-sV Probe open ports to determine service info and version numbers
-O Enable OS detection via TCP/IP stack fingerprinting
-p- Scan all 65,535 TCP ports (from 1 to 65535)
-T4 Faster timing policy
Hardening & Defense: Disable verbose service banners in Nginx, Apache, and OpenSSH configuration files (`server_tokens off`).
nmap
Fast Top 100 Common Ports Discovery Network Recon (Nmap/Netcat) Scans the top 100 most frequently used internet ports and displays only actively open services.
nmap --top-ports 100 -sV --open target.comCommand Flags Breakdown:
--top-ports 100 Scans the 100 most common TCP ports in Nmap database
--open Filters out closed and filtered ports, displaying only verified open listeners
Hardening & Defense: Ensure default firewall denies all incoming traffic except explicitly required ingress ports.
nmap
Nmap Scripting Engine (NSE) Vulnerability Scan Network Recon (Nmap/Netcat) Runs standard Nmap Scripting Engine (NSE) vulnerability detection scripts against open service banners.
nmap -sV --script vuln -p 80,443,22 target.comCommand Flags Breakdown:
-sV Service version probe necessary for script matching
--script vuln Executes known CVE / vulnerability check scripts in safe non-destructive mode
-p 80,443,22 Targets specific high-priority web and SSH services
Hardening & Defense: Regularly patch operating system packages and maintain automated static & dynamic security scans.
nmap
Enumerate Supported SSL/TLS Ciphers Network Recon (Nmap/Netcat) Audits supported TLS protocol versions (TLS 1.0, 1.1, 1.2, 1.3) and grades cipher suite strength.
nmap --script ssl-enum-ciphers -p 443 target.comCommand Flags Breakdown:
--script ssl-enum-ciphers Enumerates all supported cryptographic suites and warns on weak ciphers
-p 443 Targets HTTPS port 443
Hardening & Defense: Disable legacy CBC mode ciphers, RC4, and 3DES. Enforce modern AEAD ciphers (AES-GCM, CHACHA20-POLY1305).
nmap
UDP Service Discovery (DNS, SNMP, NTP) Network Recon (Nmap/Netcat) Audits exposed UDP ports commonly targeted for DDoS amplification attacks (DNS, NTP, SNMP).
nmap -sU -p 53,123,161 -T4 target.comCommand Flags Breakdown:
-sU UDP scan mode
-p 53,123,161 Target specific UDP ports (DNS=53, NTP=123, SNMP=161)
Hardening & Defense: Block inbound public UDP to internal administrative ports like SNMP (161) and disable open DNS recursion.
nmap
Subnet CIDR Live Host Sweep Network Recon (Nmap/Netcat) Performs ICMP echo and ARP requests across an entire subnet to find active IP addresses without port scanning.
Command Flags Breakdown:
-sn Ping scan only (disables port scanning for ultra-fast host discovery)
192.168.1.0/24 Specifies 256-address Class C CIDR range
Hardening & Defense: Implement network micro-segmentation and VLANs to isolate sensitive database and admin servers.
netcat
Netcat Fast TCP Port Banner Probe Network Recon (Nmap/Netcat) Quickly tests TCP socket reachability and connection timeouts across multiple ports using Netcat.
nc -zv -w 3 target.com 22 80 443Command Flags Breakdown:
-z Zero-I/O mode (scans without sending data payload)
-v Verbose status output
-w 3 Sets a 3-second connection timeout
Hardening & Defense: Close unused listening daemons and bind internal management services exclusively to localhost (127.0.0.1).
openssl
Connect & Inspect Remote TLS Certificate TLS & PKI (OpenSSL) Initiates a full TLS handshake with Server Name Indication (SNI) to view the server certificate chain.
openssl s_client -connect target.com:443 -servername target.comCommand Flags Breakdown:
s_client Generic SSL/TLS client emulator
-connect host:port Specifies remote host and TCP port (default 443)
-servername host Sends SNI header required by virtual hosts & CDN edge nodes
Hardening & Defense: Ensure TLS 1.3 is enabled and deprecated protocols (TLS 1.0, 1.1) and CBC ciphers are disabled.
openssl
Check Remote Certificate Expiry Date Directly TLS & PKI (OpenSSL) Extracts and prints the exact NotBefore and NotAfter validity dates of a live website in 1 command.
echo | openssl s_client -servername target.com -connect target.com:443 2>/dev/null | openssl x509 -noout -datesCommand Flags Breakdown:
2>/dev/null Silences handshake debug output
openssl x509 -noout -dates Parses only the validity window timestamps
Hardening & Defense: Configure automated ACME (Let's Encrypt / Certbot) auto-renewals with monitoring alerts 30 days prior to expiry.
openssl
Dissect Local X.509 Certificate (.crt/.pem) TLS & PKI (OpenSSL) Extracts human-readable Subject, Issuer, Validity window, SANs, and Public Key modulus from a PEM file.
openssl x509 -in cert.pem -text -nooutCommand Flags Breakdown:
x509 X.509 Certificate data management utility
-in file.pem Path to input certificate file
-text Prints full certificate fields in human-readable plain text
-noout Suppresses printing the encoded PEM block output
Hardening & Defense: Verify that certificates use RSA >= 2048-bit or ECC P-256 keys and are signed with SHA-256 or better.
openssl
Generate Secure RSA 4096-bit Private Key TLS & PKI (OpenSSL) Generates a cryptographically strong 4096-bit RSA private key using PKCS#8 format.
openssl genpkey -algorithm RSA -out server.key -pkeyopt rsa_keygen_bits:4096Command Flags Breakdown:
genpkey Modern general-purpose private key generation utility
-algorithm RSA Specifies the asymmetric cryptographic algorithm
-pkeyopt rsa_keygen_bits:4096 Enforces 4096-bit modulus length for future-proof security
Hardening & Defense: Restrict private key file permissions immediately on creation using `chmod 600 server.key`.
openssl
Generate Elliptic Curve (ECC P-256) Key & CSR TLS & PKI (OpenSSL) Generates a high-performance modern Elliptic Curve (ECDSA P-256) private key and Certificate Signing Request.
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout ecc.key -out ecc.csr -subj '/CN=example.com/O=MyOrg/C=US'Command Flags Breakdown:
-newkey ec Creates an Elliptic Curve key instead of legacy RSA
ec_paramgen_curve:prime256v1 Uses NIST P-256 curve (secp256r1)
-nodes No DES encryption on private key (unencrypted for automated server reboots)
Hardening & Defense: ECC keys provide equivalent 128-bit security to RSA 3072-bit with significantly faster TLS handshakes and lower CPU usage.
openssl
Verify Certificate against CA Root Bundle TLS & PKI (OpenSSL) Verifies the cryptographic signature chain of a certificate against trusted Root CA certificates.
openssl verify -CAfile ca-bundle.crt cert.pemCommand Flags Breakdown:
verify Validates the X.509 cryptographic signature chain
-CAfile bundle.crt Specifies the trusted Certificate Authority bundle
Hardening & Defense: Include intermediate CA certificates in your web server SSL bundle to prevent untrusted chain errors on mobile devices.
dig
Comprehensive DNS Record Audit DNS & Traffic (Dig/Tcpdump) Queries all available DNS resource records (A, AAAA, MX, TXT, NS, SOA) cleanly formatted.
dig target.com ANY +noall +answerCommand Flags Breakdown:
ANY Requests all available record types from the authoritative name server
+noall Silences verbose DNS header information
+answer Displays only the authoritative answer section
Hardening & Defense: Configure strict SPF (v=spf1 ... -all) and DMARC (p=reject) to protect your domain from email spoofing.
dig
Trace DNS Delegation Chain from Root Servers DNS & Traffic (Dig/Tcpdump) Traces the full hierarchical resolution path from IANA Root DNS servers down to the authoritative TLD server.
Command Flags Breakdown:
+trace Iteratively queries root servers, TLD servers, and authoritative nameservers
Hardening & Defense: Ensure primary and secondary nameservers are hosted on diverse Autonomous Systems (ASNs) for redundancy.
dig
Reverse DNS (PTR) Lookup for IP Address DNS & Traffic (Dig/Tcpdump) Resolves the registered reverse DNS hostname for an IPv4 or IPv6 address.
Command Flags Breakdown:
-x IP Performs in-addr.arpa reverse DNS lookup
+short Outputs only the resolved hostname
Hardening & Defense: Set valid Forward-Confirmed Reverse DNS (FCrDNS) on mail servers to prevent outbound emails from being flagged as spam.
tcpdump
Capture Web Traffic Headers on Interface DNS & Traffic (Dig/Tcpdump) Captures and inspects live TCP packet headers for incoming and outgoing web traffic.
tcpdump -i eth0 -nn -s0 -v 'tcp port 80 or tcp port 443'Command Flags Breakdown:
-i eth0 Listen on specific network interface
-nn Do not resolve hostnames or port numbers into names (faster, prevents DNS latency)
-s0 Capture full packet snapshot length without truncation
-v Verbose packet decode
Hardening & Defense: Enforce HTTPS with HSTS (`Strict-Transport-Security`) so plaintext HTTP (port 80) is never transmitted.
tcpdump
Save Filtered Packet Capture to PCAP File DNS & Traffic (Dig/Tcpdump) Captures exactly 500 packets targeting a specific host and writes them into a `.pcap` file for Wireshark inspection.
tcpdump -i any -c 500 -nn 'host 10.0.0.1 and port 443' -w capture.pcapCommand Flags Breakdown:
-c 500 Stops capturing after exactly 500 packets
-w file.pcap Writes raw packets directly to binary PCAP file
Hardening & Defense: Rotate and compress packet captures automatically to avoid consuming entire disk storage partitions.
curl
Detailed HTTP/TLS Latency & Handshake Metrics Web & HTTP (cURL/Nikto) Measures millisecond breakdown of DNS resolution, TCP connection, TLS handshake, and Time-To-First-Byte (TTFB).
curl -w "DNS: %{time_namelookup}s | Connect: %{time_connect}s | TLS: %{time_appconnect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\n" -o /dev/null -s https://target.comCommand Flags Breakdown:
-w '...' Custom output format string for timing performance variables
-o /dev/null Discards response payload body to measure pure transport speed
-s Silent mode (suppresses progress meter)
Hardening & Defense: Enable HTTP/2 and TLS 1.3 0-RTT session resumption to minimize TLS handshake latency.
curl
Inspect Response Headers & Security Policies Web & HTTP (cURL/Nikto) Sends an HTTP HEAD request and follows redirects to inspect CSP, HSTS, and X-Frame-Options headers.
curl -I -L https://target.comCommand Flags Breakdown:
-I Fetch the HTTP response headers only (HEAD request)
-L Follow HTTP 301/302 redirects to destination endpoint
Hardening & Defense: Deploy Content-Security-Policy (CSP) and `X-Content-Type-Options: nosniff` to protect against XSS and clickjacking.
curl
Test CORS Origin Reflection & Credential Leaks Web & HTTP (cURL/Nikto) Audits whether the backend server reflects untrusted Origins in `Access-Control-Allow-Origin`.
curl -I -H 'Origin: https://unauthorized-domain.com' https://api.target.com/user/profileCommand Flags Breakdown:
-H 'Origin: ...' Injects an untrusted external origin header to test reflection
Hardening & Defense: Never reflect arbitrary Origin headers with `Access-Control-Allow-Credentials: true`. Use strict origin whitelists.
nikto
Web Server Configuration & Misconfiguration Audit Web & HTTP (cURL/Nikto) Scans for outdated server software, dangerous default files, and insecure HTTP methods (PUT, TRACE).
nikto -h https://target.com -ssl -Tuning 123bCommand Flags Breakdown:
-h host Target web server URL or IP address
-ssl Enforces HTTPS encryption
-Tuning 123b Runs server misconfiguration, sensitive default files, and software version checks
Hardening & Defense: Disable HTTP TRACE and OPTIONS methods on web servers (`TraceEnable off` in Apache).
defense
NIST SP 800-63B Authentication Standards Password & Hash Defense Defines modern NIST digital identity guidelines focusing on passphrase length and breach checking over arbitrary composition rules.
# NIST SP 800-63B Compliance Checklist:
1. Minimum length >= 8 characters (14+ recommended for admins)
2. Allow up to 64+ characters (never truncate passwords)
3. Check against known breach databases (HaveIBeenPwned / common dicts)
4. No periodic forced password resets without evidence of compromise
5. Implement Multi-Factor Authentication (MFA / FIDO2 WebAuthn)Command Flags Breakdown:
SP 800-63B NIST Special Publication for Digital Identity & Authentication Guidelines
Hardening & Defense: Screen passwords against dictionary attacks and compromised password corpuses at registration and reset time.
defense
Argon2id Memory-Hard Password Hashing (PHC Winner) Password & Hash Defense Implements Argon2id, the state-of-the-art Password Hashing Competition winner designed to resist GPU/ASIC attacks via memory-hardness.
python3 -c "import base64, os; print('Argon2id Params: time_cost=3, memory_cost=64MB, parallelism=4')"Command Flags Breakdown:
memory_cost=64MB Allocates 64MB RAM per verification to defeat GPU acceleration clusters
time_cost=3 Performs 3 computational iterations
parallelism=4 Utilizes 4 parallel threads
Hardening & Defense: Migrate legacy MD5/SHA-256 databases to Argon2id or bcrypt by rehashing upon successful user login.
defense
Defensive Hash Work Factor Generation (Bcrypt) Password & Hash Defense Demonstrates defensive password hashing generation with adaptive work factor (Cost 12) using bcrypt / Argon2id.
python3 -c "import bcrypt; print('Bcrypt Salt & Cost 12:', bcrypt.gensalt(12).decode())"Command Flags Breakdown:
gensalt(12) Calculates 2^12 iterations to ensure resistance against GPU/ASIC acceleration
Hardening & Defense: Never use legacy MD5 or SHA-1 for passwords. Modern applications must use Argon2id or bcrypt (cost >= 12).
defense
Time-Based One-Time Password (TOTP / RFC 6238) Password & Hash Defense Generates standard RFC 6238 160-bit Base32 secret keys for Authenticator apps (Google Authenticator, Bitwarden, YubiKey).
python3 -c "import secrets, base64; print('TOTP Base32 Secret:', base64.b32encode(secrets.token_bytes(20)).decode())"Command Flags Breakdown:
RFC 6238 Standard Time-Based One-Time Password algorithm based on HMAC-SHA1
secrets.token_bytes(20) CSPRNG 160-bit cryptographic entropy source
Hardening & Defense: Enforce MFA for all administrative endpoints to render intercepted passwords useless to attackers.
defense
Authentication Defense: Rate Limiting & Lockout Rules Password & Hash Defense Defends authentication routes against automated brute-force attacks by capping requests to 5 per minute per IP.
# Nginx Rate Limiting Directive:
limit_req_zone $binary_remote_addr zone=login_limit:10m rate=5r/m;
limit_req zone=login_limit burst=5 nodelay;Command Flags Breakdown:
rate=5r/m Allows maximum 5 requests per minute from a single client IP
burst=5 Allows brief burst of 5 requests before returning HTTP 429 Too Many Requests
Hardening & Defense: Combine rate limiting with progressive backoff delays (1s, 2s, 4s, 8s) after consecutive failed login attempts.
fail2ban
Audit Fail2ban Automated IP Banning Status Password & Hash Defense Inspects currently banned IP addresses and failed authentication attempts recorded by Fail2ban.
fail2ban-client status sshdCommand Flags Breakdown:
status sshd Queries the SSH daemon jail status
Hardening & Defense: Configure Fail2ban to ban IPs for 24 hours after 5 failed authentication attempts within a 10-minute window.
ss
Audit All Active Listening Sockets & Process IDs Linux Hardening (SS/UFW/PAM) Modern replacement for netstat: lists all active listening TCP and UDP sockets with owning process names and PIDs.
Command Flags Breakdown:
-t Display TCP sockets
-u Display UDP sockets
-l Display listening sockets only
-p Show process using the socket
-n Numeric addresses (do not resolve names)
Hardening & Defense: Periodically audit listening ports to ensure rogue daemons or unauthorized services are not exposed.
lsof
Inspect Open Network Sockets by Process Linux Hardening (SS/UFW/PAM) Lists all open TCP listening network files, associated user accounts, and executable paths.
lsof -iTCP -sTCP:LISTEN -P -nCommand Flags Breakdown:
-iTCP Filter by TCP internet domain sockets
-sTCP:LISTEN Filter only LISTEN states
-P -n Inhibits port name and network number conversion for speed
Hardening & Defense: Investigate any listening process owned by `root` that does not require superuser privileges.
ufw
UFW Default-Deny Firewall Configuration Linux Hardening (SS/UFW/PAM) Establishes a hardened baseline firewall rule: drops all incoming traffic except explicit SSH, HTTP, and HTTPS ports.
ufw default deny incoming && ufw default allow outgoing && ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 443/tcp && ufw enableCommand Flags Breakdown:
default deny incoming Drops all unsolicited ingress connections
allow 443/tcp Opens HTTPS ingress port
enable Activates firewall rules immediately and persists across reboots
Hardening & Defense: Always change default SSH port from 22 to a custom port or restrict SSH access to a VPN subnet.
pam
Enforce Strong Linux PAM Password Policies Linux Hardening (SS/UFW/PAM) Configures Linux Pluggable Authentication Modules (PAM) to enforce NIST-compliant 14+ character password complexity.
cat << 'EOF' >> /etc/security/pwquality.conf
minlen = 14
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1
maxrepeat = 2
EOFCommand Flags Breakdown:
minlen = 14 Requires minimum 14 characters length
dcredit = -1 Requires at least 1 numeric digit
ucredit = -1 Requires at least 1 uppercase letter
ocredit = -1 Requires at least 1 special character
Hardening & Defense: Enforce SSH key-based authentication with `PasswordAuthentication no` in `/etc/ssh/sshd_config`.
Security auditing CLI reference for systems administrators and cybersecurity researchers. POSIX / Linux CLI Reference