PT0-002 · Question #603
A penetration tester is attempting to download the results from an automated vulnerability scan. However, the script does not appear to work. Given the following: Which of the following is the most…
The correct answer is C. The import requests statement is missing. The Python script is failing because it attempts to use the 'requests' library without first importing it, which will cause a NameError.
Question
A penetration tester is attempting to download the results from an automated vulnerability scan. However, the script does not appear to work. Given the following:
Which of the following is the most likely reason that the script is not working as expected?
Exhibit
Options
- AThe payload value is missing
- BThe URL is not formatted correctly.
- CThe import requests statement is missing.
- DThe request should use POST rather than GET.
How the community answered
(42 responses)- A5% (2)
- B2% (1)
- C93% (39)
Why each option
The Python script is failing because it attempts to use the 'requests' library without first importing it, which will cause a NameError.
The payload value is explicitly defined as `payload = {'key': 'value'}`, so it is not missing.
The URL 'https://example.com/api/results' is syntactically well-formed, making it unlikely to be the primary reason for the script's failure to execute.
The provided Python script snippet attempts to call functions from the 'requests' library (e.g., 'requests.get()') without including an 'import requests' statement at the beginning, which is necessary to make the library available to the script.
While some APIs require POST, a GET request is a valid method for data retrieval, and without further context, there is no inherent reason it must be POST, especially when a fundamental import error is present.
Concept tested: Python external library imports
Source: https://docs.python.org/3/tutorial/modules.html
Topics
Community Discussion
No community discussion yet for this question.
