Exercises

Please consider the following notes when you submit your solution!

Cheating

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python

import subprocess


def main():
        # decrypt file
        # run the program and capture the output
        try:
                # flag = subprocess.check_output('./fixme')
                # print result
		# print (flag)
                print ('FLAG{THISISATEST}')
        except subprocess.CalledProcessError as error:
                print (error)


if __name__ == "__main__":
        main()

Shebang

The first line of solution must be a shebang line: #!/usr/bin/env python2 or #!/usr/bin/env bash or …

solution

The solution script must be named solution not solution.sh or solution.py or …

Dependencies

Your script solution must be executable on a fresh machine -> install all additional packages!

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python2

import pip


def install(package):
    if hasattr(pip, "main"):
        pip.main(["install", "--user", package])
    else:
        pip._internal.main(["install", "--user", package])


def main():
	install("foo")
	from foo import bar


if __name__ == "__main__":
	main()

Alternatively you could also use a requirements.txt file and install the requirements like this:

1
2
3
4
5
6
7
8
import os

...

os.system("pip install --user -r requirements.txt")
import yournewmodule
...

https://pip.pypa.io/en/stable/user_guide/#id12

Files

If you need to patch a binary push the binary to the repo as well!

1
2
    with open('fixme', 'rb') as f:
IOError: [Errno 2] No such file or directory: 'fixme'

Python Version

On our VMs:

1
2
3
4
5
$ python2 --version
Python 2.7.13

$ python3 --version
Python 3.5.3

You cannot use language features from newer Python versions!

Avoiding 0 Points

Test your scripts on the VM and make sure that you push all necessary files to your repository!

Final Warning

If we cannot execute your solution with ./solution you will get 0 (zero) points!