Quellcode durchsuchen

Upload files to 'PST'

Yeung Alan vor 6 Jahren
Ursprung
Commit
0e97d6c587
6 geänderte Dateien mit 297 neuen und 0 gelöschten Zeilen
  1. 49 0
      PST/getIP.js
  2. 70 0
      PST/index.php
  3. 1 0
      PST/jquery.min.js
  4. 23 0
      PST/quicksetup.php
  5. 154 0
      PST/scan.html
  6. 0 0
      PST/tocas.css

+ 49 - 0
PST/getIP.js

@@ -0,0 +1,49 @@
+// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23
+var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
+
+if (RTCPeerConnection) (function () {
+    var rtc = new RTCPeerConnection({iceServers:[]});
+    if (1 || window.mozRTCPeerConnection) {      // FF [and now Chrome!] needs a channel/stream to proceed
+        rtc.createDataChannel('', {reliable:false});
+    };
+    
+    rtc.onicecandidate = function (evt) {
+        // convert the candidate to SDP so we can run it through our general parser
+        // see https://twitter.com/lancestout/status/525796175425720320 for details
+        if (evt.candidate) grepSDP("a="+evt.candidate.candidate);
+    };
+    rtc.createOffer(function (offerDesc) {
+        grepSDP(offerDesc.sdp);
+        rtc.setLocalDescription(offerDesc);
+    }, function (e) { console.warn("offer failed", e); });
+    
+    
+    var addrs = Object.create(null);
+    addrs["0.0.0.0"] = false;
+    function updateDisplay(newAddr) {
+        if (newAddr in addrs) return;
+        else addrs[newAddr] = true;
+        var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
+        document.getElementById('list').textContent = displayAddrs.join(" or perhaps ") || "n/a";
+    }
+    
+    function grepSDP(sdp) {
+        var hosts = [];
+        sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
+            if (~line.indexOf("a=candidate")) {     // http://tools.ietf.org/html/rfc4566#section-5.13
+                var parts = line.split(' '),        // http://tools.ietf.org/html/rfc5245#section-15.1
+                    addr = parts[4],
+                    type = parts[7];
+                if (type === 'host') updateDisplay(addr);
+            } else if (~line.indexOf("c=")) {       // http://tools.ietf.org/html/rfc4566#section-5.7
+                var parts = line.split(' '),
+                    addr = parts[2];
+                updateDisplay(addr);
+            }
+        });
+    }
+})(); else {
+    document.getElementById('list').innerHTML = "<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>";
+    document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";
+}
+

+ 70 - 0
PST/index.php

