-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |