_______ __ __ _______
| ___ || |_| || |
| | | || || ___|
| |___| || || |___ Webshell finder,
| ___|| || ___| kiddies hunter,
| | | ||_|| || | website cleaner.
|___| |_| |_||___|
Detect potentially malicious PHP files.
PHP-malware-finder 盡最大努力檢測混淆/狡猾的程式碼以及使用惡意軟體/webshell 中經常使用的 PHP 函數的檔案。
也偵測到以下編碼器/混淆器/webshell 清單:
當然,繞過 PMF 是微不足道的,但它的目標是抓住小孩子和白痴,而不是有大腦的人。如果您報告了針對 PMF 的愚蠢定制繞過,您可能屬於一個(或兩個)類別,並且應該重新閱讀先前的聲明。
檢測是透過爬行檔案系統並根據一組 YARA 規則測試檔案來執行的。是的,就是這麼簡單!
PMF 沒有使用基於雜湊的方法,而是盡可能嘗試使用語義模式來檢測諸如「 $_GET
變數被解碼兩次、解壓縮,然後傳遞給某些危險函數(如system
)」之類的情況。
git clone https://github.com/jvoisin/php-malware-finder.git
cd php-malware-finder && make
或用go install github.com/jvoisin/php-malware-finder
取代最後 2 個步驟,這將直接在${GOROOT}/bin
資料夾中編譯並安裝 PMF。
$ ./php-malware-finder -h
Usage:
php-malware-finder [OPTIONS] [Target]
Application Options:
-r, --rules-dir= Alternative rules location (default: embedded rules)
-a, --show-all Display all matched rules
-f, --fast Enable YARA's fast mode
-R, --rate-limit= Max. filesystem ops per second, 0 for no limit (default: 0)
-v, --verbose Verbose mode
-w, --workers= Number of workers to spawn for scanning (default: 32)
-L, --long-lines Check long lines
-c, --exclude-common Do not scan files with common extensions
-i, --exclude-imgs Do not scan image files
-x, --exclude-ext= Additional file extensions to exclude
-u, --update Update rules
-V, --version Show version number and exit
Help Options:
-h, --help Show this help message
或者如果您喜歡使用yara
:
$ yara -r ./data/php.yar /var/www
請記住,您應該至少使用 YARA 3.4,因為我們使用雜湊值作為白名單系統和貪婪的正規表示式。請注意,如果您打算從原始程式碼建置 yara,則必須在系統上安裝 libssl-dev 才能支援哈希。
哦,順便說一句,您可以使用make tests
來運行綜合測試套件。
如果您想避免安裝 Go 和 libyara,您也可以使用我們的 docker 映像,只需將要掃描的資料夾掛載到容器的/data
目錄:
$ docker run --rm -v /folder/to/scan:/data ghcr.io/jvoisin/php-malware-finder
檢查whitelist.yar 檔案。如果您比較懶,可以使用generate_whitelist.py 腳本為整個資料夾產生白名單。
因為:
PHP-malware-finder 根據 GNU Lesser General Public License v3 授權。
令人驚嘆的YARA 專案是根據 Apache v2.0 授權的授權。
補丁、白名單或樣本當然是非常受歡迎的。