乐易论坛-乐易网易语言培训教程火山PC视窗中文编程交流论坛

 找回密码
 立即注册

手机号登录

用手机号号登陆

微信登录

微信扫码,快速开始

QQ登录

用QQ账号登陆

办理VIP,定制软件,报名培训联系QQ[重磅]2024年实地培训高清培训目录火山PC版乐易模块使用教程
有了火山,易语言是否还有必要学习吗?易语言0基础入门课程火山PC视窗0基础入门课程
乐易论坛官方QQ群一览表易语言外挂0基础入门课程火山PC视窗火山HOOK入门课程
易语言误报处理课程QQ空间POST课程2022年火山PC易语言POST系列课程
Android逆向Jeb动态调试0基础课程QQ邮箱网页POST课程WeChat个微Hook实战课程
百日Js加密分析实战课程(无密下载)QQ群POST课程h5游戏WebSocket逆向视频
JavaScript加密特训课程易语言汇编快速入门课程破解实战系列课程
手游模拟器脚本0基础课程易语言加密防破解0基础入门课程广告位招租联系QQ1615457736
查看: 15449|回复: 4

[PHP] php网站被挂木马后的修复方法总结

[复制链接]

[PHP] php网站被挂木马后的修复方法总结

[复制链接]
已绑定手机
失落的年轻人
等级头衔

等級:程序制作者

Rank: 6Rank: 6

积分成就
易币
贡献
主题
精华
金钱
积分
2863
注册时间
2015-2-21
最后登录
1970-1-1

勋章墙

2016-12-10 19:34:15 | 显示全部楼层 |阅读模式

据统计90%查看本帖的人,都已经注册本站了哦

您需要 登录 才可以下载或查看,没有账号?立即注册

×

本文实例总结了php网站被挂木马后的修复方法。分享给大家供大家参考。具体方法如下:


在linux中我们可以使用命令来搜查木马文件,到代码安装目录执行下面命令
复制代码 代码如下:
find ./ -iname "*.php" | xargs grep -H -n "eval(base64_decode"

搜出来接近100条结果,这个结果列表很重要,木马都在里面,要一个一个文件打开验证是否是木马,如果是,马上删除掉
最后找到10个木马文件,存放在各种目录,都是php webshell,功能很齐全,用base64编码
如果你在windows中查找目录直接使用windows文件搜索就可以了,可以搜索eval或最近修改文件,然后如果是dedecms我们要查看最新dedecms漏洞呀然后修补。
下面给个php木马查找工具,直接放到你站点根目录

复制代码 代码如下:
<?php
/**************PHP Web木马扫描器************************/
/* [+] 作者: alibaba */
/* [+] MSN: weeming21@hotmail.com */
/* [+] 首发: t00ls.net , 转载请注明t00ls */
/* [+] 版本: v1.0 */
/* [+] 功能: web版php木马扫描工具*/
/* [+] 注意: 扫描出来的文件并不一定就是后门, */
/* 请自行判断、审核、对比原文件。*/
/* 如果你不确定扫出来的文件是否为后门,*/
/* 欢迎你把该文件发给我进行分析。*/
/*******************************************************/
ob_start();
set_time_limit(0);
$username = "t00ls"; //设置用户名
$password = "t00ls"; //设置密码
$md5 = md5(md5($username).md5($password));
$version = "PHP Web木马扫描器v1.0";

