How to install Bettercap on Linux Mint or Ubuntu

BetterCAP is a powerful, flexible and portable tool created to perform various types of MITM attacks against a network, manipulate HTTP, HTTPS and TCP traffic in realtime, sniff for credentials and much more.

If during installation process you get the error message, this guide will help you.

Error message while installation on Linux Mint or Ubuntu:

Building native extensions.  This could take a while…
ERROR:  Error installing bettercap:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/pcaprub-0.12.4/ext/pcaprub_c
/usr/bin/ruby2.3 -r ./siteconf20171221-16257-1jfrt8h.rb extconf.rb

[*] Running checks for pcaprub_c code…
platform is x86_64-linux-gnu
checking for ruby/thread.h… *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)2.3
    --with-pcap-dir
    --without-pcap-dir
    --with-pcap-include
    --without-pcap-include=${pcap-dir}/include
    --with-pcap-lib
    --without-pcap-lib=${pcap-dir}/lib
/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/lib/ruby/2.3.0/mkmf.rb:587:in `try_cpp'
    from /usr/lib/ruby/2.3.0/mkmf.rb:1091:in `block in have_header'
    from /usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
    from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
    from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
    from /usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
    from /usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
    from /usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
    from /usr/lib/ruby/2.3.0/mkmf.rb:1090:in `have_header'
    from extconf.rb:74:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pcaprub-0.12.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/pcaprub-0.12.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/pcaprub-0.12.4/gem_make.out

All Ruby dependencies will be automatically installed through the GEM system, however some of the GEMS need native libraries in order to compile:

sudo apt install build-essential ruby-dev libpcap-dev net-tools
sudo apt install ruby

To install Stable Release of bettercap type:

gem install bettercap

To update to a newer release:

gem update bettercap

The following part is outdated, keep in touch for updates!

Instead of the stable release, you can also clone the source code from the github repository, this will give you all the latest and experimental features, but remember that you're using a potentially unstable release:

sudo apt install git
git clone https://github.com/evilsocket/bettercap
cd bettercap
bundle install
gem build bettercap.gemspec
sudo gem install bettercap*.gem

To check out Bettercap options type:

sudo bettercap --help

Or just launch your first sniffing:

sudo sudo bettercap -X

Recommended for you:

Leave a Reply

Your email address will not be published.

Please consider supporting this blog

Love the stuff I create? Please consider donating to help things rolling faster! miloserdov.org/?p=1460