- A
TCP SYN flood
Why wrong: A SYN flood is a Denial of Service attack that sends many SYN packets without completing the handshake to overwhelm the target, not to enumerate open ports.
- B
Port scanning
The script performs a SYN scan to identify open ports by observing SYN-ACK responses, which is a form of port scanning.
- C
ARP poisoning
Why wrong: ARP poisoning involves manipulating ARP tables on a local network, not sending TCP packets to a remote target.
- D
DNS spoofing
Why wrong: DNS spoofing corrupts DNS responses, not related to TCP SYN packets.
Quick Answer
The correct answer is port scanning, specifically a TCP SYN scan. This is because the script uses Scapy to craft and send TCP SYN packets to a target IP across a range of ports, then monitors for SYN-ACK responses—a SYN-ACK reply indicates the port is open and listening, while no response or an RST packet indicates a closed or filtered port. On the CompTIA PenTest+ PT0-002 exam, this scenario tests your ability to recognize common reconnaissance techniques from code snippets; a common trap is confusing SYN scans with denial-of-service attacks, but the key distinction is the targeted port range and the expectation of a handshake response rather than flooding. Remember that a SYN scan is often called a “half-open” scan because it never completes the three-way handshake. A helpful memory tip: SYN sent, SYN-ACK received equals open port—think “SYN-ACK means crack in the stack.”
PT0-002 Tools and Code Analysis Practice Question
This PT0-002 practice question tests your understanding of tools and code analysis. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
A penetration tester is analyzing a Python script that imports the 'scapy' library. The script defines a function that sends a series of TCP SYN packets to a target IP and port range, and then waits for SYN-ACK responses. Which attack is the script performing?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
Port scanning
The script sends TCP SYN packets to a range of ports and waits for SYN-ACK responses. This is the classic behavior of a SYN scan, a type of port scanning that identifies open ports by observing which ports respond with a SYN-ACK. The use of Scapy to craft and send these packets confirms the script is performing port scanning, not a denial-of-service attack.
Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
TCP SYN flood
Why it's wrong here
A SYN flood is a Denial of Service attack that sends many SYN packets without completing the handshake to overwhelm the target, not to enumerate open ports.
- ✓
Port scanning
Why this is correct
The script performs a SYN scan to identify open ports by observing SYN-ACK responses, which is a form of port scanning.
Related concept
Read the scenario before looking for a memorised answer.
- ✗
ARP poisoning
- ✗
DNS spoofing
Common exam traps
Common exam trap: answer the scenario, not the keyword
The trap here is confusing a TCP SYN flood (a denial-of-service attack that sends many SYN packets without completing handshakes) with a SYN scan (a reconnaissance technique that sends SYN packets and analyzes responses to identify open ports).
Detailed technical explanation
How to think about this question
In a SYN scan, the attacker sends a SYN packet to each target port; if the port is open, the target responds with a SYN-ACK, and the attacker can then send an RST to tear down the half-open connection, avoiding a full TCP handshake. This technique is often called 'stealth scanning' because it may evade some logging mechanisms that only record completed connections. Scapy's low-level packet manipulation allows precise control over TCP flags, making it ideal for crafting these probes without relying on the host OS's TCP stack.
KKey Concepts to Remember
- Read the scenario before looking for a memorised answer.
- Find the constraint that changes the correct option.
- Eliminate answers that are true in general but not in this case.
TExam Day Tips
- Watch for words such as best, first, most likely and least administrative effort.
- Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.
Real-world example
How this comes up in practice
A security team runs a vulnerability scan on a web application and discovers an unpatched SQL injection flaw. The team prioritises remediation by CVSS score — critical flaws are patched within 24 hours, high within 7 days. Questions like this test whether you understand vulnerability management processes, scanning tools, and remediation prioritisation.
What to study next
Got this wrong? Here's your next step.
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
- →
Tools and Code Analysis — study guide chapter
Learn the concepts, then practise the questions
- →
Tools and Code Analysis practice questions
Targeted practice on this topic area only
- →
All PT0-002 questions
509 questions across all exam domains
- →
CompTIA PenTest+ PT0-002 study guide
Full concept coverage aligned to exam objectives
- →
PT0-002 practice test guide
How to use practice tests most effectively before exam day
Related practice questions
Related PT0-002 practice-question pages
Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.
Planning and Scoping practice questions
Practise PT0-002 questions linked to Planning and Scoping.
Information Gathering and Vulnerability Scanning practice questions
Practise PT0-002 questions linked to Information Gathering and Vulnerability Scanning.
Attacks and Exploits practice questions
Practise PT0-002 questions linked to Attacks and Exploits.
Reporting and Communication practice questions
Practise PT0-002 questions linked to Reporting and Communication.
Tools and Code Analysis practice questions
Practise PT0-002 questions linked to Tools and Code Analysis.
PT0-002 fundamentals practice questions
Practise PT0-002 questions linked to PT0-002 fundamentals.
PT0-002 scenario practice questions
Practise PT0-002 questions linked to PT0-002 scenario.
PT0-002 troubleshooting practice questions
Practise PT0-002 questions linked to PT0-002 troubleshooting.
Practice this exam
Start a free PT0-002 practice session
Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.
FAQ
Questions learners often ask
What does this PT0-002 question test?
Tools and Code Analysis — This question tests Tools and Code Analysis — Read the scenario before looking for a memorised answer..
What is the correct answer to this question?
The correct answer is: Port scanning — The script sends TCP SYN packets to a range of ports and waits for SYN-ACK responses. This is the classic behavior of a SYN scan, a type of port scanning that identifies open ports by observing which ports respond with a SYN-ACK. The use of Scapy to craft and send these packets confirms the script is performing port scanning, not a denial-of-service attack.
What should I do if I get this PT0-002 question wrong?
Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.
What is the key concept behind this question?
Read the scenario before looking for a memorised answer.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
3 more ways this is tested on PT0-002
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A penetration tester is analyzing a Python script that uses the 'scapy' library. The script contains the line: `packet = IP(dst='10.0.0.1')/TCP(dport=80, flags='S')`. The tester then uses `sr1(packet, timeout=2)`. What is the primary purpose of this code?
medium- ✓ A.Perform a TCP SYN scan to determine if port 80 is open
- B.Perform a DNS resolution for the target IP
- C.Send a TCP ACK packet to test firewall rules
- D.Complete a full TCP three-way handshake
Why A: The code constructs an IP packet with destination 10.0.0.1 and a TCP segment with destination port 80 and the SYN flag set (flags='S'). The sr1() function sends this packet and waits for a response (up to 2 seconds). This is the classic technique for a TCP SYN scan: if a SYN-ACK is received, the port is open; if an RST is received, the port is closed. The primary purpose is therefore to probe whether port 80 on the target is open.
Variation 2. A penetration tester is analyzing a Python script that uses the 'scapy' library to craft custom network packets. The relevant code is: ```python from scapy.all import * packet = IP(dst="192.168.1.1")/TCP(dport=80, flags="S") response = sr1(packet, timeout=2) if response.haslayer(TCP): print(response.getlayer(TCP).flags) ``` What is the primary goal of this script?
medium- A.To perform a TCP connect scan by completing the three-way handshake
- ✓ B.To perform a SYN scan and determine if port 80 is open
- C.To send an HTTP GET request and capture the web page
- D.To perform a UDP scan on port 80
Why B: The script uses Scapy to craft a TCP SYN packet (flags='S') to port 80 and sends it with sr1(), which waits for a single response. If a TCP layer is present in the reply, it prints the flags. This is the classic behavior of a SYN scan (half-open scan): it sends a SYN and analyzes the response to determine if the port is open (SYN-ACK) or closed (RST), without completing the handshake. Option B correctly identifies this as a SYN scan to check if port 80 is open.
Variation 3. A penetration tester is analyzing a Python script that uses the 'scapy' library to craft and send packets. The script contains the following code snippet: 'send(IP(dst=target)/TCP(dport=port, flags='S'))'. The script then listens for responses and looks for packets with flags 'SA'. Which type of scan is this script performing?
medium- A.TCP Connect scan
- ✓ B.TCP SYN scan (half-open scan)
- C.TCP FIN scan
- D.TCP Xmas scan
Why B: The script sends a TCP SYN packet (flags='S') and listens for a SYN-ACK response (flags='SA'), which is the defining behavior of a TCP SYN scan (also known as a half-open scan). This scan never completes the three-way handshake, making it stealthier than a full TCP Connect scan. The use of Scapy's `send()` function (Layer 3) rather than `sr()` or a socket-level connect confirms it is crafting raw packets, not relying on the OS's TCP stack.
Keep practising
More PT0-002 practice questions
- A penetration tester is performing passive reconnaissance on a target organization. Which of the following activities wo…
- A penetration tester is conducting passive reconnaissance on a target organization. Which technique can be used to disco…
- A penetration tester is analyzing a Python script that uses the 'requests' library to send HTTP POST requests to a targe…
- A penetration tester is analyzing a PowerShell script that contains the following code: Get-WmiObject -Class Win32_Servi…
- A client review of a penetration test report reveals confusion about why a particular vulnerability exists. The client's…
- A penetration tester has completed the test and is writing the findings section. For a critical vulnerability, the teste…
Last reviewed: Jun 11, 2026
This PT0-002 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PT0-002 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.