对公网IP列表进行端口服务扫描,发现周期内的端口服务变化情况和弱口令安全风险
可以使用PublicMonitors工具对公司的指定IP进行扫描,发现IP内的服务暴露和弱密码。
该PublicMonitors工具会调用以下的一些工具:
masscan:对已开放的端口进行扫描,查看是哪些端口对外进行了开放。
nmap:对扫描到的端口进行识别,得出该端口是哪一种类型的服务。
hydra(九头蛇):对上面的服务进行弱密码爆破。
email:将扫描的结果发送给指定的邮箱。
安装方式:
yum install -y nmap
yum install -y openssl-devel pcre-devel ncpfs-devel postgresql-devel libssh-devel gcc libpcap*
#安装九头蛇爆破工具
git clone https://github.com/vanhauser-thc/thc-hydra
cd thc-hydra
./configure
make && make install
git clone https://github.com/robertdavidgraham/masscan.git
cd masscan/
make
cp bin/masscan /bin/
#安装publicmonitors脚本
git clone https://github.com/grayddq/PublicMonitors.git
pip install -r requirements.txt
配置目录:PublicMonitors/conf/info.conf
[OPTIONS]
#IP列表文件目录
ip_file = conf/ip.txt
#弱口令账户和密码,不填写则代表不进行弱口令扫描。pass.txt默认包含top100密码
db_user = conf/user.txt
db_pass = conf/pass.txt
#扫描类型,monitors / weakpass /all
#monitors 代表最终不进行弱口令扫描
#weakpass 针对最后的一次扫描结果进行弱口令扫描
#all 代表端口监听后进行弱口令扫描
type = all
[Masscan]
#Masscan扫描器的发包数量,越大越快但漏扫量越多,1M~=2000,
rate = 2000
[Email]
#不填写则代表不发送邮箱通知
#发送的邮箱账户和密码
user =
pass =
#目标邮箱
target_email =
#smtp的server名称,如163邮箱则填写smtp.163.com
smtp_server =
使用方法:
配置PublicMonitors/conf/ip.txt,将需要扫描的IP加入到里面
然后执行python PublicMonitors.py
在实际生产环境中,可以采用定时任务的方式,对整个服务器进行扫描。