taibeihacker
Moderator
0x01 说明
本次用到的平台是:https://chaos.projectdiscovery.io/,該平台收集國外各大漏洞賞金平台,目前擁有資產規模大概在1600 0000~1800 0000,很可怕的數量,並且每小時都在增加或減少,對接非常多的第三方自建賞金平台,這比我們自己去收集某個平台會來的多,挖到的概率也更大。
0x02 自动化方案流程
使用腳本去獲取projectdiscovery平台的所有資產,資產偵察與收集就交給projectdiscovery了把下載的資產對比上次Master domain數據,判斷當前是否有新增資產出現,如果沒有就結束,就等待下一次循環如果有,就把新增的資產提取出來,創建臨時文件,並把新資產加入到Masterdomain把新增資產使用naabu 進行端口掃描,把開放的端口使用httpx來驗證,提取http存活資產把http存活資產送往nuclei進行漏洞掃描,同時也送往Xray,默認使用Xray的基礎爬蟲功能掃描常見漏洞Xray的掃描結果保存成xray-new-$(date +%F-%T).html,也可以同時添加webhook模式推送nuclei漏洞掃描結果用notify實時推送、 nuclei與xray都掃描結束後,等待下一次循環,這一切都是自動去執行
0x03 准备工作
先安裝這些工具,並設置好軟鏈接,能全局使用,這些工具安裝很簡單,不再闡述,github也有安裝教程Centos7+ 64 位配置4H 4G起【服務器一台】chaospy【資產偵查、資產下載】 https://github.com/PhotonBolt/chaospyunzip 【解壓】anew 【過濾重複】https://github.com/tomnomnom/anewnaabu【端口掃描】https://github.com/projectdiscovery/naabuhttpx 【存活檢測】https://github.com/projectdiscovery/httpxnuclei 【漏洞掃描】https://nuclei.projectdiscovery.io/Xray 【漏洞掃描】https://download.xray.cool/python 【微信通知】notify 【漏洞通知】 notify比較成熟的推送方案服務器推薦vultr,可以用我的推薦鏈接:https://www.vultr.com/?ref=9059107-8H
0x04 关于notify通知相关配置
notify安裝與配置:https://github.com/projectdiscovery/notify配置文件(沒有就創建這個文件):/root/.config/notify/provider-config.yaml
修改通知配置即可,比如我使用的通知是電報和郵件(配置任意一個即可)

測試效果
subfinder -d hackerone.com | notify -provider telegram
我這是設置是電報通知,執行結束後,如果能收到結果,那通知這塊就沒問題,可以下一步了

