Skip to content

Commit

Permalink
Add statis resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Virv12 committed Oct 17, 2024
1 parent 5fbfc0f commit d4dc6da
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 0 deletions.
103 changes: 103 additions & 0 deletions public/check/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!--
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
WARNING!
Questa pagina viene fornita per verificare ***lato client*** l'effettivo
blocco di internet. Non serve a niente tentare di modificare questo script,
perche' il controllo ***effettivo*** viene eseguito in automatico durante
la gara ***lato server***.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-->

<html>
<style>
body {
font-family: sans-serif;
font-size: xx-large;
}
</style>

<script>

function display_failed() {
document.getElementById("esito").innerHTML = "fallito";
document.body.style.backgroundColor = "darkred";
}

function display_passed() {
document.getElementById("esito").innerHTML = "superato";
document.body.style.backgroundColor = "green";
}

var blocked = 0;
function one_more_blocked() {
blocked++;
document.getElementById("successful-tests").innerHTML = blocked;
if (blocked == tests.length)
display_passed();
}


function do_test(target_url, json_field) {
var xhr = new XMLHttpRequest();
xhr.open('GET', target_url + '?nocache=' + (Math.random()).toString().replace('.',''));
xhr.timeout = 15000;
xhr.onload = function() {
var res_json = JSON.parse(xhr.response);
if (res_json[json_field].length > 0)
display_failed();
else
one_more_blocked();
}
xhr.ontimeout = function() {
one_more_blocked();
}
xhr.onerror = function() {
one_more_blocked();
}
xhr.send();
}

var tests = [
["https://jsonplaceholder.typicode.com/posts/1", "body"],
["https://httpbin.org/get", "url"],
["https://reqres.in/api/users", "data"],
["https://training.olinfo.it/ois-internet-check", "asd"]
];

tests.forEach(function(test) {
do_test(test[0], test[1]);
});

</script>

<noscript>
<style>
body {
background-color: darkred !important;
}
</style>
</noscript>

<body>
<h1>Test internet:</h1>

<h1 id="esito">(in corso...)</h1>

<a style="color: gold" href="/resources/guida.pdf">Guida in PDF su come disabilitare internet</a>

<br><br><hr>
Version of this checker: <b>4</b> <br>
Current UTC datetime: <b><span id="datetime"></span></b> <br>
Successful tests: <b><span id="successful-tests">0</span>/4</b> <br>
User agent: <b><span id="useragent"></span></b> <br>
</body>

<script>
document.getElementById("datetime").innerHTML = (new Date()).toUTCString();
document.getElementById("useragent").innerHTML = navigator.userAgent;
</script>
<html>

Binary file added public/resources/bugatti.pdf
Binary file not shown.
Binary file added public/resources/guida.pdf
Binary file not shown.
Binary file added public/resources/informativa_gdpr.pdf
Binary file not shown.
Binary file added public/resources/informativa_referenti.pdf
Binary file not shown.
Binary file added public/resources/informativa_scuole.pdf
Binary file not shown.
Binary file added public/resources/informativa_studenti.pdf
Binary file not shown.
20 changes: 20 additions & 0 deletions public/resources/lock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh -e

WS="159.149.129.94"
DOMAIN="gara.squadre.olinfo.it"

IPTABLES="/sbin/iptables"

$IPTABLES -P INPUT DROP
$IPTABLES -P OUTPUT DROP
$IPTABLES -P FORWARD DROP

$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT

$IPTABLES -A OUTPUT -d $WS -p tcp -j ACCEPT

$IPTABLES -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

echo $WS $DOMAIN >> /etc/hosts
Binary file added public/resources/regolamento.pdf
Binary file not shown.
Binary file added public/resources/syllabus.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions public/resources/unlock.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh -e

WS="159.149.129.94"
DOMAIN="squadre.olinfo.it" # usiamo vecchio dominio per retrocompatibilita'
# tanto sed cancella lo stesso la cosa giusta

IPTABLES="/sbin/iptables"

$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F
$IPTABLES -X

sed -i "/$DOMAIN/d" /etc/hosts

0 comments on commit d4dc6da

Please sign in to comment.