Install one_gadget on Ubuntu 16.04 in 2023

Page content

Ruby with version >= 2.4 is required to install one_gadget while the default ruby package on Ubuntu 16.04 is not satisfied, as shown below. If you wanna learn heap-related things on Ubuntu 16.04 to omit the additional mechanism like tcache, this post provides you the method to update ruby on Ubuntu 16.04 and install one_gadget.

ERROR:  Error installing one_gadget:
        bindata requires Ruby version >= 2.4.0.

In fact, the author of one_gadget provided suggestions, see https://github.com/david942j/one_gadget/issues/167. We further follow the method provided by https://askubuntu.com/questions/1175693/how-to-upgrade-ruby-to-version-2-4-4-on-ubuntu-16-04-for-wpscan, which leverages Brightbox PPA to install newer version of Ruby on Ubuntu 16.04.

Step 1. Adding the respository and install newer ruby

# https://www.brightbox.com/docs/ruby/ubuntu/#installation
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:brightbox/ruby-ng
sudo apt-get update

# install ruby2.4
sudo apt-get install ruby2.4

(Optional) Step 2. Install the ruby-switch

# you can use this to switch different versions of ruby
sudo apt-get install ruby-switch

# list alternative ruby versions
ruby-switch --list
# set specific version
sudo ruby-switch --set ruby2.4

Now check your ruby version by ruby -v, it should be ruby2.4. Next, run the following to install one_gadget:

sudo apt-get install gem
sudo gem install one_gadget

Done. Now you can use one_gadget.