Pwntools is a CTF framework and vulnerability exploitation development library, developed in Python and designed by Rapid, designed to allow users to write exploits easily and quickly.

Most of the Mac OS installation tutorials on the web are based on PIP installations, which are fruitless. Github also has no installation guide, and no new solution has been documented since 2016. The Apple Store offered support for the PWnTools package at Homebrew in 2017, offering the following solution.

  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.

I tried to install the above solution, but failed, probably because the Mac OS version was too low. I also tried to install Python PIP and BREW, but failed. I tried to compile the source code by myself, but failed. It turned out that Capstone was missing, and the final solution was found on StackOverflow.

Capstone is a lightweight, multi-platform, multi-architecture supported disassembly framework. Support includes ARM, ARM64, MIPS and x86/ X64 platforms.

The final solution is as follows:

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
    Copy the code
  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"
Copy the code

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
Copy the code

reference

  • Installing pwntools on macOS
  • Capstone_Makefile
  • Apple_Store_pwntools