|
| 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::Auxiliary |
| 9 | + |
| 10 | + include Msf::Exploit::Remote::HttpClient |
| 11 | + include Msf::Auxiliary::Scanner |
| 12 | + include Msf::Auxiliary::Report |
| 13 | + |
| 14 | + def initialize |
| 15 | + super( |
| 16 | + 'Name' => 'ColdFusion Version Scanner', |
| 17 | + 'Description' => %q{ |
| 18 | + This module attempts identify various flavors of ColdFusion up to version 10 |
| 19 | + as well as the underlying OS. |
| 20 | + }, |
| 21 | + 'Author' => |
| 22 | + [ |
| 23 | + 'nebulus', # Original |
| 24 | + 'sinn3r' # Fingerprint() patch for Cold Fusion 10 |
| 25 | + ], |
| 26 | + 'License' => MSF_LICENSE |
| 27 | + ) |
| 28 | + end |
| 29 | + |
| 30 | + def fingerprint(response) |
| 31 | + |
| 32 | + if(response.headers.has_key?('Server') ) |
| 33 | + if(response.headers['Server'] =~ /IIS/ or response.headers['Server'] =~ /\(Windows/) |
| 34 | + os = "Windows (#{response.headers['Server']})" |
| 35 | + elsif(response.headers['Server'] =~ /Apache\//) |
| 36 | + os = "Unix (#{response.headers['Server']})" |
| 37 | + else |
| 38 | + os = response.headers['Server'] |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + return nil if response.body.length < 100 |
| 43 | + |
| 44 | + title = "Not Found" |
| 45 | + if(response.body =~ /<title.*\/?>(.+)<\/title\/?>/im) |
| 46 | + title = $1 |
| 47 | + title.gsub!(/\s/, '') |
| 48 | + end |
| 49 | + |
| 50 | + return nil if( title == 'Not Found' or not title =~ /ColdFusionAdministrator/) |
| 51 | + |
| 52 | + out = nil |
| 53 | + |
| 54 | + if(response.body =~ />\s*Version:\s*(.*)<\/strong\><br\s\//) |
| 55 | + v = $1 |
| 56 | + out = (v =~ /^6/) ? "Adobe ColdFusion MX6 #{v}" : "Adobe ColdFusion MX7 #{v}" |
| 57 | + elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright 1995\-2012 Adobe/ and response.body =~ /Administrator requires a browser that supports frames/ ) |
| 58 | + out = "Adobe ColdFusion MX7" |
| 59 | + elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2006 Adobe/) |
| 60 | + out = "Adobe ColdFusion 8" |
| 61 | + elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2010 Adobe/ and |
| 62 | + response.body =~ /1997\-2012 Adobe Systems Incorporated and its licensors/) |
| 63 | + out = "Adobe ColdFusion 10" |
| 64 | + elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2010 Adobe/ or |
| 65 | + response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2009 Adobe Systems\, Inc\. All rights reserved/ or |
| 66 | + response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1997\-2012 Adobe Systems\, Inc\. All rights reserved/) |
| 67 | + out = "Adobe ColdFusion 9" |
| 68 | + elsif(response.body =~ /<meta name=\"Keywords\" content=\"(.*)\">\s+<meta name/) |
| 69 | + out = $1.split(/,/)[0] |
| 70 | + else |
| 71 | + out = 'Unknown ColdFusion' |
| 72 | + end |
| 73 | + |
| 74 | + if(title.downcase == 'coldfusionadministrator') |
| 75 | + out << " (administrator access)" |
| 76 | + end |
| 77 | + |
| 78 | + out << " (#{os})" |
| 79 | + return out |
| 80 | + end |
| 81 | + |
| 82 | + def run_host(ip) |
| 83 | + |
| 84 | + url = '/CFIDE/administrator/index.cfm' |
| 85 | + |
| 86 | + res = send_request_cgi({ |
| 87 | + 'uri' => url, |
| 88 | + 'method' => 'GET', |
| 89 | + }) |
| 90 | + |
| 91 | + return if not res or not res.body or not res.code |
| 92 | + res.body.gsub!(/[\r|\n]/, ' ') |
| 93 | + |
| 94 | + if (res.code.to_i == 200) |
| 95 | + out = fingerprint(res) |
| 96 | + return if not out |
| 97 | + if(out =~ /^Unknown/) |
| 98 | + print_status("#{ip} " << out) |
| 99 | + return |
| 100 | + else |
| 101 | + print_good("#{ip}: " << out) |
| 102 | + report_note( |
| 103 | + :host => ip, |
| 104 | + :port => datastore['RPORT'], |
| 105 | + :proto => 'tcp', |
| 106 | + :ntype => 'cfversion', |
| 107 | + :data => out |
| 108 | + ) |
| 109 | + end |
| 110 | + elsif(res.code.to_i == 403 and datastore['VERBOSE']) |
| 111 | + if(res.body =~ /secured with Secure Sockets Layer/ or res.body =~ /Secure Channel Required/ or res.body =~ /requires a secure connection/) |
| 112 | + print_status("#{ip} denied access to #{url} (SSL Required)") |
| 113 | + elsif(res.body =~ /has a list of IP addresses that are not allowed/) |
| 114 | + print_status("#{ip} restricted access by IP") |
| 115 | + elsif(res.body =~ /SSL client certificate is required/) |
| 116 | + print_status("#{ip} requires a SSL client certificate") |
| 117 | + else |
| 118 | + print_status("#{ip} denied access to #{url} #{res.code} #{res.message}") |
| 119 | + end |
| 120 | + end |
| 121 | + |
| 122 | + rescue OpenSSL::SSL::SSLError |
| 123 | + rescue Errno::ENOPROTOOPT, Errno::ECONNRESET, ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::ArgumentError |
| 124 | + rescue ::Timeout::Error, ::Errno::EPIPE |
| 125 | + end |
| 126 | + |
| 127 | +end |
0 commit comments