diff options
Diffstat (limited to 'kpov_judge/tasks/rename_grep_network')
-rw-r--r-- | kpov_judge/tasks/rename_grep_network/task.py | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/kpov_judge/tasks/rename_grep_network/task.py b/kpov_judge/tasks/rename_grep_network/task.py index cc21479..ce761db 100644 --- a/kpov_judge/tasks/rename_grep_network/task.py +++ b/kpov_judge/tasks/rename_grep_network/task.py @@ -42,7 +42,7 @@ computers = { 'SimpleArbiter': { 'disks': [ { - 'name': 'simpleArbiterDhcpGW', + 'name': 'simpleArbiterEntrance', }, ], 'network_interfaces': [ @@ -60,9 +60,11 @@ computers = { 'disks': [ { 'name': 'student-entrance3', + 'parts': [{'dev': 'a1', 'path': '/'}], }, { 'name': 'smallstudent-personal', + 'parts': [{'dev': 'b1', 'path': '/media'}, {'dev': 'b2', 'path': '/mnt'}] } ], 'network_interfaces': [ @@ -120,7 +122,11 @@ params_meta = { 'descriptions': { 'si': 'imenik za priklop diska', 'en': 'mountpoint', - } + }, + 'w': False, + 'public': True, + 'type': 'dirname', + 'generated': True, }, 'magicstr' : { 'descriptions': { @@ -181,7 +187,7 @@ def task(testip, testuser, passwd, mntdir, magicstr, pubseed): dst_ls = target.before target.sendline('mount') target.prompt() - mnt = target.before() + mnt = target.before results = { 'home_ls': home_ls, 'dst_ls': dst_ls, @@ -216,7 +222,7 @@ def task_check(results, params): score = 0 hidden_contents = params['magicstr'] r = random.Random(params['rndseed']) - dstfile = "".join([r.choice("qQoOp") for i in range(48)]) + "I.txt" + dstfile = "".join([r.choice("qQoOp") for i in range(64)]) + "I.txt" dstfile = dstfile.replace('O', 'I') for i in range(1000): start = "".join([r.choice(["po", "p0", "no", "ko", "fo", "qo"]) for i in range(20)]) @@ -245,20 +251,24 @@ def task_check(results, params): break hints += ["wrong file contents\n" + str(diff_pos[1])] #hints += ["wrong file contents"] - expected_ls = u"ls -l ~/*I*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params) - if re.match(expected_ls, results["dst_ls"]): - score += 3 - else: - hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"]] - if results["home_ls"].find(params['progname']) > -1: + params['dstfile'] = dstfile + expected_dst_ls = u"ls -l ~/\\*I\\*.txt\r\n-rw--w---- 1 {testuser} bilbo .*{dstfile}\r\n".format(**params) + if re.match(expected_dst_ls, results["dst_ls"]): score += 2 else: - hints += ["missing program"] - expected_tita = u"" - if results["tita_return"] == expected_tita: + hints += [u"missing file or wrong user/permissions\n" + results["dst_ls"] + "\n" + expected_dst_ls] + if results["home_ls"].find(params['dstfile']) > -1: score += 2 + expected_mnts = [ + "/dev/sdb2 on {mntdir} type ext4".format(**params), + "sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)", + "proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)", + "udev on /dev type devtmpfs (rw,nosuid,relatime,size=500680k,nr_inodes=125170,mode=755)", + "/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)",] + if all([results["mnt"].find(expected_mnt) > -1 for expected_mnt in expected_mnts]): + score += 3 else: - hints += [u"program output incorrect\n" + results["tita_return"]] + hints += ["missing or wrong mount\n"] return score, hints @@ -272,7 +282,7 @@ def prepare_disks(templates, task_params, global_params): # first create the file contents to make it easyer to check. hidden_contents = task_params['magicstr'] r = random.Random(task_params['rndseed']) - dstfile = "".join([r.choice("qQoOp") for i in range(48)]) + "I.txt" + dstfile = "".join([r.choice("qQoOp") for i in range(64)]) + "I.txt" for i in range(1000): x = "".join([r.choice(["po", "p0", "no", "ko", "fo", "qo"]) for i in range(20)]) x += "".join([r.choice("uiasdfghjkyxcvbnm1234567890ASDFGHJKYZXCVBNM") for i in range(60)]) @@ -280,26 +290,36 @@ def prepare_disks(templates, task_params, global_params): hidden_contents += x + "\n" # create hidden file dir_list = ['Qlipper', 'Thunar', 'blender', 'autostart', 'kazam', 'mc', 'netsurf', 'pulse', 'qupzilla', 'radare2', 'teamviewer', 'texstudio', 'vlc'] - ending_list = ['rc', '.conf', ''] + ending_list = ['rc', '.conf', '', '.txt'] start_list = ['net', 'dev', 'doc', 'lib', 'time', 'conf'] + for i in range(20): + start_list.append("".join([r.choice("qQoOp") for i in range(64)]) + "O") r.shuffle(dir_list) file_letters = ["mod", "co"] - d.mkdir('.hideme') + d.mkdir('/mnt/.hideme') + d.mkdir('/media/.hideme') for potential_dir in dir_list: try: - potential_dir = os.path.join('.hideme', potential_dir) - d.mkdir(potential_dir) - d.chown(1001, 1001, potential_dir) + potential_dir1 = os.path.join('/mnt/.hideme', potential_dir) + potential_dir2 = os.path.join('/media/.hideme', potential_dir) + d.mkdir(potential_dir1) + d.chown(1001, 1001, potential_dir1) + d.mkdir(potential_dir2) + d.chown(1001, 1001, potential_dir2) except: pass rndstr2 = dstfile for i in range(r.randint(2, 20)): - hidden_file_name = os.path.join(potential_dir, + hidden_file_name1 = os.path.join(potential_dir1, + rndstr2) + hidden_file_name2 = os.path.join(potential_dir2, rndstr2) - d.write(hidden_file_name, hidden_contents) - d.chown(1001, 1001, hidden_file_name) + d.write(hidden_file_name1, hidden_contents) + d.chown(1001, 1001, hidden_file_name1) file_letters = ["stamp", "", "dev", "re"] hidden_contents = "".join([r.choice("asdfghjkyxcvbnm1234567890 \n") for j in range(10000)]) + d.write(hidden_file_name2, hidden_contents) + d.chown(1001, 1001, hidden_file_name2) rndstr2 = r.choice(start_list) + \ r.choice(file_letters) + r.choice(ending_list) file_letters = file_letters + ["mod", "co"] |