對公網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
在實際生產環境中,可以採用定時任務的方式,對整個服務器進行掃描。