Skip to content

Commit 2d3f599

Browse files
committed
Moves ruby_dl helpers to proper place in repo.
* Adds fail_with methods and moves timeouts to constants.
1 parent 87d8e16 commit 2d3f599

File tree

4 files changed

+36
-152
lines changed

4 files changed

+36
-152
lines changed

lib/osx_ruby_ld_helpers.rb renamed to lib/msf/core/post/osx/ruby_dl.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module OSXRubyDLHelpers
1+
module Msf
2+
class Post
3+
module OSX
4+
module RubyDL
25
def osx_ruby_dl_header
36
<<-EOS
47
require 'dl'
@@ -372,4 +375,8 @@ def use_video?(options)
372375
end
373376
capture_code
374377
end
378+
end
379+
380+
end
381+
end
375382
end

modules/post/osx/gather/record_mic.rb

Lines changed: 0 additions & 128 deletions
This file was deleted.

modules/post/osx/manage/record_mic.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
require 'msf/core'
99
require 'shellwords'
10-
require File.join(Msf::Config.install_root, "lib", "osx_ruby_ld_helpers")
11-
10+
require 'msf/core/post/osx/ruby_dl'
1211

1312
class Metasploit3 < Msf::Post
14-
include ::Msf::Post::Common
15-
include ::Msf::Post::File
13+
include Msf::Post::Common
14+
include Msf::Post::File
1615
include Msf::Auxiliary::Report
17-
include OSXRubyDLHelpers
16+
include Msf::Post::OSX::RubyDL
17+
18+
POLL_TIMEOUT = 120
1819

1920
def initialize(info={})
2021
super(update_info(info,
@@ -50,8 +51,8 @@ def initialize(info={})
5051

5152

5253
def run
53-
fail_with(Exploit::Failure::Unknown, "Invalid session ID selected.") if client.nil?
54-
fail_with(Exploit::Failure::Unknown, "Invalid action") if action.nil?
54+
fail_with("Invalid session ID selected.") if client.nil?
55+
fail_with("Invalid action") if action.nil?
5556

5657
num_chunks = (datastore['RECORD_LEN'].to_f/datastore['SYNC_WAIT'].to_f).ceil
5758
tmp_file = datastore['TMP_FILE'].gsub('<random>') { Rex::Text.rand_text_alpha(10)+'1' }
@@ -83,7 +84,7 @@ def run
8384
Rex.sleep(datastore['SYNC_WAIT'])
8485
# start reading for file
8586
begin
86-
::Timeout.timeout(120) do
87+
::Timeout.timeout(poll_timeout) do
8788
while true
8889
if File.exist?(tmp_file)
8990
# read file
@@ -98,7 +99,7 @@ def run
9899
# store contents in file
99100
title = "OSX Mic Recording "+i.to_s
100101
f = store_loot(title, "audio/quicktime", session, contents,
101-
"osx_webcam_rec#{i}.qt", title)
102+
"osx_mic_rec#{i}.qt", title)
102103
print_good "Record file captured and saved to #{f}"
103104
print_status "Rolling record file. "
104105
break
@@ -108,8 +109,7 @@ def run
108109
end
109110
end
110111
rescue ::Timeout::Error
111-
fail_with(Exploit::Failure::Unknown,
112-
"Client did not respond to new file request, exiting.")
112+
fail_with("Client did not respond to file request after #{poll_timeout}s, exiting.")
113113
end
114114
end
115115
end
@@ -124,5 +124,9 @@ def cleanup
124124
cmd_exec("/bin/kill -9 #{@pid}")
125125
end
126126
end
127-
end
128127

128+
private
129+
130+
def poll_timeout; POLL_TIMEOUT; end
131+
def fail_with(msg); raise msg; end
132+
end

modules/post/osx/manage/webcam.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
require 'msf/core'
99
require 'shellwords'
10-
require File.join(Msf::Config.install_root, "lib", "osx_ruby_ld_helpers")
11-
10+
require 'msf/core/post/osx/ruby_dl'
1211

1312
class Metasploit3 < Msf::Post
14-
include ::Msf::Post::Common
15-
include ::Msf::Post::File
13+
include Msf::Post::Common
14+
include Msf::Post::File
1615
include Msf::Auxiliary::Report
17-
include OSXRubyDLHelpers
16+
include Msf::Post::OSX::RubyDL
17+
18+
POLL_TIMEOUT = 120
1819

1920
def initialize(info={})
2021
super(update_info(info,
@@ -59,10 +60,6 @@ def initialize(info={})
5960
], self.class)
6061
end
6162

62-
def fail_with(msg)
63-
raise msg
64-
end
65-
6663
def run
6764
fail_with("Invalid session ID selected.") if client.nil?
6865
fail_with("Invalid action") if action.nil?
@@ -97,7 +94,7 @@ def run
9794
Rex.sleep(datastore['SYNC_WAIT'])
9895
# start reading for file
9996
begin
100-
::Timeout.timeout(120) do
97+
::Timeout.timeout(poll_timeout) do
10198
while true
10299
if File.exist?(tmp_file)
103100
# read file
@@ -148,5 +145,9 @@ def cleanup
148145
cmd_exec("/bin/kill -9 #{@pid}")
149146
end
150147
end
151-
end
152148

149+
private
150+
151+
def poll_timeout; POLL_TIMEOUT; end
152+
def fail_with(msg); raise msg; end
153+
end

0 commit comments

Comments
 (0)