资源简介

Python封装的masscan接口,需要先安装masscan,可直接调用。

资源截图

代码片段和文件信息

# -*- coding:utf-8 -*-


“““
ALi
20181127
“““


import hashlib
import os
import random
import subprocess
import time


# 配置文件模板
conf_template = “““# masscan-conf
rate = %d
output-format = %s
output-status = %s
output-filename = %s
ports = %s
range = %s
excludefile = %s
“““


# 默认黑名单
exclude_template = “““0.0.0.0/8
10.0.0.0/8
100.64.0.0/10
127.0.0.0/8
169.254.0.0/16
172.16.0.0/12
192.0.0.0/24
192.0.0.0/29
192.0.0.170/32
192.0.0.171/32
192.0.2.0/24
192.88.99.0/24
192.168.0.0/16
198.18.0.0/15
198.51.100.0/24
203.0.113.0/24
240.0.0.0/4
255.255.255.255/32
153.11.0.0/16
4.53.201.0/24
5.152.179.0/24
8.12.162.0-8.12.164.255
8.14.84.0/22
8.14.145.0-8.14.147.255
8.17.250.0-8.17.252.255
23.27.0.0/16
23.231.128.0/17
37.72.172.0/23
38.72.200.0/22
50.93.192.0-50.93.197.255
50.115.128.0/20
50.117.0.0/17
50.118.128.0/17
63.141.222.0/24
64.62.253.0/24
64.92.96.0/19
64.145.79.0/24
64.145.82.0/23
64.158.146.0/23
65.49.24.0/24
65.49.93.0/24
65.162.192.0/22
66.79.160.0/19
66.160.191.0/24
68.68.96.0/20
69.46.64.0/19
69.176.80.0/20
72.13.80.0/20
72.52.76.0/24
74.82.43.0/24
74.82.160.0/19
74.114.88.0/22
74.115.0.0/24
74.115.2.0/24
74.115.4.0/24
74.122.100.0/22
75.127.0.0/24
103.251.91.0/24
108.171.32.0/24
108.171.42.0/24
108.171.52.0/24
108.171.62.0/24
118.193.78.0/23
130.93.16.0/23
136.0.0.0/16
142.111.0.0/16
142.252.0.0/16
146.82.55.93
149.54.136.0/21
149.54.152.0/21
166.88.0.0/16
172.252.0.0/16
173.245.64.0/19
173.245.194.0/23
173.245.220.0/22
173.252.192.0/18
178.18.16.0/22
178.18.26.0-178.18.29.255
183.182.22.0/24
192.92.114.0/24
192.155.160.0/19
192.177.0.0/16
192.186.0.0/18
192.249.64.0/20
192.250.240.0/20
194.110.214.0/24
198.12.120.0-198.12.122.255
198.144.240.0/20
199.33.120.0/24
199.33.124.0/22
199.48.147.0/24
199.68.196.0/22
199.127.240.0/21
199.187.168.0/22
199.188.238.0/23
199.255.208.0/24
203.12.6.0/24
204.13.64.0/21
204.16.192.0/21
204.19.238.0/24
204.74.208.0/20
205.159.189.0/24
205.164.0.0/18
205.209.128.0/18
206.108.52.0/23
206.165.4.0/24
208.77.40.0/21
208.80.4.0/22
208.123.223.0/24
209.51.185.0/24
209.54.48.0/20
209.107.192.0/23
209.107.210.0/24
209.107.212.0/24
211.156.110.0/23
216.83.33.0-216.83.49.255
216.83.51.0-216.83.63.255
216.151.183.0/24
216.151.190.0/23
216.172.128.0/19
216.185.36.0/24
216.218.233.0/24
216.224.112.0/20
194.77.40.242
194.77.40.246
165.160.0.0/16
129.123.0.0/16
144.39.0.0/16
204.113.91.0/24
“““


def masscan(rate=10000
            output_format=‘json‘
            output_status=‘all‘
            ports=‘0-99‘
            range=‘123.456.789.000-123.456.789.001‘
            excludefile=‘‘):
    “““
    调用 masscan 扫描
    调用前请确认被扫描 IP 不在 exclude_template 中 否则需要自行指定黑名单文件
    :param: rate: 每秒发包数
    :param: output_format: 输出格式 xml/binary/grepable/json/list
    :param: output_status: 输出状态 all
    :param: ports: 扫描端口范围 诸如 0 8-10
    :param: range: 扫描IP范围 诸如 1.2.3.4/24 1.2.3.4-5.6.7.8
    :param: excludefile: 自定义黑名单文件名
    :return: output_filename: 扫描结果输出文件名 cache 时返回
    “““
    # 初始化
    conf_filename exclude_filename outpu

评论

共有 条评论