CompTIA PT0-003 Practice Test

Prepare smarter and boost your chances of success with our CompTIA PT0-003 Practice test. This test helps you assess your knowledge, pinpoint strengths, and target areas for improvement. Surveys and user data from multiple platforms show that individuals who use PT0-003 practice exam are 40–50% more likely to pass on their first attempt.

Start practicing today and take the fast track to becoming CompTIA PT0-003 certified.

1880 already prepared
Updated On : 11-Sep-2025
88 Questions
4.8/5.0

Page 2 out of 9 Pages

1) #!/bin/bash

2) for i in {1..254}; do

3) ping -c1 192.168.1.$i

4) done

The tester executes the script, but it fails with the following error:

-bash: syntax error near unexpected token `ping'

Which of the following should the tester do to fix the error?

A. Add do after line 2.

B. Replace {1..254} with $(seq 1 254).

C. Replace bash with tsh.

D. Replace $i with ${i}.

A.   Add do after line 2.

Explanation
The error message -bash: syntax error near unexpected token 'ping' indicates that the Bash shell encountered the ping command where it did not expect it. This points to a problem with the loop's structure.

The provided script is:
#!/bin/bash

for i in {1..254};

ping -c1 192.168.1.$i

done

The problem is on line 2. The line ends with a semicolon (;), which tells the shell that a command is ending and another is beginning. The shell then reads line 3 and sees ping, but the for loop structure requires the do keyword to come before the command to be looped.

The fix is to add do to the end of line 2.

The corrected line 2 would be: for i in {1..254}; do

Why the Other Options Are Incorrect

B. Replace {1..254} with $(seq 1 254).
The {1..254} syntax is perfectly valid in Bash for generating a sequence of numbers. While $(seq 1 254) would also work, the error is not related to how the sequence is generated. The script would fail with the same error even after this change because the do keyword is still missing.

C. Replace bash with tsh.
There is no common shell named tsh. The script correctly uses #!/bin/bash. The error is a syntax error in the script logic, not a problem with the interpreter.

D. Replace $i with ${i}.
Using $i is standard and correct in this context. While ${i} can be used for clarity or to separate the variable from surrounding text (e.g., file_${i}.txt), it is not necessary here. The error occurs before the variable is even expanded, so this change would not fix the problem.

Reference
This is a fundamental Bash scripting syntax error. The structure of a for loop is a basic concept covered in any shell scripting guide. The error message is a classic indicator of a missing keyword, like do, then (in an if statement), or fi.

A penetration tester cannot find information on the target company's systems using common OSINT methods. The tester's attempts to do reconnaissance against internet-facing resources have been blocked by the company's WAF. Which of the following is the best way to avoid the WAF and gather information about the target company's systems?

A. HTML scraping

B. Code repository scanning

C. Directory enumeration

D. Port scanning

B.   Code repository scanning

Explanation
The scenario states that direct reconnaissance against the company's internet-facing resources is being blocked by a WAF. The best way to "avoid the WAF" is to gather intelligence from sources that are not protected by the company's WAF but still contain information about the company's systems.

Code Repository Scanning:
This involves searching public code repositories like GitHub, GitLab, or Bitbucket for code, configuration files, and documentation belonging to the target company. Developers often accidentally (or intentionally) push code containing:

API keys and passwords
Internal server names and IP addresses

Database connection strings

Source code revealing application logic and vulnerabilities

Configuration files (e.g., for cloud services) that map out the infrastructure

This information is gathered directly from the code repository's website, completely bypassing the target's production network and their WAF. It is a highly effective form of passive reconnaissance.

Why the Other Options Are Incorrect

A. HTML scraping:
This involves programmatically extracting data from the target's public websites. Since the website is an "internet-facing resource," it is almost certainly protected by the WAF. Attempting to scrape it would likely be detected and blocked by the same WAF that is preventing other reconnaissance, so it does not avoid the WAF.

C. Directory enumeration:
This is an active attack against the web server (e.g., using a tool like gobuster or dirb to find hidden directories). This direct interaction with the target's web server would be detected and blocked by the WAF.

D. Port scanning:
This is the classic active reconnaissance technique that involves sending probes to the target's IP addresses. The scenario explicitly states that such attempts are blocked, meaning the WAF or other perimeter defenses are configured to drop or reject these packets. Port scanning would not succeed in this situation.

Reference
This technique is a cornerstone of Open-Source Intelligence (OSINT) and is a critical part of modern penetration testing, especially against security-mature organizations with strong perimeter defenses. It aligns with the PenTest+ objective of understanding various information-gathering methods. Searching public code repositories is often the first step when direct scanning fails, as it can yield a treasure trove of information without triggering any alarms.

Which of the following OT protocols sends information in cleartext?

A. TTEthernet

B. DNP3

C. Modbus

D. PROFINET

C.   Modbus

Explanation
Many legacy OT protocols were designed for reliability and simplicity within isolated, trusted networks, not for security in a modern interconnected environment. As a result, they often lack basic security features like encryption.

Modbus is one of the oldest and most widely deployed OT protocols. The standard versions of Modbus (Modbus RTU and Modbus TCP) do not have any built-in encryption or authentication mechanisms. All data, including commands and sensor readings, is transmitted in cleartext. This makes it highly vulnerable to eavesdropping and manipulation on a network.

Why the Other Options Are Incorrect

A. TTEthernet (Time-Triggered Ethernet):
This is a protocol designed for highly deterministic, real-time systems (like avionics). While its specific payloads might not always be encrypted, the protocol itself operates on a principle of scheduled time slots for traffic, which provides a form of security through deterministic control. It is not typically cited as a common cleartext protocol like Modbus.

B. DNP3 (Distributed Network Protocol):
While traditional DNP3 also operated in cleartext, it has a secure version, DNP3 Secure, defined in the IEEE 1815-2012 standard, which provides authentication and integrity. The question is likely focusing on the most classic example of a cleartext protocol, which is Modbus.

D. PROFINET:
This is an industrial Ethernet standard. While its standard communication is real-time and unencrypted, it's important to note that PROFINET is often mentioned alongside Modbus as an unsecured protocol. However, Modbus is the quintessential example used in security discussions due to its extreme simplicity and widespread use. Between Modbus and PROFINET, Modbus is the more universally recognized correct answer for this specific question about cleartext transmission. PROFINET has more modern, secure profiles, whereas base Modbus has none.

Reference
The lack of security in Modbus is a well-documented critical issue in OT security. Guides like the NIST Guide to Industrial Control Systems (ICS) Security (SP 800-82) explicitly highlight Modbus as an example of a protocol that lacks confidentiality, integrity, and authentication services, making it a primary target for attackers.

Which of the following is a term used to describe a situation in which a penetration tester bypasses physical access controls and gains access to a facility by entering at the same time as an employee?

A. Badge cloning

B. Shoulder surfing

C. Tailgating

D. Site survey

C.   Tailgating

Explanation
This scenario describes a classic physical security breach known as tailgating (sometimes called "piggybacking").

Tailgating occurs when an unauthorized person follows an authorized person into a secured area without the authorized person's explicit consent or knowledge. The tester simply walks in behind the employee as the door is closing, exploiting the natural courtesy of people to hold the door or the employee's lack of awareness.

This is a common test to see if employees are properly trained to challenge strangers or if access control systems (like mantraps) are effective at preventing this exact scenario.

Why the Other Options Are Incorrect

A. Badge cloning:
This involves surreptitiously copying the data from an employee's RFID or magnetic stripe access badge to create a duplicate. This is a technical attack on the credential itself, not the social/opportunistic act of following someone through a door.

B. Shoulder surfing:
This is the act of looking over someone's shoulder to observe sensitive information, such as passwords, PINs, or data on their screen. It is an information-gathering technique, not a method for gaining physical entry.

D. Site survey:
This is a legitimate and passive reconnaissance activity where a tester observes a facility from a distance to gather information about entry points, security patrols, cameras, etc. It is the planning phase that might precede a tailgating attempt, but it is not the act of gaining entry itself.

Reference
Tailgating is a standard technique covered in the physical security assessment domain of penetration testing frameworks. It is a direct test of both technological controls (e.g., whether a door closes quickly enough) and human security awareness. This falls under the PenTest+ objective domain related to physical security attacks.

While conducting a peer review for a recent assessment, a penetration tester finds the debugging mode is still enabled for the production system. Which of the following is most likely responsible for this observation?

A. Configuration changes were not reverted.

B. A full backup restoration is required for the server.

C. The penetration test was not completed on time.

D. The penetration tester was locked out of the system.

A.   Configuration changes were not reverted.

Explanation
The scenario describes a finding during a peer review after an assessment. The key detail is that a security misconfiguration (debugging mode enabled) exists on the production system.

During a penetration test, it is common practice for the testers to request or for the client to implement temporary configuration changes to facilitate testing. This might include enabling debug logging to gather more detailed error information.

The standard procedure after testing is complete is to revert all temporary changes to restore the system to its original, hardened state. The fact that debugging mode is still enabled indicates that this crucial cleanup step was missed. The changes made for the test were not reverted, leaving the production system in a less secure state.

Why the Other Options Are Incorrect

B. A full backup restoration is required for the server.
This is an extreme measure and is not a standard part of post-penetration test cleanup. Reverting specific configuration changes is a targeted and efficient process. A full backup restoration would imply a catastrophic system compromise, which is not indicated here.

C. The penetration test was not completed on time.
While running over time might cause a rushed cleanup, it is not the direct cause of the debugging mode being enabled. The root cause is the failure to revert the change, regardless of the reason.

D. The penetration tester was locked out of the system.
This might prevent the tester from reverting the changes themselves, but it would not prevent the client's system administrators from doing so. The responsibility for the final state of the production system ultimately lies with the system owner. This observation points to a failure in the handover and cleanup process, not just a tester being locked out.

Reference
This falls under the Post-Engagement Cleanup phase of a penetration test. Professional standards, such as those outlined in the PenTest+ exam objectives (Domain 5.0: Reporting and Communication), emphasize the importance of returning the client's environment to its pre-test state. Leaving debugging enabled is a common real-world oversight that creates a significant security risk.

During a web application assessment, a penetration tester identifies an input field that allows JavaScript injection. The tester inserts a line of JavaScript that results in a prompt, presenting a text box when browsing to the page going forward. Which of the following types of attacks is this an example of?

A. SQL injection

B. SSRF

C. XSS

D. Server-side template

C.   XSS

Explanation
The question describes the exact mechanism and outcome of a Cross-Site Scripting (XSS) attack.

The Vulnerability:
An input field that does not properly sanitize or validate user input.

The Attack:
The tester injects malicious JavaScript code into the input field.

The Result:
The injected JavaScript is stored by the web application and then executed in the browsers of subsequent users who visit the page. The appearance of a prompt (a text box) is a direct result of the injected JavaScript code (e.g., using the prompt() function) running in the victim's browser.

This is a textbook example of a Stored/Persistent XSS attack, where the malicious script is permanently stored on the target server (e.g., in a database) and delivered to every user who views the compromised page.

Why the Other Options Are Incorrect

A. SQL injection (SQLi):
This attack involves injecting malicious SQL commands into an input field to interact with the application's database. The result would be unauthorized data access, modification, or deletion—not the execution of JavaScript in a user's browser.

B. SSRF (Server-Side Request Forgery):
This attack tricks the server into making unauthorized requests to internal or external resources. It targets the server's network access, not the user's browser. The outcome would be the server fetching data, not a prompt appearing in the browser.

D. Server-side template injection (SSTI):
This vulnerability occurs when user input is embedded into a server-side template (like Jinja2 or Twig) in an unsafe way, allowing the attacker to execute code on the server itself. The result would be server compromise, not client-side script execution causing a browser prompt.

Reference
XSS is a fundamental web application vulnerability listed in the OWASP Top 10 (A03:2021-Injection). The scenario described is the core definition of Stored XSS, which is a key topic within the PenTest+ exam objectives for application security testing (Domain 3.2: Given a scenario, analyze vulnerabilities). The key differentiator is the injection and execution of client-side JavaScript.

A penetration tester wants to create a malicious QR code to assist with a physical security assessment. Which of the following tools has the built-in functionality most likely needed for this task?

A. BeEF

B. John the Ripper

C. ZAP

D. Evilginx

A.   BeEF

Explanation
The goal is to create a malicious QR code for a physical security assessment. A QR code is essentially a way to encode a URL or other data that a device (like a smartphone) will automatically act upon when scanned.

BeEF (The Browser Exploitation Framework) is specifically designed to hook web browsers and launch further attacks from there. Its core functionality is to generate a malicious JavaScript hook (a "beef hook") that, when executed by a browser, gives the attacker control over the browser.

To use BeEF in a QR code attack, a penetration tester would:
Set up the BeEF server.

Generate the unique URL for the BeEF hook.

Encode that URL into a QR code using any standard QR code generator.

When a person scans the QR code with their phone, their browser will open the BeEF hook page, and their browser becomes "hooked." The tester can then use BeEF's numerous modules to perform further reconnaissance and attacks against the phone's browser.

This built-in functionality for browser hooking and control makes BeEF the ideal tool for this task.

Why the Other Options Are Incorrect

B. John the Ripper:
This is a password-cracking tool. It is used offline to crack hashes recovered from a system. It has no functionality related to generating web-based attacks or interacting with QR codes.

C. ZAP (OWASP ZAP):
This is a web application vulnerability scanner and proxy. It is used for finding flaws in websites. While it can be used to test for vulnerabilities that might be exploited via a QR code (like XSS), it does not have built-in functionality to create malicious payloads for social engineering in the way BeEF does.

D. Evilginx:
This is a tool for advanced phishing attacks that can bypass two-factor authentication by acting as a reverse proxy. It's used for stealing credentials from specific sites (like Office 365 or Gmail). While powerful, it is not designed for the general-purpose browser hooking that a QR code attack would leverage. Its setup is more complex and targeted than the simple hook generation of BeEF.

Reference
Using QR codes to deliver BeEF hooks is a well-known social engineering technique in physical penetration testing. It falls under the umbrella of client-side attacks. The PenTest+ exam objectives cover social engineering tools and methods, and BeEF is a primary tool in this category for exploiting web browsers.

A penetration tester discovers evidence of an advanced persistent threat on the network that is being tested. Which of the following should the tester do next?

A. Report the finding.

B. Analyze the finding.

C. Remove the threat.

D. Document the finding and continue testing.

A.   Report the finding.

Explanation
The discovery of an actual, ongoing malicious presence (an Advanced Persistent Threat or APT) during a penetration test is a serious incident that requires immediate and specific action. The penetration tester's role is to simulate an attack, not to respond to real ones.

The primary and immediate next step is to report the finding directly to the appropriate client contact (e.g., the point of contact for the engagement, the CISO, or the SOC manager).

This should be done verbally and immediately, not just saved for the final written report. The client needs to be informed right away so their incident response team can take over containment and eradication.

The tester should provide all relevant evidence (e.g., suspicious files, IP addresses, timestamps) to the client.

Continuing the test without informing the client could interfere with the client's incident response, potentially cause damage, and violate the rules of engagement.

Why the Other Options Are Incorrect

B. Analyze the finding.
While some initial analysis may occur to confirm the finding is indeed malicious and not a false positive, the tester should not conduct a deep forensic analysis. This is the responsibility of the client's incident response team. The tester's role is to identify and report the threat, not to investigate it extensively.

C. Remove the threat.
A penetration tester should never take action to remove a threat. This is outside the scope of a penetration testing engagement and could be considered unauthorized system modification. It could also destroy forensic evidence needed for the client's investigation and potentially disrupt business operations.

D. Document the finding and continue testing.
This is incorrect because it delays the critical communication to the client. The client has a right to know immediately about a live threat on their network. Continuing testing in an environment with an active APT can also skew results and is ethically questionable.

Reference
This scenario is a key part of the Rules of Engagement and professional conduct covered in the PenTest+ exam objectives (Domain 5.0: Reporting and Communication). Professional penetration testing standards, such as those from organizations like CREST and the EC-Council, mandate that the discovery of previously unknown malicious activity must be reported to the client immediately. The tester's job is to assess security, not to act as an incident responder.

A penetration tester gains access to a domain server and wants to enumerate the systems within the domain. Which of the following tools would provide the best oversight of domains?

A. Netcat

B. Wireshark

C. Nmap

D. Responder

C.   Nmap

Explanation:
Nmap (Network Mapper) is the best tool for enumerating systems within a domain because it is specifically designed for network discovery and mapping. It can scan networks to identify active hosts, services, operating systems, and other network characteristics. In the context of a penetration test, Nmap can be used to discover systems within a domain by scanning IP ranges or using specific scripts (e.g., SMB or DNS-related scripts) to enumerate domain-joined systems, services, and configurations.

Why Nmap?
Nmap supports a wide range of scanning techniques, such as TCP, UDP, and SYN scans, which help identify live hosts and open ports. It includes the Nmap Scripting Engine (NSE), which has scripts like smb-enum-domains or dns-zone-transfer that can enumerate domain information, such as hosts, services, and even domain controllers.

Nmap is versatile, efficient, and widely used in penetration testing for network reconnaissance, making it ideal for gaining oversight of systems within a domain.

Why not the other options?

A. Netcat:
Netcat is a versatile networking tool for tasks like port scanning, banner grabbing, or establishing connections, but it lacks the advanced enumeration capabilities of Nmap. It’s not designed for comprehensive domain enumeration and requires manual effort for each connection.

B. Wireshark:
Wireshark is a packet analyzer used for capturing and analyzing network traffic. While it can provide insights into domain-related traffic (e.g., DNS or SMB packets), it’s not a proactive enumeration tool and requires existing traffic to analyze, making it less suitable for this task.

D. Responder:
Responder is a tool for network poisoning attacks (e.g., LLMNR, NBT-NS, or WPAD poisoning) to capture credentials or relay authentication. While it can help in certain domain attack scenarios, it’s not designed for broad system enumeration within a domain.

References:
CompTIA PenTest+ (PT0-003) objectives emphasize reconnaissance and enumeration, with tools like Nmap being central to network discovery (Domain 2: Information Gathering and Vulnerability Scanning).

Nmap official documentation: https://nmap.org/book/man.html

Practical penetration testing guides often highlight Nmap for network enumeration due to its flexibility and scripting capabilities.

Given the following statements: Implement a web application firewall Upgrade end-of-life operating systems.Implement a secure software development life cycle.In which of the following sections of a penetration test report would the above statements be found?

A. Executive summary

B. Attack narrative

C. Detailed findings

D. Recommendations

D.   Recommendations

Explanation:
The statements provided—"Implement a web application firewall," "Upgrade end-of-life operating systems," and "Implement a secure software development life cycle"—are actionable suggestions aimed at addressing security vulnerabilities or improving the overall security posture of an organization. In a penetration test report, such suggestions are typically included in the Recommendations section, as they provide guidance on how to remediate identified issues or mitigate risks uncovered during the penetration test.

Why Recommendations?
The Recommendations section of a penetration test report is designed to offer practical, actionable steps to address vulnerabilities, misconfigurations, or weaknesses found during the test. These statements directly align with that purpose:

Implement a web application firewall:
This addresses potential web application vulnerabilities (e.g., SQL injection, XSS) by adding a protective layer.

Upgrade end-of-life operating systems:
This mitigates risks associated with unsupported systems that no longer receive security patches.

Implement a secure software development life cycle:
This improves long-term security by integrating security practices into software development processes.

Recommendations are typically tailored to the findings of the penetration test and aim to help the organization strengthen its defenses.

Why not the other options?

A. Executive Summary:
This section provides a high-level overview of the penetration test, including objectives, scope, key findings, and overall risk assessment. It is written for non-technical stakeholders and does not typically include specific technical recommendations like those listed.

B. Attack Narrative:
This section details the step-by-step process of how the penetration tester exploited vulnerabilities or gained access to systems. It focuses on the methodology and techniques used during the test, not on remediation steps.

C. Detailed Findings:
This section lists specific vulnerabilities, misconfigurations, or weaknesses discovered during the test, often with evidence (e.g., screenshots, logs) and their potential impact. While it may describe issues like end-of-life systems, it does not include the remediation steps, which are reserved for the Recommendations section.

References:
CompTIA PenTest+ (PT0-003) objectives, specifically Domain 5: Reporting and Communication, emphasize the structure of a penetration test report, including the Recommendations section for actionable remediation steps.

Industry standards like the Penetration Testing Execution Standard (PTES) and OWASP Testing Guide highlight the importance of providing clear recommendations in penetration test reports to guide organizations in addressing vulnerabilities.

Page 2 out of 9 Pages
PT0-003 Practice Test