Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago