Metasploit-framework: linux&solaris/priv.rb broken

Created on 31 Jan 2019  路  6Comments  路  Source: rapid7/metasploit-framework

Looks like the linux and solaris /priv.rb is broken since it attempts to use command_exists? which is defined in system.rb and not imported/included.

msf5 post(multi/manage/sudo) > use post/linux/gather/hashdump
msf5 post(linux/gather/hashdump) > set session 1
session => 1
msf5 post(linux/gather/hashdump) > run

[-] Post failed: NoMethodError undefined method `command_exists?' for #<Msf::Modules::Post__Linux__Gather__Hashdump::MetasploitModule:0x0000560bc6a82618>
[-] Call stack:
[-]   /metasploit-framework/lib/msf/core/post/linux/priv.rb:15:in `is_root?'
[-]   /metasploit-framework/modules/post/linux/gather/hashdump.rb:23:in `run'
[*] Post module execution completed
msf5 post(multi/manage/sudo) > use post/solaris/gather/hashdump 
msf5 post(solaris/gather/hashdump) > set session 2
session => 2
msf5 post(solaris/gather/hashdump) > run

[-] Post failed: NoMethodError undefined method `command_exists?' for #<Msf::Modules::Post__Solaris__Gather__Hashdump::MetasploitModule:0x00007f01e8050708>
[-] Call stack:
[-]   /metasploit-framework/lib/msf/core/post/file.rb:321:in `read_file'
[-]   /metasploit-framework/modules/post/solaris/gather/hashdump.rb:25:in `run'
[*] Post module execution completed

@bcoles if you have time to check this one out i'd appreciate, i'm deep in the password cracking PRs

bug library

All 6 comments

May be more...

[-] Post failed: NoMethodError undefined method `command_exists?' for #<Msf::Modules::Post__Linux__Gather__Hashdump::MetasploitModule:0x00005654df84eda8>
[-] Call stack:
[-]   /metasploit-framework/lib/msf/core/post/file.rb:321:in `read_file'
[-]   /metasploit-framework/modules/post/linux/gather/hashdump.rb:24:in `run'
[*] Post module execution completed

Ugh, more buggy code from #10119.

The issue with the Solaris module is in File API read_file method, rather than the Solaris Priv lib.

The issue with the Linux Priv lib is due to use of command_exists?, which exists in Linux System lib. Perhaps the Linux Priv lib should should import the Linux System lib?

Alternatively, command_exists? could be moved to the Post Common lib. command -v should work on any POSIX compatible system.

Edit I've been threatening to write POSIX post libs for a while, but haven't gotten around to it.

I'm working on a PR to rectify the immediate issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kontenbonker picture kontenbonker  路  26Comments

TheBrokenWasp picture TheBrokenWasp  路  28Comments

hacksoldier98 picture hacksoldier98  路  30Comments

ortholinux picture ortholinux  路  55Comments

nixawk picture nixawk  路  39Comments