Fixed verbosity bug and tidied up

bug/bundler_fix
Stuart Morgan 2015-12-20 01:55:44 +00:00
parent 86294a869e
commit b0eba24c5f
1 changed files with 8 additions and 7 deletions

View File

@ -29,9 +29,9 @@ class Metasploit3 < Msf::Post
)) ))
register_options([ register_options([
OptString.new('GROUP_FILTER', [true, 'Additional LDAP filters to perform when searching for initial groups', '']), OptString.new('GROUP_FILTER', [false, 'Additional LDAP filters to use when searching for initial groups', '']),
OptBool.new('SHOW_USERGROUPS', [true, 'Show the user/group membership in a greppable form.', false]), OptBool.new('SHOW_USERGROUPS', [true, 'Show the user/group membership in a greppable form to the console.', false]),
OptBool.new('SHOW_COMPUTERS', [true, 'Show basic computer information in a greppable form.', false]), OptBool.new('SHOW_COMPUTERS', [true, 'Show basic computer information in a greppable form to the console.', false]),
OptInt.new('THREADS', [true, 'Number of threads to spawn to gather membership of each group.', 20]) OptInt.new('THREADS', [true, 'Number of threads to spawn to gather membership of each group.', 20])
], self.class) ], self.class)
end end
@ -47,10 +47,10 @@ class Metasploit3 < Msf::Post
vprint_status "Retrieving AD Groups" vprint_status "Retrieving AD Groups"
begin begin
group_fields = ['distinguishedName', 'objectSid', 'samAccountType', 'sAMAccountName', 'whenChanged', 'whenCreated', 'description', 'groupType', 'adminCount', 'comments'] group_fields = ['distinguishedName', 'objectSid', 'samAccountType', 'sAMAccountName', 'whenChanged', 'whenCreated', 'description', 'groupType', 'adminCount', 'comments']
if datastore['GROUP_FILTER'] if datastore['GROUP_FILTER'].empty?
group_query = "(&(objectClass=group)(#{datastore['GROUP_FILTER']}))"
else
group_query = "(objectClass=group)" group_query = "(objectClass=group)"
else
group_query = "(&(objectClass=group)(#{datastore['GROUP_FILTER']}))"
end end
groups = query(group_query, max_search, group_fields) groups = query(group_query, max_search, group_fields)
rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e
@ -65,6 +65,7 @@ class Metasploit3 < Msf::Post
end end
# Go through each of the groups and identify the individual users in each group # Go through each of the groups and identify the individual users in each group
vprint_status "Groups retrieval completed: #{groups[:results].size} group(s)"
vprint_status "Retrieving AD Group Membership" vprint_status "Retrieving AD Group Membership"
users_fields = ['distinguishedName', 'objectSid', 'sAMAccountType', 'sAMAccountName', 'displayName', 'description', 'logonCount', 'userAccountControl', 'userPrincipalName', 'whenChanged', 'whenCreated', 'primaryGroupID', 'badPwdCount','comments', 'title', 'accountExpires', 'adminCount'] users_fields = ['distinguishedName', 'objectSid', 'sAMAccountType', 'sAMAccountName', 'displayName', 'description', 'logonCount', 'userAccountControl', 'userPrincipalName', 'whenChanged', 'whenCreated', 'primaryGroupID', 'badPwdCount','comments', 'title', 'accountExpires', 'adminCount']
@ -349,7 +350,7 @@ class Metasploit3 < Msf::Post
c_SAM_ACCOUNT_TYPE_MAX: (sat_int==0x7fffffff) ? 1 : 0, c_SAM_ACCOUNT_TYPE_MAX: (sat_int==0x7fffffff) ? 1 : 0,
} }
run_sqlite_query(db, 'ad_computers', sql_param_computer) run_sqlite_query(db, 'ad_computers', sql_param_computer)
print_line "Computer [#{sql_param_computer[:c_cn]}][#{sql_param_computer[:c_dNSHostName]}][#{sql_param_computer[:c_rid]}]" if datastore['SHOW_USERGROUPS'] print_line "Computer [#{sql_param_computer[:c_cn]}][#{sql_param_computer[:c_dNSHostName]}][#{sql_param_computer[:c_rid]}]" if datastore['SHOW_COMPUTERS']
end end
rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e