beefproject / beef

The Browser Exploitation Framework Project
https://beefproject.com
9.67k stars 2.14k forks source link

unable to load without optional packages (msf) #1694

Open blshkv opened 5 years ago

blshkv commented 5 years ago

Hello,

I have installed all required deps, however beef failed to load. First, it is "msgpack" (which is tricky), the second is xmlrpc, may be others. The error is the following:

bash$ beef 
bundler: failed to load command: /usr/lib/beef/beef (/usr/lib/beef/beef)
LoadError: cannot load such file -- xmlrpc/client
  /usr/lib64/beef/core/loader.rb:22:in `require'
  /usr/lib64/beef/core/loader.rb:22:in `<top (required)>'
  /usr/lib/beef/beef:44:in `require'
  /usr/lib/beef/beef:44:in `<top (required)>'

Could you sync the list of deps with core/loader.rb?

bcoles commented 5 years ago

Does this help?

diff --git a/core/loader.rb b/core/loader.rb
index e0d4eaa4..7f5bf8af 100644
--- a/core/loader.rb
+++ b/core/loader.rb
@@ -14,6 +14,9 @@ require 'bundler/setup'
 require 'msgpack'

 Bundler.require(:default)
+Bundler.require(:sqlite)
+Bundler.require(:geoip)
+Bundler.require(:ext_msf)

 require 'cgi'
 require 'yaml'
blshkv commented 5 years ago

no, it didn't help. I'm still getting the same error message. xmlrpc is installed btw:

/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/bin
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/bin/console
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/bin/setup
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/base64.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/client.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/config.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/create.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/datetime.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/marshal.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/parser.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/server.rb
/usr/lib64/ruby/gems/2.4.0/gems/xmlrpc-0.3.0/lib/xmlrpc/utils.rb
/usr/lib64/ruby/gems/2.4.0/specifications
/usr/lib64/ruby/gems/2.4.0/specifications/xmlrpc-0.3.0.gemspec
blshkv commented 5 years ago

you need to add xmlrpc into Gemfile.

bcoles commented 5 years ago

xmlrpc is in the Gemfile, in the ext_msf group.

It might need to be required before the require 'msgpack'. Unfortunately that config broke for me unless msgpack was after the Bundler.require call.

blshkv commented 5 years ago

oh, we made msf optional but it is not. My bad

bcoles commented 5 years ago

Msf is optional (the extension is disabled by default) it's just the dumb way we load extensions and libs that requires the gems.

I'd prefer not to require the xmlrpc and msgpack gems by default.

Bundler.require() was meant to make life easier, but it causes some hassles (#1466).

The extension loading could do some with refactoring, in particular to allow dynamic/optional loading of libs as required, depending on which extensions are enabled.

If you can offer a solution that works for your build, I'll have a look at reworking the dep loading, and possibly dropping the use of Bundler.require().

bcoles commented 5 years ago

This won't fix the dep loading issues, but may fix your build:

diff --git a/core/loader.rb b/core/loader.rb
index e0d4eaa4..b1a564bd 100644
--- a/core/loader.rb
+++ b/core/loader.rb
@@ -8,12 +8,10 @@
 require 'rubygems'
 require 'bundler/setup'

-# For some reason, on Ruby 2.5+, msgpack needs to be loaded first,
-# else metasploit integration dies due to undefined `to_msgpack`.
-# Works fine on Ruby 2.4
-require 'msgpack'
-
+Bundler.require(:ext_msf)
 Bundler.require(:default)
+Bundler.require(:sqlite)
+Bundler.require(:geoip)

 require 'cgi'
 require 'yaml'

It shouldn't require adding require 'msgpack' to the Gemfile, but maybe your env will need it (in the :ext_msf group).

diff --git a/Gemfile b/Gemfile
index 4c3cc652..d00e6eb1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -53,6 +53,7 @@ gem 'dm-migrations'
 group :ext_msf do
   gem 'msfrpc-client'
   gem 'xmlrpc'
+  gem 'msgpack'
 end

 # Notifications extension