Skip to content

Commit a75d47a

Browse files
committed
Use yardoc for new methods
Also substitute '&&' for 'and', and fix some whitespace
1 parent 3b5eb42 commit a75d47a

File tree

1 file changed

+32
-28
lines changed

1 file changed

+32
-28
lines changed

lib/msf/core/exploit/http/client.rb

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -445,28 +445,28 @@ def proxies
445445
# destination host and port. This method falls back to using the old
446446
# service.info field to represent the HTTP Server header.
447447
#
448-
# Options:
449-
# @option opts [String] :uri An HTTP URI to request in order to generate a fingerprint
450-
# @option opts [String] :method An HTTP method to use in the fingerprint request
451-
#
448+
# @option opts [String] :uri ('/') An HTTP URI to request in order to generate
449+
# a fingerprint
450+
# @option opts [String] :method ('GET') An HTTP method to use in the fingerprint
451+
# request
452452
def lookup_http_fingerprints(opts={})
453453
uri = opts[:uri] || '/'
454454
method = opts[:method] || 'GET'
455455
fprints = []
456-
456+
457457
return fprints unless framework.db.active
458-
458+
459459
::ActiveRecord::Base.connection_pool.with_connection {
460460
wspace = datastore['WORKSPACE'] ?
461461
framework.db.find_workspace(datastore['WORKSPACE']) : framework.db.workspace
462462

463463
service = framework.db.get_service(wspace, rhost, 'tcp', rport)
464464
return fprints unless service
465-
465+
466466
# Order by note_id descending so the first value is the most recent
467467
service.notes.where(:ntype => 'http.fingerprint').order("notes.id DESC").each do |n|
468-
next unless n.data and n.data.kind_of?(::Hash)
469-
next unless n.data[:uri] == uri and n.data[:method] == method
468+
next unless n.data && n.data.kind_of?(::Hash)
469+
next unless n.data[:uri] == uri && n.data[:method] == method
470470
# Append additional fingerprints to the results as found
471471
fprints.unshift n.data.dup
472472
end
@@ -481,14 +481,18 @@ def lookup_http_fingerprints(opts={})
481481
# will use it directly, otherwise it will check the database for a previous
482482
# fingerprint. Failing that, it will make a request for /.
483483
#
484-
# Options:
485-
# :response an Http::Packet as returned from any of the send_* methods
486-
# :uri an HTTP URI to request in order to generate a fingerprint
487-
# :method an HTTP method to use in the fingerprint request
488-
# :full request the full HTTP fingerprint, not just the signature
484+
# Other options are passed directly to {#connect} if :response is not given
489485
#
490-
# Other options are passed directly to +connect+ if :response is not given
486+
# @option opts [Rex::Proto::Http::Packet] :response The return value from any
487+
# of the send_* methods
488+
# @option opts [String] :uri ('/') An HTTP URI to request in order to generate
489+
# a fingerprint
490+
# @option opts [String] :method ('GET') An HTTP method to use in the fingerprint
491+
# request
492+
# @option opts [Boolean] :full (false) Request the full HTTP fingerprint, not
493+
# just the signature
491494
#
495+
# @return [String]
492496
def http_fingerprint(opts={})
493497
res = nil
494498
uri = opts[:uri] || '/'
@@ -502,7 +506,7 @@ def http_fingerprint(opts={})
502506
fprints = lookup_http_fingerprints(opts)
503507

504508
if fprints.length > 0
505-
509+
506510
# Grab the most recent fingerprint available for this service, uri, and method
507511
fprint = fprints.last
508512

@@ -528,9 +532,9 @@ def http_fingerprint(opts={})
528532
# This section handles a few simple cases of pattern matching and service
529533
# classification. This logic should be deprecated in favor of Recog-based
530534
# fingerprint databases, but has been left in place for backward compat.
531-
535+
532536
extras = []
533-
537+
534538
if res.headers['Set-Cookie'] =~ /^vmware_soap_session/
535539
extras << "VMWare Web Services"
536540
end
@@ -601,8 +605,8 @@ def http_fingerprint(opts={})
601605
info << " ( #{extras.join(", ")} )" if extras.length > 0
602606

603607
# Create a new fingerprint structure to track this response
604-
fprint = {
605-
:uri => uri, :method => method,
608+
fprint = {
609+
:uri => uri, :method => method,
606610
:code => res.code.to_s, :message => res.message.to_s,
607611
:signature => info
608612
}
@@ -614,7 +618,7 @@ def http_fingerprint(opts={})
614618
# Set-Cookie > :header_set_cookie => JSESSIONID=AAASD23423452
615619
# Server > :header_server => Apache/1.3.37
616620
# WWW-Authenticate > :header_www_authenticate => basic realm='www'
617-
621+
618622
fprint["header_#{hname}".intern] = v
619623
end
620624

@@ -623,22 +627,22 @@ def http_fingerprint(opts={})
623627

624628
# Report a new http.fingerprint note
625629
report_note(
626-
:host => rhost,
627-
:port => rport,
628-
:proto => 'tcp',
629-
:ntype => 'http.fingerprint',
630+
:host => rhost,
631+
:port => rport,
632+
:proto => 'tcp',
633+
:ntype => 'http.fingerprint',
630634
:data => fprint,
631-
# Limit reporting to one stored note per host/service combination
635+
# Limit reporting to one stored note per host/service combination
632636
:update => :unique
633637
)
634638

635639
# Report here even if info is empty since the fact that we didn't
636640
# return early means we at least got a connection and the service is up
637641
report_web_site(:host => rhost, :port => rport, :ssl => ssl, :vhost => vhost, :info => info.dup)
638-
642+
639643
# Return the full HTTP fingerprint if requested by the caller
640644
return fprint if opts[:full]
641-
645+
642646
# Otherwise just return the signature string for compatibility
643647
fprint[:signature]
644648
end

0 commit comments

Comments
 (0)