Created
          January 29, 2024 07:41 
        
      - 
      
- 
        Save erdum/3aa029e88f2d586c6ec20e1dde3b6d0a to your computer and use it in GitHub Desktop. 
    Python IP scanner
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import socket | |
| def check_port(ip, port): | |
| sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| sock.settimeout(1) | |
| result = sock.connect_ex((ip, port)) | |
| sock.close() | |
| return result == 0 | |
| def scan_ports(start_ip, end_ip, port): | |
| for i in range(start_ip, end_ip + 1): | |
| # Replace with your network range | |
| ip = f'192.168.18.{i}' | |
| print(f'Testing port host {ip}...') | |
| if check_port(ip, port): | |
| print(f'IP Address {ip} is allowing connection on port {port}') | |
| if __name__ == "__main__": | |
| start_ip = 1 | |
| end_ip = 255 | |
| # Replace with your required port | |
| target_port = 4370 | |
| scan_ports(start_ip, end_ip, target_port) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment