rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
33.78k stars 13.9k forks source link

expected file /opt/metasploit-framework/embedded/framework/lib/rex/time.rb to define constant Rex::Time, but didn't (Zeitwerk::NameError) #14796

Closed acheong08 closed 3 years ago

acheong08 commented 3 years ago

Steps to reproduce

msfupdate msfdb start msfconsole

Expected behavior

Start up properly

Current behavior

Traceback (most recent call last):ork console...\
    21: from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
    20: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    19: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
    18: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
    17: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
    16: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:125:in `initialize'
    15: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `load_db_config'
    14: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `each_pair'
    13: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:237:in `block in load_db_config'
    12: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:182:in `ilog'
    11: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `log'
    10: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `synchronize'
     9: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:94:in `block in log'
     8: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/sinks/stream.rb:27:in `log'
     7: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb:33:in `get_current_timestamp'
     6: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
     5: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
     4: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     3: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     2: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `tap'
     1: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:27:in `block in require'
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /opt/metasploit-framework/embedded/framework/lib/rex/time.rb to define constant Rex::Time, but didn't (Zeitwerk::NameError)

Metasploit version

Framework Version: 6.0.32-dev-1ed4023bdf81cacc93ae7d1c216d27c2d1099fda

gwillcox-r7 commented 3 years ago

Tried to replicate this error, but I've been unable to do so, here is my logs. It would help to know which OS you tested this on, as well as which version of Ruby you were using when testing this.

 ~/git/metasploit-framework │ upstream-master:master ?20  git update                                          ✔ │ 4s │ 2.7.2 Ruby 
Already on 'upstream-master'
Your branch is up to date with 'upstream/master'.
remote: Enumerating objects: 2444, done.
remote: Counting objects: 100% (2444/2444), done.
remote: Compressing objects: 100% (404/404), done.
remote: Total 2446 (delta 1932), reused 2444 (delta 1932), pack-reused 2
Receiving objects: 100% (2446/2446), 7.15 MiB | 10.88 MiB/s, done.
Resolving deltas: 100% (1932/1932), completed with 6 local objects.
From github.com:rapid7/metasploit-framework
 + d4e9717907...68b3b82a6b gh-pages             -> upstream/gh-pages  (forced update)
 * [new ref]               refs/pull/14797/head -> upstream/pr/14797
Already up to date.
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
First, rewinding head to replay your work on top of it...
Fast-forwarded master to upstream-master.
Total 0 (delta 0), reused 0 (delta 0)
To github.com:gwillcox-r7/metasploit-framework
   b3312ea808..abd7117a5f  master -> master
 ~/git/metasploit-framework │ master ?20  ./msfdb stop                                                       ✔ │ 27s │ 2.7.2 Ruby 
====================================================================
Running the 'stop' command for the database:
Stopping database at /home/gwillcox/.msf4/db
====================================================================

====================================================================
Running the 'stop' command for the webservice:
Stopping MSF web service PID 15216
====================================================================

 ~/git/metasploit-framework │ master ?20  ./msfdb start                                                      ✔ │ 11s │ 2.7.2 Ruby 
====================================================================
Running the 'start' command for the database:
Starting database at /home/gwillcox/.msf4/db...success
====================================================================

====================================================================
Running the 'start' command for the webservice:
Attempting to start MSF web service...success
MSF web service started and online
====================================================================

 ~/git/metasploit-framework │ master ?20  ./msfupdate                                                        ✔ │ 10s │ 2.7.2 Ruby 
[*]
[*] Attempting to update the Metasploit Framework...
[*]

[*] Checking for updates via git
[*] Note: Updating from bleeding edge
HEAD is now at abd7117a5f Land #14735, Require rubocop for new modules
Already on 'master'
Your branch is up to date with 'origin/master'.
Already up to date.
[*] Updating gems...
[DEPRECATED] `Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env` (called at ./msfupdate:231)
Using rake 13.0.3
Using Ascii85 1.1.0
Using concurrent-ruby 1.0.5
Using i18n 1.8.9
Using minitest 5.14.3
Using thread_safe 0.3.6
Using tzinfo 1.2.9
Using activesupport 5.2.4.5
Using builder 3.2.4
Using erubi 1.10.0
Using mini_portile2 2.5.0
Using racc 1.5.2
Using nokogiri 1.11.1 (x86_64-linux)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.9.0
Using rails-html-sanitizer 1.3.0
Using actionview 5.2.4.5
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 5.2.4.5
Using activemodel 5.2.4.5
Using arel 9.0.0
Using activerecord 5.2.4.5
Using public_suffix 4.0.6
Using addressable 2.7.0
Using afm 0.2.2
Using arel-helpers 2.12.0
Using ast 2.4.2
Using aws-eventstream 1.1.0
Using aws-partitions 1.427.0
Using aws-sigv4 1.2.2
Using jmespath 1.4.0
Using aws-sdk-core 3.112.0
Using aws-sdk-ec2 1.225.0
Using aws-sdk-iam 1.48.0
Using aws-sdk-kms 1.42.0
Using aws-sdk-s3 1.88.1
Using bcrypt 3.1.16
Using bcrypt_pbkdf 1.1.0
Using bindata 2.4.8
Using bit-struct 0.16
Using bson 4.12.0
Using bundler 2.1.4
Using byebug 11.1.3
Using coderay 1.1.3
Using cookiejar 0.3.3
Using daemons 1.3.1
Using diff-lcs 1.4.4
Using unf_ext 0.0.7.7
Using unf 0.1.4
Using simpleidn 0.2.1
Using dnsruby 1.61.5
Using docile 1.3.5
Using ed25519 1.2.4
Using eventmachine 1.2.7
Using em-socksify 0.3.2
Using http_parser.rb 0.6.0
Using em-http-request 1.1.7
Using factory_bot 6.1.0
Using method_source 1.0.0
Using thor 1.1.0
Using railties 5.2.4.5
Using factory_bot_rails 6.1.0
Using faker 2.16.0
Using faraday-net_http 1.0.1
Using multipart-post 2.1.1
Using ruby2_keywords 0.0.4
Using faraday 1.3.0
Using websocket-extensions 0.1.5
Using websocket-driver 0.7.3
Using faye-websocket 0.11.0
Using filesize 0.2.0
Using fivemat 1.3.7
Using hashery 2.1.2
Using hrr_rb_ssh 0.3.0.pre2
Using io-console 0.5.8
Using reline 0.2.3
Using irb 1.3.3
Using rkelly-remix 0.0.7
Using jsobfu 0.4.2
Using json 2.5.1
Using memory_profiler 1.0.0
Using metasm 1.0.4
Using metasploit-concern 3.0.1
Using metasploit-model 3.1.3
Using pg 1.2.3
Using recog 2.3.19
Using webrick 1.7.0
Using metasploit_data_models 4.1.2
Using net-ssh 6.1.0
Using rex-core 0.1.16
Using rex-socket 0.1.25
Using rubyntlm 0.6.3
Using rubyzip 2.3.0
Using metasploit-credential 4.0.3
Using metasploit-payloads 2.0.34
Using metasploit_payloads-mettle 1.0.6
Using mqtt 0.5.0
Using msgpack 1.4.2
Using nessus_rest 0.1.6
Using net-ldap 0.17.0
Using network_interface 0.0.2
Using nexpose 7.2.1
Using sawyer 0.8.2
Using octokit 4.20.0
Using openssl-ccm 1.2.2
Using openvas-omp 0.0.4
Using pcaprub 0.13.0
Using packetfu 1.1.13
Using patch_finder 1.0.2
Using ruby-rc4 0.1.5
Using ttfunk 1.7.0
Using pdf-reader 2.4.2
Using nio4r 2.5.5
Using puma 5.2.1
Using rb-readline 0.5.5
Using redcarpet 3.5.1
Using rex-text 0.2.31
Using rex-arch 0.1.14
Using rex-struct2 0.1.3
Using rex-bin_tools 0.1.7
Using rex-encoder 0.1.5
Using rexml 3.2.4
Using rex-exploitation 0.1.27
Using rex-java 0.1.6
Using rex-mime 0.1.6
Using rex-nop 0.1.2
Using rex-ole 0.1.7
Using rex-random_identifier 0.1.5
Using rex-powershell 0.1.89
Using rex-registry 0.1.4
Using rex-rop_builder 0.1.4
Using rex-sslscan 0.1.5
Using rex-zip 0.1.4
Using ruby-macho 2.5.0
Using openssl-cmac 2.0.1
Using windows_error 0.1.2
Using ruby_smb 2.0.7
Using mustermann 1.1.1
Using rack-protection 2.1.0
Using tilt 2.0.10
Using sinatra 2.1.0
Using sqlite3 1.4.2
Using sshkey 2.0.0
Using thin 1.8.0
Using tzinfo-data 1.2021.1
Using warden 1.2.9
Using xdr 3.0.2
Using xmlrpc 0.3.2
Using zeitwerk 2.4.2
Using metasploit-framework 6.0.32 from source at `.`
Using parallel 1.20.1
Using parser 3.0.0.0
Using pry 0.13.1
Using pry-byebug 3.9.0
Using rainbow 3.0.0
Using regexp_parser 2.0.3
Using rspec-support 3.10.2
Using rspec-core 3.10.1
Using rspec-expectations 3.10.1
Using rspec-mocks 3.10.2
Using rspec 3.10.0
Using rspec-rails 4.0.2
Using rspec-rerun 1.1.0
Using rubocop-ast 1.4.1
Using ruby-progressbar 1.11.0
Using unicode-display_width 2.0.0
Using rubocop 1.10.0
Using ruby-prof 1.4.2
Using simplecov-html 0.12.3
Using simplecov 0.18.2
Using swagger-blocks 3.0.0
Using timecop 0.9.4
Using yard 0.9.26
Bundle complete! 16 Gemfile dependencies, 175 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
 ~/git/metasploit-framework │ master ?20  ./msfconsole                                                        ✔ │ 5s │ 2.7.2 Ruby 
