rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
34.18k stars 13.98k forks source link

msfconsole exith wit error code! uninitialized constant Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::BUILTIN_LIBRARIES (NameError) #9440

Closed x-cod3r closed 4 years ago

x-cod3r commented 6 years ago

Steps to reproduce

just launching ./msfconsole from terminal

Expected behavior

open msfconsole

Current behavior

don't open and exit with this error code in terminal

./msfconsole
/home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows/railgun.rb:10:in `<module:Railgun>': uninitialized constant Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::BUILTIN_LIBRARIES (NameError)
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows/railgun.rb:7:in `<module:Windows>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows/railgun.rb:6:in `<class:Post>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows/railgun.rb:5:in `<module:Msf>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows/railgun.rb:4:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows.rb:13:in `<module:Windows>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post/windows.rb:3:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post.rb:18:in `<class:Post>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/post.rb:6:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/exploit.rb:32:in `<class:Exploit>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/exploit.rb:30:in `<module:Msf>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/exploit.rb:5:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:26:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/auxiliary.rb:16:in `<class:Auxiliary>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/auxiliary.rb:14:in `<module:Msf>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/auxiliary.rb:4:in `<top (required)>'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require'
    from /var/lib/gems/2.3.0/gems/backports-3.11.0/lib/backports/std_lib.rb:9:in `require_with_backports'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core.rb:66:in `<top (required)>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `require'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `<top (required)>'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `require'
    from /home/xcoder/evil/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `<top (required)>'
    from ./msfconsole:47:in `require'
    from ./msfconsole:47:in `<main>'

System stuff

Linux parrot 4.11.0-parrot6-amd64 #1 SMP Parrot 4.11.6-1parrot6 (2017-06-28) x86_64 GNU/Linux

Metasploit version

latest and downloaded throug git

I installed Metasploit with:

OS

Linux parrot 4.11.0-parrot6-amd64 #1 SMP Parrot 4.11.6-1parrot6 (2017-06-28) x86_64 GNU/Linux

bcoles commented 6 years ago

+1 for this

I'm getting the same error with Ruby 2.5.1 on Kali 2018 and Ruby 2.5.1 (rbenv) on fully upgraded Kali 2017.

root@kali-2018:~/Desktop/metasploit-framework# ./msfconsole 
Traceback (most recent call last):
    37: from ./msfconsole:48:in `<main>'
    36: from ./msfconsole:48:in `require'
    35: from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `<top (required)>'
    34: from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `require'
    33: from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `<top (required)>'
    32: from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `require'
    31: from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in `<top (required)>'
    30: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
    29: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
    28: from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in `<top (required)>'
    27: from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in `<module:Msf>'
    26: from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in `<class:Auxiliary>'
    25: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
    24: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
    23: from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:27:in `<top (required)>'
    22: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
    21: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
    20: from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in `<top (required)>'
    19: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
    18: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
    17: from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:5:in `<top (required)>'
    16: from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:30:in `<module:Msf>'
    15: from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:32:in `<class:Exploit>'
    14: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
    13: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
    12: from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:6:in `<top (required)>'
    11: from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:18:in `<class:Post>'
    10: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
     9: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
     8: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:3:in `<top (required)>'
     7: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:13:in `<module:Windows>'
     6: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require_with_backports'
     5: from /var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9:in `require'
     4: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:4:in `<top (required)>'
     3: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:5:in `<module:Msf>'
     2: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:6:in `<class:Post>'
     1: from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:7:in `<module:Windows>'
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:10:in `<module:Railgun>': uninitialized constant Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::BUILTIN_LIBRARIES (NameError)
bcoles commented 6 years ago

I tried to reproduce this with an another slightly older Kali 2017 VM I had lying around with a slightly older msf (HEAD dated April 8th) and Ruby 2.3.6p384 (no rbenv/rvm).

Both packaged and git repo msfconsole work fine.

git pull and bundle install --- still works fine.

apt-get update && apt-get dist-upgrade --- upgrade to Kali 2018 and system Ruby 2.5.1; removed ruby2.3 and ruby2.3-dev and all ruby 2.3 gems.

