0
点赞
收藏
分享

微信扫一扫

python IP段指定端口扫描

JamFF 2022-10-16 阅读 73

#!/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)

懂得,原来世界如此简单!



举报

相关推荐

0 条评论