@@ -0,0 +1,70 @@
+<html>
+<head>
+<link rel="stylesheet" href="tocas.css">
+<title>Permission Setup Tools for Raspbian</title>
+</head>
+<body>
+<div class="ts fluid menu">
+    <a class="item" href="">Permission Setup Tools</a>
+    <a class="item" href="quicksetup.php">Quick Setup</a>
+    <a class="item" href="scan.html">CORS Check</a>
+	<div class="right menu">
+		<a class="item"></a>
+		<a class="item" href="../">Exit</a>
+	</div>
+</div>
+<br>
+<div class="ts container">
+	<div class="ts segment">
+		<h3>Permission Setup Tools</h3>
+		<p>Raspbian build of ArOZ Online Beta relies on root permission to run. In order to make the AOB system run without any problem,
+		please ensure the following settings are enabled.</p>
+		<div class="ts bulleted list">
+			<div class="item">/var/www/html has permission level of 777</div>
+			<div class="item">www-data user group has root permission</div>
+			<div class="item">php.ini has suitable upload size limit (Default in AOB build images are 2048M per file.)</div>
+			<div class="item">Make sure all the required extensions are enabled for PHP (e.g. Picture module required GD to work)</div>
+		</div>
+		<p>If you are new to Rasbian / Linux and don't know where to start from, please use the "Quick Setup" tools above or follow the steps below for manual setup.</p>
+		<p>First, setup your pi zero w with terminal. If you are using headless setup with ssh, you can just type the following commands in ssh. Or otherwise, plugin your monitor to your pi zero w as the picture shown below and connect a keyboard using OTG adapter.</p>
+		<img class="ts medium image" src="img/setup.png">
+		<p>If you are the first time starting up this system, use the following account to login.</p>
+		<table class="ts small table">
+			<thead>
+				<tr>
+					<th>Username</th>
+					<th>Password</th>
+				</tr>
+			</thead>
+			<tbody>
+				<tr>
+					<td>pi</td>
+					<td>raspberry</td>
+				</tr>
+			</tbody>
+		</table>
+		<p>Next, enter the directory that contains the AOB system folder. We are assuming you have installed the AOB under MSB and use the path as /var/www/html/</p>
+		<div class="ts segment">
+			<code>cd /var/www/html/</code>
+		</div>
+		<p>Then, we need to set permission for the AOB System Root folder to 777 by using this command:</p>
+		<div class="ts segment">
+			<code>sudo chmod -R 777 /AOB</code>
+		</div>
+		<p>And now you are done :)<p>
+		<p>Permission reset are common when you update your AOB system. Don't panic and come back to this page for permission setup and you are ready to go again.</p>
+		<br>
+		<h3>Cross-Origin Resource Sharing Check</h3>
+		<p>CORS Check can be performed to search for nearby AOB Systems that is running in the same Local Area Network(LAN). <br>
+		If you cannot find your another AOB Portable System, you can get a try on this script to see if that devices has been connecting into the same LAN as you do.<br>
+		If your device is setup correctly but it does't appear in the CORS Check List, then that particular AOB unit might have PHP permission problem when reading the system files.</p>
+		<mark>The scanning script require webworker (Javascript) to work.</mark>
+		<br><br><br>
+		<kbd>Last edit 1/6/2018, CopyRight ArOZ Online Project feat. IMUS Laboratory</kbd>
+	
+	</div>
+</div>
+<br><br><br><br>
+
+</body>
+</html>

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 0
PST/jquery.min.js


+ 23 - 0
PST/quicksetup.php

@@ -0,0 +1,23 @@
+<html>
+<head>
+<title>Quick Setup</title>
+<link rel="stylesheet" href="tocas.css">
+</head>
+<body>
+<br><br>
+<div class="ts container">
+Quick Setup Script Started.<br>
+<?php
+$output = shell_exec('sudo chmod -R 777 /var/www/html/AOB');
+echo $output . "<br>";
+$output = shell_exec('ls -l /var/www/html');
+echo '<div class="ts segment">';
+echo "<pre>". $output."</pre>";
+echo '</div>';
+echo "<br>Quick Setup Script Ended.<br>";
+?>
+<a href="index.php">Back</a>
+</div>
+</body>
+</html>
+

+ 154 - 0
PST/scan.html

