1、背景
最近參加了一次攻防演練,因為準備不夠充分導致結果差強人意,事實證明,沒有一個清晰的思路在這個拼手速的時代是干不過人家的,事后重新梳理總結一下。
其實也沒什么新東西,總體大概就是盡可能全面的搜集資產,然后全方位掃描,最后搭配手工擴大戰果。
2、收集資產
根據IP收集url
使用棱洞魔改版:https://github.com/lemonlove7/EHole_magic

.\ehole.exe fofaext -l ip.txt
ip.txt的話格式最好是xxx.xxx.xxx.xxx:xxx afrog會自動識別掃描
61.*.*.*:909061.*.*.*:338961.*.*.*:5361.*.*.*:900061.*.*.*:754761.*.*.*:143361.*.*.*:200061.*.*.*:829161.*.*.*:55461.*.*.*:9090
goby全端口掃描

測繪平臺收集url
https://hunter.qianxin.com/
https://fofa.info/
https://quake.#/
多語法搜索
不同的語法進行資產搜集,搜集的資產會更全面
以 fofa 為例
domain="xxxx.com" host="xxxx.com" header="xxxx.com" cert="xxxx.com"
其他手段
google語法
查找文本內容:site:*.edu.cn intext: vpn | 用戶名 | 密碼 | 帳號 | 默認密碼查找后臺地址:site:域名 inurl:login|admin|manage|member|admin_login|login_admin|system|login|user|main|cms查找可注入點:site:域名 inurl:aspx|jsp|php|asp查找上傳漏洞:site:域名 inurl:file|load|editor|Files找eweb編輯器:site:域名 inurl:ewebeditor|editor|uploadfile|eweb|edit存在的數據庫:site:域名 filetype:mdb|asp|#查看腳本類型:site:域名 filetype:asp/aspx/php/jsp迂回策略入侵:inurl:cms/data/templates/images/index/

各種敏感數據收集:
filetyle:xls inurl:gov username passwordinurl:phpmyadmin/main.php intitle:phpmyadminfiletype:inc inurl:config.inc hostfiletype:sql cdb_members inurl:forumdatafiletype:txt inurl:"新建文本文檔.txt"密碼inurl:phpinfo.php intitle:"phpinfo()""PHP Version"+"Server API"filetype:log inurl:log mdb

github
*.edu.cn password
3、漏洞掃描
awvs
這里我用的是docker,直接運行下邊的命令
docker run -it -d -p 13443:3443 xiaomimi8/docker-awvs-14.7.220401065

這里還要搭配另一個工具來批量添加任務https://github.com/test502git/awvs14-scan
使用前先在config.ini修把url和apikey修改為自己的

nuclei
工具下載地址https://github.com/projectdiscovery/nuclei
nuclei -list urls.txt
xray
下載高級版https://www.iculture.cc/
被動代理就不說了,這里說下另一種批量主動的方法
# coding:utf-8
import reimport osimport sysimport time
def scan(): file = open("urls.txt") urls = [] for line in file: lines = line.strip('\n') urls.append(lines) file.close() for url in urls: name = url.replace('https://', '').replace('http://', '').replace('/', '').replace('\n', '').replace(':', '-') try: os.mkdir('scan_report') except: pass cmd = 'xray.exe webscan --basic-crawler {0}/ --html-output {1}.html'.format(url.replace('\n', ''), './scan_report/' + name) os.system(cmd.replace('\n', '')) time.sleep(0.2)
if __name__ == "__main__": scan()
代碼保存為urlscan.py
很簡單,url放urls.txt里,urls.txt放xray.exe根目錄
接下來還要稍微改下xray配置config.yaml
把過濾gov什么的刪了或者注釋掉
python urlscan.py

結束后會自動生成scan_report目錄,結果都保存在里面
afrog
下載地址https://github.com/zan8in/afrog
常用方法,只要中危及以上的漏洞
.\afrog.exe -T url.txt -S medium, high, critical

api掃描
urlfind
工具下載地址https://github.com/pingc0y/URLFinder
項目中有詳細的使用說明,這里寫下我比較常用的
.\URLFinder-windows-amd64.exe -s 200 -m 3 -u http://124.71.137.81:8081 -o .

Packer-Fuzzer
工具地址https://github.com/rtcatc/Packer-Fuzzer