[!] The following modules could not be loaded!..\
[!]     /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/office365userenum.py
[!] Please see /home/gwillcox/.msf4/logs/framework.log for details.

Unable to handle kernel NULL pointer dereference at virtual address 0xd34db33f
EFLAGS: 00010046
eax: 00000001 ebx: f77c8c00 ecx: 00000000 edx: f77f0001
esi: 803bf014 edi: 8023c755 ebp: 80237f84 esp: 80237f60
ds: 0018   es: 0018  ss: 0018
Process Swapper (Pid: 0, process nr: 0, stackpage=80377000)

Stack: 90909090990909090990909090
       90909090990909090990909090
       90909090.90909090.90909090
       90909090.90909090.90909090
       90909090.90909090.09090900
       90909090.90909090.09090900
       ..........................
       cccccccccccccccccccccccccc
       cccccccccccccccccccccccccc
       ccccccccc.................
       cccccccccccccccccccccccccc
       cccccccccccccccccccccccccc
       .................ccccccccc
       cccccccccccccccccccccccccc
       cccccccccccccccccccccccccc
       ..........................
       ffffffffffffffffffffffffff
       ffffffff..................
       ffffffffffffffffffffffffff
       ffffffff..................
       ffffffff..................
       ffffffff..................

Code: 00 00 00 00 M3 T4 SP L0 1T FR 4M 3W OR K! V3 R5 I0 N5 00 00 00 00
Aiee, Killing Interrupt handler
Kernel panic: Attempted to kill the idle task!
In swapper task - not syncing

       =[ metasploit v6.0.32-dev-abd7117a5f               ]
+ -- --=[ 2102 exploits - 1131 auxiliary - 358 post       ]
+ -- --=[ 592 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 7 evasion                                       ]

Metasploit tip: Use sessions -1 to interact with the 
last opened session

msf6 > version
Framework: 6.0.32-dev-abd7117a5f
Console  : 6.0.32-dev-abd7117a5f
msf6 > 
hakusaro commented 3 years ago

Hi! I installed Metasploit locally on this machine just a few days ago, and then ran msfupdate only for msfconsole to die after starting. I'm on Darwin Luella.lan 19.6.0 Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64 x86_64. The initial install was Feb 18, 2021 (via the wiki instructions for macOS), and I ran msfupdate without rebooting the system or shutting down the db after doing this. Now, msfconsole refuses to start.

Traceback (most recent call last):ork console...\
    21: from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
    20: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    19: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
    18: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
    17: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
    16: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:125:in `initialize'
    15: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `load_db_config'
    14: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `each_pair'
    13: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:237:in `block in load_db_config'
    12: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:182:in `ilog'
    11: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `log'
    10: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `synchronize'
     9: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:94:in `block in log'
     8: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/sinks/stream.rb:27:in `log'
     7: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb:33:in `get_current_timestamp'
     6: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
     5: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
     4: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     3: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     2: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `tap'
     1: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:27:in `block in require'
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /opt/metasploit-framework/embedded/framework/lib/rex/time.rb to define constant Rex::Time, but didn't (Zeitwerk::NameError)

The system has not rebooted and the metasploit framework web UI and database have been in. the post-install state (i.e., running) until I ran msfupdate today. The uptime is up 24 days, 7:23. I'm not super familiar with how metasploit leverages the system ruby, but I do have a weird install (I have ruby 3 installed using rbenv -- is that weird?). I can provide gem env if that would help.

Edit: to be clear, the console started fine before today (so I didn't examine the environment or anything when it worked, obviously)

Edit 2: That's macOS Catalina 10.15.7. I called msfupdate from /opt/metasploit-framework/bin/msfupdate. Gem env:

particles@Luella ~ % rbenv version
system (set by /Users/particles/.ruby-version)
particles@Luella ~ % ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
particles@Luella ~ % gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.6.3 (2019-04-16 patchlevel 62) [universal.x86_64-darwin19]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.6.0
  - USER INSTALLATION DIRECTORY: /Users/particles/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /Users/particles/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-19
  - GEM PATHS:
     - /Library/Ruby/Gems/2.6.0
     - /Users/particles/.gem/ruby/2.6.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/particles/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Applications/Wireshark.app/Contents/MacOS

I totally take the credit for having a really botched ruby install on this machine -- and I can fix that and try again, but it did work before, so, food for thought? I only switched back to system ruby after thinking it might be ruby 3 causing issues. After switching back to 3, this is the gem env:

particles@Luella ~ % rbenv versions
* system (set by /Users/particles/.ruby-version)
  3.0.0
particles@Luella ~ % rbenv local 3.0.0
particles@Luella ~ % ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
particles@Luella ~ % gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.3
  - RUBY VERSION: 3.0.0 (2020-12-25 patchlevel 0) [x86_64-darwin19]
  - INSTALLATION DIRECTORY: /Users/particles/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /Users/particles/.local/share/gem/ruby/3.0.0
  - RUBY EXECUTABLE: /Users/particles/.rbenv/versions/3.0.0/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/particles/.rbenv/versions/3.0.0/bin
  - SPEC CACHE DIRECTORY: /Users/particles/.local/share/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/particles/.rbenv/versions/3.0.0/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-19
  - GEM PATHS:
     - /Users/particles/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0
     - /Users/particles/.local/share/gem/ruby/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/particles/.rbenv/versions/3.0.0/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/particles/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Applications/Wireshark.app/Contents/MacOS
gwillcox-r7 commented 3 years ago

@hakusaro I would remove Ruby 3 if you have it installed via rbenv and that is what is currently being used to start Metasploit. Ruby 3.0 is not supported by Metasploit as per #14666. Try execute the command ruby --version to make sure you aren't using Ruby 3.0 first and then if uninstalling it so that you use a version of Ruby 2.7.x doesn't work, and your still getting the same error, then let me know and I can dig into it further.

Its possible this may be a setup or OS specific issue given I can't replicate this on Ubuntu 20.04 LTS.

hakusaro commented 3 years ago

@gwillcox-r7 soz for the editing -- I edited a couple times and dumped the gem env using both system and 3.0.0. This time I won't do that.

I've now installed 2.7.2 and switched to it, and I hit the same error? 🤔

I'm not quite sure what's off in this equation. I assume msfupdate takes care of gems and the like?

Last login: Wed Feb 24 00:30:36 on ttys000
particles@Luella ~ % rbenv local 2.7.2
particles@Luella ~ % ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
particles@Luella ~ % gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.1.4
  - RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin19]
  - INSTALLATION DIRECTORY: /Users/particles/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
  - USER INSTALLATION DIRECTORY: /Users/particles/.gem/ruby/2.7.0
  - RUBY EXECUTABLE: /Users/particles/.rbenv/versions/2.7.2/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /Users/particles/.rbenv/versions/2.7.2/bin
  - SPEC CACHE DIRECTORY: /Users/particles/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/particles/.rbenv/versions/2.7.2/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-19
  - GEM PATHS:
     - /Users/particles/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
     - /Users/particles/.gem/ruby/2.7.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/particles/.rbenv/versions/2.7.2/bin
     - /usr/local/Cellar/rbenv/1.1.2/libexec
     - /Users/particles/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Applications/Wireshark.app/Contents/MacOS
particles@Luella ~ % /opt/metasploit-framework/bin/msfdb start
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here
====================================================================
Running the 'start' command for the database:
Starting database at /Users/particles/.msf4/db...success
====================================================================

====================================================================
Running the 'start' command for the webservice:
Attempting to start MSF web service...success
MSF web service started and online
====================================================================

particles@Luella ~ % /opt/metasploit-framework/bin/msfdb stop 
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here
====================================================================
Running the 'stop' command for the database:
Stopping database at /Users/particles/.msf4/db
====================================================================

====================================================================
Running the 'stop' command for the webservice:
Stopping MSF web service PID 52017
====================================================================

particles@Luella ~ % /opt/metasploit-framework/bin/msfupdate 
Switching to root user to update the package
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
Downloading package...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  210M  100  210M    0     0  22.1M      0  0:00:09  0:00:09 --:--:-- 24.1M
Checking signature...
Package "metasploitframework-latest.pkg":
   Status: signed by a developer certificate issued by Apple for distribution
   Signed with a trusted timestamp on: 2021-02-23 11:53:39 +0000
   Certificate Chain:
    1. Developer ID Installer: Rapid7 LLC (UL6CGN7MAL)
       Expires: 2025-08-13 18:13:28 +0000
       SHA256 Fingerprint:
           D2 95 1E A4 7F 4A D1 EE 18 52 6C AB 67 18 17 9D 53 7E 27 62 12 4E 
           FD 94 8D 33 94 E5 C6 40 BF 3A
       ------------------------------------------------------------------------
    2. Developer ID Certification Authority
       Expires: 2027-02-01 22:12:15 +0000
       SHA256 Fingerprint:
           7A FC 9D 01 A6 2F 03 A2 DE 96 37 93 6D 4A FE 68 09 0D 2D E1 8D 03 
           F2 9C 88 CF B0 B1 BA 63 58 7F
       ------------------------------------------------------------------------
    3. Apple Root CA
       Expires: 2035-02-09 21:40:36 +0000
       SHA256 Fingerprint:
           B0 B1 73 0E CB C7 FF 45 05 14 2C 49 F1 29 5E 6E DA 6B CA ED 7E 2C 
           68 C5 BE 91 B5 A1 10 01 F0 24