PHP Web 木马扫描器
$realpath = realpath('./');
$selfpath = $_SERVER['PHP_SELF'];
$selfpath = substr($selfpath, 0, strrpos($selfpath,'/'));
define('REALPATH', str_replace('//','/',str_replace('\','/',substr($realpath, 0, strlen($realpath) - strlen($selfpath)))));
define('MYFILE', basename(__FILE__));
define('MYPATH', str_replace('\', '/', dirname(__FILE__)).'/');
define('MYFULLPATH', str_replace('\', '/', (__FILE__)));
define('HOST', "http://".$_SERVER['HTTP_HOST']);
?>
<html>
<head>
<title><?php echo $version?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
body{margin:0px;}
body,td{font: 12px Arial,Tahoma;line-height: 16px;}
a {color: #00f;text-decoration:underline;}
a:hover{color: #f00;text-decoration:none;}
.alt1 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f1f1f1;padding:5px 10px 5px 5px;}
.alt2 td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#f9f9f9;padding:5px 10px 5px 5px;}
.focus td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#ffffaa;padding:5px 10px 5px 5px;}
.head td{border-top:1px solid #fff;border-bottom:1px solid #ddd;background:#e9e9e9;padding:5px 10px 5px 5px;font-weight:bold;}
.head td span{font-weight:normal;}
</style>
</head>
<body>
<?php
if(!(isset($_COOKIE['t00ls']) && $_COOKIE['t00ls'] == $md5) && !(isset($_post['username']) && isset($_POST['password']) && (md5(md5($_POST['username']).md5($_POST['password']))==$md5)))
{
echo '<form id="frmlogin" name="frmlogin" method="post" action="">用户名: <input type="text" name="username" id="username" /> 密码: <input type="password" name="password" id="password" /> <input type="submit" name="btnLogin" id="btnLogin" value="登陆" /></form>';
}
elseif(isset($_POST['username']) && isset($_POST['password']) && (md5(md5($_POST['username']).md5($_POST['password']))==$md5))
{
setcookie("t00ls", $md5, time()+60*60*24*365,"/");
echo "登陆成功!";
header( 'refresh: 1; url='.MYFILE.'?action=scan' );
exit();
}
else
{
setcookie("t00ls", $md5, time()+60*60*24*365,"/");
$setting = getSetting();
$action = isset($_GET['action'])?$_GET['action']:"";

if($action=="logout")
{
setcookie ("t00ls", "", time() - 3600);
Header("Location: ".MYFILE);
exit();
}
if($action=="download" && isset($_GET['file']) && trim($_GET['file'])!="")
{
$file = $_GET['file'];
ob_clean();
if (@file_exists($file)) {
header("Content-type: Application/octet-stream");
header("Content-Disposition: filename="".basename($file).""");

echo file_get_contents($file);
}
exit();
}
?>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr class="head">
<td><?php echo $_SERVER['SERVER_ADDR']?><span style="float: right; font-weight:bold;"><?php echo "<a href='http://www.t00ls.net/'>$version</a>"?></span></td>
</tr>
<tr class="alt1">
<td><span style="float: right;"><?=date("Y-m-d H:i:s",mktime())?></span>
<a href="?action=scan">扫描</a> |
<a href="?action=setting">设定</a> |
<a href="?action=logout">登出</a>
</td>
</tr>
</tbody></table>
<br>
<?php
if($action=="setting")
{
if(isset($_POST['btnsetting']))
{
$Ssetting = array();
$Ssetting['user']=isset($_POST['checkuser'])?$_POST['checkuser']:"php | php? | phtml";
$Ssetting['all']=isset($_POST['checkall'])&&$_POST['checkall']=="on"?1:0;
$Ssetting['hta']=isset($_POST['checkhta'])&&$_POST['checkhta']=="on"?1:0;
setcookie("t00ls_s", base64_encode(serialize($Ssetting)), time()+60*60*24*365,"/");
echo "设置完成!";
header( 'refresh: 1; url='.MYFILE.'?action=setting' );
exit();
}
?>
<form name="frmSetting" method="post" action="?action=setting">
<FIELDSET style="width:400px">
<LEGEND>扫描设定</LEGEND>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="60">文件后缀:</td>
<td width="300"><input type="text" name="checkuser" id="checkuser" style="width:300px;" value="<?php echo $setting['user']?>"></td>
</tr>
<tr>
<td><label for="checkall">所有文件</label></td>
<td><input type="checkbox" name="checkall" id="checkall" <?php if($setting['all']==1) echo "checked"?>></td>
</tr>
<tr>
<td><label for="checkhta">设置文件</label></td>
<td><input type="checkbox" name="checkhta" id="checkhta" <?php if($setting['hta']==1) echo "checked"?>></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="btnsetting" id="btnsetting" value="提交">
</td>
</tr>
</table>
</fieldset>
</form>
<?php
}
else
{
$dir = isset($_POST['path'])?$_POST['path']:MYPATH;
$dir = substr($dir,-1)!="/"?$dir."/":$dir;
?>
<form name="frmScan" method="post" action="">
<table width="100%%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="35" style="vertical-align:middle; padding-left:5px;">扫描路径:</td>
<td width="690">
<input type="text" name="path" id="path" style="width:600px" value="<?php echo $dir?>">
  <input type="submit" name="btnScan" id="btnScan" value="开始扫描"></td>
</tr>
</table(www.jb51.net)>
</form>
<?php
if(isset($_POST['btnScan']))
{
$start=mktime();
$is_user = array();
$is_ext = "";
$list = "";

if(trim($setting['user'])!="")
{
$is_user = explode("|",$setting['user']);
if(count($is_user)>0)
{
foreach($is_user as $key=>$value)
$is_user[$key]=trim(str_replace("?","(.)",$value));
$is_ext = "(.".implode("($|.))|(.",$is_user)."($|.))";
}
}
if($setting['hta']==1)
{
$is_hta=1;
$is_ext = strlen($is_ext)>0?$is_ext."|":$is_ext;

$is_ext.="(^.htaccess$)";
}
if($setting['all']==1 || (strlen($is_ext)==0 && $setting['hta']==0))
{
$is_ext="(.+)";
}

$php_code = getCode();
if(!is_readable($dir))
$dir = MYPATH;
$count=$scanned=0;
scan($dir,$is_ext);
$end=mktime();
$spent = ($end - $start);
?>
<div style="padding:10px; background-color:#ccc">扫描: <?php echo $scanned?> 文件| 发现: <?php echo $count?> 可疑文件| 耗时: <?php echo $spent?> 秒</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="head">
<td width="15" align="center">No.</td>
<td width="48%">文件</td>
<td width="12%">更新时间</td>
<td width="10%">原因</td>
<td width="20%">特征</td>
<td>动作</td>
</tr>
<?php echo $list?>
</table>
<?php
}
}
}
ob_flush();
?>
</body>
</html>
<?php
function scan($path = '.',$is_ext){
global $php_code,$count,$scanned,$list;
$ignore = array('.', '..' );
$replace=array(" ","n","r","t");
$dh = @opendir( $path );
while(false!==($file=readdir($dh))){
if( !in_array( $file, $ignore ) ){
if( is_dir( "$path$file" ) ){
scan("$path$file/",$is_ext);
} else {
$current = $path.$file;
if(MYFULLPATH==$current) continue;
if(!preg_match("/$is_ext/i",$file)) continue;
if(is_readable($current))
{
$scanned++;
$content=file_get_contents($current);
$content= str_replace($replace,"",$content);
foreach($php_code as $key => $value)
{
if(preg_match("/$value/i",$content))
{
$count++;
$j = $count % 2 + 1;
$filetime = date('Y-m-d H:i:s',filemtime($current));
$reason = explode("->",$key);
$url = str_replace(REALPATH,HOST,$current);
preg_match("/$value/i",$content,$arr);
$list.="
<tr class='alt$j'
);
}
?>

            希望大家基于php的网站安全建设有所帮助。



回复

使用道具 举报

已绑定手机
已实名认证
飘雪
等级头衔

等級:程序设计师

Rank: 7Rank: 7Rank: 7

积分成就
易币
贡献
主题
精华
金钱
积分
3669
注册时间
2016-4-6
最后登录
1970-1-1

勋章墙

2016-12-11 00:28:05 | 显示全部楼层
感谢感谢,谢谢楼主分享
回复

使用道具 举报

lwa1321
等级头衔

等級:程序开发员

Rank: 8Rank: 8

积分成就
易币
贡献
主题
精华
金钱
积分
5084
注册时间
2016-11-5
最后登录
1970-1-1

勋章墙

2016-12-12 12:08:06 | 显示全部楼层
太棒了,感谢楼主,Mrak一下
回复

使用道具 举报

已绑定手机
Bill-ck
等级头衔

等級:编程起步

Rank: 5Rank: 5

积分成就
易币
贡献
主题
精华
金钱
积分
630
注册时间
2015-11-12
最后登录
1970-1-1

勋章墙

2016-12-12 15:54:59 | 显示全部楼层
666666666666666太棒了,感谢楼主,Mrak一下
回复

使用道具 举报

3059926098
等级头衔

等級:编程学徒

Rank: 3Rank: 3

积分成就
易币
贡献
主题
精华
金钱
积分
316
注册时间
2016-6-1
最后登录
1970-1-1

勋章墙

2017-11-1 18:12:31 | 显示全部楼层

太棒了,感谢楼主,Mrak一下
回复

使用道具 举报

如果懒得打字,请选择右侧内容快捷回复 提醒:以任何方式进行『恶意灌水』的行为,进行封号处理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

热点推荐上一条 /5 下一条

QQ|网站地图|手机版|小黑屋|乐易论坛-乐易网 | 湘ICP备19007035号

拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表乐易立场!

娄底市乐易网络科技有限公司声明:乐易原创培训课程版权均为我公司所有,未经许可,不得擅自翻录,盗版,破解本站课课程,我们将保留法律诉讼的权利

GMT+8, 2024-4-27 10:15 , Processed in 0.053809 second(s), 56 queries .

Powered by Discuz! X3.4

Copyright © Tencent Cloud.

快速回复 返回顶部 返回列表