Still works fine with packaged msfconsole. msfconsole from git also worked fine after bundle install.

busterb commented 6 years ago

@bcoles interesting, related to https://github.com/rapid7/metasploit-framework/issues/9923 I'd wager.

busterb commented 6 years ago

Confirmed it worked fine with a fresh Kali install on system ruby 2.5.1. What are the prerequisites to reproducing this? Does it require some older gems to be installed?

If we have a circular dependency, maybe it's more a case of it hitting it randomly based on how the filesystem is arranged (speculating that the dependency resolver is influenced by the order in which files are naturally found in the filesystem).

bcoles commented 6 years ago

Your guess is as good as mine.

I have a Parrot VM that's fairly fresh. Works fine. I'm upgrading it now.

busterb commented 6 years ago

Maybe a place to start:

macOS RVM Ruby 2.5.1

$ ruby -W2 ./msfconsole -qx 'quit' 2> warnings.txt && grep circular warnings.txt | wc -l
     139
bcoles commented 6 years ago

"Fairly fresh" Kali 2018 (system Ruby 2.5.1) with msf from git repo:

Old Kali 2018 updated from Kali 2017 (rbenv Ruby 2.5.1) with msf from git repo:

bundle install run as root on both systems.

busterb commented 6 years ago

I suspect that any circular dependencies are bad, an this seems to confirm that the number of detected cycles is environment-dependent (it'd be interesting to know if the warnings.txt file is identical between runs).

Submitted https://github.com/rapid7/metasploit-framework/pull/9960 as an initial salvo against the noise here.

bcoles commented 6 years ago

warnings are identical between runs.

63 is less than 139 as the above error causes msf to bail before full load.

busterb commented 6 years ago

Ah, right! I wonder if the last warning in your file is the first circular dependency we should resolve to fix this issue.

bcoles commented 6 years ago
root@kali-2018:~/Desktop/metasploit-framework# head warnings.txt 
/var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/core_ext/hash/slice.rb:21: warning: method redefined; discarding old slice
/root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:31: warning: assigned but unused variable - stdin
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/hex.rb:65: warning: `%' after local variable or literal is interpreted as binary operator
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/hex.rb:65: warning: even though it seems like string literal
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/hex.rb:57: warning: assigned but unused variable - cnt
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/hex.rb:58: warning: assigned but unused variable - snl
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/compress.rb:25: warning: assigned but unused variable - temp
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/pattern.rb:56: warning: assigned but unused variable - setnum
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/table.rb:179: warning: assigned but unused variable - old
/var/lib/gems/2.5.0/gems/rex-text-0.2.20/lib/rex/text/table.rb:413: warning: `<<' after local variable or literal is interpreted as binary operator
root@kali-2018:~/Desktop/metasploit-framework# grep circular warnings.txt | head
/var/lib/gems/2.5.0/gems/rex-registry-0.1.3/lib/rex/registry/lfkey.rb:2: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-registry-0.1.3/lib/rex/registry/nodekey.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-struct2-0.1.2/lib/rex/struct2/c_struct_template.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
/var/lib/gems/2.5.0/gems/backports-3.11.3/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /var/lib/gems/2.5.0/gems/rex-socket-0.1.14/lib/rex/socket.rb
bcoles commented 6 years ago

The OP for this bug is dated January and reportedly affected Parrot.

On my only Parrot system (built late Feb), packaged msfconsole (4.x branch) worked both before and after full system update (and reboot).

I haven't tested the git repo. Waiting on git clone to complete...

busterb commented 6 years ago

Now try:

--- a/lib/msf/core.rb
+++ b/lib/msf/core.rb
@@ -11,7 +11,7 @@
 ###

 # Include backported features for older versions of Ruby
-require 'backports'
+#require 'backports'

Then tail the warnings file. That might give us a clue where it breaks.

bcoles commented 6 years ago

warnings4.txt

root@kali-2018:~/Desktop/metasploit-framework# ruby -W2 ./msfconsole -qx 'quit' 2> warnings4.txt
root@kali-2018:~/Desktop/metasploit-framework# md5sum warnings*
4fca0ef3e9246cce796cedbfd610e8a1  warnings2.txt
4fca0ef3e9246cce796cedbfd610e8a1  warnings3.txt
328df3741f35e7fb7948229b8ecfc340  warnings4.txt
4fca0ef3e9246cce796cedbfd610e8a1  warnings.txt
root@kali-2018:~/Desktop/metasploit-framework# wc -l warnings*
  1955 warnings2.txt
  1955 warnings3.txt
  1662 warnings4.txt
  1955 warnings.txt
  7527 total
root@kali-2018:~/Desktop/metasploit-framework# tail warnings4.txt 
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in `<class:Auxiliary>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `<top (required)>'
    from ./msfconsole:48:in `require'
    from ./msfconsole:48:in `<main>'
bcoles commented 6 years ago
root@kali-2018:~/Desktop/metasploit-framework# tail -n 100 warnings4.txt 
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/module/auxiliary_action.rb:2:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
/var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274: warning: loading in progress, circular require considered harmful - /root/Desktop/metasploit-framework/lib/msf/core.rb
    from ./msfconsole:48:in  `<main>'
    from ./msfconsole:48:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in  `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in  `<class:Auxiliary>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:27:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:5:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:30:in  `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:32:in  `<class:Exploit>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:6:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:14:in  `<class:Post>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux.rb:2:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux.rb:6:in  `<module:Linux>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux/busy_box.rb:3:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:413: warning: assigned but unused variable - loadres
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:446: warning: assigned but unused variable - unloadres
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:474: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:490: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:504: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:522: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:541: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:556: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:575: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:591: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:37: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/util.rb:564: warning: assigned but unused variable - key
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb:217: warning: assigned but unused variable - args
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:65: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:71: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:78: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:10:in `<module:Railgun>': uninitialized constant Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::BUILTIN_LIBRARIES (NameError)
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:7:in `<module:Windows>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:6:in `<class:Post>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:5:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:4:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:13:in `<module:Windows>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:18:in `<class:Post>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:6:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:32:in `<class:Exploit>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:30:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:5:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:27:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in `<class:Auxiliary>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload/apk.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/payload_generator.rb:2:in `<top (required)>'
    from ./msfconsole:48:in `require'
    from ./msfconsole:48:in `<main>'
busterb commented 6 years ago

How about: https://github.com/rapid7/metasploit-framework/compare/master...busterb:payload-requires?expand=1

(I'm not able to reproduce this locally, so this is based on your backtraces)

bcoles commented 6 years ago
root@kali-2018:~/Desktop/metasploit-framework# tail -n 100 warnings5.txt 
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in  `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in  `<class:Auxiliary>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:27:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:5:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:30:in  `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:32:in  `<class:Exploit>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:6:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:14:in  `<class:Post>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux.rb:2:in  `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux.rb:6:in  `<module:Linux>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/linux/busy_box.rb:3:in  `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in  `load_dependency'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `block in require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:274:in  `require'
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:413: warning: assigned but unused variable - loadres
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:446: warning: assigned but unused variable - unloadres
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:474: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:490: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:504: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:522: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:541: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:556: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:575: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/registry.rb:591: warning: assigned but unused variable - e
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:37: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/util.rb:564: warning: assigned but unused variable - key
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/multicall.rb:217: warning: assigned but unused variable - args
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:65: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:71: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/usr/lib/ruby/vendor_ruby/rex/post/meterpreter/extensions/stdapi/railgun/dll_function.rb:78: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument
/root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:10:in `<module:Railgun>': uninitialized constant Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::BUILTIN_LIBRARIES (NameError)
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:7:in `<module:Windows>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:6:in `<class:Post>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:5:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows/railgun.rb:4:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:13:in `<module:Windows>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post/windows.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:18:in `<class:Post>'
    from /root/Desktop/metasploit-framework/lib/msf/core/post.rb:6:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:32:in `<class:Exploit>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:30:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/exploit.rb:5:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mqtt.rb:3:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary/mixins.rb:27:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:16:in `<class:Auxiliary>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:14:in `<module:Msf>'
    from /root/Desktop/metasploit-framework/lib/msf/core/auxiliary.rb:4:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/msf/core.rb:66:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework.rb:25:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/database.rb:1:in `require'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/database.rb:1:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/parsed_options/base.rb:17:in `require'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/parsed_options/base.rb:17:in `<top (required)>'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/parsed_options/console.rb:2:in `require'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/parsed_options/console.rb:2:in `<top (required)>'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:263:in `require'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:263:in `const_get'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:263:in `block in constantize'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:259:in `each'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:259:in `inject'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/inflector/methods.rb:259:in `constantize'
    from /var/lib/gems/2.5.0/gems/activesupport-4.2.10/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:73:in `parsed_options_class'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:69:in `parsed_options'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:47:in `require_environment!'
    from /root/Desktop/metasploit-framework/lib/metasploit/framework/command/base.rb:81:in `start'
    from ./msfconsole:48:in `<main>'
diff --git a/lib/msf/core.rb b/lib/msf/core.rb
index 6eca2772ce..50369871b6 100644
--- a/lib/msf/core.rb
+++ b/lib/msf/core.rb
@@ -11,7 +11,7 @@
 ###

 # Include backported features for older versions of Ruby
-require 'backports'
+#require 'backports'

 # The framework-core depends on Rex
 require 'rex'
diff --git a/lib/msf/core/payload.rb b/lib/msf/core/payload.rb
index 4dde9d07d2..49f56a6903 100644
--- a/lib/msf/core/payload.rb
+++ b/lib/msf/core/payload.rb
@@ -21,9 +21,11 @@ class Payload < Msf::Module

   # Platform specific includes
   require 'msf/core/payload/aix'
+  require 'msf/core/payload/apk'
   require 'msf/core/payload/bsd'
   require 'msf/core/payload/linux'
   require 'msf/core/payload/osx'
+  require 'msf/core/payload/php'
   require 'msf/core/payload/solaris'
   require 'msf/core/payload/windows'
   require 'msf/core/payload/netware'
diff --git a/lib/msf/core/payload/apk.rb b/lib/msf/core/payload/apk.rb
index cddbee7108..301f1a3bf4 100644
--- a/lib/msf/core/payload/apk.rb
+++ b/lib/msf/core/payload/apk.rb
@@ -1,6 +1,5 @@
 # -*- coding: binary -*-

-require 'msf/core'
 require 'rex/text'
 require 'tmpdir'
 require 'nokogiri'
diff --git a/lib/msf/core/payload/php.rb b/lib/msf/core/payload/php.rb
index bf5190cde9..d78018d147 100644
--- a/lib/msf/core/payload/php.rb
+++ b/lib/msf/core/payload/php.rb
@@ -1,5 +1,4 @@
 # -*- coding: binary -*-
-require 'msf/core'

 ###
 #
diff --git a/lib/msf/core/payload_generator.rb b/lib/msf/core/payload_generator.rb
index 577f591d35..d55e7c03ed 100644
--- a/lib/msf/core/payload_generator.rb
+++ b/lib/msf/core/payload_generator.rb
@@ -1,5 +1,5 @@
 # -*- coding: binary -*-
-require 'msf/core/payload/apk'
+require 'msf/core/payload'
 require 'active_support/core_ext/numeric/bytes'
 module Msf

diff --git a/lib/msf/util/exe.rb b/lib/msf/util/exe.rb
index dd0c3d819e..2d08cdc12d 100644
--- a/lib/msf/util/exe.rb
+++ b/lib/msf/util/exe.rb
@@ -641,9 +641,6 @@ require 'msf/core/exe/segment_appender'
       opts[:payload] = 'stdin'
       opts[:encoder] = '@x86/service,'+(opts[:serviceencoder] || '')

-      # XXX This should not be required, it appears there is a dependency inversion
-      # See https://github.com/rapid7/metasploit-framework/pull/9851
-      require 'msf/core/payload_generator'
       venom_generator = Msf::PayloadGenerator.new(opts)
       code_service = venom_generator.multiple_encode_payload(code)
       return to_winpe_only(framework, code_service, opts)
diff --git a/msfconsole b/msfconsole
index 5e2b72eb22..1c17100284 100755
--- a/msfconsole
+++ b/msfconsole
@@ -45,7 +45,6 @@ end
 begin
   require Pathname.new(__FILE__).realpath.expand_path.parent.join('config', 'boot')
   require 'metasploit/framework/command/console'
-  require 'msf/core/payload_generator'
   Metasploit::Framework::Command::Console.start
 rescue Interrupt
   puts "\nAborting..."
busterb commented 6 years ago

Looks like a different path to the same end.

bcoles commented 6 years ago

I can now reproduce this on latest up-to-date Parrot.

Packaged msfconsole v4.16.48-dev works. Version from git repo fails.

busterb commented 6 years ago

Thanks, I'll try Parrot.

busterb commented 6 years ago

I resumed poking at parrot on a plane, and found something odd in that 'rex' seemed to be provided by '/usr/lib/ruby/vendor_ruby/rex/proto/'. Then I had an AHA! moment and uninstalled Kali / Parrot's 'ruby-librex' package.

'ruby-librex' is the somewhat unmaintained 'rollup' package for rex, and now it's out of date. It has a single dependency as far as I know, 'ruby-msfrpc-client' -> 'beef-xss'. So really we need to untangle the mess that is different versions of rex living inside and outside of the framework tree. Also, there's really no reason 'ruby-msfrpc-client' really needs to depend on rex at all. It just uses it for an http client, a more robust version surely exists in other sources.

If you uninstall Kali / Parrotsec's 'ruby-librex', package, running ./msfconsole works again in these environments. Alternately, you can not use the system 'ruby' and use rvm, and I think that also fixes it.

bcoles commented 6 years ago

@busterb I've verified your assertion is correct (on Parrot and Kali 2018). Repeating for those playing along at home:

sudo apt-get remove ruby-librex

Kali/Parrot ruby env is a bit of a mess in general.

Regarding not using system Ruby, that may or may not be sufficient.

rvm : the error doesn't occur on Kali 1.0.6 system; but it's so old that it's not a feasible test case.

rbenv : the error does occur on Kali 2018.

Regarding BeEF's dependence on msfrpc-client, BeEF no longer ships a Gemfile.lock and enforces only a minimum version requirement for msfrpc-client. This should allow package maintainers to ship an up-to-date msfrpc-client dependency; and thus an up-to-date rex dep.

busterb commented 6 years ago

OK, I'll look at updating msfrpc-client so this can sort of resolve itself, as the most straightforward fix to begin with.

busterb commented 6 years ago

Initial PR to remove the dependency above.

bcoles commented 6 years ago

Updating Kali system packages broke my msf git clone again. I had to apt-get remove ruby-librex again.

fragsalat commented 5 years ago

I'm having a similar issue while your solution doesn't help. It is the same error message but related to another package.

/home/msf/metasploit-framework/modules/payloads/singles/bsd/vax/shell_reverse_tcp.rb:24:in `initialize': uninitialized constant Msf::Handler::ReverseTcp (NameError)
        from /home/msf/metasploit-framework/lib/msf/core/payload_set.rb:198:in `new'
        from /home/msf/metasploit-framework/lib/msf/core/payload_set.rb:198:in `add_module'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:73:in `on_module_load'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:184:in `load_module'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:239:in `block in load_modules'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:49:in `block (2 levels) in each_module_reference_name'
        from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:133:in `block in find'
        from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `catch'
        from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `find'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:40:in `block in each_module_reference_name'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `foreach'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `each_module_reference_name'
        from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:238:in `load_modules'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:119:in `block in load_modules'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `each'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `load_modules'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:41:in `block in add_module_path'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `each'
        from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `add_module_path'
        from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:50:in `block in init_module_paths'
        from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `each'
        from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `init_module_paths'
        from /home/msf/metasploit-framework/lib/msf/ui/console/driver.rb:161:in `initialize'
        from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `new'
        from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `driver'
        from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
        from /home/msf/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
        from ./msfconsole:49:in `<main>'

There are 6k lines of warning based on the command you posted previously. Here is at least the tail of this output

warings.txt tail

/home/msf/metasploit-framework/lib/msf/util/document_generator/normalizer.rb:122: warning: assigned but unused variable - r
/home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9: warning: loading in progress, circular require considered harmful - /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/redcarpet-3.4.0/lib/redcarpet.rb
        from ./msfconsole:49:in  `
' from /home/msf/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start' from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start' from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:60:in `driver' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/ui.rb:11:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/ui/console.rb:11:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/ui/console/driver.rb:6:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/ui/console/command_dispatcher.rb:117:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:24:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/util/document_generator.rb:8:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/metasploit-framework/lib/msf/util/document_generator/normalizer.rb:1:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/redcarpet-3.4.0/lib/redcarpet.rb:2:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/redcarpet-3.4.0/lib/redcarpet/compat.rb:1:in `' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:240:in `load_dependency' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/activesupport-4.2.11/lib/active_support/dependencies.rb:274:in `block in require' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require_with_backports' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/backports-3.11.4/lib/backports/std_lib.rb:9:in `require' /home/msf/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:1929: warning: method redefined; discarding old cmd_unsetg_help /home/msf/metasploit-framework/lib/msf/ui/console/command_dispatcher/core.rb:1902: warning: previous definition of cmd_unsetg_help was here /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:73: warning: instance variable @driver_options not initialized /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:3477: warning: assigned but unused variable - i /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:5412: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:5495: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:5587: warning: assigned but unused variable - incoming_length /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:7137: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:7781: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:8090: warning: parentheses after method name is interpreted as an argument list, not a decomposed argument /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rb-readline-0.5.5/lib/rbreadline.rb:14: warning: method redefined; discarding old ord /home/msf/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:107: warning: instance variable @current_data_service not initialized /home/msf/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:29: warning: instance variable @error not initialized /home/msf/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:29: warning: instance variable @error not initialized /home/msf/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:29: warning: instance variable @error not initialized /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:10: warning: instance variable @module_paths_inited not initialized /home/msf/metasploit-framework/modules/payloads/singles/bsd/vax/shell_reverse_tcp.rb:24:in `initialize': uninitialized constant Msf::Handler::ReverseTcp (NameError) from /home/msf/metasploit-framework/lib/msf/core/payload_set.rb:198:in `new' from /home/msf/metasploit-framework/lib/msf/core/payload_set.rb:198:in `add_module' from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:73:in `on_module_load' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:184:in `load_module' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:239:in `block in load_modules' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:49:in `block (2 levels) in each_module_reference_name' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:133:in `block in find' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `catch' from /home/msf/.rvm/gems/ruby-2.5.3@metasploit-framework/gems/rex-core-0.1.13/lib/rex/file.rb:132:in `find' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:40:in `block in each_module_reference_name' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `foreach' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/directory.rb:30:in `each_module_reference_name' from /home/msf/metasploit-framework/lib/msf/core/modules/loader/base.rb:238:in `load_modules' from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:119:in `block in load_modules' from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `each' from /home/msf/metasploit-framework/lib/msf/core/module_manager/loading.rb:117:in `load_modules' from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:41:in `block in add_module_path' from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `each' from /home/msf/metasploit-framework/lib/msf/core/module_manager/module_paths.rb:40:in `add_module_path' from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:50:in `block in init_module_paths' from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `each' from /home/msf/metasploit-framework/lib/msf/base/simple/framework/module_paths.rb:49:in `init_module_paths' from /home/msf/metasploit-framework/lib/msf/ui/console/driver.rb:161:in `initialize' from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `new' from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:62:in `driver' from /home/msf/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start' from /home/msf/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start' from ./msfconsole:49:in `
'

Edit: Everyhting works with 4.11.7 but not with latest master

LouDnl commented 5 years ago

I made a small fix, worked for me: https://github.com/rapid7/metasploit-framework/pull/11138

ccondon-r7 commented 4 years ago

I'm scared to poke this thread, but...is this still an issue, if you know, @bcoles and @busterb? 😨

bcoles commented 4 years ago

@ccondon-r7 I have no idea. Let's close it, and if something goes wrong, blame @wvu-r7

ccondon-r7 commented 4 years ago

You read my mind, @bcoles 😂