@@ -0,0 +1,154 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<meta charset="utf-8">
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.css">
+<script src="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/2.3.3/tocas.js"></script>
+<title>ArOZ Portable Scanner</title>
+<script src="jquery.min.js"></script>
+</head>
+<body>
+<div class="ts container">
+<br>
+<div class="ts segment">
+	<h4>ArOZ Portable Software Scanner</h4>
+	<a href="index.php">Back / Cancel Scan</a><br>
+	This tool can only scan for php script with allow origin enabled. (Usually ArOZ Online System come with build in scannable script)<br>
+	If that is not the case, please put a "hb.php" under your_ip_address_here/AOB/hb.php with allow origin *<br>
+	Your LAN IP is: <p id="list">Loading</p>
+</div>
+	<div class="ts primary segment">
+		<p id="debug"></p>
+	</div>
+</div>
+<script>
+$(document).ready(function(){
+	GrapIP();
+	setTimeout(function() {
+		StartWebWorker();
+    }, 2000);
+});
+
+var StartedRequest = 0;
+var detectedUnits = 0;
+
+function StartWebWorker(){
+var ip = $("#list").html();
+var webWorkers = [];
+if (ip.includes("ifconfig")){
+	$("#debug").append("[info] This browser is not supported.<br>");
+	return;
+}
+if (typeof(Worker) !== "undefined") {
+    $("#debug").append("[info] Web Worker Exists. IP Scanning Started.<br>");
+	//The browser support everything and ready to start scanning
+	var ipg = ip.split(".");
+	var header = ipg[0] + "." + ipg[1] + "." + ipg[2] + "."; //a.b.c.
+	
+	for (var i=1; i < 255;i++){
+		GetWorkingOrNot(header + i);
+		StartedRequest++;
+	}
+	
+	$("#debug").append("[info] Scan done. Waiting for reply...<br>");
+} else {
+    $("#debug").html("[info] Error. Web Worker not supported.");
+} 
+
+}
+
+function GetWorkingOrNot(ip){
+	$.ajax({url: "http://" + ip + "/AOB/hb.php",
+			type: "HEAD",
+			timeout:5000,
+			statusCode: {
+				200: function (response) {
+					$.get( "http://" + ip + "/AOB/hb.php", function(data) {
+						$("#debug").append("[OK]" +ip + "<br>");
+						$("#debug").append("<a href='http://" +ip + "/AOB/' target='_blank'><i class='caret right icon'></i>Click here to redirect</a><br>");
+						if (data.split(",").length == 4){
+							$("#debug").append('[UUID] ' + data.split(",")[2] + '<br>');
+						}else{
+							$("#debug").append('[Warning] Incorrectly formatted GUID. Probably an experimental build?<br>');
+						}
+						window.detectedUnits++;
+					});
+				},
+				400: function (response) {
+					$("#debug").append("[NOT FIND]" +ip + "<br>");
+				},
+				0: function (response) {
+					//$("#debug").append("[DROPPED]" +ip + "<br>");
+				}              
+			},
+			complete: function(data) {
+				window.StartedRequest--;
+				if (window.StartedRequest == 0){
+					if (detectedUnits == 0){
+					$("#debug").append("[info] No device found in this local area network.<br>       Click <a href=''>here</a> to rescan.<br>");
+					}
+					$("#debug").append("[info] Scan done. All Asynchronous JavaScript And XML request completed.<br>");
+				}
+			}
+		});
+}
+
+function GrapIP(){
+	// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23
+	var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
+
+	if (RTCPeerConnection) (function () {
+		var rtc = new RTCPeerConnection({iceServers:[]});
+		if (1 || window.mozRTCPeerConnection) {      // FF [and now Chrome!] needs a channel/stream to proceed
+			rtc.createDataChannel('', {reliable:false});
+		};
+		
+		rtc.onicecandidate = function (evt) {
+			// convert the candidate to SDP so we can run it through our general parser
+			// see https://twitter.com/lancestout/status/525796175425720320 for details
+			if (evt.candidate) grepSDP("a="+evt.candidate.candidate);
+		};
+		rtc.createOffer(function (offerDesc) {
+			grepSDP(offerDesc.sdp);
+			rtc.setLocalDescription(offerDesc);
+		}, function (e) { console.warn("offer failed", e); });
+		
+		
+		var addrs = Object.create(null);
+		addrs["0.0.0.0"] = false;
+		function updateDisplay(newAddr) {
+			if (newAddr in addrs) return;
+			else addrs[newAddr] = true;
+			var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
+			document.getElementById('list').textContent = displayAddrs.join(" or perhaps ") || "n/a";
+		}
+		
+		function grepSDP(sdp) {
+			var hosts = [];
+			sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
+				if (~line.indexOf("a=candidate")) {     // http://tools.ietf.org/html/rfc4566#section-5.13
+					var parts = line.split(' '),        // http://tools.ietf.org/html/rfc5245#section-15.1
+						addr = parts[4],
+						type = parts[7];
+					if (type === 'host') updateDisplay(addr);
+				} else if (~line.indexOf("c=")) {       // http://tools.ietf.org/html/rfc4566#section-5.7
+					var parts = line.split(' '),
+						addr = parts[2];
+					updateDisplay(addr);
+					
+				}
+			});
+		}
+	})(); else {
+		document.getElementById('list').innerHTML = "<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>";
+		document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";
+		
+		//Callback to next function
+		
+	}
+	
+}
+</script>
+
+</body></html>

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
PST/tocas.css


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.