Installing package...
installer: Package name is Metasploit-framework
installer: Upgrading at base path /
installer: The upgrade was successful.
Cleaning up...
metasploitframework-latest.pkg
particles@Luella ~ % /opt/metasploit-framework/bin/msfdb start
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/actionpack-5.2.4.5/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here
====================================================================
Running the 'start' command for the database:
Starting database at /Users/particles/.msf4/db...success
====================================================================

====================================================================
Running the 'start' command for the webservice:
Attempting to start MSF web service...success
MSF web service started and online
====================================================================

particles@Luella ~ % msfconsole
zsh: command not found: msfconsole
particles@Luella ~ % /opt/metasploit-framework/bin/msfconsole 
Traceback (most recent call last):ork console...-
    21: from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
    20: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    19: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
    18: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
    17: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
    16: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:125:in `initialize'
    15: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `load_db_config'
    14: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `each_pair'
    13: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:237:in `block in load_db_config'
    12: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:182:in `ilog'
    11: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `log'
    10: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `synchronize'
     9: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:94:in `block in log'
     8: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/sinks/stream.rb:27:in `log'
     7: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb:33:in `get_current_timestamp'
     6: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
     5: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
     4: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     3: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     2: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `tap'
     1: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:27:in `block in require'
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /opt/metasploit-framework/embedded/framework/lib/rex/time.rb to define constant Rex::Time, but didn't (Zeitwerk::NameError)
particles@Luella ~ % 
gwillcox-r7 commented 3 years ago

@hakusaro Hmm out of interest can you try running sudo msfconsole? Its possible msfupdate, given that it is running as root, has set up things for the root user, but not for your normal user for some reason.

Right now though my gut feeling is that somewhere within that callstack we aren't importing an expected library though. I just want to make sure it isn't some weird environment misconfiguration first before I assign this the bug label.

hakusaro commented 3 years ago

Barring incompetence because my hands are cold and can't type, sudo didn't help.

particles@Luella ~ % cd /opt/metasploit-framework 
particles@Luella metasploit-framework % ls -lah
total 120
drwxr-xr-x    8 root  wheel   256B Feb 24 00:53 .
drwxr-xr-x    3 root  wheel    96B Feb 18 18:58 ..
-rw-r--r--    1 root  wheel    45K Feb 23 03:51 LICENSE
drwxr-xr-x  206 root  wheel   6.4K Feb 24 00:53 LICENSES
drwxr-xr-x   15 root  wheel   480B Feb 24 00:53 bin
drwxr-xr-x    8 root  wheel   256B Feb 18 03:46 embedded
-rw-r--r--    1 root  wheel   6.9K Feb 23 03:51 version-manifest.json
-rw-r--r--    1 root  wheel   3.4K Feb 23 03:51 version-manifest.txt
particles@Luella metasploit-framework % ls bin
msfbinscan  msfdb       msfpescan   msfrpc      msfvenom
msfconsole  msfelfscan  msfremove   msfrpcd
msfd        msfmachscan msfrop      msfupdate
particles@Luella metasploit-framework % ls -lah bin
total 112
drwxr-xr-x  15 root  wheel   480B Feb 24 00:53 .
drwxr-xr-x   8 root  wheel   256B Feb 24 00:53 ..
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfbinscan
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfconsole
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfd
-rwxr-xr-x   1 root  wheel   592B Feb 23 03:51 msfdb
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfelfscan
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfmachscan
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfpescan
-rwxr-xr-x   1 root  wheel   1.1K Feb 23 03:51 msfremove
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfrop
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfrpc
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfrpcd
-rwxr-xr-x   1 root  wheel   5.9K Feb 23 03:51 msfupdate
-rwxr-xr-x   1 root  wheel   2.7K Feb 23 03:51 msfvenom

At least in my experience, Zeitwerk can be somewhat peculiar, but I haven't sank my teeth in to really dig into it. My hunch is the same as yours, but I'm almost more skeptical of my environment than anything else. I'm wary of blowing the whole thing up though, on the off chance that something went bad during the update and others might hit the same thing. If you want, I can totally try that in about 12ish hours post-sleep.

Edit: Rats, forgot error.

