Introduction |
|
xxv | |
Assessment Test |
|
xxxix | |
|
Chapter 1 Penetration Testing |
|
|
1 | (30) |
|
What Is Penetration Testing? |
|
|
2 | (3) |
|
|
2 | (2) |
|
Adopting the Hacker Mindset |
|
|
4 | (1) |
|
|
5 | (1) |
|
Reasons for Penetration Testing |
|
|
5 | (3) |
|
Benefits of Penetration Testing |
|
|
6 | (1) |
|
Regulatory Requirements for Penetration Testing |
|
|
7 | (1) |
|
Who Performs Penetration Tests? |
|
|
8 | (2) |
|
Internal Penetration Testing Teams |
|
|
8 | (1) |
|
External Penetration Testing Teams |
|
|
9 | (1) |
|
Selecting Penetration Testing Teams |
|
|
10 | (1) |
|
The CompTIA Penetration Testing Process |
|
|
10 | (4) |
|
|
11 | (1) |
|
Information Gathering and Vulnerability Scanning |
|
|
11 | (1) |
|
|
12 | (1) |
|
Reporting and Communication |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (3) |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (1) |
|
|
17 | (8) |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
Debuggers and Software Testing Tools |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
25 | (1) |
|
|
26 | (1) |
|
Activity 1.1 Adopting the Hacker Mindset |
|
|
26 | (1) |
|
Activity 1.2 Using the Cyber Kill Chain |
|
|
26 | (1) |
|
|
27 | (4) |
|
Chapter 2 Planning and Scoping Penetration Tests |
|
|
31 | (28) |
|
Scoping and Planning Engagements |
|
|
34 | (10) |
|
|
35 | (1) |
|
Known Environments and Unknown Environments |
|
|
35 | (2) |
|
|
37 | (2) |
|
Scoping Considerations---A Deeper Dive |
|
|
39 | (3) |
|
Support Resources for Penetration Tests |
|
|
42 | (2) |
|
Penetration Testing Standards and Methodologies |
|
|
44 | (2) |
|
Key Legal Concepts for Penetration Tests |
|
|
46 | (3) |
|
|
46 | (1) |
|
Data Ownership and Retention |
|
|
47 | (1) |
|
Permission to Attack (Authorization) |
|
|
47 | (1) |
|
Environmental Differences and Location Restrictions |
|
|
48 | (1) |
|
Regulatory Compliance Considerations |
|
|
49 | (2) |
|
|
51 | (1) |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
54 | (5) |
|
Chapter 3 Information Gathering |
|
|
59 | (50) |
|
Footprinting and Enumeration |
|
|
63 | (15) |
|
|
64 | (1) |
|
Location and Organizational Data |
|
|
65 | (3) |
|
Infrastructure and Networks |
|
|
68 | (6) |
|
|
74 | (3) |
|
Google Dorks and Search Engine Techniques |
|
|
77 | (1) |
|
Password Dumps and Other Breach Data |
|
|
77 | (1) |
|
|
78 | (1) |
|
Passive Enumeration and Cloud Services |
|
|
78 | (1) |
|
Active Reconnaissance and Enumeration |
|
|
78 | (21) |
|
|
79 | (1) |
|
|
79 | (6) |
|
Networks, Topologies, and Network Traffic |
|
|
85 | (3) |
|
Packet Crafting and Inspection |
|
|
88 | (2) |
|
|
90 | (7) |
|
Information Gathering and Code |
|
|
97 | (2) |
|
|
99 | (1) |
|
Information Gathering and Defenses |
|
|
99 | (1) |
|
Defenses Against Active Reconnaissance |
|
|
100 | (1) |
|
Preventing Passive Information Gathering |
|
|
100 | (1) |
|
|
100 | (1) |
|
|
101 | (1) |
|
|
102 | (2) |
|
Activity 3.1 Manual OSINT Gathering |
|
|
102 | (1) |
|
Activity 3.2 Exploring Shodan |
|
|
102 | (1) |
|
Activity 3.3 Running an Nmap Scan |
|
|
103 | (1) |
|
|
104 | (5) |
|
Chapter 4 Vulnerability Scanning |
|
|
109 | (42) |
|
Identifying Vulnerability Management Requirements |
|
|
112 | (9) |
|
|
112 | (4) |
|
|
116 | (1) |
|
Support for Penetration Testing |
|
|
116 | (1) |
|
|
117 | (1) |
|
Determining Scan Frequency |
|
|
118 | (2) |
|
Active vs. Passive Scanning |
|
|
120 | (1) |
|
Configuring and Executing Vulnerability Scans |
|
|
121 | (10) |
|
Scoping Vulnerability Scans |
|
|
121 | (1) |
|
Configuring Vulnerability Scans |
|
|
122 | (7) |
|
|
129 | (2) |
|
Software Security Testing |
|
|
131 | (7) |
|
Analyzing and Testing Code |
|
|
131 | (2) |
|
Web Application Vulnerability Scanning |
|
|
133 | (5) |
|
Developing a Remediation Workflow |
|
|
138 | (3) |
|
|
140 | (1) |
|
Testing and Implementing Fixes |
|
|
141 | (1) |
|
Overcoming Barriers to Vulnerability Scanning |
|
|
141 | (2) |
|
|
143 | (1) |
|
|
143 | (1) |
|
|
144 | (2) |
|
Activity 4.1 Installing a Vulnerability Scanner |
|
|
144 | (1) |
|
Activity 4.2 Running a Vulnerability Scan |
|
|
145 | (1) |
|
Activity 4.3 Developing a Penetration Test Vulnerability Scanning Plan |
|
|
145 | (1) |
|
|
146 | (5) |
|
Chapter 5 Analyzing Vulnerability Scans |
|
|
151 | (44) |
|
Reviewing and Interpreting Scan Reports |
|
|
152 | (10) |
|
|
156 | (6) |
|
|
162 | (3) |
|
|
162 | (1) |
|
|
162 | (1) |
|
Understanding Informational Results |
|
|
163 | (1) |
|
Reconciling Scan Results with Other Data Sources |
|
|
164 | (1) |
|
|
164 | (1) |
|
|
165 | (21) |
|
Server and Endpoint Vulnerabilities |
|
|
166 | (9) |
|
|
175 | (6) |
|
Virtualization Vulnerabilities |
|
|
181 | (2) |
|
|
183 | (1) |
|
Web Application Vulnerabilities |
|
|
184 | (2) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
188 | (2) |
|
Activity 5.1 Interpreting a Vulnerability Scan |
|
|
188 | (1) |
|
Activity 5.2 Analyzing a CVSS Vector |
|
|
188 | (1) |
|
Activity 5.3 Developing a Penetration Testing Plan |
|
|
189 | (1) |
|
|
190 | (5) |
|
Chapter 6 Exploiting and Pivoting |
|
|
195 | (48) |
|
|
198 | (8) |
|
|
198 | (1) |
|
|
199 | (2) |
|
Identifying the Right Exploit |
|
|
201 | (3) |
|
|
204 | (2) |
|
|
206 | (7) |
|
|
206 | (6) |
|
|
212 | (1) |
|
|
213 | (1) |
|
|
213 | (9) |
|
|
213 | (1) |
|
|
214 | (1) |
|
|
214 | (1) |
|
|
214 | (1) |
|
Fileless Malware and Living Off the Land |
|
|
215 | (1) |
|
Scheduled Tasks and cron Jobs |
|
|
216 | (1) |
|
|
217 | (2) |
|
|
219 | (1) |
|
|
220 | (1) |
|
|
220 | (1) |
|
|
220 | (1) |
|
|
220 | (1) |
|
Network Segmentation Testing and Exploits |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
222 | (6) |
|
Common Post-Exploit Attacks |
|
|
222 | (3) |
|
|
225 | (1) |
|
|
226 | (1) |
|
|
226 | (1) |
|
Escaping and Upgrading Limited Shells |
|
|
227 | (1) |
|
|
228 | (3) |
|
Scheduled Jobs and Scheduled Tasks |
|
|
228 | (1) |
|
|
228 | (1) |
|
|
229 | (1) |
|
|
229 | (1) |
|
Data Exfiltration and Covert Channels |
|
|
230 | (1) |
|
|
230 | (1) |
|
|
231 | (1) |
|
|
232 | (1) |
|
|
233 | (1) |
|
|
234 | (1) |
|
|
235 | (2) |
|
|
235 | (1) |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
237 | (6) |
|
Chapter 7 Exploiting Network Vulnerabilities |
|
|
243 | (44) |
|
|
247 | (1) |
|
Conducting Network Exploits |
|
|
247 | (10) |
|
|
247 | (2) |
|
|
249 | (2) |
|
|
251 | (3) |
|
|
254 | (1) |
|
DoS Attacks and Stress Testing |
|
|
255 | (2) |
|
|
257 | (1) |
|
Exploiting Windows Services |
|
|
257 | (4) |
|
NetBIOS Name Resolution Exploits |
|
|
257 | (4) |
|
|
261 | (1) |
|
Identifying and Exploiting Common Services |
|
|
261 | (8) |
|
Identifying and Attacking Service Targets |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
264 | (1) |
|
|
265 | (1) |
|
|
266 | (1) |
|
|
267 | (1) |
|
|
268 | (1) |
|
Stress Testing for Availability |
|
|
269 | (1) |
|
|
269 | (9) |
|
|
269 | (1) |
|
|
270 | (1) |
|
Attacking Captive Portals |
|
|
270 | (1) |
|
Eavesdropping, Evil Twins, and Wireless On-Path Attacks |
|
|
271 | (4) |
|
Other Wireless Protocols and Systems |
|
|
275 | (1) |
|
|
276 | (1) |
|
|
277 | (1) |
|
|
277 | (1) |
|
|
278 | (1) |
|
|
279 | (1) |
|
|
279 | (3) |
|
Activity 7.1 Capturing Hashes |
|
|
279 | (1) |
|
Activity 7.2 Brute-Forcing Services |
|
|
280 | (1) |
|
Activity 7.3 Wireless Testing |
|
|
281 | (1) |
|
|
282 | (5) |
|
Chapter 8 Exploiting Physical and Social Vulnerabilities |
|
|
287 | (24) |
|
Physical Facility Penetration Testing |
|
|
290 | (4) |
|
|
290 | (4) |
|
|
294 | (1) |
|
|
294 | (8) |
|
In-Person Social Engineering |
|
|
295 | (2) |
|
|
297 | (1) |
|
|
298 | (1) |
|
Using Social Engineering Tools |
|
|
298 | (4) |
|
|
302 | (1) |
|
|
303 | (1) |
|
|
303 | (3) |
|
Activity 8.1 Designing a Physical Penetration Test |
|
|
303 | (1) |
|
Activity 8.2 Brute-Forcing Services |
|
|
304 | (1) |
|
|
305 | (1) |
|
|
306 | (5) |
|
Chapter 9 Exploiting Application Vulnerabilities |
|
|
311 | (44) |
|
Exploiting Injection Vulnerabilities |
|
|
314 | (6) |
|
|
314 | (1) |
|
Web Application Firewalls |
|
|
315 | (1) |
|
|
316 | (3) |
|
|
319 | (1) |
|
Command Injection Attacks |
|
|
319 | (1) |
|
|
320 | (1) |
|
Exploiting Authentication Vulnerabilities |
|
|
320 | (7) |
|
|
321 | (1) |
|
|
322 | (4) |
|
|
326 | (1) |
|
Exploiting Authorization Vulnerabilities |
|
|
327 | (4) |
|
Insecure Direct Object References |
|
|
327 | (1) |
|
|
328 | (2) |
|
|
330 | (1) |
|
|
331 | (1) |
|
Exploiting Web Application Vulnerabilities |
|
|
331 | (4) |
|
Cross-Site Scripting (XSS) |
|
|
331 | (3) |
|
|
334 | (1) |
|
|
335 | (1) |
|
Unsecure Coding Practices |
|
|
335 | (5) |
|
|
335 | (1) |
|
|
336 | (1) |
|
|
336 | (1) |
|
|
337 | (1) |
|
|
337 | (1) |
|
|
338 | (2) |
|
|
340 | (1) |
|
Application Testing Tools |
|
|
341 | (5) |
|
Static Application Security Testing (SAST) |
|
|
341 | (1) |
|
Dynamic Application Security Testing (DAST) |
|
|
342 | (4) |
|
|
346 | (1) |
|
|
346 | (1) |
|
|
347 | (1) |
|
|
347 | (2) |
|
Activity 9.1 Application Security Testing Techniques |
|
|
347 | (1) |
|
Activity 9.2 Using the ZAP Proxy |
|
|
348 | (1) |
|
Activity 9.3 Creating a Cross-Site Scripting Vulnerability |
|
|
348 | (1) |
|
|
349 | (6) |
|
Chapter 10 Attacking Hosts, Cloud Technologies, and Specialized Systems |
|
|
355 | (50) |
|
|
360 | (8) |
|
|
361 | (4) |
|
|
365 | (2) |
|
|
367 | (1) |
|
Credential Attacks and Testing Tools |
|
|
368 | (4) |
|
|
368 | (1) |
|
Offline Password Cracking |
|
|
369 | (2) |
|
Credential Testing and Brute-Forcing Tools |
|
|
371 | (1) |
|
Wordlists and Dictionaries |
|
|
371 | (1) |
|
|
372 | (2) |
|
|
372 | (1) |
|
|
373 | (1) |
|
Metasploit and Remote Access |
|
|
373 | (1) |
|
|
374 | (1) |
|
Attacking Virtual Machines and Containers |
|
|
374 | (5) |
|
|
375 | (2) |
|
|
377 | (2) |
|
Attacking Cloud Technologies |
|
|
379 | (5) |
|
|
379 | (1) |
|
Attacking and Using Misconfigured Cloud Assets |
|
|
380 | (2) |
|
|
382 | (1) |
|
Tools for Cloud Technology Attacks |
|
|
383 | (1) |
|
|
384 | (5) |
|
Attacking IoT, ICS, Embedded Systems, and SCADA Devices |
|
|
389 | (3) |
|
|
392 | (1) |
|
|
393 | (2) |
|
|
395 | (1) |
|
|
396 | (4) |
|
Activity 10.1 Dumping and Cracking the Windows SAM and Other Credentials |
|
|
396 | (1) |
|
Activity 10.2 Cracking Passwords Using Hashcat |
|
|
397 | (1) |
|
Activity 10.3 Setting Up a Reverse Shell and a Bind Shell |
|
|
398 | (2) |
|
|
400 | (5) |
|
Chapter 11 Reporting and Communication |
|
|
405 | (24) |
|
The Importance of Communication |
|
|
409 | (2) |
|
Defining a Communication Path |
|
|
409 | (1) |
|
|
410 | (1) |
|
|
410 | (1) |
|
Recommending Mitigation Strategies |
|
|
411 | (5) |
|
Finding: Shared Local Administrator Credentials |
|
|
412 | (1) |
|
Finding: Weak Password Complexity |
|
|
413 | (1) |
|
Finding: Plaintext Passwords |
|
|
414 | (1) |
|
Finding: No Multifactor Authentication |
|
|
414 | (2) |
|
|
416 | (1) |
|
Finding: Unnecessary Open Services |
|
|
416 | (1) |
|
Writing a Penetration Testing Report |
|
|
416 | (5) |
|
Structuring the Written Report |
|
|
417 | (3) |
|
Secure Handling and Disposition of Reports |
|
|
420 | (1) |
|
Wrapping Up the Engagement |
|
|
421 | (2) |
|
|
421 | (1) |
|
|
421 | (1) |
|
|
421 | (1) |
|
Follow-Up Actions/Retesting |
|
|
422 | (1) |
|
|
422 | (1) |
|
Retention and Destruction of Data |
|
|
422 | (1) |
|
|
423 | (1) |
|
|
423 | (1) |
|
|
424 | (1) |
|
Activity 11.1 Remediation Strategies |
|
|
424 | (1) |
|
Activity 11.2 Report Writing |
|
|
424 | (1) |
|
|
425 | (4) |
|
Chapter 12 Scripting for Penetration Testing |
|
|
429 | (56) |
|
Scripting and Penetration Testing |
|
|
431 | (7) |
|
|
432 | (1) |
|
|
433 | (1) |
|
|
434 | (1) |
|
|
435 | (1) |
|
|
435 | (1) |
|
|
436 | (2) |
|
Variables, Arrays, and Substitutions |
|
|
438 | (6) |
|
|
439 | (1) |
|
|
440 | (1) |
|
|
441 | (1) |
|
|
441 | (1) |
|
|
442 | (1) |
|
|
442 | (2) |
|
|
444 | (1) |
|
|
445 | (7) |
|
|
446 | (1) |
|
|
447 | (1) |
|
|
448 | (1) |
|
|
449 | (1) |
|
|
450 | (1) |
|
|
451 | (1) |
|
|
452 | (1) |
|
|
453 | (18) |
|
|
458 | (7) |
|
|
465 | (6) |
|
|
471 | (1) |
|
Redirecting Standard Input and Output |
|
|
471 | (1) |
|
Comma-Separated Values (CSV) |
|
|
472 | (1) |
|
|
472 | (2) |
|
|
472 | (1) |
|
|
473 | (1) |
|
|
473 | (1) |
|
|
473 | (1) |
|
|
474 | (1) |
|
JavaScript Object Notation (JSON) |
|
|
474 | (1) |
|
|
475 | (1) |
|
|
475 | (1) |
|
The Role of Coding in Penetration Testing |
|
|
476 | (1) |
|
|
476 | (1) |
|
Automating Penetration Tests |
|
|
477 | (1) |
|
|
477 | (1) |
|
|
477 | (1) |
|
|
478 | (2) |
|
Activity 12.1 Reverse DNS Lookups |
|
|
478 | (1) |
|
|
479 | (1) |
|
|
480 | (5) |
|
Appendix A Answers to Review Questions |
|
|
485 | (24) |
|
Chapter 1 Penetration Testing |
|
|
486 | (1) |
|
Chapter 2 Planning and Scoping Penetration Tests |
|
|
487 | (2) |
|
Chapter 3 Information Gathering |
|
|
489 | (2) |
|
Chapter 4 Vulnerability Scanning |
|
|
491 | (2) |
|
Chapter 5 Analyzing Vulnerability Scans |
|
|
493 | (2) |
|
Chapter 6 Exploiting and Pivoting |
|
|
495 | (2) |
|
Chapter 7 Exploiting Network Vulnerabilities |
|
|
497 | (2) |
|
Chapter 8 Exploiting Physical and Social Vulnerabilities |
|
|
499 | (2) |
|
Chapter 9 Exploiting Application Vulnerabilities |
|
|
501 | (2) |
|
Chapter 10 Attacking Hosts, Cloud Technologies, and Specialized Systems |
|
|
503 | (2) |
|
Chapter 11 Reporting and Communication |
|
|
505 | (1) |
|
Chapter 12 Scripting for Penetration Testing |
|
|
506 | (3) |
|
Appendix B Solution to Lab Exercise |
|
|
509 | (2) |
|
Solution to Activity 5.2 Analyzing a CVSS Vector |
|
|
510 | (1) |
Index |
|
511 | |