March 2019
Beginner
490 pages
12h 40m
English
Sockets are the fundamental building blocks for network communications, and we can easily check whether a specific port is open, closed, or filtered by calling the connect_ex() method. For example, we could have a script that reads the IP address and a list of ports and return information about each port regarding whether it is open or closed.
You can find the following code in the socket_port_scan.py file:
#!/usr/bin/env python3import socketipaddress =input("Enter ip address or domain for port scanning:")port_init= input("Enter first port: ")port_end = input("Enter last port: ")for port in range(int(port_init), int(port_end)+1): sock= socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.settimeout(5) result = ...Read now
Unlock full access