particles@Luella ~ % sudo /opt/metasploit-framework/bin/msfconsole
Password:
Sorry, try again.
Password:
Traceback (most recent call last):ork console...\
    21: from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
    20: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    19: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
    18: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
    17: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
    16: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:125:in `initialize'
    15: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `load_db_config'
    14: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `each_pair'
    13: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:237:in `block in load_db_config'
    12: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:182:in `ilog'
    11: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `log'
    10: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:90:in `synchronize'
     9: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_dispatcher.rb:94:in `block in log'
     8: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/sinks/stream.rb:27:in `log'
     7: from /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb:33:in `get_current_timestamp'
     6: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
     5: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
     4: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     3: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     2: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `tap'
     1: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:27:in `block in require'
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /opt/metasploit-framework/embedded/framework/lib/rex/time.rb to define constant Rex::Time, but didn't (Zeitwerk::NameError)
gwillcox-r7 commented 3 years ago

@hakusaro Thanks for the update. @bwatters-r7 @dwelch-r7 either of you able to look into this some more seeing as I don't have a Mac PC to try replicate this on? Looks like this could potentially be a bug in our Zeitwerk code.

hakusaro commented 3 years ago

@gwillcox-r7 thank you so, so much for the live troubleshooting! I really appreciate it! I'd be more than happy to run anything else if you need additional information. I'll report back if I get it working too! Cheers!

adfoster-r7 commented 3 years ago

@hakusaro I wasn't able to replicate this.

Would you let me know the output of this command:

ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb

If that file exists, then it shouldn't - and we've found out problem 👀

After that, would you mind modifying this file for me please:

/opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb

To add :: to the start of Time.now:

-    return Time.now.strftime("%m/%d/%Y %H:%M:%S")
+    return ::Time.now.strftime("%m/%d/%Y %H:%M:%S")

After saving that file, does that make the problem go away? Note that you may need to edit that file with sudo. If it still doesn't work, just double check that file has been modified with tail /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb

acheong08 commented 3 years ago

I am on MacOS 11.2.1. The problem appears to have been fixed by installing metasploit with homebrew instead of the installer.

acheong08 commented 3 years ago

However, this error has popped up...

 $ msfconsole
[-] Error while running command db_connect: Failed to connect to the HTTP data service: Data Service does not appear to be responding

Call stack:
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/command_dispatcher/db.rb:2045:in `rescue in db_connect_http'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/command_dispatcher/db.rb:2040:in `db_connect_http'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/command_dispatcher/db.rb:1806:in `cmd_db_connect'
/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:542:in `run_command'
/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:491:in `block in run_single'
/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:485:in `each'
/opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:485:in `run_single'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:248:in `block in load_db_config'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `each_pair'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:235:in `load_db_config'
/opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:125:in `initialize'
/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
/opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
/opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
adfoster-r7 commented 3 years ago

@acheong08 Homebrew eventually uses the omnibus installer under the hood: https://github.com/Homebrew/homebrew-cask/blob/5f2283429cdd335e8e9b8aff63eef312e36ab7e9/Casks/metasploit.rb#L5

I think it's a bug with `msfupdate itself, which I'll be able to confirm when @hakusaro gives the result of this command:

ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb

In this scenario I imagine you manually deleted /opt/metasploit-framework or similar before installing with homebrew? 🤔

hakusaro commented 3 years ago
particles@Luella metasploit-framework % ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb
-rw-r--r--  1 root  wheel  667 Feb 18 03:46 /opt/metasploit-framework/embedded/framework/lib/rex/time.rb

It looks like after making the modification you suggested, there are more conflicts and already-defined things.