4、手工測試
web邏輯漏洞
任意用戶注冊可爆破用戶名爆破用戶名,密碼用戶名注入萬能密碼用戶名Xss修改返回包信息,登入他人賬戶修改cookie中的參數,如user,adminid等HTML源碼、JS等查看信息搜集后臺登錄參數修改為注冊參數/reg、/register、/sign等密碼重置1.重置一個賬戶,不發送驗證碼,設置驗證碼為空發送請求。2.發送驗證碼,查看相應包3.驗證碼生存期的爆破4.修改相應包為成功的相應包5.手工直接跳轉到校驗成功的界面6.兩個賬戶,重置別人密碼時,替換驗證碼為自己正確的驗證碼7.重置別人密碼時,替換為自己的手機號8.重置自己的成功時,同意瀏覽器重置別人的,不發驗證碼9.替換用戶名,ID,cookie,token參數等驗證身份的參數10.通過越權修改他人的找回信息如手機/郵箱來重置
RCE漏洞
1.url參數,不僅僅可能存在ssrf漏洞,也有很大概率存在命令執行,可能調用系統命令如curl
示例:
index.php?id=2;}phpinfo();/*http://www.xxx.com/cmd.php?cmd=whoamihttp://xxx.cn/AdminPage/conf/runCmd?cmd=id
2.變量/提交的數據
常見在post包中exec、shell、path等參數
測試payload:
& 不管前后命令是否執行成功都會執行前后命令&& 具有短路效果。前面的命令執行成功才能執行后面的命令| 管道符, 上一條命令的輸出,作為下一條命令參數(輸入) 。在拼接時,無論左邊是false還是true,右邊都會執行|| 具有短路效果。 前面的命令執行不成功才能執行后面的命令
各種框架、cms通用nday
https://github.com/MzzdToT/HAC_Bored_Writing
5、橫向思路
fscan工具 https://github.com/shadow1ng/fscan/releases/tag/1.8.2
各數據庫弱口令掃描
手工測試
通過命令行快速收集服務器網絡拓撲、密碼等重要文件。
dir /a /s /b "D:\*.txt"dir /a /s /b "D:\*pass*"dir /a /s /b "D:\*login* dir /a /s /b "D:\*user* dir /a /s /b D:\\password.txt dir /a /s /b "D:\*.conf" "D:\*.ini" "D:\*.inc" "D:\*.config"dir /a /s /b "C:\*.txt" "C:\*.xls*" "C:\*.xlsx*" "C:\*.docx" | findstr "拓撲"/C 參數來指定要查找的字符串 但是有雙引號的話加不加/C感覺區別不大dir /a /s /b "C:\*.conf" "C:\*.ini*" "C:\*.inc*" "C:\*.config" | findstr /C:"運維"dir /a /s /b "D:\*.txt" "D:\*.xls*" "D:\*.xlsx*" "D:\*.docx" | findstr /C:"密碼"
部分命令執行結果


編寫成一鍵式bat
@echo off set "drive=D:"dir /a /s /b "%drive%\*.txt" >>result.txtdir /a /s /b "%drive%\*pass*" >>result.txtdir /a /s /b "%drive%\*login* >>result.txtdir /a /s /b "%drive%\*user* >>result.txtdir /a /s /b "%drive%\password.txt" >>result.txtdir /a /s /b "%drive%\*.conf" "%drive%\*.ini" "%drive%\*.inc" "%drive%\*.config" >>result.txtdir /a /s /b "%drive%\*.txt" "%drive%\*.xls*" "%drive%\*.xlsx*" "%drive%\*.docx" | findstr "拓撲" >>result.txtdir /a /s /b "%drive%\*.conf" "%drive%\*.ini*" "%drive%\*.inc*" "%drive%\*.config" | findstr /C:"運維" >>result.txtdir /a /s /b "%drive%\*.txt" "%drive%\*.xls*" "%drive%\*.xlsx*" "%drive%\*.docx" | findstr /C:"密碼" >>result.txtecho "find success"
保存為23.bat直接運行即可,最后在result.txt中查看運行結果
嘶吼專業版
FreeBuf
安全牛
上官雨寶
一顆小胡椒
一顆小胡椒
一顆小胡椒
RacentYY
007bug
上官雨寶