rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
33.99k stars 13.94k forks source link

Usr/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require': cannot load such file -- net/smtp (LoadError) #16080

Closed REALXLOLX closed 2 years ago

REALXLOLX commented 2 years ago

How to solve this ? sr/lib/ruby/gems/3.1.0/gems/zeitwerk-2.5.3/lib/zeitwerk/kernel.rb:35:in `require': cannot load such file -- net/smtp (LoadError)

3V3RYONE commented 2 years ago

This might be a result of broken gem installation. Did you get any error responses while running the command bundle install to install Metasploit?

REALXLOLX commented 2 years ago

This might be a result of broken gem installation. Did you get any error responses while running the command bundle install to install Metasploit?

Yes bro

bcoles commented 2 years ago

This might be a result of broken gem installation. Did you get any error responses while running the command bundle install to install Metasploit?

Yes bro

What errors do you get?


It looks like this might be a bug due to updates in Ruby 3.1.

https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/

The following default gems are now bundled gems. You need to add the following libraries to Gemfile under the bundler environment.

net-ftp 0.1.3
net-imap 0.2.2
net-pop 0.1.1
net-smtp 0.3.1
matrix 0.4.2
prime 0.1.2
debug 1.4.0

This may resolved by adding 'net-smtp' to the Gemspec.

diff --git a/metasploit-framework.gemspec b/metasploit-framework.gemspec
index bb66725c7e..00f56e5d49 100644
--- a/metasploit-framework.gemspec
+++ b/metasploit-framework.gemspec
@@ -142,6 +142,7 @@ Gem::Specification.new do |spec|
   spec.add_runtime_dependency 'bcrypt_pbkdf'
   spec.add_runtime_dependency 'ruby_smb', '~> 3.0'
   spec.add_runtime_dependency 'net-ldap'
+  spec.add_runtime_dependency 'net-smtp'
   spec.add_runtime_dependency 'winrm'

   #

However, this may break Metasploit on older versions of Ruby. I bricked my install after this change, although possibly due to unrelated reasons. (Edit: bricking was coincidence. unrelated to this change.)

# ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]
# ./msfconsole 
Traceback (most recent call last):
    17: from ./msfconsole:18:in `<main>'
    16: from ./msfconsole:18:in `require'
    15: from /root/Desktop/metasploit-framework/lib/msfenv.rb:17:in `<top (required)>'
    14: from /root/Desktop/metasploit-framework/lib/msfenv.rb:17:in `require'
    13: from /root/Desktop/metasploit-framework/config/environment.rb:2:in `<top (required)>'
    12: from /root/Desktop/metasploit-framework/config/environment.rb:2:in `require'
    11: from /root/Desktop/metasploit-framework/config/application.rb:1:in `<top (required)>'
    10: from /root/Desktop/metasploit-framework/config/application.rb:1:in `require'
     9: from /var/lib/gems/2.7.0/gems/railties-6.1.4.4/lib/rails.rb:13:in `<top (required)>'
     8: from /var/lib/gems/2.7.0/gems/railties-6.1.4.4/lib/rails.rb:13:in `require'
     7: from /var/lib/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:6:in `<top (required)>'
     6: from /var/lib/gems/2.7.0/gems/railties-6.1.4.4/lib/rails/application.rb:6:in `require'
     5: from /var/lib/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/key_generator.rb:4:in `<top (required)>'
     4: from /var/lib/gems/2.7.0/gems/activesupport-6.1.4.4/lib/active_support/key_generator.rb:4:in `require'
     3: from /usr/lib/ruby/2.7.0/openssl.rb:18:in `<top (required)>'
     2: from /usr/lib/ruby/2.7.0/openssl.rb:18:in `require'
     1: from /usr/lib/ruby/2.7.0/openssl/config.rb:14:in `<top (required)>'
/usr/lib/ruby/2.7.0/openssl/config.rb:14:in `require': superclass mismatch for class StringIO (TypeError)
Dilovan200 commented 2 years ago

can someone write me the exact command step by step how i can do it have exactly the same problem

bcoles commented 2 years ago

can someone write me the exact command step by step how i can do it have exactly the same problem

This might work if you're using Metasploit from git.

cd to the git repository and paste the following patch into smtp.patch:

diff --git a/metasploit-framework.gemspec b/metasploit-framework.gemspec
index 2f25088e8c..2dc7fcdcae 100644
--- a/metasploit-framework.gemspec
+++ b/metasploit-framework.gemspec
@@ -142,6 +142,7 @@ Gem::Specification.new do |spec|
   spec.add_runtime_dependency 'bcrypt_pbkdf'
   spec.add_runtime_dependency 'ruby_smb', '~> 3.0'
   spec.add_runtime_dependency 'net-ldap'
+  spec.add_runtime_dependency 'net-smtp', '~> 0.3.1'
   spec.add_runtime_dependency 'winrm'

   #

Apply the patch with git apply smtp.patch. Run bundle install.

github-actions[bot] commented 2 years ago

Hi!

This issue has been left open with no activity for a while now.

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.

RRA876 commented 2 years ago

I am facing the same problem Can anyone tell the step by step commands to fix the issue

bcoles commented 2 years ago

I am facing the same problem Can anyone tell the step by step commands to fix the issue

This may or may not work.

https://github.com/rapid7/metasploit-framework/issues/16080#issuecomment-1025080513

RRA876 commented 2 years ago

This doesn't work please tell another solution

your-olym commented 2 years ago

when I started the beef ,I got

/Users/dsa/c/bin/beef-0.5.4.0/extensions/social_engineering/mass_mailer/mass_mailer.rb:10:in `require': cannot load such file -- net/smtp (LoadError)
    from /Users/dsa/c/bin/beef-0.5.4.0/extensions/social_engineering/mass_mailer/mass_mailer.rb:10:in `<class:MassMailer>'
    from /Users/dsa/c/bin/beef-0.5.4.0/extensions/social_engineering/mass_mailer/mass_mailer.rb:9:in `<module:SocialEngineering>'

,and I don't know where to paste the code. there was no error when I made command "./install" and I used it on mac OS -- catalina.

bcoles commented 2 years ago

when I started the beef ,I got

This is the Metasploit issue tracker. BeEF is over here: https://github.com/beefproject/beef/issues

That said, it looks like a Ruby 3 issue. BeEF does not yet fully support Ruby 3.