0

鉴于最近 bash - Shellshock 的错误,我想在我的 Mac OS X Snow Leopard (10.6.8) 中更新我的 Bash(和 Sh)程序。我故意使用 10.6.8,所以我现在不想更新到更新版本的 OS X。

我已阅读此问答 -如何在 Mac OSX Mountain Lion 中升级 Bash 并设置正确的路径? 但它对我不起作用,因为我没有安装 [home?]brew(或 Xcode,或任何编译器等)。我刚刚开始在 Max OS X 平台上进行编程。

顺便说一句,当我在终端中键入 brew update 时,我得到以下输出:

[489]$ brew update
-bash: brew: command not found

那么,我需要执行哪些步骤(从头开始)才能为 OS X 10.6.8安装固定版本的bash ?
是吗:

  1. 安装 XCode 3.2.6(我现在正在下载 4.1 GB 的安装文件)
  2. 安装 Homebrew(如何?)
  3. 按照如何在 Mac OSX Mountain Lion 中升级 Bash 中的步骤并将其设置为正确的路径??

或者,由于我使用的是 OS X 10.6.8,我是否需要从某处下载 Bash 代码并使用 XCode 3.2.6(或 4.2,如果我付费)并手动替换 /bin/bash 和 /bin/ .sh 文件?

就像我说的,我是 Mac 上的新手,但我确实有 [有点过时的] 编程经验。

谢谢。

4

4 回答 4

2

您也可以在全终端样式中执行此操作(给出 Lion 更新包):

# pkgutil --expand ~/BashUpdateLion.pkg ~/BashUpdate
# vi ~/BashUpdate/Distribution

编辑InstallationCheckVolumeCheck函数,如下所示:

function InstallationCheck(prefix) {
     return true;
}
function VolumeCheck(prefix) {
     return true;
}

最后再次将其扁平化为可安装的包

# pkgutil --flatten ~/BashUpdate ~/Desktop/BashUpdateModified.pkg
于 2014-11-07T13:06:37.467 回答
2

Homebrew 是一个适用于 Mac 的包管理系统。很多人用它来管理 mysql、python 和(你可能已经猜到了)bash。Homebrew 所做的只是简单地安装这些包并让它们对用户可用。虽然有些人确实将它用于 bash,但使用 Homebrew 更新 bash 并不能保护他们的整个系统免受 shellshock(我的团队今天测试并确定)。

我建议您为您的 OS X 版本下载 XCode,下载 xcode 命令行实用程序(通过转到首选项 -> 下载 -> 命令行实用程序),然后运行我编写的这个脚本。需要明确的是,此脚本只是遵循此处概述的相同步骤,我只是让开发团队更容易更新。

您可以将此代码复制到可执行的 bash 脚本中并使用 ./bash-fixer.sh 运行它

#!/bin/bash
# In all good conscience, I can not guarantee anything in this script. 
# I've tested it to the best of my ability, but please use at your own risk

    if [ "$EUID" -eq 0 ]; then
      echo "DO NOT RUN AS SUDO! Running as sudo will break the world and will make your computer very unhappy."
      echo "There are commands later that are appropriately sudo'd."
      exit 1
    fi

    xcode-select --version

    if [[ $? != 0 ]] ; then
      echo "You need to install the xcode stuff that makes magic. Let's try that together"
      xcode-select --install || echo "Something broke. Try running \"xcode-select --install\" manually" && exit 1
    fi

    cd ~/
    test=$( env x='() { :;}; echo vulnerable' bash -c 'echo hello' | wc -l )

    if [[ ${test} -lt 2 ]]; then
      echo "Your version of bash is up to date"
    else
      mkdir -p bash-fix
      cd bash-fix
      curl https://opensource.apple.com/tarballs/bash/bash-92.tar.gz | tar zxf -
      cd bash-92/bash-3.2
      for i in $(seq -f "%03g" 52 54); do
        curl https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patches/bash32-$i | patch -p0
      done
      cd ..

      xcodebuild
      sudo cp /bin/bash /bin/bash.old
      sudo cp /bin/sh /bin/sh.old

      echo
      echo
      echo "Current version of bash is $(build/Release/bash --version | head -1 | awk -F "version " '{ print $2 }')"
      echo "Current version of sh is $(build/Release/sh --version | head -1 | awk -F "version " '{ print $2 }' )"

      if [[ $(build/Release/bash --version) =~ "3.2.54(1)-release" && $(build/Release/sh --version) =~ "3.2.54(1)-release" ]]; then
        echo "So far so good. Let's do some more checks, because we like dilligence"
      else
        echo "The bash and shell versions are not showing up as being the most recent. Something is afoot!"
        exit 1
      fi

      if [[ "${test}" < 2 ]]; then
        echo "Your version of bash is up to date"
        exit 0
      else
        echo "Something went horribly wrong!"
        exit 1
      fi

      echo "Awesome. All checks have passed. Cleaning up, and removing executable privaleges from the old bash and sh, just in case"
      sudo cp build/Release/bash /bin
      sudo cp build/Release/sh /bin
      sudo chmod a-x /bin/bash.old /bin/sh.old

    fi

