Skip to content

Commit 92dba8f

Browse files
committed
Land rapid7#7290, env var check for WinSCP module
2 parents a30711d + a9c3c5d commit 92dba8f

File tree

1 file changed

+8
-0
lines changed
  • modules/post/windows/gather/credentials

1 file changed

+8
-0
lines changed

modules/post/windows/gather/credentials/winscp.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ def run
114114
end
115115
env = get_envs('APPDATA', prog_files_env, 'USERNAME')
116116

117+
if env['APPDATA'].nil?
118+
fail_with(Failure::Unknown, 'Target does not have environment variable APPDATA')
119+
elsif env[prog_files_env].nil?
120+
fail_with(Failure::Unknown, "Target does not have environment variable #{prog_files_env}")
121+
elsif env['USERNAME'].nil?
122+
fail_with(Failure::Unknown, 'Target does not have environment variable USERNAME')
123+
end
124+
117125
user_dir = "#{env['APPDATA']}\\..\\.."
118126
user_dir << "\\.." if user_dir.include?('Users')
119127

0 commit comments

Comments
 (0)