diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..dcc99f24d --- /dev/null +++ b/Gemfile @@ -0,0 +1,38 @@ +# BeEF's Gemfile + +# +# Copyright 2011 Wade Alcorn wade@bindshell.net +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +gem "thin" +gem "ansi" +gem "term-ansicolor", :require => "term/ansicolor" +gem "dm-core" +gem "json" +gem "data_objects" +gem "dm-sqlite-adapter" +gem "parseconfig" +gem "erubis" +gem "dm-migrations" + +# for the console shell extension +gem "librex", "0.0.52" + +# for running unit tests +gem "msfrpc-client" +gem "curb" +gem "test-unit" + +source "http://rubygems.org" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..8ae3fc5c4 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,56 @@ +GEM + remote: http://rubygems.org/ + specs: + addressable (2.2.6) + ansi (1.4.1) + curb (0.7.16) + daemons (1.1.5) + data_objects (0.10.7) + addressable (~> 2.1) + dm-core (1.2.0) + addressable (~> 2.2.6) + dm-do-adapter (1.2.0) + data_objects (~> 0.10.6) + dm-core (~> 1.2.0) + dm-migrations (1.2.0) + dm-core (~> 1.2.0) + dm-sqlite-adapter (1.2.0) + dm-do-adapter (~> 1.2.0) + do_sqlite3 (~> 0.10.6) + do_sqlite3 (0.10.7) + data_objects (= 0.10.7) + erubis (2.7.0) + eventmachine (0.12.10) + json (1.6.4) + librex (0.0.52) + msfrpc-client (1.0.1) + librex (>= 0.0.32) + msgpack (>= 0.4.5) + msgpack (0.4.6) + parseconfig (0.5.2) + rack (1.4.0) + term-ansicolor (1.0.7) + test-unit (2.4.3) + thin (1.3.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + +PLATFORMS + ruby + +DEPENDENCIES + ansi + curb + data_objects + dm-core + dm-migrations + dm-sqlite-adapter + erubis + json + librex (= 0.0.52) + msfrpc-client + parseconfig + term-ansicolor + test-unit + thin diff --git a/README b/README index 36146b20c..8e4e587ec 100644 --- a/README +++ b/README @@ -22,12 +22,15 @@ Most of the contents of this file will eventually be added to /install.rb. In th 3. Prerequisites (Linux) 4. Prerequisites (Mac OSX) 5. Install instructions + 6. Run instructions 1. Prerequisites (platform independent) - BeEF requires ruby 1.9 + BeEF requires ruby 1.9 and the "bundler" gem. Bundler can be installed by: + + gem install bundler 2. Prerequisites (Windows) @@ -39,7 +42,7 @@ Most of the contents of this file will eventually be added to /install.rb. In th 3. Prerequisites (Linux) - !!! This must be done PRIOR to running the BeEF installer !!! + !!! This must be done PRIOR to running the bundle install command !!! On linux you will need to find the packages specific to your distribution for sqlite. An example for Ubuntu systems is: @@ -63,8 +66,12 @@ Most of the contents of this file will eventually be added to /install.rb. In th Navigate to the ruby source directory and run: - ruby install + bundle install - The installer verifies required gems, including any specific version dependencies + Bundler installs all the pre-requisite gems. - The installer offers a choice of auto-installing missing gems or provides the command so you can install gems manually + 6. Run instructions + + Simply run: + + ./beef diff --git a/core/loader.rb b/core/loader.rb index 8b472d9d9..7851468fd 100644 --- a/core/loader.rb +++ b/core/loader.rb @@ -15,21 +15,15 @@ # @note Include here all the gems we are using require 'rubygems' -require 'thin' -require 'dm-core' -require 'dm-migrations' -require 'json' -require 'ansi' -require 'optparse' +require 'bundler/setup' +Bundler.require(:default) require 'cgi' require 'yaml' require 'singleton' require 'ipaddr' require 'base64' require 'xmlrpc/client' -require 'erubis' require 'openssl' -require 'term/ansicolor' # @note Include the filters require 'core/filters' diff --git a/install b/install index 9d111a2d0..518f56516 100755 --- a/install +++ b/install @@ -16,8 +16,6 @@ # limitations under the License. # -require 'rubygems' - puts "\nWelcome to the BeEF installer!" if RUBY_VERSION < '1.9' @@ -32,112 +30,9 @@ end puts "\nPlease make sure you have installed SQLite before proceeding. For instructions on how to do this please see the README file" -# array of required gems - add to as needed (specify a version if needed eg "gem_name, =x.x.x") -$gems_required = ["thin", "ansi", "term-ansicolor", "dm-core", "json", "data_objects", "do_sqlite3", "sqlite3", "dm-sqlite-adapter", - "parseconfig", "erubis", "dm-migrations"] +puts "\nInstall Bundler: gem install bundler" -# array of missing non-version specific gems installed -$gems_missing = Array.new +puts "\nRun bundler in your BeEF folder: bundle install" -# array of missing version specific gems installed -$gems_missing_version = Array.new +puts "\nRun BeEF: ./beef" -# check all required gems (dependencies) are present -def dep_check - $gems_required.each do |current_gem| - begin - if current_gem.include? "," - tokens = current_gem.split(",") - gem tokens[0], tokens[1] - else - gem current_gem - end - rescue Gem::LoadError - if current_gem.include? "," - $gems_missing_version << current_gem - else - $gems_missing << current_gem - end - end - end - if $gems_missing.length == 0 && $gems_missing_version.length == 0 - return true - else - return false - end -end - -# display install options -def display_opts - puts "\n1) Install all required gems automatically\n" + "2) List required gems and exit so they can be installed manually\n" + "3) Exit installer\n\n" - option = gets - return option -end - -# generate install command for missing gems -def install_command - if (RUBY_PLATFORM =~ /linux/ or RUBY_PLATFORM =~ /darwin/) and Process.uid != 0 - cmd = "sudo gem install" - $gems_missing.each do |current_gem| - cmd = cmd + " #{current_gem}" - end - if $gems_missing_version.length != 0 - $gems_missing_version.each do |current_gem| - if cmd == "sudo gem install" - cmd = cmd + " #{current_gem}" - else - cmd = cmd + " && sudo gem install #{current_gem}" - end - end - end - else - cmd = "gem install" - $gems_missing.each do |current_gem| - cmd = cmd + " #{current_gem}" - end - if $gems_missing_version.length != 0 - $gems_missing_version.each do |current_gem| - if cmd == "gem install" - cmd = cmd + " #{current_gem}" - else - cmd = cmd + " & gem install #{current_gem}" - end - end - end - end - cmd = cmd.delete "," "'" - cmd = cmd.gsub("=", "-v") - cmd += " --no-rdoc --no-ri" - return cmd -end - -# install missing gems -def install_gems - puts install_command + "\n" - system(install_command) -end - -dep_met = dep_check() - -if dep_met == false - puts "\nSome gems required by BEeF are not present on your system please select an option to continue:" - option = display_opts - while option != "1\n" and option != "2\n" and option != "3\n" - puts "\nInvalid option entered, please select a valid option to continue:" - option = display_opts - end - if option == "1\n" - install_gems - elsif option == "2\n" - cmd = install_command - puts "\nPlease run the following command to update and install all required gems:\n\n" + cmd + "\n\n" - elsif option == "3\n" - puts "\nExiting...\n\n" - end -else - puts "\nAll required gems are present - please run './beef' to start using BEeF\n\n" - puts "\nThe Default username/password are beef/beef\n\n" - puts "\nAll feedback welcome - http://beef.googlecode.com/\n\n" -end - -puts "*** If you wish experiment with the shell interface ensure you also run:\nsudo gem install librex -v0.0.52 --no-rdoc --no-ri\n\n"