#!/usr/bin/python
# -*- coding: utf-8 -*-
# 查找哪台电脑开了远程端口
from socket import *
# 3389
host = '192.168.11.'
opened_ports = []
for ip in range(1, 254):
sock = socket(AF_INET, SOCK_STREAM)
sock.settimeout(1)
print('scan:{}'.format(ip))
result = sock.connect_ex((gethostbyname(host + str(ip)), 3389))
if result == 0:
print('*********:{}'.format(ip))
opened_ports.append(ip)
print("Opened ports:")
for i in opened_ports:
print(i)
标签:opened,端口扫描,ip,sock,python,IP,print,ports
From: https://www.cnblogs.com/qianxunman/p/16788132.html