python扫描端口 使用python实现扫描端口示例

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python扫描端口 使用python实现扫描端口示例

  2021-03-19 我要评论
想了解使用python实现扫描端口示例的相关内容吗,在本文为您仔细讲解python扫描端口的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:扫描端口,下面大家一起来学习吧。

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.')

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们