Imagemagick升级脚本-OneinStack

5月3日,图像处理软件ImageMagick就被公布出一个严重的0day漏洞(CVE-2016-3714),攻击者通过此漏洞可执行任意命令,最终窃取重要信息取得服务器控制权。

详细信息参考:https://www.imagemagick.org/discourse-server/viewtopic.php?f=4&t=29588

该漏洞在6.9.3-10、7.0.1-1及以上版本得到修复,下面来看看OneinStack或《lnmp一键安装包》(最新下载OneinStack默认已经升级,无此漏洞)之前版本怎么来通过升级修复这个漏洞,如下(2016-05-31更新至6.9.4-5):

  1. cd /root/oneinstack   #进入oneinstack工具目录
  2. #cd /root/lnmp  #如果安装使用的是lnmp
  3. tmux   #进入tmux模式下,防止断网导致升级中断
  4. wget http://mirrors.linuxeye.com/scripts/update_ImageMagick.sh  #下载升级脚本
  5. chmod +x update_ImageMagick.sh   #赋权权限
  6. ./update_ImageMagick.sh   #升级,注:请勿sh或bash update_ImageMagick.sh方式执行脚本

如下图表示升级成功:

Imagemagick升级脚本-OneinStack

脚本内容如下(update_ImageMagick.sh):

  1. #!/bin/bash
  2. # Author:  yeho <lj2007331 AT gmail.com>
  3. # BLOG:  https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. #       http://oneinstack.com
  9. #       https://github.com/lj2007331/oneinstack
  10. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  11. clear
  12. printf 
  13. #######################################################################
  14. #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
  15. #                  upgrade ImageMagick for OneinStack                 #
  16. #       For more information please visit http://oneinstack.com       #
  17. #######################################################################
  18. . ./options.conf
  19. . ./include/color.sh
  20. . ./include/download.sh
  21. ImageMagick_version=6.9.4-1
  22. imagick_version=3.4.1
  23. if [ -e “/usr/local/imagemagick/bin/convert” ];then
  24.     OLD_ImageMagick_version=`/usr/local/imagemagick/bin/Magick-config –version | awk ‘{print $1}’`
  25. else
  26.     echo “${CWARNING}You do not have to install Imagemagick! ${CEND}”
  27.     exit 1
  28. fi
  29. Stop_ImageMagick() {
  30. if [ -e “$php_install_dir/etc/php.d/ext-imagick.ini” ];then
  31.     /bin/mv $php_install_dir/etc/php.d/ext-imagick.ini{,_bk}
  32. elif [ ! -e “$php_install_dir/etc/php.d/ext-imagick.ini” -a -n “`grep imagick.so $php_install_dir/etc/php.ini`” ];then
  33.     sed -i ‘s@extension.*imagick.so.*@;&@’ $php_install_dir/etc/php.ini
  34. fi
  35. [ -e “$apache_install_dir/conf/httpd.conf” ] && service httpd restart || service php-fpm restart
  36. /bin/mv /usr/local/imagemagick{,_`date +“%Y%m%d_%H%M%S”`}
  37. }
  38. Start_ImageMagick() {
  39. if [ -e “$php_install_dir/etc/php.d/ext-imagick.ini_bk” ];then
  40.     /bin/mv $php_install_dir/etc/php.d/ext-imagick.ini{_bk,}
  41. elif [ ! -e “$php_install_dir/etc/php.d/ext-imagick.ini” -a -n “`grep imagick.so $php_install_dir/etc/php.ini`” ];then
  42.     sed -i ‘s@;extension.*imagick.so.*@extension=imagick.so@’ /usr/local/php/etc/php.ini
  43. fi
  44. [ -e “$apache_install_dir/conf/httpd.conf” ] && service httpd restart || service php-fpm restart
  45. }
  46. Check_ImageMagick() {
  47. if [ -n “`/usr/local/imagemagick/bin/convert -version | grep “$ImageMagick_version“`” ];then
  48.     echo “You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_ImageMagick_version${CEND} to ${CWARNING}$ImageMagick_version${CEND}”
  49. else
  50.     echo “${CWARNING}Imagemagick upgrade failed! ${CEND}”
  51. fi
  52. }
  53. Install_ImageMagick() {
  54. cd $oneinstack_dir/src
  55. src_url=http://mirrors.linuxeye.com/oneinstack/src/ImageMagick-$ImageMagick_version.tar.gz && Download_src
  56. tar xzf ImageMagick-$ImageMagick_version.tar.gz
  57. cd ImageMagick-$ImageMagick_version
  58. ./configure –prefix=/usr/local/imagemagick –enable-shared –enable-static
  59. make && make install
  60. cd ..
  61. rm -rf ImageMagick-$ImageMagick_version
  62. cd ..
  63. }
  64. Install_php-imagick() {
  65. cd $oneinstack_dir/src
  66. if [ -e “$php_install_dir/bin/phpize” ];then
  67.     if [ “`$php_install_dir/bin/php -r ‘echo PHP_VERSION;’ | awk -F. ‘{print $1”.“$2}’`” == ‘5.3‘ ];then
  68.         src_url=http://mirrors.linuxeye.com/oneinstack/src/imagick-3.3.0.tgz && Download_src
  69.         tar xzf imagick-3.3.0.tgz
  70.         cd imagick-3.3.0
  71.     else
  72.         src_url=http://mirrors.linuxeye.com/oneinstack/src/imagick-$imagick_version.tgz && Download_src
  73.         tar xzf imagick-$imagick_version.tgz
  74.         cd imagick-$imagick_version
  75.     fi
  76.     make clean
  77.     export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
  78.     $php_install_dir/bin/phpize
  79.     ./configure –with-php-config=$php_install_dir/bin/php-config –with-imagick=/usr/local/imagemagick
  80.     make && make install
  81.     cd ..
  82.     rm -rf imagick-$imagick_version
  83. fi
  84. cd ..
  85. }
  86. Stop_ImageMagick
  87. Install_ImageMagick
  88. Install_php-imagick
  89. Start_ImageMagick
  90. Check_ImageMagick

Tue May 10 21:51:18 CST 2016


【AD】美国洛杉矶CN2 VPS/香港CN2 VPS/日本CN2 VPS推荐,延迟低、稳定性高、免费备份_搬瓦工vps

【AD】RackNerd 推出的 KVM VPS 特价优惠,在纽约、西雅图、圣何塞和阿什本每年仅需 12.88 美元!