Custom Network Reconnaissance Tool
I developed this tool to understand the TCP Three-Way Handshake and how network sockets function at the OS level. It scans a target IP for common open ports (21, 22, 80, 443, etc.) and reports back on service availability.
socket moduleThe script attempts to create a connection to a specific port. If the connect_ex() method returns 0, the port is open. If it returns an error code, the port is closed or filtered. I implemented a timeout feature to ensure the scanner doesn't hang on unresponsive IPs.
import socket
target = "127.0.0.1"
ports = [21, 22, 80, 443, 3389]
print(f"Scanning {target}...")
for port in ports:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socket.setdefaulttimeout(1)
result = s.connect_ex((target, port))
if result == 0:
print(f"[+] Port {port} is OPEN")
s.close()