Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metasploit integration with BeEF fails on Kali Linux 2022.1 #2396

Open
h00die-gr3y opened this issue Apr 16, 2022 · 10 comments
Open

Metasploit integration with BeEF fails on Kali Linux 2022.1 #2396

h00die-gr3y opened this issue Apr 16, 2022 · 10 comments

Comments

@h00die-gr3y
Copy link

I am trying to get the integation with Metasploit to work but it fails.
See failure below:

# ./beef
[21:26:03][] Browser Exploitation Framework (BeEF) 0.5.4.0-pre
[21:26:03] | Twit: @beefproject
[21:26:03] | Site: https://beefproject.com
[21:26:03] | Blog: http://blog.beefproject.com
[21:26:03] |_ Wiki: https://github.com/beefproject/beef/wiki
[21:26:03][
] Project Creator: Wade Alcorn (@wadealcorn)
Traceback (most recent call last):
17: from ./beef:164:in <main>
16: from /usr/share/beef-xss/core/extensions.rb:31:in load
15: from /usr/share/beef-xss/core/extensions.rb:31:in each
14: from /usr/share/beef-xss/core/extensions.rb:32:in block in load
13: from /usr/share/beef-xss/core/extension.rb:37:in load
12: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require
11: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency
10: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require
9: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
8: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
7: from /usr/share/beef-xss/extensions/metasploit/extension.rb:95:in <top (required)>
6: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require
5: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency
4: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require
3: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
2: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
1: from /usr/share/beef-xss/extensions/metasploit/rest/msf.rb:1:in <top (required)>
/usr/share/beef-xss/extensions/metasploit/rest/msf.rb:1:in `require_relative': cannot load such file -- /var/lib/beef-xss/core/main/router/router (LoadError)

Same happens if you use the beef-xss command to start.
See log output below.

# journalctl -u beef-xss
Apr 16 18:47:23 cerberus systemd[1]: Started beef-xss.
Apr 16 18:47:27 cerberus beef[12995]: /usr/share/beef-xss/extensions/metasploit/rest/msf.rb:1:in require_relative': cannot load such file -- /var/lib/beef-xss/core/main/router/router (LoadError)
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/extensions/metasploit/rest/msf.rb:1:in <top (required)>
Apr 16 18:47:27 cerberus beef[12995]: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/extensions/metasploit/extension.rb:95:in <top (required)>
Apr 16 18:47:27 cerberus beef[12995]: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:148:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in block in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in load_dependency
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/rubygems-integration/all/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in require
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/core/extension.rb:37:in load
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/core/extensions.rb:32:in block in load
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/core/extensions.rb:31:in each
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/core/extensions.rb:31:in load
Apr 16 18:47:27 cerberus beef[12995]: from /usr/share/beef-xss/beef:164:in <main>
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27][] Browser Exploitation Framework (BeEF) 0.5.4.0-pre
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27] | Twit: @beefproject
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27] | Site: https://beefproject.com
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27] | Blog: http://blog.beefproject.com
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27] |_ Wiki: https://github.com/beefproject/beef/wiki
Apr 16 18:47:27 cerberus beef[12995]: [18:47:27][
] Project Creator: Wade Alcorn (@wadealcorn)
Apr 16 18:47:27 cerberus systemd[1]: beef-xss.service: Main process exited, code=exited, status=1/FAILURE
Apr 16 18:47:27 cerberus systemd[1]: beef-xss.service: Failed with result 'exit-code'.
Apr 16 18:47:27 cerberus systemd[1]: beef-xss.service: Consumed 4.333s CPU time.

This error happens when you change the /usr/share/beef-xss/config.yaml file and set metasploit enable to true.

metasploit:
      enable: true

Putting it back to false solves the issue and beef starts up normally.

I am running Kali Linux 2022.1 on a Rasberry PI
# uname -a
Linux cerberus 5.4.83-Re4son-v8l+ #4 SMP PREEMPT Debian kali-pi (2021-11-05) aarch64 GNU/Linux

Ruby version
# ruby -v
ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [aarch64-linux-gnu]

Metasploit version:
msf6 auxiliary() > version
Framework: 6.1.37-dev
Console : 6.1.37-dev

It looks like a Ruby v3 issue, but i would appreciate if this can be fixed.
Having BeEF without a working Metasploit integration is a bit of a bummer...

@bcoles
Copy link
Collaborator

bcoles commented Apr 16, 2022

Yeah it's most likely Ruby 3 related.

For what it's worth, I get a different error. msfrpcd bursts into flames upon connection.

# ruby3.0 ./msfrpcd -f -a 127.0.0.1 -p 55552 -P abc123 -U msf
[*] MSGRPC starting on 127.0.0.1:55552 (SSL):Msg...
[*] MSGRPC ready at 2022-04-16 18:30:46 -0400.
/usr/lib/ruby/3.0.0/psych/versions.rb:5: warning: already initialized constant Psych::VERSION
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/versions.rb:5: warning: previous definition of VERSION was here
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::ANY
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF8
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF16LE
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF16BE
/usr/lib/ruby/3.0.0/psych/class_loader.rb:7: warning: already initialized constant Psych::ClassLoader::BIG_DECIMAL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:7: warning: previous definition of BIG_DECIMAL was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:8: warning: already initialized constant Psych::ClassLoader::COMPLEX
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:8: warning: previous definition of COMPLEX was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:9: warning: already initialized constant Psych::ClassLoader::DATE
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:9: warning: previous definition of DATE was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:10: warning: already initialized constant Psych::ClassLoader::DATE_TIME
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:10: warning: previous definition of DATE_TIME was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:11: warning: already initialized constant Psych::ClassLoader::EXCEPTION
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:11: warning: previous definition of EXCEPTION was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:12: warning: already initialized constant Psych::ClassLoader::OBJECT
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:12: warning: previous definition of OBJECT was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:13: warning: already initialized constant Psych::ClassLoader::PSYCH_OMAP
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:13: warning: previous definition of PSYCH_OMAP was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:14: warning: already initialized constant Psych::ClassLoader::PSYCH_SET
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:14: warning: previous definition of PSYCH_SET was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:15: warning: already initialized constant Psych::ClassLoader::RANGE
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:15: warning: previous definition of RANGE was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:16: warning: already initialized constant Psych::ClassLoader::RATIONAL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:16: warning: previous definition of RATIONAL was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:17: warning: already initialized constant Psych::ClassLoader::REGEXP
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:17: warning: previous definition of REGEXP was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:18: warning: already initialized constant Psych::ClassLoader::STRUCT
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:18: warning: previous definition of STRUCT was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:19: warning: already initialized constant Psych::ClassLoader::SYMBOL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:19: warning: previous definition of SYMBOL was here
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
/usr/lib/ruby/3.0.0/psych/class_loader.rb:38:in `class_eval': (eval):2: syntax error, unexpected ',', expecting '}' (SyntaxError)
  load {"Exception"=>Exception, "Object"=>Object, "Psych::Om...
                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
..."=>Exception, "Object"=>Object, "Psych::Omap"=>Psych::Omap, ...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...ct, "Psych::Omap"=>Psych::Omap, "Psych::Set"=>Psych::Set, "R...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...Omap, "Psych::Set"=>Psych::Set, "Range"=>Range, "Rational"=>...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...t"=>Psych::Set, "Range"=>Range, "Rational"=>Rational, "Regex...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
..."=>Range, "Rational"=>Rational, "Regexp"=>Regexp, "Struct"=>...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...l"=>Rational, "Regexp"=>Regexp, "Struct"=>Struct, "Symbol"=>...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...exp"=>Regexp, "Struct"=>Struct, "Symbol"=>Symbol, "Complex"=...
...                              ^
(eval):2: syntax error, unexpected ',', expecting `end'
...uct"=>Struct, "Symbol"=>Symbol, "Complex"=>Complex}
...                              ^
(eval):2: syntax error, unexpected '}', expecting `end'
...l"=>Symbol, "Complex"=>Complex}
...                              ^
	from /usr/lib/ruby/3.0.0/psych/class_loader.rb:38:in `block in <class:ClassLoader>'
	from /usr/lib/ruby/3.0.0/psych/class_loader.rb:36:in `each'
	from /usr/lib/ruby/3.0.0/psych/class_loader.rb:36:in `<class:ClassLoader>'
	from /usr/lib/ruby/3.0.0/psych/class_loader.rb:6:in `<module:Psych>'
	from /usr/lib/ruby/3.0.0/psych/class_loader.rb:5:in `<top (required)>'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /usr/lib/ruby/3.0.0/psych/nodes/node.rb:3:in `<top (required)>'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /usr/lib/ruby/3.0.0/psych/nodes.rb:2:in `<top (required)>'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /usr/lib/ruby/3.0.0/psych.rb:15:in `<top (required)>'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/faker-2.20.0/lib/faker.rb:5:in `<top (required)>'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /var/lib/gems/3.0.0/gems/zeitwerk-2.5.4/lib/zeitwerk/kernel.rb:35:in `require'
	from /root/Desktop/metasploit-framework/lib/msf/core/cert_provider.rb:10:in `rand_vars'
	from /root/Desktop/metasploit-framework/lib/msf/core/cert_provider.rb:51:in `ssl_generate_certificate'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/ssl.rb:97:in `ssl_generate_certificate'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/ssl.rb:111:in `ssl_generate_certificate'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/ssl.rb:125:in `makessl'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/ssl_tcp_server.rb:47:in `initsock'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/comm/local.rb:207:in `create_by_type'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/comm/local.rb:33:in `create'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket.rb:51:in `create_param'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/tcp_server.rb:39:in `create_param'
	from /var/lib/gems/3.0.0/gems/rex-socket-0.1.35/lib/rex/socket/tcp_server.rb:29:in `create'
	from /root/Desktop/metasploit-framework/lib/rex/proto/http/server.rb:145:in `start'
	from /root/Desktop/metasploit-framework/lib/rex/service_manager.rb:80:in `start'
	from /root/Desktop/metasploit-framework/lib/rex/service_manager.rb:24:in `start'
	from /root/Desktop/metasploit-framework/lib/msf/core/rpc/v10/service.rb:51:in `start'
	from /root/Desktop/metasploit-framework/plugins/msgrpc.rb:94:in `run'
	from ./msfrpcd:105:in `start_rpc_service'
	from ./msfrpcd:233:in `<main>'
# bundle3.0 exec ./beef
[18:30:52][*] Browser Exploitation Framework (BeEF) 0.5.4.0
[18:30:52]    |   Twit: @beefproject
[18:30:52]    |   Site: https://beefproject.com
[18:30:52]    |   Blog: http://blog.beefproject.com
[18:30:52]    |_  Wiki: https://github.com/beefproject/beef/wiki
[18:30:52][*] Project Creator: Wade Alcorn (@WadeAlcorn)
[18:30:52][*] Connecting to Metasploit on 127.0.0.1:55552
[18:30:52][!] [Metasploit] RPC call to 'auth.login' failed: Failed to open TCP connection to 127.0.0.1:55552 (Connection refused - connect(2) for "127.0.0.1" port 55552)
[18:30:52][!] ["/usr/share/rubygems-integration/all/gems/msfrpc-client-1.1.2/lib/msfrpc-client/client.rb:264:in `rescue in send_rpc_request'", "/usr/share/rubygems-integration/all/gems/msfrpc-client-1.1.2/lib/msfrpc-client/client.rb:261:in `send_rpc_request'", "/usr/share/rubygems-integration/all/gems/msfrpc-client-1.1.2/lib/msfrpc-client/client.rb:117:in `call'", "/root/Desktop/beef/extensions/metasploit/rpcclient.rb:122:in `call'", "/usr/share/rubygems-integration/all/gems/msfrpc-client-1.1.2/lib/msfrpc-client/client.rb:63:in `login'", "/root/Desktop/beef/extensions/metasploit/rpcclient.rb:137:in `login'", "/root/Desktop/beef/extensions/metasploit/api.rb:22:in `block in post_soft_load'", "/usr/lib/ruby/3.0.0/timeout.rb:97:in `block in timeout'", "/usr/lib/ruby/3.0.0/timeout.rb:35:in `block in catch'", "/usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'", "/usr/lib/ruby/3.0.0/timeout.rb:35:in `catch'", "/usr/lib/ruby/3.0.0/timeout.rb:112:in `timeout'", "/root/Desktop/beef/extensions/metasploit/api.rb:20:in `post_soft_load'", "/root/Desktop/beef/core/api.rb:198:in `call'", "/root/Desktop/beef/core/api.rb:198:in `block in fire'", "/root/Desktop/beef/core/api.rb:194:in `each'", "/root/Desktop/beef/core/api.rb:194:in `fire'", "/root/Desktop/beef/core/modules.rb:60:in `load'", "/root/Desktop/beef/beef:170:in `<top (required)>'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `load'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:58:in `kernel_load'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli/exec.rb:23:in `run'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli.rb:484:in `exec'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli.rb:31:in `dispatch'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/cli.rb:25:in `start'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/exe/bundle:48:in `block in <top (required)>'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'", "/usr/share/rubygems-integration/all/gems/bundler-2.3.5/exe/bundle:36:in `<top (required)>'", "/usr/bin/bundle3.0:23:in `load'", "/usr/bin/bundle3.0:23:in `<main>'"]
[18:30:52][!] API Fire Error: Authentication failed in {:owner=>BeEF::Extension::Metasploit::API::MetasploitHooks, :id=>19}.post_soft_load()
-- migration_context()
   -> 0.0086s
[18:30:52][*] BeEF is loading. Wait a few seconds...
[18:30:56][*] 9 extensions enabled:
[18:30:56]    |   XSSRays
[18:30:56]    |   Social Engineering
[18:30:56]    |   Requester
[18:30:56]    |   Proxy
[18:30:56]    |   Network
[18:30:56]    |   Metasploit
[18:30:56]    |   Events
[18:30:56]    |   Demos
[18:30:56]    |_  Admin UI
[18:30:56][*] 316 modules enabled.
[18:30:56][*] 2 network interfaces were detected.
[18:30:56][*] running on network interface: 127.0.0.1
[18:30:56]    |   Hook URL: http://127.0.0.1:3000/hook.js
[18:30:56]    |_  UI URL:   http://127.0.0.1:3000/ui/panel
[18:30:56][*] running on network interface: 192.168.200.130
[18:30:56]    |   Hook URL: http://192.168.200.130:3000/hook.js
[18:30:56]    |_  UI URL:   http://192.168.200.130:3000/ui/panel
[18:30:56][*] RESTful API key: 43e5871c3475399fb862b460d16d7158d5227079
[18:30:56][*] HTTP Proxy: http://127.0.0.1:6789
[18:30:56][*] BeEF server started (press control+c to stop)

Loading the RPC service via msfconsole results in less issues.

msf6 > load msgrpc ServerHost=127.0.0.1 Pass=abc123 SSL=y
[*] MSGRPC Service:  127.0.0.1:55552  (SSL)
[*] MSGRPC Username: msf
[*] MSGRPC Password: abc123
[*] Successfully loaded plugin: msgrpc
/usr/lib/ruby/3.0.0/psych/versions.rb:5: warning: already initialized constant Psych::VERSION
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/versions.rb:5: warning: previous definition of VERSION was here
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::ANY
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF8
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF16LE
/usr/lib/x86_64-linux-gnu/ruby/3.0.0/psych.so: warning: already initialized constant Psych::Parser::UTF16BE
/usr/lib/ruby/3.0.0/psych/class_loader.rb:7: warning: already initialized constant Psych::ClassLoader::BIG_DECIMAL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:7: warning: previous definition of BIG_DECIMAL was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:8: warning: already initialized constant Psych::ClassLoader::COMPLEX
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:8: warning: previous definition of COMPLEX was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:9: warning: already initialized constant Psych::ClassLoader::DATE
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:9: warning: previous definition of DATE was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:10: warning: already initialized constant Psych::ClassLoader::DATE_TIME
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:10: warning: previous definition of DATE_TIME was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:11: warning: already initialized constant Psych::ClassLoader::EXCEPTION
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:11: warning: previous definition of EXCEPTION was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:12: warning: already initialized constant Psych::ClassLoader::OBJECT
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:12: warning: previous definition of OBJECT was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:13: warning: already initialized constant Psych::ClassLoader::PSYCH_OMAP
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:13: warning: previous definition of PSYCH_OMAP was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:14: warning: already initialized constant Psych::ClassLoader::PSYCH_SET
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:14: warning: previous definition of PSYCH_SET was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:15: warning: already initialized constant Psych::ClassLoader::RANGE
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:15: warning: previous definition of RANGE was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:16: warning: already initialized constant Psych::ClassLoader::RATIONAL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:16: warning: previous definition of RATIONAL was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:17: warning: already initialized constant Psych::ClassLoader::REGEXP
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:17: warning: previous definition of REGEXP was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:18: warning: already initialized constant Psych::ClassLoader::STRUCT
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:18: warning: previous definition of STRUCT was here
/usr/lib/ruby/3.0.0/psych/class_loader.rb:19: warning: already initialized constant Psych::ClassLoader::SYMBOL
/var/lib/gems/3.0.0/gems/psych-4.0.3/lib/psych/class_loader.rb:19: warning: previous definition of SYMBOL was here
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
(eval):2: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
msf6 > lsof -i :55552
[*] exec: lsof -i :55552

COMMAND       PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
ruby      1474784 root    7u  IPv4 3171034      0t0  TCP localhost:55552 (LISTEN)
bundle3.0 1474820 root    6u  IPv4 3171041      0t0  TCP localhost:55650->localhost:55552 (ESTABLISHED)
msf6 > 

But BeEF times out during connect.

# bundle3.0 exec ./beef
[18:32:33][*] Browser Exploitation Framework (BeEF) 0.5.4.0
[18:32:33]    |   Twit: @beefproject
[18:32:33]    |   Site: https://beefproject.com
[18:32:33]    |   Blog: http://blog.beefproject.com
[18:32:33]    |_  Wiki: https://github.com/beefproject/beef/wiki
[18:32:33][*] Project Creator: Wade Alcorn (@WadeAlcorn)
[18:32:33][*] Connecting to Metasploit on 127.0.0.1:55552
[18:32:43][!] API Fire Error: execution expired in {:owner=>BeEF::Extension::Metasploit::API::MetasploitHooks, :id=>19}.post_soft_load()
-- migration_context()
   -> 0.0097s
[18:32:43][*] BeEF is loading. Wait a few seconds...
[18:32:47][*] 9 extensions enabled:
[18:32:47]    |   XSSRays
[18:32:47]    |   Social Engineering
[18:32:47]    |   Requester
[18:32:47]    |   Proxy
[18:32:47]    |   Network
[18:32:47]    |   Metasploit
[18:32:47]    |   Events
[18:32:47]    |   Demos
[18:32:47]    |_  Admin UI
[18:32:47][*] 316 modules enabled.
[18:32:47][*] 2 network interfaces were detected.
[18:32:47][*] running on network interface: 127.0.0.1
[18:32:47]    |   Hook URL: http://127.0.0.1:3000/hook.js
[18:32:47]    |_  UI URL:   http://127.0.0.1:3000/ui/panel
[18:32:47][*] running on network interface: 192.168.200.130
[18:32:47]    |   Hook URL: http://192.168.200.130:3000/hook.js
[18:32:47]    |_  UI URL:   http://192.168.200.130:3000/ui/panel
[18:32:47][*] RESTful API key: df32082cf6f6796fdf794d8417b67f14b1728615
[18:32:47][*] HTTP Proxy: http://127.0.0.1:6789
[18:32:47][*] BeEF server started (press control+c to stop)

@h00die-gr3y
Copy link
Author

Yep, I did not even reaching that point. In my case BeEF already crashes during the start.

By the way, your zeitwerk errors looks pretty familiar. They also popup when you try to integrate beef_bind into Metasploit.
Another story, but unfortunately it also does not work.

@presianbg
Copy link

Same here... how can we track down the issue and fix it ?

@r4444zy
Copy link

r4444zy commented Jun 4, 2022

[14:54:14][*] Browser Exploitation Framework (BeEF) 0.5.4.0
[14:54:14]    |   Twit: @beefproject
[14:54:14]    |   Site: https://beefproject.com
[14:54:14]    |   Blog: http://blog.beefproject.com
[14:54:14]    |_  Wiki: https://github.com/beefproject/beef/wiki
[14:54:14][*] Project Creator: Wade Alcorn (@WadeAlcorn)
[14:54:15][*] Connecting to Metasploit on 141.255.153.162:55552
[14:54:25][!] API Fire Error: execution expired in {:owner=>BeEF::Extension::Metasploit::API::MetasploitHooks, :id=>19}.post_soft_load()
-- migration_context()
   -> 0.0169s
[14:54:25][*] BeEF is loading. Wait a few seconds...
[14:54:28][*] 9 extensions enabled:
[14:54:28]    |   XSSRays
[14:54:28]    |   Social Engineering
[14:54:28]    |   Requester
[14:54:28]    |   Proxy
[14:54:28]    |   Network
[14:54:28]    |   Metasploit
[14:54:28]    |   Events
[14:54:28]    |   Demos
[14:54:28]    |_  Admin UI
[14:54:28][*] 309 modules enabled.
[14:54:28][*] 3 network interfaces were detected.
[14:54:28][*] running on network interface: 127.0.0.1
[14:54:28]    |   Hook URL: http://127.0.0.1:3000/hook.js
[14:54:28]    |_  UI URL:   http://127.0.0.1:3000/ui/panel
[14:54:28][*] running on network interface: 192.168.3.132
[14:54:28]    |   Hook URL: http://192.168.3.132:3000/hook.js
[14:54:28]    |_  UI URL:   http://192.168.3.132:3000/ui/panel
[14:54:28][*] running on network interface: 141.255.153.162
[14:54:28]    |   Hook URL: http://141.255.153.162:3000/hook.js
[14:54:28]    |_  UI URL:   http://141.255.153.162:3000/ui/panel
[14:54:28][*] RESTful API key: 1e1707ef478cf1bc0e0b60b41d265569c69cda89
[14:54:28][!] [GeoIP] Could not find MaxMind GeoIP database: '/usr/share/GeoIP/GeoLite2-City.mmdb'
[14:54:28][*] HTTP Proxy: http://127.0.0.1:6789
[14:54:28][*] BeEF server started (press control+c to stop)

also i thought that because port 55552 is closed but i have no idea ,

image

but when i check the port of beef 3000 it is open

image

anyone can help please ?

@r4444zy
Copy link

r4444zy commented Jun 4, 2022

also why does metasploit doesnt have a listener as beef does?

image

@bcoles
Copy link
Collaborator

bcoles commented Jun 4, 2022

also why does metasploit doesnt have a listener as beef does?

BeEF does not start Metasploit RPCd automatically. You can set it to start msfrpcd with auto_msfrpcd.

https://github.com/beefproject/beef/blob/master/extensions/metasploit/config.yaml

@r4444zy
Copy link

r4444zy commented Jun 4, 2022

appears this error

[15:26:29][*] Browser Exploitation Framework (BeEF) 0.5.4.0
[15:26:29]    |   Twit: @beefproject
[15:26:29]    |   Site: https://beefproject.com
[15:26:29]    |   Blog: http://blog.beefproject.com
[15:26:29]    |_  Wiki: https://github.com/beefproject/beef/wiki
[15:26:29][*] Project Creator: Wade Alcorn (@WadeAlcorn)
[15:26:30][*] [Metasploit] Found msfrpcd: /usr/share/metasploit-framework//msfrpcd
[15:26:30][*] [Metasploit] Attempt to start msfrpcd, this may take a while. PID: 8063
/usr/share/metasploit-framework/config/application.rb:1:in `require': cannot load such file -- rails (LoadError)
	from /usr/share/metasploit-framework/config/application.rb:1:in `<top (required)>'
	from /usr/share/metasploit-framework/config/environment.rb:2:in `require'
	from /usr/share/metasploit-framework/config/environment.rb:2:in `<top (required)>'
	from /usr/share/metasploit-framework/lib/msfenv.rb:17:in `require'
	from /usr/share/metasploit-framework/lib/msfenv.rb:17:in `<top (required)>'
	from /usr/share/metasploit-framework//msfrpcd:119:in `require'
	from /usr/share/metasploit-framework//msfrpcd:119:in `<main>'

@r4444zy
Copy link

r4444zy commented Jun 4, 2022

any solution ?

@RiotGamesU
Copy link

Still the same, can't even start normally.

@blue-shorts
Copy link

/usr/share/beef-xss/extensions/metasploit/rest/msf.rb:1:in `require_relative': cannot load such file -- /var/lib/beef-xss/core/main/router/router (LoadError)

I was getting this same error. I realized that the Kali Linux beef package puts beef's configs all over the place, then symlinks around to consolidate into /usr/share/beef-xss:

┌──(root㉿kali)-[/usr/share/beef-xss]
└─# ll                                              
total 40
drwxr-xr-x  3 root root 4096 Aug  3 11:47 arerules
-rwxr-xr-x  1 root root 7175 Jun  7 09:34 beef
-rw-r--r--  1 root root 1460 Nov  9  2021 beef_cert.pem
-rw-r--r--  1 root root 2484 Nov  9  2021 beef_key.pem
lrwxrwxrwx  1 root root   25 Jun  7 09:34 config.yaml -> /etc/beef-xss/config.yaml
drwxr-xr-x  6 root root 4096 Aug  3 11:47 core
lrwxrwxrwx  1 root root   17 Jun  7 09:34 db -> /var/lib/beef-xss
lrwxrwxrwx  1 root root   28 Jun  7 09:34 extensions -> /var/lib/beef-xss/extensions
-rw-r--r--  1 root root 2074 Jun  7 09:34 Gemfile
drwxr-xr-x 14 root root 4096 Aug  3 11:47 modules
-rwxr-xr-x  1 root root  265 Jun  7 09:34 set-new-pass.rb
drwxr-xr-x  5 root root 4096 Aug  3 11:47 tools
lrwxrwxrwx  1 root root   21 Jun  7 09:34 update-geoipdb -> ../../bin/geoipupdate

The problem is that the extensions are actually under /var/lib/beef-xss, while core is really under /usr/share/beef-xss. When the extension tries to load core using a relative path (relative to itself), it results in the incorrect path, and thusly not finding the file (because it’s actually under /usr/share, not /var/lib).

Why not just follow the same pattern? I created a symlink from /var/lib/beef-xss/core back to where core actually is, and I was able to load beef as expected:

sudo ln -s /usr/share/beef-xss/core /var/lib/beef-xss/core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants