Skip to content

Commit c24fdb8

Browse files
author
Brent Cook
committed
Land rapid7#4389, Meatballs1's fix for enum_ad_* post module regressions
Fixes rapid7#4387 by adjusting for the new return type from ADSI queries.
2 parents 3ee6010 + e914061 commit c24fdb8

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lib/msf/core/post/windows/ldap.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def get_default_naming_context(domain=nil)
149149
query_result = query_ldap(session_handle, "", 0, "(objectClass=computer)", ["defaultNamingContext"])
150150
first_entry_fields = query_result[:results].first
151151
# Value from First Attribute of First Entry
152-
default_naming_context = first_entry_fields.first
152+
default_naming_context = first_entry_fields.first[:value]
153153
vprint_status("Default naming context #{default_naming_context}")
154154
return default_naming_context
155155
end
@@ -231,7 +231,7 @@ def query_ldap(session_handle, base, scope, filter, fields)
231231
values_result = values.join(',') if values
232232
vprint_status("Values #{values}")
233233

234-
field_results << values_result
234+
field_results << {:type => 'unknown', :value => values_result}
235235
end
236236

237237
entry_results << field_results

modules/post/windows/gather/enum_ad_computers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def run
8181

8282
report = {}
8383
0.upto(fields.length-1) do |i|
84-
field = result[i] || ""
84+
field = result[i][:value] || ""
8585

8686
# Only perform these actions if the database is connected and we want
8787
# to store in the DB.
@@ -92,7 +92,7 @@ def run
9292
report[:name] = dns
9393
hostnames << dns
9494
when 'operatingSystem'
95-
report[:os_name] = field
95+
report[:os_name] = field.gsub("\xAE",'')
9696
when 'distinguishedName'
9797
if field =~ /Domain Controllers/i
9898
# TODO: Find another way to mark a host as being a domain controller

modules/post/windows/gather/enum_ad_service_principal_names.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def parse_result(result, fields)
100100
row = []
101101

102102
0.upto(fields.length-1) do |i|
103-
field = (result[i].nil? ? "" : result[i])
103+
field = (result[i][:value].nil? ? "" : result[i][:value])
104104

105105
if fields[i] == 'servicePrincipalName'
106106
break if field.blank?

modules/post/windows/gather/enum_ad_to_wordlist.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class Metasploit3 < Msf::Post
2626
'company',
2727
'streetAddress',
2828
'sAMAccountName',
29-
'userAccountControl',
3029
'comment',
3130
'description'
3231
]
@@ -37,7 +36,7 @@ def initialize(info={})
3736
'Description' => %q{
3837
This module will gather information from the default Active Domain (AD) directory
3938
and use these words to seed a wordlist. By default it enumerates user accounts to
40-
build the wordlist
39+
build the wordlist.
4140
},
4241
'License' => MSF_LICENSE,
4342
'Author' => ['Thomas Ring'],
@@ -69,7 +68,7 @@ def run
6968
@words_dict = {}
7069
q[:results].each do |result|
7170
result.each do |field|
72-
search_words(field)
71+
search_words(field[:value])
7372
end # result.each
7473
end # q.each
7574

modules/post/windows/gather/enum_ad_user_comments.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ def run
6565

6666
report = {}
6767
result.each do |field|
68-
if field.nil?
68+
if field[:value].nil?
6969
row << ""
7070
else
71-
row << field
71+
row << field[:value]
72+
7273
end
7374
end
7475

0 commit comments

Comments
 (0)