漏洞扫描器 - cmd命令行执行

该漏洞扫描器可以通过cmd命令行执行。

cmd命令行执行方式通过Click模块实现,Click用于快速创建命令行,相比于Argparse更加简便。代码如下所示:

@click.command()
@click.option("--verbose", help="Verbose or not (default False)", type=bool, required=False, default=True)
@click.option("--port", help="Port ranges, example: 22 or 1-1024 (default 1-65535)", default="1-65535")
@click.option("--ping", help="ICMP ping before scan", default=True)
@click.option("--syn", help="TCP SYN scan", default=True)
@click.option("--ssh", help="If SSH service is open, scan ssh version and detect weak password or not", default=True)
@click.option("--os_ttl", help="Use the parameter ttl to scan the type of OS", default=True)
@click.option("--os_nmap", help="Use the tool nmap to scan the type of OS", default=True)
@click.option("--size", help="Thread group size", default=1000)
@click.option("--timeout", help="How much time to wait after the last packet has been sent", default=3.0)
@click.argument("dst", required=True, type=str)

首先用 @click.command() 装饰scanner() 函数,使之成为命令行接口。

随后通过 @click.option() 等装饰函数添加命令行选项。

@click.option()函数的第一个参数指定了命定行选项的名称;help为参数说明,将在帮助界面向用户展示出来;default参数设置命令行参数的默认值;此外还可以通过nargs参数指定命令行参数接收的值的个数。

@click.argument(“dst”, required=True, type=str) 函数用来添加固定参数,要求必须输入目标IP地址。

下图为cmd帮助界面,可以看到dst参数为必填参数,还有可选选项列表。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43619058/article/details/125129707
今日推荐