写入一句话木马:
echo '<?php eval($_POST[1]); ?>' > /www/wwwroot/demo/mu.php
//用于测试
查看关键字:
grep -r "function(p,a,c,k,e,d)" --include=*.{html,php} /www/wwwroot
查看一句话木马:
find /www/wwwroot -type f -name "*.php" |xargs grep "eval(" > grep.txt
find /www/wwwroot -type f -name "*.php" | xargs grep "eval(" |more
精准查找一句话木马:
grep -r --include=*.php '[^a-z]eval($_POST' /www/wwwroot > grep.txt
grep -r --include=*.php 'file_put_contents(.*$_POST.?);' /www/wwwroot > grep.txt
经测试查不出来马:
find /www/wwwroot -name "*.php" -type f -print0 | xargs -0 egrep "(phpspy|c99sh|milw0rm|eval\(gzuncompress\(base64_decoolcode|eval\(base64_decoolcode|spider_bc|gzinflate)" | awk -F: '{print $1}' | sort | uniq
find /www/wwwroot/ -type f -atime -1
最近一天被访问的文件
find /www/wwwroot/ -name dedesql.class.php -exec ls -l {} \;
搜索文件并显示权限大小等。
网站安全设置:
将php文件设置为读
find /www/wwwroot/ -type f -name *.php -exec chmod 444 {} \;
将目录设置为读和执行
find /www/wwwroot/ -type d -exec chmod 555 {} \;
注意:此设置开启后网站后台不能添加和删除文章,因为目录没有写入权限。但已经存在的webshell可以修改html文件内容,也能提升自身权限到777,更改所有文件和子目录权限到777,通过改变权限后可以删除文件和目录,但不能在主目录创建文件和目录,因为主目录是555,所以只能预防,必须确保网站内没有webshell 才可以临时开启。
完美源码 » Linux查找webshell