Question
What type of scan is the script used to run on a target host in this python code? import socket, threading def TCP_connect(ip, port_number, delay,
What type of scan is the script used to run on a target host in this python code?
import socket, threading
def TCP_connect(ip, port_number, delay, output): TCPsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) TCPsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) TCPsock.settimeout(delay) try: TCPsock.connect((ip, port_number)) output[port_number] = 'Listening' except: output[port_number] = ''
def scan_ports(host_ip, delay):
threads = [] # To run TCP_connect concurrently output = {} # For printing purposes
# Spawning threads to scan ports for i in range(10000): t = threading.Thread(target=TCP_connect, args=(host_ip, i, delay, output)) threads.append(t)
# Starting threads for i in range(10000): threads[i].start()
# Locking the main thread until all threads complete for i in range(10000): threads[i].join()
# Printing listening ports from small to large for i in range(10000): if output[i] == 'Listening': print(str(i) + ': ' + output[i])
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started