PT0-002 · Question #393
Given the following code: Which of the following tasks could be accomplished with the script?
The correct answer is D. Port scan. A port scanning script typically uses socket programming to attempt TCP connections (or send probes) to a range of port numbers on a target host. In Python, this commonly involves a loop over port numbers, creating a socket, calling connect() or connect_ex(), and checking…
Question
Given the following code:
Which of the following tasks could be accomplished with the script?
Options
- AReverse shell
- BPing sweep
- CFile download
- DPort scan
How the community answered
(35 responses)- A17% (6)
- B9% (3)
- C3% (1)
- D71% (25)
Explanation
A port scanning script typically uses socket programming to attempt TCP connections (or send probes) to a range of port numbers on a target host. In Python, this commonly involves a loop over port numbers, creating a socket, calling connect() or connect_ex(), and checking whether the connection succeeds or fails. If it succeeds, the port is open; if it fails/times out, the port is closed or filtered. This is fundamentally different from a reverse shell (which opens a persistent connection and redirects stdin/stdout), a ping sweep (which uses ICMP across multiple hosts), or a file download (which uses HTTP/FTP protocols to retrieve data). The pattern of iterating ports and testing connectivity is the signature of a port scanner.
Topics
Community Discussion
No community discussion yet for this question.