CompTIA PenTest+ Certification Exam PT0-002 Question # 48 Topic 5 Discussion

CompTIA PenTest+ Certification Exam PT0-002 Question # 48 Topic 5 Discussion

PT0-002 Exam Topic 5 Question 48 Discussion:
Question #: 48
Topic #: 5

During a security assessment, a penetration tester decides to implement a simple TCP port scanner to check the open ports from 1000 to 2000. Which of the following Python scripts would achieve this task?


A.

fori in range(1000, 2001): s = socket(AF_INET, SOCK_STREAM)

conn = s.connect_ex((host_IP, i))

if (conn == 0):

print(fPort {i} OPEN’)


B.

close ()


C.

fori in range(1001, 2000): s = socket(AF_INET, SOCK_STREAM) conn = s.connect—ex((host_IP, i)) if (conn == 0): print (f'Port {i} OPEN’) s.close ()


D.

fori in range(1000, 2001): s = socket(AF—INET, SOCK_DGRAM) conn = s.connect—ex((host_IP, i)) if (conn == 0): print(f’Port {i} OPEN’) s.close ()


E.

fori in range (1000, 2000): s = socket(SOCK_STREAM, AF_INET) conn = s.connect—ex((host—IP, i)) if (conn == 0): print (f'Port {i} OPEN') s.close()


Get Premium PT0-002 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.