From bdea3b3b2ea1c1b830619db402a9b40c214e9c70 Mon Sep 17 00:00:00 2001 From: "gasperfele@fri1.uni-lj.si" Date: Mon, 20 Mar 2017 13:02:20 +0000 Subject: Added first draft of the entrance exam git-svn-id: https://svn.lusy.fri.uni-lj.si/kpov-public-svn/kpov-public@405 5cf9fbd1-b2bc-434c-b4b7-e852f4f63414 --- kpov_judge/courses/fri_kpov/05/preparation | 2 +- .../tasks/edit_find_grep_compile_convert/task.py | 260 ++ kpov_judge/web/kpov_judge/icons/computer.svg | 1877 +++++++++++ kpov_judge/web/kpov_judge/icons/drive-harddisk.svg | 491 +++ kpov_judge/web/kpov_judge/icons/internet.svg | 3398 ++++++++++++++++++++ 5 files changed, 6027 insertions(+), 1 deletion(-) create mode 100644 kpov_judge/tasks/edit_find_grep_compile_convert/task.py create mode 100644 kpov_judge/web/kpov_judge/icons/computer.svg create mode 100644 kpov_judge/web/kpov_judge/icons/drive-harddisk.svg create mode 100644 kpov_judge/web/kpov_judge/icons/internet.svg diff --git a/kpov_judge/courses/fri_kpov/05/preparation b/kpov_judge/courses/fri_kpov/05/preparation index 214ed3a..86fe4ae 120000 --- a/kpov_judge/courses/fri_kpov/05/preparation +++ b/kpov_judge/courses/fri_kpov/05/preparation @@ -1 +1 @@ -../../../tasks/entrance_exam \ No newline at end of file +../../../tasks/edit_find_grep_compile_convert \ No newline at end of file diff --git a/kpov_judge/tasks/edit_find_grep_compile_convert/task.py b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py new file mode 100644 index 0000000..1d7f210 --- /dev/null +++ b/kpov_judge/tasks/edit_find_grep_compile_convert/task.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# TODO: +# - check if everything is filled in (computers, params, preparation) +# - improve scoring +# - test +# - switch to a real SSH/SFTP client to properly handle filenames + + +instructions = { + 'si':u""" +Ustvari dva navidezna računalnika s slikama diskov +- SimpleArbiter s sliko diska simpleArbiterDhcp in +SmallStudent s sliko diska student-entrance2. + +Na SimpleArbiter se lahko prijaviš z uporabniškim imenom tester in geslom test. +Na SmallStudent se lahko prijaviš kot root z geslom kaboom. + +Poskrbi, da bo SmallStudent s SimpleArbiter dostopen na naslovu {testip}. + +Na SmallStudent ustvari uporabnika {testuser} z geslom {pass}. + +Na SmallStudent je nekje v domačem imeniku uporabnika "bilbo" skrita datoteka, ki vsebuje niz {magicstr}. +Skopiraj jo v domači imenik {testuser} in poimenuj {dstfile}. +Poskrbi, da bo lastnik {testuser}, skupina pa naj ostane nespremenjena. +Brati naj jo ima pravico samo lastnik. +V {dstfile} zamenjaj vse vrstice oblike poXYZlz, kjer so XYZ poljubni znaki, tako, da bo namesto XYZ niz "kaka". + +Napiši program v poljubnem programskem jeziku, ki kot argument sprejme število B med 0 in 7. +Program naj prebere znak s standardnega izhoda in izpiše vrstico z nizom "ta", +če je B-ti bit v znaku nastavljen na 1, in "ti" sicer. +Program poimenuj {progname} in ga spravi v domači imenik {testuser}. +""", + 'en': u''' +Create two virtual machines +- SimpleArbiter using simpleArbiterDhcp as the disk image and +SmallStudent using student-entrance2 as its disk. + +You can log in as testr on SimpleArbiter with the password test. +You can log in as root on SimpleStudent with the password kaboom. + +Make sure that SmallStudent is accessible from SimpleArbiter on IP {testip}. + +Create a user {testuser} with the password {pass} on SmallStudent. + +There is a file containing {magicstr} hidden somewhere in the home directory of +user "bilbo". +Copy the into the home directory of user bilbo and name it {dstfile}. +Change the owner to {testuser} and leave the group unchanged. +Make sure only the owner has the right to read it. +In {dstfile}, replace all lines of the form poXYZlz where XYZ are arbitrary characters so that XYZ is replaced by "kaka". + +Write a program in any programming language. +The program should accept a single argument, B, which is a number between 0 and 7. +It should read a character from standard input and output "ta" if B-th bit in this character is +set to 1. If B-th bit is not set, the program should output "ti". +Name the program {progname} and place it in the home directory of {testuser}. +''', +} + +instructions = {'si': 'Potrpite.', 'en': 'Have patience.'} + +computers = { + 'SimpleArbiter': { + 'disks': [ + { + 'name': 'simpleArbiterDhcpGW', + }, + ], + 'network_interfaces': [ + { + 'network': 'net1', + 'network': 'net2', + }, + ], + 'flavor': 'm1.tiny', + 'config_drive': False, + } + 'SmallStudent': { + 'disks': [ + { + 'name': 'student-entrance2', + }, + ], + 'network_interfaces': [ + { + 'network': 'net2', + }, + ], + 'flavor': 'm1.tiny', + 'config_drive': False, + } +} + +networks = { + 'net1': { + 'public': True, + }, + 'net2': { + 'public': False, + } +} + +params_meta = { + 'testip': { + 'descriptions': { + 'si': 'IP SmallStudent', + 'en': 'IP SmallStudent', + }, + 'w': False, + 'public': True, + 'type': 'IP', + 'generated': True, + }, + 'testuser': { + 'descriptions': { + 'si': 'Uporabnik na SmallStudent', + 'en': 'Username on SmallStudent', + }, + 'w': False, + 'public': True, + 'type': 'username', + 'generated': True, + }, + 'pass': { + 'descriptions': { + 'si': 'Geslo na SmallStudent', + 'en': 'Password on SmallStudent', + }, + 'w': False, + 'public': True, + 'type': None, + 'generated': True, + + }, + 'magicstr':{ + 'descriptions': { + 'si': 'Niz v iskani datoteki', + 'en': 'String in the file you need to find', + }, + 'w': False, + 'public': True, + 'type': None, + 'generated': True, + + }, + 'dstfile':{ + 'descriptions': { + 'si': 'Ciljno ime datoteke', + 'en': 'Destination filename', + }, + 'w': False, + 'public': True, + 'type': 'filename', + 'generated': True, + }, + 'progname':{ + 'descriptions': { + 'si': 'Ime programa', + 'en': 'Program filename', + }, + 'w': False, + 'public': True, + 'type': 'filename', + 'generated': True, + }, + 'pubseed':{ + 'descriptions': { + 'si': 'Nekaj nepredvidenega', + 'en': 'A random seed', + }, + 'w': False, + 'public': True, + 'type': None, + 'generated': True, + }, + 'rndseed':{ + 'descriptions': { + 'si': 'random seed za skrito datoteko', + 'en': 'random seed for hiding the file', + }, + 'w': False, + 'public': True, + 'type': None, + 'generated': True, + }, +} + +def task(host, folder): + from pexpect import pxssh + # ideally, this would be done using a SFTP client instead of pxssh + target = pxssh.pxssh() + target.login(host, 'test', 'test') + results = { + 'files': target.run('ls -1').split('\n'), # XXX: file may have newlines + 'contents': target.run("cat *"), # XXX: may include other files in $HOME + } + target.logout() + return results + +def gen_params(user_id, params_meta): + import random + params = dict() + r = random.Random(user_id) + params['testip'] = kpov_random_helpers.IPv4_addr_gen(r, + network = '10.94.80.0/19', n_generated=1)[0] + params['testuser'] = kpov_random_helpers.default_generators['username'](r) + params['pass'] = kpov_random_helpers.alnum_gen(8) + params['magicstr'] = kpov_random_helpers.alnum_gen(8) + params['dstfile'] = kpov_random_helpers.default_generators['filename'](r) + params['progname'] = kpov_random_helpers.default_generators['filename'](r) + while params['dstfile'] == params['progname']: + params['progname'] = kpov_random_helpers.default_generators['filename'](r) + params['pubseed'] = kpov_random_helpers.alnum_gen(8) + params['rndseed'] = kpov_random_helpers.alnum_gen(8) + return params + + +def task_check(results, params): + import os + if rl == tl: + score += 4 + else: + hints += ["wrong files"] + return score, hints + + +def prepare_disks(templates, task_params, global_params): + import random + import os + #print "Haha!" + #print params + #print templates + d = templates['SmallStudent'] + r = random.Random(task_params['rndseed']) + # create hidden file + dir_list = ['Qlipper', 'Thunar', 'blender', 'autostart', 'kazam', 'mc', 'netsurf', 'pulse', 'qupzilla', 'radare2', 'teamviewer', 'texstudio', 'vlc'] + rndstr1 = r.choice(dir_list) + ending_list = ['rc', '.conf', ''] + start_list = ['net', 'dev', 'doc', 'lib', 'time', 'conf'] + rndstr2 = r.choice(start_list) + \ + r.choice("abcdexghijuop") + r.choice(ending_list) + hidden_file_dir = os.path.join('/home/bilbo/.config', + rndstr1) + d.mkdir(hidden_file_dir) + hidden_file_name = os.path.join(hidden_file_dir, + rndstr2) + d.chown(1002, 1002, hidden_file_dir) + d.chown(1002, 1002, hidden_file_name) + # TODO create the file contents + s = task_params['magicstr'] + # add poXYZlz lines to s + d.write(hidden_file_name, s) + # TODO create some additional files + + write_default_config(templates['simpleArbiterDhcpGW'], global_params) + # finish here + # rename + diff --git a/kpov_judge/web/kpov_judge/icons/computer.svg b/kpov_judge/web/kpov_judge/icons/computer.svg new file mode 100644 index 0000000..6da674d --- /dev/null +++ b/kpov_judge/web/kpov_judge/icons/computer.svg @@ -0,0 +1,1877 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg b/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg new file mode 100644 index 0000000..5f36f85 --- /dev/null +++ b/kpov_judge/web/kpov_judge/icons/drive-harddisk.svg @@ -0,0 +1,491 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Drive - Hard Disk + + + Jakub Steiner + + + + + hdd + hard drive + fixed + media + solid + + + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/kpov_judge/web/kpov_judge/icons/internet.svg b/kpov_judge/web/kpov_judge/icons/internet.svg new file mode 100644 index 0000000..5efbd24 --- /dev/null +++ b/kpov_judge/web/kpov_judge/icons/internet.svg @@ -0,0 +1,3398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1