使用python实现扫描端口示例_python教程-查字典教程网
使用python实现扫描端口示例
使用python实现扫描端口示例
发布时间:2016-12-28 来源:查字典编辑
摘要:python最简洁易懂的扫描端口代码.运行绝对会很有惊奇感复制代码代码如下:fromthreadingimportThread,active...

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学习
    脚本专栏子分类