让我知道你是怎么做到的,祝你好运!

于 2014-09-29T23:13:08.240 回答
1

http://hacksagogo.wordpress.com/2014/10/02/shell-shock-os-x-bash-update-installer-for-snow-leopard/

这是给那些疯狂的人、不合时宜的人、麻烦制造者、方孔中的圆钉的人。那些以不同方式看待事物的人......并且仍在运行 Snow Leopard。

1.- 在 PackageMaker 中打开 bashUpdateLion.pkg

2.- 转到项目/原始编辑模式并修改“Distribution”文件中的“InstallationCheck”和“VolumeCheck”功能,如下所示:

function InstallationCheck(prefix) {
    return true; }

function VolumeCheck(prefix) {
    return true; }

3.- 点击“构建”并为安装程序包选择一个名称。

这就是所有人。

于 2014-10-02T16:15:07.397 回答
1

请注意,Apple 于 2014 年 9 月 29 日发布了一组 Bash 的官方补丁版本。但是,支持只能追溯到 Lion,而不是 Snow Leopard。因此,您仍然无法在 Snow Leopard 上构建和安装您自己的补丁版本。

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

APPLE-SA-2014-09-29-1 OS X bash Update 1.0

OS X bash Update 1.0 is now available and addresses the following:

Bash
Available for: OS X Lion v10.7.5, OS X Lion Server v10.7.5, OS X Mountain Lion v10.8.5,
OS X Mavericks v10.9.5
Impact: In certain configurations, a remote attacker may be able to execute arbitrary
shell commands
Description: An issue existed in Bash's parsing of environment variables. This issue was
addressed through improved environment variable parsing by better detecting the end of
the function statement.
This update also incorporated the suggested CVE-2014-7169 change, which resets the
parser state.
In addition, this update added a new namespace for exported functions by creating a
function decorator to prevent unintended header passthrough to Bash. The names of all
environment variables that introduce function definitions are required to have a
prefix "__BASH_FUNC<" and suffix ">()" to prevent unintended function passing via
HTTP headers.
CVE-ID
CVE-2014-6271 : Stephane Chazelas
CVE-2014-7169 : Tavis Ormandy


OS X bash Update 1.0 may be obtained from the following webpages:
http://support.apple.com/kb/DL1767 – OS X Lion
http://support.apple.com/kb/DL1768 – OS X Mountain Lion
http://support.apple.com/kb/DL1769 – OS X Mavericks

To check that bash has been updated:

* Open Terminal
* Execute this command:
bash --version
* The version after applying this update will be:
OS X Mavericks:  GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin13)
OS X Mountain Lion:  GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin12)
OS X Lion:  GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin11)

Information will also be posted to the Apple Security Updates
web site: http://support.apple.com/kb/HT1222

This message is signed with Apple's Product Security PGP key,
and details are available at:
https://www.apple.com/support/security/pgp/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)

iQIcBAEBAgAGBQJUKdToAAoJEBcWfLTuOo7t4QEP/jrigiLB9GYO5JIdVHSFPUtx
MBr4hAe90LnyAIuhxny1PgAC8BZCPv4otm6DQBQSlX1PxLv8TWm8yp5IKCKJP6ZN
Smm+OqJLLWwcTOVv345bi5W9dp2nyZVLjWxx9MUfn4YLxKrBJ3fKyHWIycD0WpbD
4kfXW1G1JGTtyUX6Ge2lnhbOiYBPxJN2TSX4qEmix3KLmEwCwsZVgbjzW2ijNO0O
3AaUkFIICAECMCE+VZj/fGFQaEmYaPzpt3Tjy+X2NdXL8E0hnui4ymfU0DyR39Oz
8DQpP499hISeXucdAEH6b2mMO2pOmuDs6FWTSS6talT8ftLUpTmWqv2Rghto5ZXN
b8RZpOp9RUwurZPMq66BjbHfidEaLjMPCVcfAnjO6HwBaKGQ5kM5+ThPA5/DLSL6
gGPa4t3qM/JdQAzm8da9m62vjWZ1BXzIlLSmxpIq/5bDMpBNiA783f+uuDUjpQ/N
3SkKNn2U47VsCLYaoSSmL6FUBLsInnNvwkVyNsnMiEjMVn/BtV5ogAYAc8SSvGM7
Mlx9OBKYork0bNuViPK09j/8te74tt6t38B+0lb4mG5m1r2CyI96f2uVBpKkqDlj
K6INwsDZKqtg1Y+6xtnJb9F3ZNZarzSxZa2C8qKaVCH11vLaXVPJJCrYspWnV8yI
DrlKtF9VhcfUGTKJiRNX
=ZVVk
-----END PGP SIGNATURE——
于 2014-09-30T04:49:57.917 回答