Lab15: Python| Scanning Metasploitable Host for Open Ports with Python Socket Module| Cyber Security

Published: 17 April 2024
on channel: Learn With Rubel
418
3

Define the Python socket module:
The Python socket module lets programmers connect their Python programs to networks. With sockets, Python apps can send and receive data over networks using TCP or UDP. It helps create, address, and manage connections, and handle errors. This makes it easy to build all sorts of networked apps, from simple chat programs to big, complex systems.
---------------------------------------------------------------------------------------------------------------------
import socket

metaServer = input("Enter a Metasploitable host to scan: ")
metaServerIP = socket.gethostbyname(metaServer)
print(metaServerIP)

print("-" * 60)
print("Please wait, Scanning Metasploitable host", metaServerIP)
print("-" * 60)

for port in range(1, 100):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((metaServerIP, port))
if result == 0:
print("Port {}: Open".format(port))
sock.close()
---------------------------------------------------------------------------------------------------------------------








#Networking, #CCNA, #CCNP, #linux, #AWS, #InformationTechnology, #ITCertification, #raspberry pi, #ethicalhacking


On this page of the site you can watch the video online Lab15: Python| Scanning Metasploitable Host for Open Ports with Python Socket Module| Cyber Security with a duration of hours minute second in good quality, which was uploaded by the user Learn With Rubel 17 April 2024, share the link with friends and acquaintances, this video has already been watched 418 times on youtube and it was liked by 3 viewers. Enjoy your viewing!