I need to perform a security audit on one of our web servers by detecting its open ports, and I’d like to use Python to automate this task. I have some experience with Python’s socket programming, but I’m uncertain about:
- The most efficient way to scan a range of ports.
- Which libraries (like socket, scapy, or an nmap wrapper) are best suited for this purpose.
- How to handle issues like timeouts, exceptions, and concurrent scanning. If anyone could share a sample script or guide on setting up such a scan, it would be extremely helpful.