Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

In network security, it is important to understand port scanning. Hackers use tools to scan a network and determine if there are open ports and if they contain some sort of vulnerability. To scan ports, you first have to find active hosts on a network. Once you find active hosts and discover a list of IP addresses for those hosts, a port scan can be performed to gather information about open ports and analyze services running on those ports. A port scan is the process of sending packets to an active host's ports and learning details that can help you gain access to that host or to discover open vulnerabilities on your network.

Some common ports are:
Port 20 - File Transfer Protocol or FTP
Port 22 - Secure Shell protocol or SSH
Port 23 - Telnet protocol for unencrypted transfer
Port 80 - HyperText Transfer Protocol or HTTP
Port 443 - HyperText Transfer Protocol Secure or HTTPS

The Well Known Ports are those from 0 through 1023

We are going to simulate a port scan by filling a list with 100 random port numbers. These values will be used as the keys in a dictionary where the values will be randomly generated integers 0 / 1. The 0 will be a closed port and a 1 will be an open port.

Your first TODO is to create a function called "create_host_IPs( )" that randomly generates a list of 10 IP addresses with 4 random octets values, concatenating the 4 values into a string and appending it to a host list. The function returns the generated host list. The random values can be limited to a range of 10 to 200.

Your next TODO is to create another function called "simulate_scan(h)" that iterates through the host list (received as h ) and then creates a new list called open_ports. The function should use a nested for loop that iterates through the host list, and then iterates through the returned list from a call to "create_random_open_ports()". If the returned list value is 1, then append it to your open_ports list. This simulates a scan of all the IPs in the host list and creates randomly generated open ports. Finally it should print the host IP and a list of open ports as displayed in this example output.

The default values can be found in the pictures

 

= zyBooks
My library > CYB/135: ...
2.16: LAB: Port Scan (Mo...
8 Adam Brygidyr
▼
main.py
#Closed port = 0, Open port = 1
for key in new_ports:
r1 = random.randint(0,1)
new_ports [key] = r1
return new_ports
17
%3D
18
19
20
21
22
23 # TODO: create a function called create_host_IPs() that randomly generates a list of .
24 # concatenating the 4 values into a string and appending it to a host list.
25 # host list
The funci
26 def create_host_IPs(():
27
host
[]
28
octet1 =
29
octet2 =
30
octet3
%3D
31
octet4 =
32
#Add loop with range 1 - 11 to create the 10 host IPs EX: 192.123.11.1
33
expand button
Transcribed Image Text:= zyBooks My library > CYB/135: ... 2.16: LAB: Port Scan (Mo... 8 Adam Brygidyr ▼ main.py #Closed port = 0, Open port = 1 for key in new_ports: r1 = random.randint(0,1) new_ports [key] = r1 return new_ports 17 %3D 18 19 20 21 22 23 # TODO: create a function called create_host_IPs() that randomly generates a list of . 24 # concatenating the 4 values into a string and appending it to a host list. 25 # host list The funci 26 def create_host_IPs((): 27 host [] 28 octet1 = 29 octet2 = 30 octet3 %3D 31 octet4 = 32 #Add loop with range 1 - 11 to create the 10 host IPs EX: 192.123.11.1 33
= zyBooks
My library > CYB/135: .
2.16: LAB: Port Scan (Mo...
8 Adam Brygidyr
▼
main.py
34
35
36 # TODO: create a function called simulate_scan(h) that iterates through the host list
37 # then creates a new list called open_ports.
38 # through the host list, and then iterates through the returned list from a call to ci
39 # If the returned list value is 1, then append it to your open_ports list.
40 # This simulates a scan of all the IPs in the host list and creates randomly generated
41 # Finally it should print the host IP and a list of open ports as displayed in assigni
42 def simulate_scan(h):
43
The function should use a nested for lo
44
45
46 if
name
_main__":
==
47
#Simulate port scanning for open ports
active_hosts = create_host_IPs()
simulate_scan(active_hosts)
48
49
50
expand button
Transcribed Image Text:= zyBooks My library > CYB/135: . 2.16: LAB: Port Scan (Mo... 8 Adam Brygidyr ▼ main.py 34 35 36 # TODO: create a function called simulate_scan(h) that iterates through the host list 37 # then creates a new list called open_ports. 38 # through the host list, and then iterates through the returned list from a call to ci 39 # If the returned list value is 1, then append it to your open_ports list. 40 # This simulates a scan of all the IPs in the host list and creates randomly generated 41 # Finally it should print the host IP and a list of open ports as displayed in assigni 42 def simulate_scan(h): 43 The function should use a nested for lo 44 45 46 if name _main__": == 47 #Simulate port scanning for open ports active_hosts = create_host_IPs() simulate_scan(active_hosts) 48 49 50
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education