From c8994053b1ff9ccf47b532be6567c0f7f33f5f3c Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 24 Aug 2018 21:08:09 +0200 Subject: fixed typos, back some required files --- tools/boca-submit-log | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/cron-boca-fixssh | 1 + tools/cron-boca-log | 1 + tools/cron-boca-submit | 1 + tools/tst.php | 11 --------- 5 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 tools/boca-submit-log create mode 100644 tools/cron-boca-fixssh create mode 100644 tools/cron-boca-log create mode 100644 tools/cron-boca-submit delete mode 100644 tools/tst.php (limited to 'tools') diff --git a/tools/boca-submit-log b/tools/boca-submit-log new file mode 100644 index 0000000..836225e --- /dev/null +++ b/tools/boca-submit-log @@ -0,0 +1,66 @@ +#!/bin/bash + +if [ "`id -u`" != "0" ]; then + echo "Must be run as root" + exit 1 +fi +if [[ ! -e /etc/bocaip ]] ; then + BOCASERVER=50.116.19.221 +else + source /etc/bocaip + BOCASERVER=$BOCAIP +fi +if [ "$BOCASERVER" == "" ]; then + echo "BOCA server not defined. Aborting" + exit 1 +fi + +for zcount in 1 2 3 4 5 6; do + +grep "session opened for user root" /var/log/auth.log |grep -v cron:session | grep -v systemd:session | tail -n 100 > /root/.logroot.tmp +[ -f /root/.logroot ] || touch /root/.logroot +diff /root/.logroot /root/.logroot.tmp > /root/.logroot.diff 2>/dev/null +res=$? +if [ "$res" != "0" ]; then + for i in uuencode wget tr perl sha256sum cut; do + p=`which $i` + if [ -x "$p" ]; then + echo -n "" + else + echo "$i" not found + exit 1 + fi + done + temp=/root/.temp.`date +%s%N`.txt + md=`wget -4 --no-check-certificate -t 2 -T 5 -S https://$BOCASERVER/boca/logexternal.php -O /dev/null --save-cookies ${temp}.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1` + echo "$md" | grep -q PHPSESS + if [ "$?" == "0" ]; then + md=`echo $md | cut -f2 -d'=' | cut -f1 -d';'` + res=`cat /root/submissions/code 2>/dev/null` + res=`echo -n "${res}${md}" | sha256sum - | cut -f1 -d' '` + + echo -n "comp=`cat /root/submissions/comp`" > $temp + echo -n "&code=$res" >> $temp + echo -n "&data=" >> $temp + grep "^>" /root/.logroot.diff | uuencode -m zzzzzzzzzz | grep -v "begin-base64.*zzzzzzzzzz" | perl -MURI::Escape -lne 'print uri_escape($_)' >> $temp + + wget -4 --no-check-certificate -t 2 -T 5 "https://$BOCASERVER/boca/logexternal.php" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O ${temp}.out --post-file=$temp >/dev/null 2>/dev/null + rm -f $temp + rm -f ${temp}.cookie.txt + grep -qi incorrect ${temp}.out + res=$? + rm ${temp}.out + if [ "$res" == "0" ]; then + echo "$BOCASERVER: User or password incorrect" + exit 3 + fi + else + echo "$BOCASERVER: connection failed" + exit 2 + fi +fi +mv /root/.logroot.tmp /root/.logroot +[ "$zcount" == "6" ] || sleep 8 +done + +exit 0 diff --git a/tools/cron-boca-fixssh b/tools/cron-boca-fixssh new file mode 100644 index 0000000..ac7b597 --- /dev/null +++ b/tools/cron-boca-fixssh @@ -0,0 +1 @@ +* * * * * root /usr/sbin/boca-fixssh >>/var/log/boca-fixssh.out 2>>/var/log/boca-fixssh.err diff --git a/tools/cron-boca-log b/tools/cron-boca-log new file mode 100644 index 0000000..d1a27bc --- /dev/null +++ b/tools/cron-boca-log @@ -0,0 +1 @@ +* * * * * root /usr/sbin/boca-submit-logroot >>/var/log/boca-submit-logroot.out 2>>/var/log/boca-submit-logroot.err diff --git a/tools/cron-boca-submit b/tools/cron-boca-submit new file mode 100644 index 0000000..5fda786 --- /dev/null +++ b/tools/cron-boca-submit @@ -0,0 +1 @@ +*/2 * * * * root /usr/bin/boca-submit-run-cron >>/var/log/bocacron.out 2>>/var/log/bocacron.err diff --git a/tools/tst.php b/tools/tst.php deleted file mode 100644 index 38f5fd0..0000000 --- a/tools/tst.php +++ /dev/null @@ -1,11 +0,0 @@ - -- cgit v1.2.3