From 8172596c0b12abf6ce9b3b5f5885cd3ead37d6b5 Mon Sep 17 00:00:00 2001 From: OJ Date: Sun, 8 Dec 2013 20:58:03 +1000 Subject: [PATCH] Fix rendering of result total --- .../console/command_dispatcher/extapi/adsi.rb | 67 +++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb b/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb index 34f4b5e71f..12ab620654 100644 --- a/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb +++ b/lib/rex/post/meterpreter/ui/console/command_dispatcher/extapi/adsi.rb @@ -22,8 +22,9 @@ class Console::CommandDispatcher::Extapi::Adsi # def commands { - "adsi_user_enum" => "Enumerate all users on the specified domain.", - "adsi_computer_enum" => "Enumerate all computers on the specified domain." + "adsi_user_enum" => "Enumerate all users on the specified domain.", + "adsi_computer_enum" => "Enumerate all computers on the specified domain.", + "adsi_domain_query" => "Enumerate all objects on the specified domain that match a filter." } end @@ -85,7 +86,7 @@ class Console::CommandDispatcher::Extapi::Adsi print_line print_line(table.to_s) - print_line("Total users: #{users.length}") + print_line("Total users: #{users[:results].length}") print_line @@ -142,7 +143,65 @@ class Console::CommandDispatcher::Extapi::Adsi print_line print_line(table.to_s) - print_line("Total computers: #{computers.length}") + print_line("Total computers: #{computers[:results].length}") + + print_line + + return true + end + + # + # Options for the adsi_domain_query command. + # + @@adsi_domain_query_opts = Rex::Parser::Arguments.new( + "-h" => [ false, "Help banner" ] + ) + + def adsi_domain_query_usage + print( + "\nUsage: adsi_computer_enum [field 2 [field ..]] [-h]\n\n" + + "Enumerate the objects on the target domain.\n\n" + + "Enumeration returns the set of fields that are specified.\n" + + @@adsi_domain_query_opts.usage) + end + + # + # Enumerate domain computers. + # + def cmd_adsi_domain_query(*args) + parent_window = nil + include_unknown = false + + args.unshift("-h") if args.length < 3 + + @@adsi_domain_query_opts.parse(args) { |opt, idx, val| + case opt + when "-h" + adsi_domain_query_usage + return true + end + } + + domain = args.shift + filter = args.shift + + objects = client.extapi.adsi.domain_query(domain, filter, args) + + table = Rex::Ui::Text::Table.new( + 'Header' => "#{domain} Objects", + 'Indent' => 0, + 'SortIndex' => 0, + 'Columns' => objects[:fields] + ) + + objects[:results].each do |c| + table << c + end + + print_line + print_line(table.to_s) + + print_line("Total objects: #{objects[:results].length}") print_line