Reconnaissance and Enumeration
A Python script uses socket.connect_ex() to flag TCP ports 21 and 25 as open on each in-scope host. The tester also needs the service banner each port sends on connect. What should be added to the script?
Show the answer
Correct answerA. Call s.recv(1024) after connecting and print the decoded bytes
AWhy this is right: recv() reads the greeting the service sends on connect, which is banner grabbing.
BWhy not this: Shutting down the read side would stop the socket from receiving the banner at all.
CWhy not this: listen() puts a socket into server mode for incoming connections; it cannot read a remote banner.
DWhy not this: bind() attaches the socket to a local address, so it cannot be pointed at the target to read data.
FTP and SMTP services send a greeting banner as soon as the TCP session opens, so reading from the connected socket with recv() captures it. listen() is a server-side call and does not read data from a remote service.