Back to All Tools
Auditing, Diagnostics & System Hardening Manual

Security CLI Manual & Cheat Sheet

Quick interactive reference guide for standard security and network auditing CLI tools (Nmap, OpenSSL, Dig, Tcpdump, cURL) with parameter breakdowns and defensive mitigation advice.

Security CLI Manual & Command Cheat Sheet

Auditing & Defense Manual

Comprehensive interactive CLI reference with flag breakdowns and defensive hardening advice across Nmap, OpenSSL, Dig, Tcpdump, cURL, and Linux System Hardening.

33 Commands Available
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.com
Command Flags Breakdown:
-sSTCP SYN scan (half-open, doesn't complete TCP connection)
-PnTreat all hosts as online (skips initial ICMP ping discovery)
-T4Aggressive 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.com
Command Flags Breakdown:
-sVProbe open ports to determine service info and version numbers
-OEnable OS detection via TCP/IP stack fingerprinting
-p-Scan all 65,535 TCP ports (from 1 to 65535)
-T4Faster 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.com
Command Flags Breakdown:
--top-ports 100Scans the 100 most common TCP ports in Nmap database
--openFilters 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.com
Command Flags Breakdown:
-sVService version probe necessary for script matching
--script vulnExecutes known CVE / vulnerability check scripts in safe non-destructive mode
-p 80,443,22Targets 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.com
Command Flags Breakdown:
--script ssl-enum-ciphersEnumerates all supported cryptographic suites and warns on weak ciphers
-p 443Targets 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.com
Command Flags Breakdown:
-sUUDP scan mode
-p 53,123,161Target 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.

nmap -sn 192.168.1.0/24
Command Flags Breakdown:
-snPing scan only (disables port scanning for ultra-fast host discovery)
192.168.1.0/24Specifies 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 443
Command Flags Breakdown:
-zZero-I/O mode (scans without sending data payload)
-vVerbose status output
-w 3Sets 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.com
Command Flags Breakdown:
s_clientGeneric SSL/TLS client emulator
-connect host:portSpecifies remote host and TCP port (default 443)
-servername hostSends 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 -dates
Command Flags Breakdown:
2>/dev/nullSilences handshake debug output
openssl x509 -noout -datesParses 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 -noout
Command Flags Breakdown:
x509X.509 Certificate data management utility
-in file.pemPath to input certificate file
-textPrints full certificate fields in human-readable plain text
-nooutSuppresses 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:4096
Command Flags Breakdown:
genpkeyModern general-purpose private key generation utility
-algorithm RSASpecifies the asymmetric cryptographic algorithm
-pkeyopt rsa_keygen_bits:4096Enforces 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 ecCreates an Elliptic Curve key instead of legacy RSA
ec_paramgen_curve:prime256v1Uses NIST P-256 curve (secp256r1)
-nodesNo 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.pem
Command Flags Breakdown:
verifyValidates the X.509 cryptographic signature chain
-CAfile bundle.crtSpecifies 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 +answer
Command Flags Breakdown:
ANYRequests all available record types from the authoritative name server
+noallSilences verbose DNS header information
+answerDisplays 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.

dig target.com +trace
Command Flags Breakdown:
+traceIteratively 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.

dig -x 1.1.1.1 +short
Command Flags Breakdown:
-x IPPerforms in-addr.arpa reverse DNS lookup
+shortOutputs 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 eth0Listen on specific network interface
-nnDo not resolve hostnames or port numbers into names (faster, prevents DNS latency)
-s0Capture full packet snapshot length without truncation
-vVerbose 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.pcap
Command Flags Breakdown:
-c 500Stops capturing after exactly 500 packets
-w file.pcapWrites 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.com
Command Flags Breakdown:
-w '...'Custom output format string for timing performance variables
-o /dev/nullDiscards response payload body to measure pure transport speed
-sSilent 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.com
Command Flags Breakdown:
-IFetch the HTTP response headers only (HEAD request)
-LFollow 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/profile
Command 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 123b
Command Flags Breakdown:
-h hostTarget web server URL or IP address
-sslEnforces HTTPS encryption
-Tuning 123bRuns 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-63BNIST 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=64MBAllocates 64MB RAM per verification to defeat GPU acceleration clusters
time_cost=3Performs 3 computational iterations
parallelism=4Utilizes 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 6238Standard 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/mAllows maximum 5 requests per minute from a single client IP
burst=5Allows 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 sshd
Command Flags Breakdown:
status sshdQueries 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.

ss -tulpn
Command Flags Breakdown:
-tDisplay TCP sockets
-uDisplay UDP sockets
-lDisplay listening sockets only
-pShow process using the socket
-nNumeric 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 -n
Command Flags Breakdown:
-iTCPFilter by TCP internet domain sockets
-sTCP:LISTENFilter only LISTEN states
-P -nInhibits 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 enable
Command Flags Breakdown:
default deny incomingDrops all unsolicited ingress connections
allow 443/tcpOpens HTTPS ingress port
enableActivates 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
EOF
Command Flags Breakdown:
minlen = 14Requires minimum 14 characters length
dcredit = -1Requires at least 1 numeric digit
ucredit = -1Requires at least 1 uppercase letter
ocredit = -1Requires 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

Network & Port Auditing

Standard Nmap discovery syntax, service version queries, and UDP exposure audits for network administrators.

TLS & PKI Operations

OpenSSL commands for testing certificate chains, generating RSA/ECC keys, and converting certificate formats.

Defensive Hardening Advice

Practical tips on rate limiting, firewall configurations, and disabling verbose server banners to harden infrastructure.