0x05 部署过程
請確保上面提到的工具都已安裝好,現在我們來構造一個sh腳本文件,這個腳本就把上面說的流程都做了一遍命名為: wadong.sh , 添加執行權限: chmod +xwadong.sh
wadong.sh腳本主要完成資產偵察資產收集、端口掃描,去重檢測,存活探測,漏洞掃描,結果通知的功能
腳本:
#!/bin/bash
# 使用chaospy,只下載有賞金資產數據
#python3 chaospy.py --download-hackerone
#python3 chaospy.py --download-rewards #下載所有賞金資產
#./chaospy.py --download-bugcrowd 下載BugCrowd 資產
#./chaospy.py --download-hackerone 下載Hackerone 資產
#./chaospy.py --download-intigriti 下載Intigriti 資產
#./chaospy.py --download-external 下載自託管資產
#./chaospy.py --download-swags 下載程序Swags 資產
#./chaospy.py --download-rewards 下載有獎勵的資產
#./chaospy.py --download-norewards 下載沒有獎勵的資產
#對下載的進行解壓,使用awk把結果與上次的做對比,檢測是否有新增
if ls | grep '.zip' /dev/null; then
unzip '*.zip' /dev/null
cat *.txt newdomains.md
rm -f *.txt
awk 'NR==FNR{lines[$0];next} !($0 in lines)' alltargets.txtls newdomains.md domains.txtls
rm -f newdomains.md
################################################################################## 發送新增資產手機通知
echo '資產偵察結束$(date +%F-%T)' | notify -silent -provider telegram
echo '找到新域$(wc -l domains.txtls) 個' | notify -silent -provider telegram
################################################################################## 更新nuclei漏洞掃描模板
nuclei -silent -update
nuclei -silent -ut
rm -f *.zip
else
echo '沒有找到新程序' | notify -silent -provider telegram
fi
if [ -s domains.txtls ];then
echo '開始使用naabu 對新增資產端口掃描' | notify -silent -provider telegram
fine_line=$(cat domains.txtls | wc -l )
num=1
K=10000
j=true
F=0
while $j
do
echo $fine_line
if [ $num -lt $fine_line ];then
m=$(($num+$K))
sed -n ''$num','$m'p' domains.txtls domaint.txtls
((num=num+$m))
naabu -stats -l domaint.txtls -p 80,443,8080,2053,2087,2096,8443,2083,2086,2095,8880,2052,2082,3443,8791,8887,8888,444,9443,2443,10000,10001,8082,8444,20000,8081,8445,8446,8447 -silent -o open-domain.txtls /dev/null | echo '端口掃描'
echo '端口掃描結束,開始使用httpx探測存活' | notify -silent -provider telegram
httpx -silent -stats -l open-domain.txtls -fl 0 -mc 200,302,403,404,204,303,400,401 -o newurls.txtls /dev/null
echo 'httpx共找到存活資產$(wc -l newurls.txtls) 個' | notify -silent -provider telegram
cat newurls.txtls new-active-$(date +%F-%T).txt #保存新增資產記錄
cat domaint.txtls alltargets.txtls
echo '已將存活資產存在加入到歷史緩存$(date +%F-%T)' | notify -silent -provider telegram
echo '開始使用nuclei 對新增資產進行漏洞掃描' | notify -silent -provider telegram
cat newurls.txtls | nuclei -rl 300 -bs 35 -c 30 -mhe 10 -ni -o res-all-vulnerability-results.txt -stats -silent -severity critical,medium,high,low | notify -silent -provider telegram
echo 'nuclei 漏洞掃描結束' | notify -silent -provider telegram
#使用xray掃描,記得配好webhook,不配就刪掉這項,保存成文件也可以
#echo '開始使用xray 對新增資產進行漏洞掃描' | notify -silent -provider telegram
#xray_linux_amd64 webscan --url-file newurls.txtls --webhook-output http://www.qq.com/webhook --html-output xray-new-$(date +%F-%T).html
#echo 'xray 漏洞掃描結束,xray漏洞報告請上服務器查看' | notify -silent -provider telegram
rm -f open-domain.txtls
rm -f domaint.txtls
rm -f newurls.txtls
else
echo 'ssss'
j=false
sed -n ''$num','$find_line'p' domains.txtls domaint.txtls
naabu -stats -l domaint.txtls -p 80,443,8080,2053,2087,2096,8443,2083,2086,2095,8880,2052,2082,3443,8791,8887,8888,444,9443,2443,10000,10001,8082,8444,20000,8081,8445,8446,8447 -silent -o open-domain.txtls /dev/null | echo '端口掃描'
echo '端口掃描結束,開始使用httpx探測存活' | notify -silent -provider telegram
httpx -silent -stats -l open-domain.txtls -fl 0 -mc 200,302,403,404,204,303,400,401 -o newurls.txtls /dev/null
echo 'httpx共找到存活資產$(wc -l newurls.txtls) 個' | notify -silent -provider telegram
cat newurls.txtls new-active-$(date +%F-%T).txt #保存新增資產記錄
cat domaint.txtls alltargets.txtls
echo '已將存活資產存在加入到歷史緩存$(date +%F-%T)' | notify -silent -provider telegram
echo '開始使用nuclei 對新增資產進行漏洞掃描' | notify -silent -provider telegram
cat newurls.txtls | nuclei -rl 300 -bs 35 -c 30 -mhe 10 -ni -o res-all-vulnerability-results.txt -stats -silent -severity critical,medium,high,low | notify -silent -provider telegram
echo 'nuclei 漏洞掃描結束' | notify -silent -provider telegram
#使用xray掃描,記得配好webhook,不配就刪掉這項,保存成文件也可以
#echo '開始使用xray 對新增資產進行漏洞掃描' | notify -silent -provider telegram
#xray_linux_amd64 webscan --url-file newurls.txtls --webhook-output http://www.qq.com/webhook --html-output xray-new-$(date +%F-%T).html
#echo 'xray 漏洞掃描結束,xray漏洞報告請上服務器查看' | notify -silent -provider telegram
rm -f open-domain.txtls
rm -f domaint.txtls
rm -f newurls.txtls
fi
done
rm -f domains.txtls
else
################################################################################## Send result to notify if no new domains found
echo '沒有新域$(date +%F-%T)' | notify -silent -provider telegram
fi
再構建一個first.sh文件,這個腳本只執行一次就行,後續也就用不到了, 主要用於第一次產生歷史緩存域,標記為舊資產
添加執行權限: chmod +x first.sh
#!/bin/bash
# 使用chaospy,只下載有賞金資產數據
./chaospy.py --download-new
./chaospy.py --download-rewards
#對下載的進行解壓,
if ls | grep '.zip' /dev/null; then
unzip '*.zip' /dev/null
rm -f alltargets.txtls
cat *.txt alltargets.txtls
rm -f *.txt
rm -f *.zip
echo '找到域$(wc -l alltargets.txtls) 個,已保存成緩存文件alltargets.txt'
fi
0x06 开始赏金自动化
在確保以上工具都安裝好的情況下1、執行first.sh 腳本,讓本地產生足夠多的緩存域名,標記為舊資產
./first.sh2、循環執行bbautomation.sh腳本,sleep 3600秒就是每小時一次,也就是腳本
xunhuan.sh:
#!/bin/bashwhile true; do ./wadong.sh;sleep 3600; done3.chaospy腳本已做了大概修改,優化延遲掃描時間和報錯#!/usr/bin/python3import requestsimport time,os,argparse#ColorsBlack='\033[30m'Red='\033[31m'Green='\033[32m'Yellow='\033[33m'Blue='\033[34m'Magenta='\033[35m'Cyan='\033[36m'LightGray='\033[37m'DarkGray='\033[90m'LightRed='\033[91m'LightGreen='\033[92m'LightYellow='\033[93m'LightBlue='\033[94m'LightMagenta='\033[95m'LightCyan='\033[96m'White='\033[97m'Default='\033[0m'banner=''' %s ________ ____/____//_ ____ _____ _____/__ \__ __///__ \/__ `/__ \/___//_///////___/////_///_/(__ ) ____//_//\____/_//_/\__,_/\____/____/_/\__,//____/%s Small Tool written based on chaos from projectdiscovery.io %s https://chaos.projectdiscovery.io/%s *Author - Moaaz (https://twitter.com/photonbo1t)* %s \n '''%(LightGreen,Yellow,DarkGray,DarkGray,Default)parser=argparse.ArgumentParser(description='ChaosPY Tool')parser.add_argument('-list',dest='list',help='List all programs',action='store_true')parser.add_argument('--list-bugcrowd',dest='list_bugcrowd',help='List BugCrowd programs',action='store_true')parser.add_argument('--list-hackerone',dest='list_hackerone',help='List Hackerone programs',action='store_true')parser.add_argument('--list-intigriti',dest='list_intigriti',help='List Intigriti programs',action='store_true')parser.add_argument('--list-external',dest='list_external',help='List Self Hosted programs',action='store_true')parser.add_argument('--list-swags',dest='list_swags',help='List programs Swags Offers',action='store_true')parser.add_argument('--list-rewards',dest='list_rewards',help='List programs with rewards',action='store_true')parser.add_argument('--list-norewards',dest='list_norewards',help='List programs with no rewards',action='store_true')parser.add_argument('--list-new',dest='list_new',help='List new programs',action='store_true')parser.add_argument('--list-updated',dest