Penetration Testing
From rules of engagement and reconnaissance to exploitation and the final report, penetration testing as told through the free samples of the Leanpub books on offensive security.
Created from the free samples of 13 Leanpub books and the descriptions and tables of contents of 2 more, with every source cited.
Penetration testing is the authorised simulation of an attack on a computer system, network or application, carried out to find the weaknesses that can be exploited, to show what their exploitation would mean, and to tell the owner how to close them. One of the sources defines a penetration test as a time-boxed, authorised assessment within a defined scope, and sets it beside its neighbours: a vulnerability assessment catalogues known weaknesses without exploiting them, a red-team exercise imitates an adversary's methods to test whether the organisation detects and responds, and adversary emulation models an exercise on the documented techniques of a known threat group.[2] Offensive security is the name for all of them together.[2]
What separates the work from a crime is permission. Written authorisation that names the assets in scope and the period of testing is what turns otherwise criminal activity into a security assessment.[1] The books on the subject share a second concern, that testing has been confused with running tools. One opens with two testers at the same keyboard, the junior copying a scanner's forty-two findings into a template and the senior asking what the application does and where trust begins and ends, and argues that what divides them is methodology and not skill with tools.[1] A book on bug bounty hunting says the same of its own field.[5] All of the books used here were published in 2026.
This article covers authorisation and scope, the phases of a test, the standard tools and the case for writing one's own, Active Directory, web, cloud and other targets, bug bounty programmes, exploit development and the defences against it, reverse engineering, and the use of language models in the work. Its sources are the free samples of 13 Leanpub books and the public descriptions and tables of contents of 2 more. Where a sample says something, it is cited; where a book has no sample, it is cited only for what its description and contents list say, and the note in the Sources list says so. Because the subject can be misused, the article describes methods and tools and gives no instructions. Cybersecurity as a whole has its own article.
Where to start
A reader with no background in security can begin with Offensive Security with Kali Linux (2026), which asks only for basic computer literacy, a first acquaintance with a terminal and knowing what an IP address is, and which spends its first three chapters on what offensive security is, on the Kali Linux platform and on networking before any testing begins.[2] It addresses students, IT staff moving into security, defenders who need to understand attackers, and working testers who want a reference to the whole lifecycle.[2]
For someone who already knows the tools and wants the reasoning behind them, Offensive Security Testing (2026) assumes foundational networking, the common command-line tools and a basic understanding of web technologies, and describes itself as neither a tool manual nor a catalogue of vulnerabilities.[1] Practical Metasploit (2026) takes one framework and works through it for testers who are comfortable in a terminal and have a lab of their own.[3]
The other sources are for readers with a particular aim. Inside the Domain: A Field Manual for Active Directory Penetration Testing (2026) assumes familiarity with Windows domains, Kerberos, NTLM and networking.[4] The Effective Bug Bounty Playbook (2026) expects its reader to know what an HTTP request looks like and to have used an intercepting proxy, and sends complete beginners elsewhere first.[5] BlackHat Ruby (2026) is for programmers who want to build tools and is not an introduction to Ruby.[6] Buffer Overflow Exploitation and Defense Evasion (2026) asks for C with pointers and dynamic memory allocation and teaches assembly from the beginning,[7] and The Reverse Engineering Handbook: From Beginner to Expert (2026) asks for basic programming in C or Python and no knowledge of assembly or debugging.[9]
History
The exploitation of software faults is as old as the networks that carry it. In November 1988 a worm spread across the early Internet by sending a Unix network service more data than its fixed-size buffer could hold, overwriting a return address on the stack and so running its own code on the remote machine; an estimated ten per cent of the computers then connected were infected.[7] The same class of fault still produces thousands of entries in the public vulnerability database every year.[7]
The tools of the modern trade arrived over the following two decades. One source lists the milestones: the Nmap network scanner in 1997, the Metasploit exploitation framework in 2003, BackTrack, the first Linux distribution built for penetration testing, in 2006, and its successor Kali Linux in 2013.[2] Before Metasploit, exploit code circulated on chat channels and mailing lists, each piece in its own format, and each had to be checked again before it was safe to aim at a target; testers wrote their own exploits by hand and carried them onto the network themselves.[3] The framework's first release, in October 2003, was written in Perl and held eleven exploits. It was rewritten in Ruby in 2007, a job of about eighteen months, and bought in 2009 by a security company that kept the open-source line under its existing licence.[3]
The same source describes the wider change as one from exploration driven by individual curiosity to a profession with standard methodologies, certifications and legal protection for those who are authorised.[2] Bug bounty programmes, in which organisations pay outside researchers for the faults they report, are the most recent addition, and the sources treat them as an established occupation.[5]
Authorisation, scope and the law
Unauthorised access to a computer system is a crime in nearly every jurisdiction: under the Computer Fraud and Abuse Act in the United States, the Computer Misuse Act in the United Kingdom, and the national laws that follow the Budapest Convention on Cybercrime of 2001 elsewhere.[2] The books place the point before any technique, and none treats it as a formality. Permission has to be written, since verbal approval is not enough,[2] and, as the book on Metasploit puts it, outside a signed scope document a tester's work and an intrusion look the same to a court.[3] The Active Directory manual adds that owning the book authorises nothing.[4]
The document that carries the permission is the rules of engagement. In the fullest account among the sources it has six parts: the boundaries of scope, with the excluded systems named as explicitly as the included ones; the hours in which testing may take place; how far the tester may go once a weakness is found; the techniques that are forbidden, such as denial of service or the social engineering of staff; who is told what and how quickly, with critical findings reported within hours; and how the data met during the test is stored and destroyed.[1] A rule covering everything under a company's domain name is given as an example of scope that is too loose.[1] For a Windows domain the checklist grows to include account-lockout thresholds, limits on the volume of authentication attempts and separate levels of approval for attacks on credentials.[4]
Practice belongs in a laboratory. The sources agree on its shape: an attacking machine, deliberately vulnerable targets and a virtual network cut off from production systems and the Internet, with snapshots so that a target can be restored after each exercise.[1][2]
The testing lifecycle
A test follows a published methodology. The frameworks most often named are the Penetration Testing Execution Standard, the OWASP Web Security Testing Guide, NIST Special Publication 800-115 and the Open Source Security Testing Methodology Manual, and although their vocabulary differs their phases are much the same.[1] One source gives seven: pre-engagement, intelligence gathering, threat modelling, vulnerability analysis, exploitation, post-exploitation and reporting.[2] The sequence is not strictly linear, because what is found late in a test often sends the tester back to an earlier phase.[1]
Reconnaissance
Reconnaissance is the collection of information about the target before it is tested, and it is passive where it draws on third parties and active where it sends traffic to the target itself.[1] The book on bug bounty hunting sets out three principles for it: a short list of live and interesting assets is worth more than a long list of dead ones, passive methods come before active ones, and reconnaissance is repeated, because an organisation's exposed systems change and newly deployed services are the least hardened.[5] Its passive sources are certificate transparency logs, which record a subdomain whenever a certificate is issued for it, search engines, the services that index devices reachable from the Internet, and public code repositories, where organisations leave keys and internal addresses.[5] The line between this phase and the next is one of intent: reconnaissance asks what exists, and vulnerability identification asks what is broken.[1]
Validation and exploitation
A scanner reports that a vulnerability may exist; exploitation establishes whether it does. The difference between the two answers is described as most of the value of a report, since a fault rated critical can be unexploitable in a particular environment while one of moderate severity gives a direct route in.[3] In professional testing exploitation is a controlled proof of concept, limited by the rules of engagement and intended to show impact without causing disruption.[1] Post-exploitation then asks what an attacker could reach from the first foothold, through higher privileges and movement to other machines, the purpose being to measure the extent of a compromise and not to cause damage.[2]
Reporting
The report is the main thing a client receives.[2] It holds an executive summary for readers without technical knowledge, the findings with their evidence and remediation, an account of what was tested and how, and recommendations in order of priority; a thorough test that is badly reported does not lead to anything being fixed.[1] The Active Directory manual asks the tester to separate verified findings from exposures that are possible but untested, and notes that an attempt that failed does not show that the path is closed.[4]
Tools and frameworks
Kali Linux is the distribution most testers work from. It ships with more than six hundred security tools,[2] and the book built on it names the usual ones by task: Burp Suite for web applications, Aircrack-ng for wireless networks, BloodHound and Impacket for Active Directory, Hashcat and John the Ripper for passwords, and Metasploit for exploitation in general.[2] Its author warns that the version numbers and syntax reflect 2026 and that the methodology is what lasts.[2]
Metasploit is an open-source framework, written in Ruby, for developing and running exploit code.[3] Its design is modular. Exploit modules target one known vulnerability, payload modules supply the code that runs if the exploit succeeds, auxiliary modules do the scanning and enumeration that involve no payload, and post-exploitation modules run once access exists; because any exploit can be paired with any suitable payload, a tester who understands one module understands the form of the next.[3] A current checkout is reported to hold 2,677 exploit modules and 1,325 auxiliary ones, and 165 modules were added in 2024 by 62 developers.[3] Since version 6.5 the modules carry tags for the techniques of the MITRE ATT&CK framework that they implement.[3] The book is candid about one limit: the framework's encoders exist to make a payload arrive intact and are not a reliable way past modern endpoint defences.[3] The framework is also on the syllabus of the main certifications, and defenders study it because real intruders use it too.[3]
A separate line of books argues for writing tools as well as using them. BlackHat Ruby holds that a tester who cannot see inside a tool cannot fully trust its output or adapt it when its assumptions fail, and has the reader build scanners, protocol parsers and fuzzers in Ruby, the language Metasploit is written in, with a later chapter on how defenders detect what has been built.[6] It concedes that Ruby is neither the dominant language of security tooling nor the fastest.[6] The methodology book takes the same position, explaining its code part by part so that readers can modify a tool or write their own when the existing ones fall short.[1]
Active Directory
Active Directory, the identity service at the centre of most corporate Windows networks, has a literature of its own, because a weakness there is rarely one fault and usually a chain of permissions and trust relationships. Inside the Domain: A Field Manual for Active Directory Penetration Testing starts from the observation that no single, maintained methodology covers the whole of an Active Directory assessment, and arranges the scattered material into six phases: reconnaissance, initial access, privilege escalation, lateral movement, credential access and post-exploitation.[4] The phases are offered as a map for planning and not as an order that must be followed.[4]
The manual models a domain as a graph. Users, groups, computers and the control relationships between them are nodes and edges, and a single permission becomes significant when it joins another exposure; a flat list of vulnerabilities does not show this.[4] It adds cautions: the graph is a model and not proof that a chain was carried out, the shortest path is not the easiest or the most likely, and defenders do best by removing the points through which many paths pass.[4] It marks the boundary with cloud identity services as needing its own authorisation, and its edition note states that the example commands inherited from the first edition are not claimed to have been run against current releases of the tools.[4] The methodology book treats the same ground at the level of protocol, on the argument that a tester who understands how Kerberos issues tickets will see misconfigurations that a script written for known faults does not.[1]
Web, cloud and other targets
Web applications and their programming interfaces take four chapters of the methodology book, which builds from the HTTP protocol through authentication and authorisation to injection, flaws in business logic, race conditions and newer protocols such as GraphQL and OAuth.[1] Its chapter on cloud platforms concentrates on identity relationships and trust boundaries instead of one provider's commands.[1]
Some targets need knowledge of their own. Blockchain Security: Attack and Defense (2026) concerns smart contracts and decentralised finance, where the contract's code is public, a deployed contract cannot be changed, and an attacker can borrow the capital for an attack within a single transaction; it divides the attack surface into five layers, from consensus and networking up to the client interface.[13]
Bug bounty hunting
A bug bounty programme is vulnerability research by outside researchers within a scope that the organisation publishes, with payment for valid findings.[5] It differs from a penetration test in how the work is organised and paid. A test is a bounded engagement by one team, paid for its time; a bounty programme runs continuously, is open to researchers everywhere, and pays only for results, which rewards efficiency and leaves each researcher competing with all the others.[5] One platform is reported to have paid researchers 81 million dollars in its 2025 financial year.[5]
The Effective Bug Bounty Playbook sets itself against two beliefs. The first is that large rewards come from luck; it holds that what looks like luck is pattern recognition built by practice.[5] The second is that more tools produce more findings. A scanner finds what every other researcher's scanner finds, and it cannot find a flaw in business logic, such as a discount code that can be redeemed twice because it is checked before the transaction is committed, since that requires knowing what the rule was meant to be.[5] The book's alternative is a repeatable process, with automation used for discovery and first triage and manual analysis kept for the most promising areas.[5] Its opening example is a breach of 2019 in which a well-documented class of fault became one of the largest thefts of financial data because it connected to over-broad cloud permissions and to the storage behind them, which is its case for chaining modest weaknesses into a path.[5]
Exploit development and its defences
Beneath the frameworks lies the writing of exploits, and its classical subject is memory corruption. Buffer Overflow Exploitation and Defense Evasion traces the problem to the design in which instructions and data share one memory: if data can be placed where the processor expects instructions, the processor can be made to run it.[7] Operating systems now answer with non-executable memory, randomised address layouts, stack canaries and control-flow integrity, and the book pairs each technique of attack with the mitigation that answers it, gives a chapter to the history of bypasses, and ends with detection and forensics.[7] Its stated purpose is educational and defensive, and it asks readers who find such faults in software they do not own to report them privately to the vendor and to publish only after a fix.[7]
The contest between attack and defence has a history of its own, told in the first chapter of Evasion Engineering (2026), a reference for experienced engineers whose own note describes its subject as dual-use and its code as illustrative.[8] It divides the history of detection into four phases: signature matching from the 1980s, behavioural and heuristic analysis, machine-learning classifiers from about 2015, and the present endpoint detection and response platforms, each of which changed what an intruder had to do.[8] It also observes that every layer of monitoring a defender adds is itself new code that can be attacked.[8] The methodology book draws its line on the other side, and states that it does not teach techniques whose main purpose is to evade real monitoring.[1]
Reverse engineering
Reverse engineering, the recovery of what a compiled program does from the program itself, supports vulnerability research and has wider uses. The Reverse Engineering Handbook: From Beginner to Expert introduces it through three cases: a suspicious attachment that has to be understood without its author's help, two systems that must exchange data over a protocol nobody documented, and the firmware of a device that controls critical infrastructure.[9] It moves from processor architecture and assembly to disassemblers and debuggers, among them Ghidra, Radare2 and GDB, and then to malware, mobile applications and firmware.[9] On the law it notes that the United States and the European Union both permit reverse engineering for interoperability and that the position elsewhere varies.[9]
Static analysis reads a program at rest; dynamic instrumentation watches it run. Mastering Frida (2026) is about Frida, an open-source toolkit that injects code into a live process so that it reports what it calls and what it passes, which reaches data that exists only briefly in memory and never on disk.[10] The book holds that the tool has no sense of who owns the process it touches, so the boundary of authorisation rests wholly on the user, and it explains how instrumentation is detected without offering ways to hide it.[10]
Practical Agentic Reverse Engineering (2026) hands the mechanical part of the work to a coding agent that drives Ghidra and similar tools through an open-source server. Its rule is that the agent's fluent summary is an inference while the bytes and cross-references are observations, so every claim is traced back to the binary and checked, and the question being asked, the authorisation and the final verification stay with the person.[11]
Language models in offensive security
The newest books concern automation by language models. Intelligent Discovery (2026) surveys the use of machine learning in finding, ranking and repairing vulnerabilities, from classifiers built on hand-made features, through fuzzers that learn from a program's execution which inputs are worth trying, to language models that write test harnesses, triage alerts and draft patches.[12] Its thesis is that the workflows which work are hybrid ones under human oversight, and it lists the failures alongside the gains: models report vulnerabilities that do not exist, produce patches that compile and are wrong, and reason poorly across files.[12]
Two books by one author, Building Autonomous Bug Bounty Agents (2026) and Autonomous AI Red Teaming & Swarm Intelligence (2026), have no samples and are described in nearly the same terms, as guides to building a Python pipeline of four stages: passive reconnaissance, crawling of web applications, triage of the results by a language model, and the generation of reports.[14][15] The contents list of the bug bounty playbook also includes a chapter on workflows assisted by such models.[5]
Questions about Penetration Testing
Which penetration testing book should I start with?
Offensive Security with Kali Linux asks only for basic computer literacy and introductory networking, and covers the whole lifecycle from reconnaissance to reporting.[2] A reader who already uses the tools and wants the reasoning behind them can go to Offensive Security Testing, which describes itself as neither a tool manual nor a catalogue of vulnerabilities.[1]
What is the difference between a penetration test and a vulnerability assessment?
Is penetration testing legal?
What are the phases of a penetration test?
How is bug bounty hunting different from penetration testing?
What is Metasploit used for?
Sources
Every source is a Leanpub book or course. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.
- 1.Offensive Security Testing, Steve Publications: Methodologies for Professional Assessment Free sample: the introduction and the first part of chapter 1 (rules of engagement and scope, the testing lifecycle, building an isolated laboratory). 2026. Free sample: PDF · EPUB
- 2.Offensive Security with Kali Linux, Steve Publications: A Comprehensive Guide to Ethical Hacking and Penetration Testing Free sample: the contents list, the introduction and the opening of chapter 1 (the history of offensive security, the disciplines within it, the phases of a test, the legal position). 2026. Free sample: PDF · EPUB
- 3.Practical Metasploit, Ground Truth Books: Mastering the Metasploit Framework from First Exploit to Advanced Post-Exploitation Free sample: chapter 1 (the framework's history, why testers use it, its components) and chapter 2 on the module system; the laboratory chapters are not in it. 2026. Free sample: PDF · EPUB
- 4.Inside the Domain: A Field Manual for Active Directory Penetration Testing, Thomas A. Anderson Free sample: the legal notice, preface, engagement safeguards, the foundations of Active Directory and the first of the six phases, reconnaissance. 2026. Free sample: PDF
- 5.The Effective Bug Bounty Playbook, Steve Publications: A Systematic Approach to Finding High-Impact Vulnerabilities Free sample: the introduction (what bug bounty hunting is, systems against tools) and the first part of chapter 1 on reconnaissance and its passive sources. 2026. Free sample: PDF · EPUB
- 6.BlackHat Ruby, Steve Publications: Building Offensive Security Tools, Exploit Frameworks, and Vulnerability Research Instrumentation Free sample: the contents list, preface and introduction (why build tools, Ruby's place in security tooling, ethics and consent); no code. 2026. Free sample: PDF · EPUB
- 7.Buffer Overflow Exploitation and Defense Evasion, Steve Publications: A Deep Dive into Memory Corruption Vulnerabilities, Exploitation, and Defense Free sample: the introduction and the opening of chapter 1 on processor and memory architecture; no exploit walkthrough. 2026. Free sample: PDF · EPUB
- 8.Evasion Engineering, Steve Publications: A Comprehensive Technical Reference: From Foundational Concepts to Advanced Implementation Free sample: the contents list, the introduction and chapter 1 on the history of detection and evasion; cited for that history only. 2026. Free sample: PDF · EPUB
- 9.The Reverse Engineering Handbook: From Beginner to Expert, Steve Publications: A Complete Guide to Binary Analysis, Debugging, and Software Deconstruction Free sample: the contents list, the introduction (three motivating cases, the plan of the book, ethics and the law) and the opening of chapter 1. 2026. Free sample: PDF · EPUB
- 10.Mastering Frida, Steve Publications: Dynamic Instrumentation, Reverse Engineering and Security Testing with frida.re Free sample: the contents list, the introduction (what dynamic instrumentation does, authorisation, version notes) and the opening of chapter 1. 2026. Free sample: PDF · EPUB
- 11.Practical Agentic Reverse Engineering, Ground Truth Books: Binaries, Electron, Android and the Web with REA and Ghidra Free sample: chapter 1 (the tool, the evidence loop, who the book is for) and the opening of chapter 5; chapters 2 to 4 are headings only. 2026. Free sample: PDF · EPUB
- 12.Intelligent Discovery, Steve Publications: AI-Powered Vulnerability Research and Software Security Free sample: the introduction (how machine learning entered vulnerability research, the thesis, the eight parts) and the first part of chapter 1 on the scale and classification of vulnerabilities. 2026. Free sample: PDF · EPUB
- 13.Blockchain Security: Attack and Defense, Krzysztof Rybiński Free sample: a condensed summary in lists and tables (adversaries, the five-layer attack surface, virtual-machine mechanics, defensive practices); no chapter prose. 2026. Free sample: PDF
- 14.Building Autonomous Bug Bounty Agents, Muhammad Ahmad Ejaz: Automating Recon, Triage, and Reporting with Python & AI No sample: from the description and table of contents. 2026.
- 15.Autonomous AI Red Teaming & Swarm Intelligence, Muhammad Ahmad Ejaz: Building LLM-Powered Security Assessment Frameworks with Python No sample: from the description and table of contents. 2026.
Further reading
Other books in the library on the same ground, not cited above.
- Reverse Engineering with Claude Code, Steve Publications: AI-Assisted Analysis, Understanding, and Reconstruction of Software Systems A method for analysing source, binaries, protocols and file formats of systems one owns or is authorised to examine, with a coding agent as assistant. 2026. Free sample: PDF · EPUB
- Build Your Own Cloud Competition, Susumu Tomita: Design, Build, and Run GameDay-Inspired AWS Challenges with TenkaCloud On designing and running automatically scored cloud competitions, including flag challenges and fault injection. 2026.
- DDoS & DrDoS Attacks Tools, Mitigation & Incident Response, DZ Manik: **Understanding Network Attacks, Defensive Tools, Mitigation Strategies & Effective Incident Response. A defender's guide to denial-of-service and reflection attacks, their detection, mitigation and incident response. 2026.