使用python实现扫描端口示例

我热爱春天,因为春天充满了生机,充满了新的希望!

python最简洁易懂的扫描端口代码.运行绝对会很有惊奇感


from threading import Thread, activeCount

import socket

import os

def test_port(dst,port):

os.system('title '+str(port)) cli_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try: indicator = cli_sock.connect_ex((dst, port))

if indicator == 0:

print(port)

cli_sock.close()

except: pass


if __name__=='__main__':

dst = '192.168.0.22' i = 0

while i < 65536:

if activeCount() <= 200:

Thread(target = test_port, args = (dst, i)).start() i = i + 1

while True:

if activeCount() == 2: break input('Finished scanning.')

到此这篇关于使用python实现扫描端口示例就介绍到这了。最安全的生活方式——付出>索取。更多相关使用python实现扫描端口示例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

您可能有感兴趣的文章
Python自动化运维-使用Python脚本监控华为AR路由器关键路由变化

Python自动化运维-netmiko模块设备自动发现

Python自动化运维—netmiko模块连接并配置华为交换机

Python自动化运维-利用Python-netmiko模块备份设备配置

Python自动化运维-Paramiko模块和堡垒机实战