Security, Programming, Pentesting
by {"login"=>"averagesecurityguy", "email"=>"stephen@averagesecurityguy.info", "display_name"=>"averagesecurityguy", "first_name"=>"", "last_name"=>""}
Update: I wrote this article before I realized that ubuntu and therefore BT5 comes with a script called update-alternatives. The update-alternatives script allows you to switch between different versions of java and ruby. If you are having trouble running a ruby script in BT5 try running update-alternative --config ruby
and changing the ruby version. If that doesn't work then keep reading the rest of this article for other possible fixes.
I was playing around with BT5 today and noticed that it uses Ruby 1.9.2 as the default Ruby interpreter. Ruby 1.8 is installed as well if you would rather use it. To run a Ruby script using 1.8 just run ruby1.8 script.rb
. If you come across a Ruby-based tool in BT5 that does not work then try running it using ruby1.8 before troubleshooting. If you want to run the script under Ruby 1.9.2 you may run into some problems I have listed a few below and how to fix them.
Often times when running a Ruby script that requires gems Ruby has to be told to load 'rubygems' before it loads installed gems. This can be done either by adding require 'rubygems'
to each Ruby script before require
ing other gems or by setting the environment variable RUBYOPT. To set the environment variable add the line export RUBYOPT="rubygems"
to your .bashrc file in your home directory and then run source .bashrc
For whatever reason Ruby cannot find the gems loaded for Ruby 1.9.2. To fix this set the environment variable GEM_HOME by adding the line export GEM_HOME=/var/lib/gems/1.9.2
to the .bashrc file in your home directory. You will need to run source .bashrc
for the changes to take effect.
For security reasons Ruby 1.9.2 does not search the current directory when looking for require
d files. There are three options for dealing with this:
require 'cewl_lib'
to require './cewl_lib'
, which defeats the purpose of not searching the current directory.require 'cewl_lib'
to require_relative 'lib/cewl_lib'
. This is not backward compatible with Ruby 1.8.7require 'cewl_lib'
to require File.expand_path(File.join(File.dirname(__FILE__), 'cewl_lib'))
, which is backward compatible with Ruby 1.8.7. This is the method I used.