Scapy is a Python library that does low-level packet manipulation. It’s also useful in playing with Amazon Dash Buttons. There are plenty of older instructions on getting it running on Mac OS X, but many of these don’t work on Mac OS X 10.11/10.12 where System Integrity Protection (SIP) is enabled by default. Here’s a script to do it for you:
#!/bin/bash echo "We need root permissions to install libdnet" sudo echo "OK" curl -O "https://bootstrap.pypa.io/get-pip.py" python get-pip.py --user PIP_BIN=$HOME/Library/Python/2.7/bin/pip $PIP_BIN install scapy --user $PIP_BIN install pypcap --user curl -L https://github.com/dugsong/libdnet/archive/libdnet-1.12.zip -o libdnet-1.12.zip unzip libdnet-1.12.zip cd libdnet-libdnet-1.12 ./configure make sudo make install cd python python setup.py install --user
A few notes:
- You will need the Command Line Tools package to compile libdnet. If you don’t have them installed already, you should be automagically prompted by the OS.
- We use the
--userflag to install locally in our home directory, avoiding problems with SIP (which protects system files, including parts of the shared Python directories)
- We use pypcap rather than pcapy, because the latter does not work
- The latest version of libdnet is 1.12 (contrary to the SourceForge page, which indicates that the latest is 1.11), and can be found on GitHub