
2.16 LAB: Port Scan (Modules)
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.
Ex: IPv4 address should look like this:
192.168.34.23Your 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.
Ex: Your output should contain 10 IP reports. Here is and example of 2 of the 10 reports:
Host IP: 66.78.126.11 Open ports are: [53, 87, 21, 57, 71, 37, 61, 38, 45, 94, 84, 26, 72, 52, 75, 41, 90, 88, 82, 59, 50, 36, 60, 16, 51, 76, 24, 66, 33, 63, 86, 93, 34, 85] Host IP: 11.96.129.20 Open ports are: [15, 77, 19, 72, 78, 37, 93, 42, 26, 30, 79, 16, 47, 48, 43, 50, 82, 60, 46, 10, 62, 96, 12, 99, 76, 51, 32, 24, 61, 87, 73, 65, 85, 67, 29]import random
def create_random_open_ports():
#Create empty list / dictionary
port = []
ports = {}
#Fill list with 100 random port numbers from 10 - 100
for i in range(1,101):
random_port = random.randint(10, 100)
port.append(random_port)
#Create a new dictionary with ports numbers as keys
new_ports = ports.fromkeys(port, 0)
#Iterate through new dictionary add random 0 / 1
#Closed port = 0, Open port = 1
for key in new_ports:
r1 = random.randint(0,1)
new_ports[key] = r1
return new_ports
# TODO: create a function called create_host_IPs() that randomly generates a list of 10 IP addresses
# concatenating the 4 values into a string and appending it to a host list. The function returns the generated
# host list
def create_host_IPs():
host = []
octet1 = ""
octet2 = ""
octet3 = ""
octet4 = ""
#Add loop with range 1 - 11 to create the 10 host IPs EX: 192.123.11.1
# TODO: create a 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 assignment information.
def simulate_scan(h):
if __name__ == "__main__":
#Simulate port scanning for open ports
active_hosts = create_host_IPs()
simulate_scan(active_hosts)
need code
![entry level cyber
* Home
Gradebook
zy Section 2.16 - CYE X
A python - LAB: Sor X
b My Questions | ba X
Search Results |C
G 5.16 LAB: Cryptog X
+
i learn.zybooks.com/zybook/CYB_135_54915392/chapter/2/section/16
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 2.16: LAB: Port Scan (Modules)
E zyBooks catalog
? Help/FAQ
Kenneth Schultz -
Host IP: 11.96.129.20
Open ports are:
[15, 77, 19, 72, 78, 37, 93, 42, 26, 30, 79, 16, 47, 48, 43, 50, 82, 60, 46, 10, 62, 96, 12, 99,
76, 51, 32, 24, 61, 87, 73, 65, 85, 67, 29]
346682.2019644.gx3zgy7
LAB
2.16.1: LAB: Port Scan (Modules)
5/10
АCTIVITY
main.py
Load default template...
rnew_por ts = ports.ir'oMkeys(porı, v)
14
15
#Iterate through new dictionary add random e / 1
#Closed port = 0, Open port = 1
for key in new_ports:
r1 = random.randint (0,1)
new_ports[key] = r1
return new_ports
16
17
18
19
20
21
22
23 # TODO: create a function called create_host_IPs() that randomly generates a list of 10 IP addresses
24 # concatenating the 4 values into a string and appending it to a host list.
25 # host list
The function returns the generated
26 def create_host_IPs():
host = [1
27
28
octet1 =
29
octet2 =
30
octet3
31
octet4 = ""
32
#Add loop with range 1 - 11 to create the 10 host IPs EX: 192.123.11.1
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
second box.
Develop mode
Submit mode
Enter program input (optional)
192.168.34.23
main py
4:10 AM
O Type here to search
77°F Cloudy
9/18/2021](https://content.bartleby.com/qna-images/question/7ef9d07b-5934-4723-aca6-faf08a622511/c780645c-fd7a-422e-b830-589c2bc16f65/vep4koq_thumbnail.png)
![entry level cyber
* Home
Gradebook
zy Section 2.16 - CYE X
A python - LAB: Sor X
b My Questions | ba X
Search Results |C
G 5.16 LAB: Cryptog X
+
i learn.zybooks.com/zybook/CYB_135_54915392/chapter/2/section/16
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 2.16: LAB: Port Scan (Modules)
E zyBooks catalog
? Help/FAQ
Kenneth Schultz -
Host IP: 11.96.129.20
Open ports are:
[15, 77, 19, 72, 78, 37, 93, 42, 26, 30, 79, 16, 47, 48, 43, 50, 82, 60, 46, 10, 62, 96, 12, 99,
76, 51, 32, 24, 61, 87, 73, 65, 85, 67, 29]
346682.2019644.gx3zgy7
LAB
2.16.1: LAB: Port Scan (Modules)
5/10
АCTIVITY
main.py
Load default template...
35
36 # TODO: create a function called simulate_scan(h) that iterates through the host list (received as h) and
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 create_random_open_ports().
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 open ports.
41 # Finally it should print the host IP and a list of open ports as displayed in assignment information.
42 def simulate_scan(h):|
The function should use a nested for Loop that iterates
43
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
51
52
Run your program as often as you'd like, before submitting for grading. Below, type any needed
input values in the first box, then click Run program and observe the program's output in the
second box.
Develop mode
Submit mode
Enter program input (optional)
192.168.34.23
main py
4:10 AM
O Type here to search
77°F Cloudy
9/18/2021](https://content.bartleby.com/qna-images/question/7ef9d07b-5934-4723-aca6-faf08a622511/c780645c-fd7a-422e-b830-589c2bc16f65/lg4g8u_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

- C programming: Fill Out the TODO'S IN THE PROGRAM : #include <stdlib.h> // EXIT_ codes#include <stdbool.h> // bool#include <stdio.h> // printf, scanf#include <string.h> // strlen, strcmp#include "udp.h" // udp library#define CLIENT_LISTENER_PORT 4097#define SERVER_LISTENER_PORT 4098#define MAX_CHARS_PER_MESSAGE 80//-----------------------------------------------------------------------------// Main//-----------------------------------------------------------------------------int main(int argc, char* argv[]){char *remoteIp;char *mode;int remotePort;char str[MAX_CHARS_PER_MESSAGE+1];bool quit = false;bool sendMode;// Verify arguments are goodbool goodArguments = (argc == 3);if (goodArguments){remoteIp = argv[1];mode = argv[2];goodArguments = (strcmp(mode, "server") == 0) || (strcmp(mode, "client") ==0);}if (!goodArguments){printf("usage: chat IPV4_ADDRESS MODE\n");printf(" where:\n");printf(" IPV4_ADDRESS is address of the remote machine\n");printf(" MODE is…arrow_forwardT The information in DNA is stored as a code made up of four chemical bases which are represented by four upper case letters A, T, G, C. An example DNA sequence could be: ATGAG An interesting phenomena here is that when two DNA sequences are attempted to combine, A can only pair with T whereas G can only pair with C. Two DNA sequences for example ATGC and TACG are considered 'fully complementary' because the bases (letters) in every index position can be paired to each other (see the image). ATGC ATGC ATGC XX TACG Fully Complementary TACC SNP TTCA CA Non Complementary Two DNA sequences for example ATGC and TACC are considered 'SNP type' because there is exactly one index position (last position in this case) in which the bases(letters) can not be paired. Two DNA sequences for example ATGC and TTCA are considered "non complementary' because there are more than one index position (second and fourth in this case) in which the bases can not be paired. Write a program that will ask the user…arrow_forwardC programming: Fill Out the TODO'S IN THE PROGRAM : #include <stdlib.h> // EXIT_ codes#include <stdbool.h> // bool#include <stdio.h> // printf, scanf#include <string.h> // strlen, strcmp#include "udp.h" // udp library#define CLIENT_LISTENER_PORT 4097#define SERVER_LISTENER_PORT 4098#define MAX_CHARS_PER_MESSAGE 80//-----------------------------------------------------------------------------// Main//-----------------------------------------------------------------------------int main(int argc, char* argv[]){char *remoteIp;char *mode;int remotePort;char str[MAX_CHARS_PER_MESSAGE+1];bool quit = false;bool sendMode;// Verify arguments are goodbool goodArguments = (argc == 3);if (goodArguments){remoteIp = argv[1];mode = argv[2];goodArguments = (strcmp(mode, "server") == 0) || (strcmp(mode, "client") ==0);}if (!goodArguments){printf("usage: chat IPV4_ADDRESS MODE\n");printf(" where:\n");printf(" IPV4_ADDRESS is address of the remote machine\n");printf(" MODE is…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





