CompTIA PenTest+ (PT0-003) — Question 185
A penetration tester uses a Python script to enumerate open ports across a list of IP addresses. The current script runs sequentially, which slows it down during larger engagements. The tester wants to improve the script’s performance so it can handle multiple targets simultaneously.
Which of the following changes is the best way to achieve this goal?
Answer options
- A. Using the time.sleep() function to throttle the scanning rate
- B. Importing a library that allows use of workers
- C. Replacing the range() function with a while loop
- D. Changing the port list from a tuple to a dictionary for better lookup speed
Correct answer: B
Explanation
The best option is B, as importing a library that allows the use of workers enables concurrent execution of port scans, significantly improving performance. Option A would actually slow down the scanning process by introducing delays, while options C and D do not address the issue of parallel processing and thus would not enhance the script's efficiency.