Question 14 of 52 from exam PT0-001: CompTIA PenTest+

Question 14 of 52 from exam PT0-001: CompTIA PenTest+

Question

A penetration tester wrote the following script to be used in one engagement:

#!/usr/bin/python
import socket, sys

ports = [21,22,23,25, 80,139,443, 445, 3306, 3389]
if len(sys.argv)

target = socket.gethostbyname (sys.argv[1])

else:
print ("foo few arguments.”)
print ("syntax: python {} <>”.format (sys-argv[0]))
sys-exit ()

try:

for port in port:
3 = socket. socket (socket.AF_INET, socket. SOCK_STREAM)
s.settimeout (2)
results = s.connect_ex((target,port))
if result == 0:
print ("Port {} is opened”. format (port) )
except KeyboardInterrupt
print (“Exiting..
sys.exit ()

Which of the following actions will this script perform?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.