scan.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5. <meta charset="utf-8">
  6. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.css">
  7. <script src="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.js"></script>
  8. <title>ArOZ Portable Scanner</title>
  9. <script src="jquery.min.js"></script>
  10. </head>
  11. <body>
  12. <div class="ts container">
  13. <br>
  14. <div class="ts segment">
  15. <h4>ArOZ Portable Software Scanner</h4>
  16. <a href="index.php">Back / Cancel Scan</a><br>
  17. This tool can only scan for php script with allow origin enabled. (Usually ArOZ Online System come with build in scannable script)<br>
  18. If that is not the case, please put a "hb.php" under your_ip_address_here/AOB/hb.php with allow origin *<br>
  19. Your LAN IP is: <p id="list">Loading</p>
  20. </div>
  21. <div class="ts primary segment">
  22. <p id="debug"></p>
  23. </div>
  24. </div>
  25. <script>
  26. $(document).ready(function(){
  27. GrapIP();
  28. setTimeout(function() {
  29. StartWebWorker();
  30. }, 2000);
  31. });
  32. var StartedRequest = 0;
  33. var detectedUnits = 0;
  34. function StartWebWorker(){
  35. var ip = $("#list").html();
  36. var webWorkers = [];
  37. if (ip.includes("ifconfig")){
  38. $("#debug").append("[info] This browser is not supported.<br>");
  39. return;
  40. }
  41. if (typeof(Worker) !== "undefined") {
  42. $("#debug").append("[info] Web Worker Exists. IP Scanning Started.<br>");
  43. //The browser support everything and ready to start scanning
  44. var ipg = ip.split(".");
  45. var header = ipg[0] + "." + ipg[1] + "." + ipg[2] + "."; //a.b.c.
  46. for (var i=1; i < 255;i++){
  47. GetWorkingOrNot(header + i);
  48. StartedRequest++;
  49. }
  50. $("#debug").append("[info] Scan done. Waiting for reply...<br>");
  51. } else {
  52. $("#debug").html("[info] Error. Web Worker not supported.");
  53. }
  54. }
  55. function GetWorkingOrNot(ip){
  56. $.ajax({url: "http://" + ip + "/AOB/hb.php",
  57. type: "HEAD",
  58. timeout:5000,
  59. statusCode: {
  60. 200: function (response) {
  61. $.get( "http://" + ip + "/AOB/hb.php", function(data) {
  62. $("#debug").append("[OK]" +ip + "<br>");
  63. $("#debug").append("<a href='http://" +ip + "/AOB/' target='_blank'><i class='caret right icon'></i>Click here to redirect</a><br>");
  64. if (data.split(",").length == 4){
  65. $("#debug").append('[UUID] ' + data.split(",")[2] + '<br>');
  66. }else{
  67. $("#debug").append('[Warning] Incorrectly formatted GUID. Probably an experimental build?<br>');
  68. }
  69. window.detectedUnits++;
  70. });
  71. },
  72. 400: function (response) {
  73. $("#debug").append("[NOT FIND]" +ip + "<br>");
  74. },
  75. 0: function (response) {
  76. //$("#debug").append("[DROPPED]" +ip + "<br>");
  77. }
  78. },
  79. complete: function(data) {
  80. window.StartedRequest--;
  81. if (window.StartedRequest == 0){
  82. if (detectedUnits == 0){
  83. $("#debug").append("[info] No device found in this local area network.<br> Click <a href=''>here</a> to rescan.<br>");
  84. }
  85. $("#debug").append("[info] Scan done. All Asynchronous JavaScript And XML request completed.<br>");
  86. }
  87. }
  88. });
  89. }
  90. function GrapIP(){
  91. // NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23
  92. var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
  93. if (RTCPeerConnection) (function () {
  94. var rtc = new RTCPeerConnection({iceServers:[]});
  95. if (1 || window.mozRTCPeerConnection) { // FF [and now Chrome!] needs a channel/stream to proceed
  96. rtc.createDataChannel('', {reliable:false});
  97. };
  98. rtc.onicecandidate = function (evt) {
  99. // convert the candidate to SDP so we can run it through our general parser
  100. // see https://twitter.com/lancestout/status/525796175425720320 for details
  101. if (evt.candidate) grepSDP("a="+evt.candidate.candidate);
  102. };
  103. rtc.createOffer(function (offerDesc) {
  104. grepSDP(offerDesc.sdp);
  105. rtc.setLocalDescription(offerDesc);
  106. }, function (e) { console.warn("offer failed", e); });
  107. var addrs = Object.create(null);
  108. addrs["0.0.0.0"] = false;
  109. function updateDisplay(newAddr) {
  110. if (newAddr in addrs) return;
  111. else addrs[newAddr] = true;
  112. var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
  113. document.getElementById('list').textContent = displayAddrs.join(" or perhaps ") || "n/a";
  114. }
  115. function grepSDP(sdp) {
  116. var hosts = [];
  117. sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
  118. if (~line.indexOf("a=candidate")) { // http://tools.ietf.org/html/rfc4566#section-5.13
  119. var parts = line.split(' '), // http://tools.ietf.org/html/rfc5245#section-15.1
  120. addr = parts[4],
  121. type = parts[7];
  122. if (type === 'host') updateDisplay(addr);
  123. } else if (~line.indexOf("c=")) { // http://tools.ietf.org/html/rfc4566#section-5.7
  124. var parts = line.split(' '),
  125. addr = parts[2];
  126. updateDisplay(addr);
  127. }
  128. });
  129. }
  130. })(); else {
  131. document.getElementById('list').innerHTML = "<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>";
  132. document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";
  133. //Callback to next function
  134. }
  135. }
  136. </script>
  137. </body></html>