器 PHP 后門/webshell 排查命令)
Linux 服務(wù)器 PHP 后門/webshell 排查常用命令適用場(chǎng)景入侵排查、網(wǎng)站后門查殺、CTF 靶場(chǎng)溯源、運(yùn)維日常巡檢前提絕大多數(shù)木馬特征eval、system、assert、exec、$_POST、$_GET、base64_decode、create_function等變形加密木馬無(wú)法靠命令檢出僅做明文后門篩查。一、前置通用規(guī)范排查優(yōu)先掃描網(wǎng)站根目錄不要無(wú)腦全局/掃描速度差距極大文件名帶空格、特殊符號(hào)統(tǒng)一用find -print0 xargs -0屏蔽報(bào)錯(cuò)末尾加2/dev/null消除大量 Permission deniedgrep -l只輸出可疑文件grep -n輸出具體惡意代碼行號(hào)。二、基礎(chǔ)全局明文后門篩查命令1. 經(jīng)典高危函數(shù)一鍵篩查eval、system、assert、exec# 標(biāo)準(zhǔn)版推薦find網(wǎng)站目錄-typef-name*.php-print0|xargs-0grep-lEeval\(\$_|system\(\$_|assert\(\$_|exec\(|shell_exec\(|passthru\(2/dev/null# 全局全盤掃描謹(jǐn)慎使用慢find/-typef-name*.php!-path/proc/*!-path/sys/*!-path/dev/*-print0|xargs-0grep-lEeval\(\$_|system\(\$_|assert\(\$_2/dev/null2. 排查一句話木馬經(jīng)典特征$_POST、$_GET、$_REQUESTfind/www/wwwroot-name*.php-print0|xargs-0grep-lE\$_POST\[|\$_GET\[|\$_REQUEST\[3. 排查Base64加密變形木馬find/www/wwwroot-name*.php-print0|xargs-0grep-lbase64_decode4. 排查回調(diào)、匿名函數(shù)后門 create_functionfind/www/wwwroot-name*.php-print0|xargs-0grep-lcreate_function5. 組合綜合篩查一次性查大部分常見(jiàn)明文后門find/www/wwwroot-typef-name*.php-print0|xargs-0grep-lEeval|system|exec|assert|passthru|shell_exec|base64_decode|gzdecode|urldecode|create_function三、精準(zhǔn)定位查看惡意代碼行號(hào)去掉-l加-n顯示文件行數(shù)方便快速編輯刪除木馬find/www/wwwroot-name*.php-print0|xargs-0grep-nEeval\(\$_|system\(\$_四、非常規(guī)木馬排查命令1. 排查圖片馬jpg/png 內(nèi)嵌PHP代碼find/www/wwwroot-iname*.jpg-o-iname*.png-o-iname*.gif-print0|xargs-0grep-l?php2. 排查隱藏后門文件名帶點(diǎn)、空白文件名find/www/wwwroot-name .php-o-name*.php.-o-name.php3. 排查短標(biāo)簽后門?find/www/wwwroot-name*.php-print0|xargs-0grep-l?五、時(shí)間維度排查入侵溯源黑客常用近期上傳后門1. 查找24小時(shí)內(nèi)新建/修改的PHP文件入侵最常用find/www/wwwroot-name*.php-mtime-1-mtime -11天內(nèi)修改-mtime -22天內(nèi)-ctime查看文件創(chuàng)建時(shí)間。2. 查找權(quán)限異常后門777高危權(quán)限木馬find/www/wwwroot-name*.php-perm777六、文件差異排查對(duì)比備份找出新增后門有網(wǎng)站備份時(shí)diff對(duì)比目錄差異diff-r網(wǎng)站備份目錄 現(xiàn)有網(wǎng)站目錄統(tǒng)計(jì)文件數(shù)量快速判斷是否新增大量陌生phpls-lR/www/wwwroot|grep.php|wc-l七、日志輔助排查定位木馬上傳來(lái)源Nginx/Apache 查找上傳POST訪問(wèn)記錄grep-ipost /www/wwwlogs/nginx.log查找webshell常見(jiàn)訪問(wèn)路徑grep-Eeval|shell|backdoor|phpspy/www/wwwlogs/nginx.log八、批量清理后門小命令確認(rèn)安全后使用批量刪除定位到的木馬先ls預(yù)覽再刪find/www/wwwroot-name*.php-print0|xargs-0grep-leval($_|xargsrm-f統(tǒng)一修正PHP文件安全權(quán)限find/www/wwwroot-name*.php-print0|xargs-0chmod644九、排查局限性與補(bǔ)充說(shuō)明無(wú)法檢出字符串拆分、多層加密、異或加密、動(dòng)態(tài)拼接、內(nèi)存馬、組件漏洞后門排查到可疑文件處理流程備份文件→查看修改時(shí)間→查看訪問(wèn)日志溯源→刪除后門→修復(fù)漏洞上傳漏洞、弱密碼、注入高效方案明文命令篩查 專業(yè)查殺工具河馬、D盾Linux版、clamav殺毒組合使用。十、最簡(jiǎn)日常巡檢一鍵命令find/www/wwwroot-typef-name*.php-print0|xargs-0grep-lEeval|system|exec|assert|base64_decode|create_function2/dev/null