Skip to content

Commit 4dd285c

Browse files
author
HD Moore
committed
Merge pull request #4 from jlee-r7/feature/recog
Feature/recog
2 parents 3b5eb42 + 5cb016c commit 4dd285c

File tree

4 files changed

+77
-75
lines changed

4 files changed

+77
-75
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

lib/msf/core/exploit/remote/browser_exploit_server.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def get_detection_html(user_agent)
362362
<%= js_os_detect %>
363363
<%= js_ajax_post %>
364364
<%= js_misc_addons_detect %>
365-
<%= js_ie_addons_detect if os.match(/^Windows/) and client == HttpClients::IE %>
365+
<%= js_ie_addons_detect if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
366366
367367
function objToQuery(obj) {
368368
var q = [];
@@ -388,7 +388,7 @@ def get_detection_html(user_agent)
388388
"<%=REQUIREMENT_KEY_SET[:flash]%>" : window.misc_addons_detect.getFlashVersion()
389389
};
390390
391-
<% if os.match(/^Windows/) and client == HttpClients::IE %>
391+
<% if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
392392
d['<%=REQUIREMENT_KEY_SET[:office]%>'] = window.ie_addons_detect.getMsOfficeVersion();
393393
d['<%=REQUIREMENT_KEY_SET[:mshtml_build]%>'] = ScriptEngineBuildVersion().toString();
394394
<%

modules/auxiliary/scanner/smb/smb_version.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def initialize
3434
)
3535

3636
deregister_options('RPORT')
37+
deregister_options('SMBDIRECT')
3738
@smb_port = 445
3839
end
3940

@@ -42,7 +43,7 @@ def rport
4243
end
4344

4445
def smb_direct
45-
@smbdirect || datastore['SMBDirect']
46+
(@smb_port == 445)
4647
end
4748

4849
# Fingerprint a single host
@@ -55,10 +56,10 @@ def run_host(ip)
5556

5657
begin
5758
res = smb_fingerprint()
58-
59+
5960
#
6061
# Create the note hash for smb.fingerprint
61-
#
62+
#
6263
conf = {
6364
:native_os => res['native_os'],
6465
:native_lm => res['native_lm']
@@ -82,7 +83,7 @@ def run_host(ip)
8283
match_conf['os.edition'] = res['edition']
8384
end
8485

85-
if res['sp'].to_s.length > 0
86+
if res['sp'].to_s.length > 0
8687
desc << " #{res['sp'].downcase.gsub('service pack ', 'SP')}"
8788
conf[:os_sp] = res['sp']
8889
match_conf['os.version'] = res['sp']
@@ -95,7 +96,7 @@ def run_host(ip)
9596
end
9697

9798
if res['lang'].to_s.length > 0 and res['lang'] != 'Unknown'
98-
desc << " (language:#{res['lang']}"
99+
desc << " (language:#{res['lang']})"
99100
conf[:os_lang] = res['lang']
100101
match_conf['os.language'] = conf[:os_lang]
101102
end
@@ -130,7 +131,7 @@ def run_host(ip)
130131
:port => rport,
131132
:proto => 'tcp',
132133
:ntype => 'fingerprint.match',
133-
:data => match_conf
134+
:data => match_conf
134135
)
135136
else
136137
desc = "#{res['native_os']} (#{res['native_lm']})"

modules/post/windows/gather/enum_ad_computers.rb

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ def run
6666

6767
# Results table holds raw string data
6868
results_table = Rex::Ui::Text::Table.new(
69-
'Header' => "Domain Computers",
70-
'Indent' => 1,
71-
'SortIndex' => -1,
72-
'Columns' => fields
73-
)
69+
'Header' => "Domain Computers",
70+
'Indent' => 1,
71+
'SortIndex' => -1,
72+
'Columns' => fields
73+
)
7474

7575
# Hostnames holds DNS Names to Resolve
7676
hostnames = []
@@ -81,40 +81,37 @@ def run
8181

8282
report = {}
8383
0.upto(fields.length-1) do |i|
84-
if result[i].nil?
85-
field = ""
86-
else
87-
field = result[i]
88-
89-
# Only perform these actions if the database is connected and we want
90-
# to store in the DB.
91-
if db and datastore['STORE_DB']
92-
case fields[i]
93-
when 'dNSHostName'
94-
dns = field
95-
report[:name] = dns
96-
hostnames << dns
97-
when 'operatingSystem'
98-
report[:os_name] = os
99-
when 'distinguishedName'
100-
if field =~ /Domain Controllers/i
101-
# TODO: Find another way to mark a host as being a domain controller
102-
# The 'purpose' field should be server, client, device, printer, etc
103-
# report[:purpose] = "DC"
104-
end
105-
when 'operatingSystemServicePack'
106-
# XXX: Does this take into account the leading 'SP' string?
107-
108-
if field.to_i > 0
109-
report[:os_sp] = 'SP' + field
110-
end
111-
if field =~ /(Service Pack|SP)\s?(\d+)/
112-
report[:os_sp] = 'SP' + $2
113-
end
114-
115-
when 'description'
116-
report[:info] = field
84+
field = result[i] || ""
85+
86+
# Only perform these actions if the database is connected and we want
87+
# to store in the DB.
88+
if db && datastore['STORE_DB']
89+
case fields[i]
90+
when 'dNSHostName'
91+
dns = field
92+
report[:name] = dns
93+
hostnames << dns
94+
when 'operatingSystem'
95+
report[:os_name] = field
96+
when 'distinguishedName'
97+
if field =~ /Domain Controllers/i
98+
# TODO: Find another way to mark a host as being a domain controller
99+
# The 'purpose' field should be server, client, device, printer, etc
100+
#report[:purpose] = "DC"
101+
report[:purpose] = "server"
117102
end
103+
when 'operatingSystemServicePack'
104+
# XXX: Does this take into account the leading 'SP' string?
105+
106+
if field.to_i > 0
107+
report[:os_sp] = 'SP' + field
108+
end
109+
if field =~ /(Service Pack|SP)\s?(\d+)/
110+
report[:os_sp] = 'SP' + $2
111+
end
112+
113+
when 'description'
114+
report[:info] = field
118115
end
119116
end
120117

@@ -125,7 +122,7 @@ def run
125122
results_table << row
126123
end
127124

128-
if db and datastore['STORE_DB']
125+
if db && datastore['STORE_DB']
129126
print_status("Resolving IP addresses...")
130127
ip_results = client.net.resolve.resolve_hosts(hostnames, AF_INET)
131128

0 commit comments

Comments
 (0)