Mac OSX(Mac OS10.11) 安裝 pwntools 失敗的最新解決方案

pwntools是一個 CTF 框架和漏洞利用開發庫,用 Python 開發,由 rapid 設計,旨在讓使用者簡單快速的編寫 exploit。

網上針對 Mac OS 的安裝教程大多都是基於 pip 安裝的方式,無果,官方 Github 也沒有相關的安裝指南,文檔於2016年就未再給出新的解決方案。Apple Store 在 2017 年在 Homebrew 提供了對 pwntools 的軟件包的支持,給出瞭如下的解決方案。

  1. Press Command+Space and type Terminal and press enter/return key.
  2. Run in Terminal app:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
    and press enter/return key.
    If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
  3. Run:
    brew install pwntools

Done! You can now use pwntools.

針對上述解決方案,我嘗試着進行了安裝,未果,原因可能是因爲 Mac OS 版本太低的問題,也通過 Python 的pip 安裝,brew 安裝的方式去嘗試,都是失敗,自己嘗試編譯源代碼還是失敗,最後查了一下資料,原來是缺少 Capstone,最終的解決方案在 stackoverflow 上找到了。

Capstone 是一個輕量級的多平臺多架構支持的反彙編框架。支持包括 ARM,ARM64,MIPS 和 x86/x64 平臺。

最終的解決方案如下:

capstone==3.0.5 still tries to build for both i386 and x86_64, this is already fixed on master and will be released with the next version. Looking at the Makefile, there are two possibilities:

  1. Turn off MACOS_UNIVERSAL

    $ MACOS_UNIVERSAL=no pip install capstone
  2. Install the development version from current master branch, with LIBARCHS already adapted for Mojave:

$ pip install "git+https://github.com/aquynh/capstone.git#egg=capstone&subdirectory=bindings/python"

Make sure you use quotes in the last command or escape the ampersand (&), otherwise bash will cut the command and run in background instead.

Once capstone is installed, you will have to deal with unicorn in the same manner and finally should be able to install pwntools. I didn't test it anymore, but the one-liner for the installation will be

$ MACOS_UNIVERSAL=no pip install pwntools

參考文獻

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章