summaryrefslogtreecommitdiff
path: root/kpov_judge
diff options
context:
space:
mode:
authorgasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-11-01 22:03:39 +0000
committergasperfele@fri1.uni-lj.si <gasperfele@fri1.uni-lj.si@5cf9fbd1-b2bc-434c-b4b7-e852f4f63414>2015-11-01 22:03:39 +0000
commitc861903f376fa38dd7981405cc2980557b325bb5 (patch)
treee84adf10b3af038358573d33ea25a2f638a41f24 /kpov_judge
parent5bbc36ca551dfb1167469e9e24a000e53f7bc4d9 (diff)
Added task.
git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@347 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414
Diffstat (limited to 'kpov_judge')
-rw-r--r--kpov_judge/tasks/mock_entrance_exam/task.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/kpov_judge/tasks/mock_entrance_exam/task.py b/kpov_judge/tasks/mock_entrance_exam/task.py
index 8a0f80f..6aa2144 100644
--- a/kpov_judge/tasks/mock_entrance_exam/task.py
+++ b/kpov_judge/tasks/mock_entrance_exam/task.py
@@ -152,13 +152,15 @@ def task(student_IP, net_prog_name,
def gen_params(user_id, params_meta):
import random
- r = random.Random(user_id)
+ r = random.Random(user_id+'evil cornholio')
params = kpov_random_helpers.default_gen(user_id, params_meta)
homedir = '/home/student/'
params['env_c'] = "".join([r.choice('ABCDEFGHIJKLMNPRSTUVZ') for i in xrange(5)])
params['P_c'] = "".join([r.choice('abcdefghijklmnoprst') for i in xrange(5)]) + ".c"
params['param_gen_seed'] = str(r.randint(0, 2**24))
params['c_destroy_gen_seed'] = str(r.randint(0, 2**24))
+ dest_net = kpov_random_helpers.IPv4_subnet_gen(r, '10.0.2.128/26', 26)
+ params['student_IP'] = kpov_random_helpers.IPv4_addr_gen(r, dest_net)[0]
for k in ['P_c', 'P_executable', 'out_stderr_c', 'P_script', 'out_stdout_c']:
params[k] = homedir + params[k]
return params
@@ -246,13 +248,13 @@ int main(int argc, char **argv){
for (i = 0; i<100; i++){
printf("%c", 32 + (arg[i % arg_len] ^ var[i % env_len]) % 64);
r += (int)arg[i % arg_len] + (int)var[i % env_len] + i;
- if (i % 20 == 0){
+ if (i % 17 == 0){
printf("RAUS\\n");
}
- if (i % 31 == 0){
+ if (i % 29 == 0){
printf("ma");
}
- fprintf(stderr, "%c", (r % 32) + 'A');
+ fprintf(stderr, "%c", (r % 31) + 'A');
if (i % 23 == 0){
fprintf(stderr, "PATACIS\\n");
}
@@ -262,13 +264,13 @@ int main(int argc, char **argv){
return r % 16;
}
'''
- evil_shell_source = """#!/bin/sh
-while true; do
- ifconfig eth1 10.0.2.19;
- ifconfig eth0 10.0.2.20;
- ifconfig eth2 10.0.2.21;
+ evil_shell_source = """#!/bin/bash -e
+{ while true; do
+ ifconfig eth1 10.0.4.19 2> /dev/null;
+ ifconfig eth0 10.0.4.20 2> /dev/null;
+ ifconfig eth2 10.0.4.21 2> /dev/null;
sleep 10;
-done
+done; }&
"""
import random
d = templates['student-entrance']
@@ -285,12 +287,13 @@ done
destroyed_c_source += c
d.write(params['P_c'], destroyed_c_source)
d.chown(1000, 1000, params['P_c'])
- sh_path ='/usr/local/bin/' + params['net_prog_name']
- d.write(sh_path, evil_shell_source)
- d.chmod(0775, sh_path)
+ sh_path = r.choice(['/usr/share/doc', '/var/lib', '/usr/local/share', '/etc/alternatives'])
+ sh_file = sh_path + '/' + params['net_prog_name']
+ d.write(sh_file, evil_shell_source)
+ d.chmod(0775, sh_file)
d.write("/etc/rc.local", """#!/bin/sh -e
-
+export PATH=$PATH:{}
{} &
exit 0
-""".format(sh_path))
+""".format(sh_path, params['net_prog_name']))