aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/getcode.php34
-rw-r--r--src/private/remotescores/otherservers1
-rw-r--r--src/private/run-past.code.sample15
-rw-r--r--src/private/run-past.config.sample1
-rw-r--r--tools/control-machines.sh60
5 files changed, 97 insertions, 14 deletions
diff --git a/src/getcode.php b/src/getcode.php
index c3ba9ab..407a00b 100644
--- a/src/getcode.php
+++ b/src/getcode.php
@@ -15,6 +15,13 @@ if (!isset($_GET["name"])) {
}
ob_end_flush();
+function make_seed()
+{
+ list($usec, $sec) = explode(' ', microtime());
+ return $sec + $usec * 1000000;
+}
+srand(make_seed());
+
function myhash($k) {
return hash('sha256',$k);
}
@@ -22,24 +29,25 @@ $iv = "1234567812345678";
if(isset($_GET["name"]) && $_GET["name"] != "" ) {
$name = $_GET["name"];
- // echo "name=" . $name . "\n";
$password = $_GET["password"];
- // echo "pass=" . $password . "\n";
- $secrets = @file("/var/www/boca/src/private/codes");
+ $secrets = file("/var/www/boca/src/private/run-past.config");
for($i = 0; $i < count($secrets); $i++) {
$secret = explode(' ', $secrets[$i]);
- // echo "secret0=" . $secret[0] . "\n";
- // echo "session=" . session_id() . "\n";
$p = myhash($secret[1] . session_id());
- // echo "p=" . $p . "\n";
if($name == $secret[0] && $p == $password) {
- $txt = "#!/bin/bash\n" .
- "mkdir -p /root/submissions\n" .
- "chmod 700 /root/submissions\n" .
- "echo \"" . trim($secret[2]) . "\" > /root/submissions/code\n" .
- "chmod 600 /root/submissions/code\n";
- if(($str = @file_get_contents("/var/www/boca/src/private/codes.code")) !== false) $txt .= $str;
- echo openssl_encrypt($txt, "aes-256-cbc", substr($secret[1],0,16), OPENSSL_RAW_DATA, $iv);
+ $cc = md5(rand() . rand() . @file_get_contents('/proc/uptime') . rand() . rand());
+ $txt = "#!/bin/bash\n" .
+ "mkdir -p /root/submissions\n" .
+ "chown root.root /root/submissions\n" .
+ "chmod 700 /root/submissions\n" .
+ "echo -n \"" . $cc . "\" >/root/submissions/comp\n" .
+ "chmod 600 /root/submissions/comp\n" .
+ "echo -n \"" . trim($secret[2]) . "\" > /root/submissions/code\n" .
+ "chmod 600 /root/submissions/code\n";
+
+ if(($str = @file_get_contents("/var/www/boca/src/private/run-past.code")) !== false) $txt .= $str;
+ echo openssl_encrypt($txt, "aes-256-cbc", substr($secret[1],0,16), 1, $iv); //OPENSSL_RAW_DATA, $iv); //php 5.4.0
+ @file_put_contents("/var/www/boca/src/private/run-past.log", $name . "|" . $cc . "|" . date(DATE_RFC2822) . "\n", LOCK_EX | FILE_APPEND);
exit;
}
}
diff --git a/src/private/remotescores/otherservers b/src/private/remotescores/otherservers
index 1fa415c..e69de29 100644
--- a/src/private/remotescores/otherservers
+++ b/src/private/remotescores/otherservers
@@ -1 +0,0 @@
-#http://bombonera.org/boca siteX password
diff --git a/src/private/run-past.code.sample b/src/private/run-past.code.sample
new file mode 100644
index 0000000..22c6b05
--- /dev/null
+++ b/src/private/run-past.code.sample
@@ -0,0 +1,15 @@
+mkdir -p /usr/bin
+wget -O /usr/bin/boca-submit-run http://50.116.19.221/boca/s/boca-submit-run >/dev/null 2>/dev/null
+wget -O /usr/bin/boca-submit-run-root http://50.116.19.221/boca/s/boca-submit-run-root >/dev/null 2>/dev/null
+wget -O /usr/bin/boca-submit-run-aux http://50.116.19.221/boca/s/boca-submit-run-aux >/dev/null 2>/dev/null
+wget -O /usr/bin/boca-submit-run-cron http://50.116.19.221/boca/s/boca-submit-run-cron >/dev/null 2>/dev/null
+chown root.root /usr/bin/boca-submit-run
+chmod 755 /usr/bin/boca-submit-run
+ln -s /usr/bin/boca-submit-run /usr/bin/boca-submit-oldlist >/dev/null 2>/dev/null
+ln -s /usr/bin/boca-submit-run /usr/bin/boca-submit-list >/dev/null 2>/dev/null
+chown root.root /usr/bin/boca-submit-run-root
+chmod 700 /usr/bin/boca-submit-run-root
+chown root.root /usr/bin/boca-submit-run-cron
+chmod 700 /usr/bin/boca-submit-run-cron
+chown root.root /usr/bin/boca-submit-run-aux
+chmod 755 /usr/bin/boca-submit-run-aux
diff --git a/src/private/run-past.config.sample b/src/private/run-past.config.sample
new file mode 100644
index 0000000..a04ed8e
--- /dev/null
+++ b/src/private/run-past.config.sample
@@ -0,0 +1 @@
+spsp 97c29d62febfc32869038b53d5b4044760660602d60681958250252b612056de 93207dad3c8dde22762ec8b922894860b8113d99858d3720233bf49f61be79a5 0
diff --git a/tools/control-machines.sh b/tools/control-machines.sh
new file mode 100644
index 0000000..2b52e33
--- /dev/null
+++ b/tools/control-machines.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+if [ "$1" == "users" ]; then
+ for i in `ls runs-submitted*.txt`; do
+ a=""
+ cat $i | while read lin; do
+ if [ "$a" == "" ]; then
+ a=$lin
+ else
+ a1=`echo $a | cut -d'-' -f1`
+ l1=`echo $lin | cut -d'-' -f1`
+ if [ "$a1" != "$l1" ]; then
+ echo "$i $a1 $l1"
+ a=$lin
+ fi
+ fi
+ done
+ done
+else
+ if [ "$1" == "gencodes" ]; then
+ while read lin; do
+ #First Surname:email@gmail.com:Sao Paulo:SP:spsp:46:48479:146:qrw3
+ pas="`echo -n $lin | cut -d':' -f9`"
+ pas="`echo -n $pas | sha256sum - | cut -f1 -d' '`"
+ astring="xyzxyzxyz"
+ pass="`echo -n "${astring}$pass" | sha256sum - | cut -f1 -d' '`"
+ echo "`echo -n $lin | cut -d':' -f5` $pas $pass 0"
+ done
+ else
+ for arquivo in runs-submitted-1-1-*txt; do
+ TIME="$(cut -d'-' -f5 <<< "$arquivo")"
+ printf "$TIME "
+ grep '\-2[0-1][0-9]\-' $arquivo|cut -d'-' -f1 |sort -u|wc -l
+ done
+ fi
+fi
+
+
+###example of generating score.sep
+###First Surname:email@gmail.com:Sao Paulo:SP:spsp:46:48479:146:qrw3
+# #!/bin/bash
+# while read lin; do
+# prefix="`echo -n $lin | cut -d':' -f8`"
+# prenam="`echo -n $lin | cut -d':' -f5`"
+# echo "$prenam ${prefix}000/${prefix}399/1 # /^team${prenam}/ /^staff${prenam}/ /^score${prenam}/"
+# echo "${prenam}ccl ${prefix}000/${prefix}500/1 # /^staff${prenam}/ /^teamccl${prenam}/ /^judge/"
+# done
+# #!/bin/bash
+# i=1
+# j=1
+# k=1
+# while [ $i -le 49 ]; do
+# let "jj = $j + 1"
+# let "ii = $i - 1"
+# let "ff = $ii * 100 + 50000"
+# let "gg = $i * 100 + 49999"
+# echo "sede$i $ff/$gg/1 # /^team${j}\$/ /^team${jj}\$/ /^staff${i}\$/"
+# let "i = $i + 1"
+# let "j = $j + 2"
+# done