PortScanner.py 488 B

123456789101112131415161718192021222324252627
  1. #!env/bin/python
  2. import socket
  3. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  4. host = "192.168.1.1"
  5. port = 80
  6. def scan_port(host: str, port: int):
  7. if s.connect_ex((host, port)):
  8. print("Port is closed")
  9. else:
  10. print("Port is open")
  11. s.close()
  12. #scan_port(host, port)
  13. scan_port("77.91.103.40", 22)
  14. scan_port("77.91.103.40", 25)
  15. scan_port("77.91.103.40", 80)
  16. scan_port("77.91.103.40", 139)
  17. scan_port("77.91.103.40", 443)
  18. scan_port("77.91.103.40", 445)