From 4d9c902970c275d7eec39ef0c44cc1b611a09122 Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 11:25:22 +0100 Subject: more checks for string issues --- tools/boca-submit-run-root-wrapper.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/boca-submit-run-root-wrapper.c b/tools/boca-submit-run-root-wrapper.c index 6e8ca66..94ba282 100644 --- a/tools/boca-submit-run-root-wrapper.c +++ b/tools/boca-submit-run-root-wrapper.c @@ -2,10 +2,26 @@ #include #include #include -char str[10000]; +char str[3000]; +char *clean(char *s) { + int i; + if(s[0]=='"') s++; + for(i=0; i < 299 && s[i]; ++i) { + if(s[i] == '"' || + s[i] == '\\' || + s[i] == '$' || + s[i] == '`') { + if(s[i+1] == 0) s[i]=0; + else s[i]='_'; + } + } + if(i >= 299) s[i]=0; + return s; +} int main(int argc, char **argv) { if(argc != 8) return 1; - sprintf(str,"/usr/bin/boca-submit-run-root %1000s %1000s %1000s %1000s %1000s %1000s %1000s",argv[1],argv[2],argv[3],argv[4],argv[5],argv[6],argv[7]); + sprintf(str,"/usr/bin/boca-submit-run-root \"%300s\" \"%300s\" \"%300s\" \"%300s\" \"%300s\" \"%300s\" \"%300s\"", + clean(argv[1]),clean(argv[2]),clean(argv[3]),clean(argv[4]),clean(argv[5]),clean(argv[6]),clean(argv[7])); setuid(0); system(str); return 0; -- cgit v1.2.3 From cb1fdb34041d04490a30712464c5e2e05ac78429 Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 11:32:32 +0100 Subject: more checks to strings --- tools/boca-submit-run-root | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/boca-submit-run-root b/tools/boca-submit-run-root index 0fac460..0ae0b39 100755 --- a/tools/boca-submit-run-root +++ b/tools/boca-submit-run-root @@ -42,12 +42,18 @@ if [ "$7" != "" ]; then chmod 700 /root/submissions nom=/root/submissions/`date +%s%N`.bocarun.tmp - echo "BOCASERVER=`echo $1 | tr -cd '[[:alnum:]]._+-/'`" > "$nom" - echo "user=`echo $2 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" - echo "pass=`echo $3 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" - echo "problem=`echo $4 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" - echo "language=`echo $5 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" - echo "name=`echo $6 | tr -cd '[[:alnum:]]._+-/'`" >> "$nom" + tmpvar=`echo "$1" | tr -cd '[[:alnum:]]._+-/'` + echo "BOCASERVER=$tmpvar" > "$nom" + tmpvar=`echo "$2" | tr -cd '[[:alnum:]]._+-/'` + echo "user=$tmpvar" >> "$nom" + tmpvar=`echo "$3" | tr -cd '[[:alnum:]]._+-/'` + echo "pass=$tmpvar" >> "$nom" + tmpvar=`echo "$4" | tr -cd '[[:alnum:]]._+-/'` + echo "problem=$tmpvar" >> "$nom" + tmpvar=`echo "$5" | tr -cd '[[:alnum:]]._+-/'` + echo "language=$tmpvar" >> "$nom" + tmpvar=`echo "$6" | tr -cd '[[:alnum:]]._+-/'` + echo "name=$tmpvar" >> "$nom" echo -en "data=\"" >> "$nom" uuencode -m zzzzzzzzzz < `echo -n "$7" | tr -cd '[[:alnum:]]._+-/'` | grep -v "begin-base64.*zzzzzzzzzz" >> "$nom" echo "\"" >> "$nom" -- cgit v1.2.3 From cc3aa973b6bc448bd52d1f6bfb9e9613c4dfbfdd Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 11:44:16 +0100 Subject: further checks --- tools/boca-submit-run-root | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/boca-submit-run-root b/tools/boca-submit-run-root index 0ae0b39..3bba4aa 100755 --- a/tools/boca-submit-run-root +++ b/tools/boca-submit-run-root @@ -62,7 +62,11 @@ if [ "$7" != "" ]; then # uniq=`date +%sN`-`sha256sum "$7"` # uniq=`echo $uniq | sha256sum - | cut -f1 -d' '` uniq=`sha256sum "$7" | cut -f1 -d' '` - code=`cat /root/submissions/code` + code=`cat /root/submissions/code 2>/dev/null` + if [ "$code" == "" ]; then + echo "ERROR: this computer is not configured to submit runs" + exit 1 + fi comp="error" if [ -r /root/submissions/comp ]; then comp=`cat /root/submissions/comp` -- cgit v1.2.3 From 5513df3ed8ce07ae9516d834c4ac176d5bfc0cf2 Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 12:00:11 +0100 Subject: fixes to code submission distribution --- tools/boca-auth-runs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/boca-auth-runs b/tools/boca-auth-runs index c03fc4f..821202f 100755 --- a/tools/boca-auth-runs +++ b/tools/boca-auth-runs @@ -26,17 +26,17 @@ for i in wget sha256sum cut; do done temp=/tmp/.temp.`date +%s%N`.txt -md=`wget -t 2 -T 5 -S http://$BOCASERVER/boca/getcode.php -O /dev/null --save-cookies ${temp}.cookie.txt --keep-session-cookies 2>&1 | grep PHPSESS | tail -n1` +md=`wget -t 2 -T 7 -S http://$BOCASERVER/boca/getcode.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';'` ress=`echo -n $pass | sha256sum - | cut -f1 -d' '` res=`echo -n "${ress}${md}" | sha256sum - | cut -f1 -d' '` - wget -t 2 -T 5 "http://$BOCASERVER/boca/getcode.php?name=${user}&password=${res}" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O $temp 2>/dev/null >/dev/null + wget -t 2 -T 15 "http://$BOCASERVER/boca/getcode.php?name=${user}&password=${res}" --load-cookies ${temp}.cookie.txt --keep-session-cookies --save-cookies ${temp}.cookie.txt -O $temp 2>/dev/null >/dev/null grep -qi incorrect $temp if [ $? == 0 ]; then echo "" - echo "$BOCASERVER: User or password incorrect" + echo "$BOCASERVER: User or password incorrect, or unconfigured server" rm -f $temp rm -f ${temp}.cookie.txt exit 3 -- cgit v1.2.3 From 64295ec40df409db908c6ccc7fe748b0c893c84f Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 12:13:06 +0100 Subject: option to give server address --- tools/boca-auth-runs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/boca-auth-runs b/tools/boca-auth-runs index 821202f..0e1a866 100755 --- a/tools/boca-auth-runs +++ b/tools/boca-auth-runs @@ -10,9 +10,13 @@ if [ "$BOCASERVER" == "" ]; then fi user="$1" if [ "$user" == "" ]; then - echo "parameter user missing" + echo "parameter user missing. Usage: $0 []" exit 1 fi +if [ "$2" != "" ]; then + BOCASERVER=$2 +fi +echo "Server at $BOCASERVER" read -s -p "Password: " pass for i in wget sha256sum cut; do -- cgit v1.2.3 From 691ea427023510ade5eac9a4594d1abf40164053 Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 12:34:25 +0100 Subject: examples of setting codes --- tools/control-machines.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tools/control-machines.sh (limited to 'tools') 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 -- cgit v1.2.3 From 5592a6c28bdf04165d60a9579f70f9c63fc830ca Mon Sep 17 00:00:00 2001 From: Cassio de Campos Date: Fri, 4 Aug 2017 12:38:05 +0100 Subject: bf --- tools/boca-submit-run-root | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/boca-submit-run-root b/tools/boca-submit-run-root index 3bba4aa..eb2528f 100755 --- a/tools/boca-submit-run-root +++ b/tools/boca-submit-run-root @@ -64,12 +64,13 @@ if [ "$7" != "" ]; then uniq=`sha256sum "$7" | cut -f1 -d' '` code=`cat /root/submissions/code 2>/dev/null` if [ "$code" == "" ]; then - echo "ERROR: this computer is not configured to submit runs" + echo "ERROR: this computer is not configured to submit runs -- code missing" exit 1 fi - comp="error" - if [ -r /root/submissions/comp ]; then - comp=`cat /root/submissions/comp` + comp=`cat /root/submissions/comp 2>/dev/null` + if [ "$comp" == "" ]; then + echo "ERROR: this computer is not configured to submit runs -- comp missing" + exit 1 fi res=`echo -n "${code}${uniq}${comp}${dateerr}" | sha256sum - | cut -f1 -d' '` echo "uniq=$uniq" >> "$nom" -- cgit v1.2.3