particles@Luella metasploit-framework % sudo !!
sudo vim /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb
Password:
particles@Luella metasploit-framework % bin/msfconsole
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient/open_pipe.rb:63: warning: already initialized constant Rex::Proto::SMB::SimpleClient::OpenPipe::STATUS_BUFFER_OVERFLOW
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client/open_pipe.rb:63: warning: previous definition of STATUS_BUFFER_OVERFLOW was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient/open_pipe.rb:64: warning: already initialized constant Rex::Proto::SMB::SimpleClient::OpenPipe::STATUS_PIPE_BROKEN
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client/open_pipe.rb:64: warning: previous definition of STATUS_PIPE_BROKEN was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb:21: warning: already initialized constant Rex::Proto::SMB::SimpleClient::CONST
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client.rb:13: warning: previous definition of CONST was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb:22: warning: already initialized constant Rex::Proto::SMB::SimpleClient::CRYPT
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client.rb:14: warning: previous definition of CRYPT was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb:23: warning: already initialized constant Rex::Proto::SMB::SimpleClient::UTILS
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client.rb:15: warning: previous definition of UTILS was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb:24: warning: already initialized constant Rex::Proto::SMB::SimpleClient::XCEPT
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client.rb:16: warning: previous definition of XCEPT was here
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb:25: warning: already initialized constant Rex::Proto::SMB::SimpleClient::EVADE
/opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simple_client.rb:17: warning: previous definition of EVADE was here
Traceback (most recent call last):
    47: from /opt/metasploit-framework/bin/../embedded/framework/msfconsole:23:in `<main>'
    46: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
    45: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
    44: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `driver'
    43: from /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:60:in `new'
    42: from /opt/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:157:in `initialize'
    41: from /opt/metasploit-framework/embedded/framework/lib/msf/base/simple/framework/module_paths.rb:50:in `init_module_paths'
    40: from /opt/metasploit-framework/embedded/framework/lib/msf/base/simple/framework/module_paths.rb:50:in `each'
    39: from /opt/metasploit-framework/embedded/framework/lib/msf/base/simple/framework/module_paths.rb:51:in `block in init_module_paths'
    38: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/module_paths.rb:40:in `add_module_path'
    37: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/module_paths.rb:40:in `each'
    36: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/module_paths.rb:41:in `block in add_module_path'
    35: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/loading.rb:168:in `load_modules'
    34: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/loading.rb:168:in `each'
    33: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/loading.rb:170:in `block in load_modules'
    32: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/base.rb:244:in `load_modules'
    31: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/directory.rb:33:in `each_module_reference_name'
    30: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/directory.rb:33:in `foreach'
    29: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/directory.rb:43:in `block in each_module_reference_name'
    28: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/rex-core-0.1.16/lib/rex/file.rb:132:in `find'
    27: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/rex-core-0.1.16/lib/rex/file.rb:132:in `catch'
    26: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/rex-core-0.1.16/lib/rex/file.rb:133:in `block in find'
    25: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/directory.rb:52:in `block (2 levels) in each_module_reference_name'
    24: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/base.rb:245:in `block in load_modules'
    23: from /opt/metasploit-framework/embedded/framework/lib/msf/core/modules/loader/base.rb:190:in `load_module'
    22: from /opt/metasploit-framework/embedded/framework/lib/msf/core/module_manager/loading.rb:108:in `on_module_load'
    21: from /opt/metasploit-framework/embedded/framework/lib/msf/core/payload_set.rb:208:in `add_module'
    20: from /opt/metasploit-framework/embedded/framework/lib/msf/core/payload_set.rb:208:in `new'
    19: from /opt/metasploit-framework/embedded/framework/modules/payloads/stagers/windows/bind_named_pipe.rb:21:in `initialize'
    18: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
    17: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
    16: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
    15: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
    14: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
    13: from /opt/metasploit-framework/embedded/framework/lib/msf/core/handler/bind_named_pipe.rb:23:in `<top (required)>'
    12: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
    11: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
    10: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     9: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     8: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:26:in `require'
     7: from /opt/metasploit-framework/embedded/framework/lib/rex/proto/smb.rb:8:in `<top (required)>'
     6: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `require'
     5: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:257:in `load_dependency'
     4: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/activesupport-5.2.4.5/lib/active_support/dependencies.rb:291:in `block in require'
     3: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
     2: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `tap'
     1: from /opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:38:in `block in require'
/opt/metasploit-framework/embedded/lib/ruby/gems/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/loader/callbacks.rb:18:in `on_file_autoloaded': expected file /opt/metasploit-framework/embedded/framework/lib/rex/proto/smb/simpleclient.rb to define constant Rex::Proto::SMB::Simpleclient, but didn't (Zeitwerk::NameError)
particles@Luella metasploit-framework % 
adfoster-r7 commented 3 years ago

Confirmed, looks like this issue appears when you have an old version of metasploit and run msfupdate. The time.rb file was deleted as part of this PR: https://github.com/rapid7/metasploit-framework/pull/14696

We'll need to make some code changes to metasploit-framework or to the installer, potentially both. A work around is removing the old version entirely, and reinstalling from scratch 👍

acheong08 commented 3 years ago

@acheong08 Homebrew eventually uses the omnibus installer under the hood: https://github.com/Homebrew/homebrew-cask/blob/5f2283429cdd335e8e9b8aff63eef312e36ab7e9/Casks/metasploit.rb#L5

I think it's a bug with `msfupdate itself, which I'll be able to confirm when @hakusaro gives the result of this command:

ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb

In this scenario I imagine you manually deleted /opt/metasploit-framework or similar before installing with homebrew? 🤔

Used msfremove and then installed with homebrew

acheong08 commented 3 years ago
 $ ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb
ls: /opt/metasploit-framework/embedded/framework/lib/rex/time.rb: No such file or directory
acheong08 commented 3 years ago

Confirmed, looks like this issue appears when you have an old version of metasploit and run msfupdate. The time.rb file was deleted as part of this PR: #14696

We'll need to make some code changes to metasploit-framework or to the installer, potentially both. A work around is removing the old version entirely, and reinstalling from scratch 👍

That was a solution. Metasploit now starts properly

imperd1x commented 3 years ago

@hakusaro I wasn't able to replicate this.

Would you let me know the output of this command:

ls -la /opt/metasploit-framework/embedded/framework/lib/rex/time.rb

If that file exists, then it shouldn't - and we've found out problem 👀

After that, would you mind modifying this file for me please:

/opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb

To add :: to the start of Time.now:

-    return Time.now.strftime("%m/%d/%Y %H:%M:%S")
+    return ::Time.now.strftime("%m/%d/%Y %H:%M:%S")

After saving that file, does that make the problem go away? Note that you may need to edit that file with sudo. If it still doesn't work, just double check that file has been modified with tail /opt/metasploit-framework/embedded/framework/lib/rex/logging/log_sink.rb

This solution helped me :) thanks

acheong08 commented 3 years ago

Works for me too

acheong08 commented 3 years ago

Reinstalling metasploit manually by deleting /opt/metasploit-framework/ and then changing return Time.now.strftime("%m/%d/%Y %H:%M:%S") fixes all the warning logs

adfoster-r7 commented 3 years ago

Closing this for now as the ::Time fix was landed in 6.0.33

There's still a problem with the omnibus installer not deleting previous files, I tracked this down to: https://github.com/rapid7/metasploit-omnibus/blob/2d289bf4831e2d8103bf6df5e5ad7a2a1e908aed/config/templates/metasploit-framework-wrappers/msfupdate.erb#L123-L126

The workaround for now is to uninstall and reinstall metasploit if you're upgrading from an older version before 6.0.32 to a newer version. Full workaround: https://github.com/rapid7/metasploit-framework/issues/14798#issuecomment-789584106

bualisina042 commented 2 years ago

expected file /data/data/com.termux/files/home/metasploit-framework/lib/msf/core/payload/apk.rb to define constant Msf::Payload::Apk, but didn't (Zeitwerk::NameError)

bualisina042 commented 2 years ago

Please fix it

expected file /data/data/com.termux/files/home/metasploit-framework/lib/msf/core/payload/apk.rb to define constant Msf::Payload::Apk, but didn't (Zeitwerk::NameError)

bualisina042 commented 2 years ago

![Uploading Screenshot_2022-01-20-19-34-26-42.jpg…]()

gwillcox-r7 commented 2 years ago

expected file /data/data/com.termux/files/home/metasploit-framework/lib/msf/core/payload/apk.rb to define constant Msf::Payload::Apk, but didn't (Zeitwerk::NameError)

Termux is not supported by Metasploit. See https://github.com/rapid7/metasploit-framework/issues/11023. Termux stopped supporting hacking tools in 2021 and we never officially supported Termux as a installation platform for Metasploit.

bualisina042 commented 2 years ago

But I am using metasploit from 3 years in termux but today I do some mistake

On Thu, 20 Jan 2022, 10:18 pm Grant Willcox, @.***> wrote:

expected file /data/data/com.termux/files/home/metasploit-framework/lib/msf/core/payload/apk.rb to define constant Msf::Payload::Apk, but didn't (Zeitwerk::NameError)

Termux is not supported by Metasploit. See #11023 https://github.com/rapid7/metasploit-framework/issues/11023. Termux stopped supporting hacking tools in 2021 and we never officially supported Termux as a installation platform for Metasploit.

— Reply to this email directly, view it on GitHub https://github.com/rapid7/metasploit-framework/issues/14796#issuecomment-1017736142, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMPJWBU77UM2OYFFH7GD3LUXA7XPANCNFSM4YD52PFQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

gwillcox-r7 commented 2 years ago

But I am using metasploit from 3 years in termux but today I do some mistake On Thu, 20 Jan 2022, 10:18 pm Grant Willcox, @.> wrote: expected file /data/data/com.termux/files/home/metasploit-framework/lib/msf/core/payload/apk.rb to define constant Msf::Payload::Apk, but didn't (Zeitwerk::NameError) Termux is not supported by Metasploit. See #11023 <#11023>. Termux stopped supporting hacking tools in 2021 and we never officially supported Termux as a installation platform for Metasploit. — Reply to this email directly, view it on GitHub <#14796 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXMPJWBU77UM2OYFFH7GD3LUXA7XPANCNFSM4YD52PFQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.>

Sorry but we never did support Termux with Metasploit at any point in the past or present officially. As such Termux is prone to break at any point due to either an update that we do to our code, or an update that Termux does to their own code. Whilst there are various support groups that may be able to assist you with your question, unfortunately as this is not a supported platform we are unable to assist with Termux related questions.

I'd also make sure your Metasploit version is at least 6.0.33 as Alan mentioned above as this contains the fix for the issue mentioned here.

fahmidme commented 2 years ago

I came across this issue recently. I deleted /opt/metasploit-framework folder, turned off my antivirus, and then installed it again using the installation documentation. It worked perfectly.