Merge #3713, @hmoore-r7's SIP cleanup of my SIP cleanup

bug/bundler_fix
Jon Hart 2014-08-26 17:52:35 -07:00
commit 1f35c0ff1c
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
1 changed files with 44 additions and 24 deletions

View File

@ -16,15 +16,9 @@ module Msf
return false return false
end end
# We know it is SIP, so report # Extracted headers, stored as a hash where the key is the header name
report_service( # and the value is a list of all values seen for the header, covering the
host: rhost, # case where the same header value is seen multiple times
port: rport,
proto: proto.downcase,
name: 'sip'
)
# Do header extraction as necessary
extracted_headers = {} extracted_headers = {}
unless desired_headers.nil? || desired_headers.empty? unless desired_headers.nil? || desired_headers.empty?
desired_headers.each do |desired_header| desired_headers.each do |desired_header|
@ -32,22 +26,48 @@ module Msf
extracted_headers[desired_header] ||= [] extracted_headers[desired_header] ||= []
extracted_headers[desired_header] |= found_header extracted_headers[desired_header] |= found_header
end end
end
# report on any extracted headers # Create a SIP OPTIONS fingerprint hash
extracted_headers.each do |k, v| fprint = {
'code' => options_response.code,
'message' => options_response.message
}
# compact the header values, append the header information to the
# fingerprint hash
extracted_headers.each_pair do |k,v|
value = v.join(',')
extracted_headers[k] = value
fprint['header_' + k.gsub('-', '_').downcase] = value
end
# Create a summary of the response
status = options_response.status_line.dup
unless extracted_headers.keys.empty?
status << ": #{extracted_headers}"
end
# Report the service with the status information
report_service(
host: rhost,
port: rport,
proto: proto.downcase,
name: 'sip',
info: status
)
# Report the fingerprint information
report_note( report_note(
host: rhost, host: rhost,
port: rport, port: rport,
proto: proto.downcase, proto: proto.downcase,
type: "sip_header.#{k.gsub(/-/, '_').downcase}", type: "sip.options.fingerprint",
data: v.join(',') data: fprint
) )
end
end
status = "#{endpoint} #{options_response.status_line}" # Display the actual result to the user
status += ": #{extracted_headers}" unless extracted_headers.empty? print_status(endpoint + " " + status)
print_status(status)
true true
end end