diff --git a/phunkypython1/description.md b/phunkypython1/description.md new file mode 100644 index 0000000..29d5588 --- /dev/null +++ b/phunkypython1/description.md @@ -0,0 +1,5 @@ +The other day we happened upon a dusty old laptop covered in duct tape and surrounded by several papers with notes scrawled all over them. Upon inspection, we found that the laptop contained several python files labeled `phunky`. + +We've determined that each of the files contains a mini reversing challenge. The first task is simple: Find the value of `x` such that the program prints out `easyctf`. + +[phunky1.py](${phunky1_py}) \ No newline at end of file diff --git a/phunkypython1/grader.py b/phunkypython1/grader.py new file mode 100644 index 0000000..24175c3 --- /dev/null +++ b/phunkypython1/grader.py @@ -0,0 +1,22 @@ +from cStringIO import StringIO + +def get_flag(random): + n = random.randint(10**16, 10**19) + return n + +def generate_phunky(random): + n = get_flag(random) + digs = [n + ord(t) for t in 'easyctf'] + prog = 'x = 0 # REDACTED\ndigs = {}\nout = ""\nfor letter in reversed(digs):\n out = chr(letter - x) + out\nprint out'.format(str(digs)) + return StringIO(prog) + +def generate(random): + return dict(files={ + "phunky1.py": generate_phunky + }) + +def grade(random, key): + n = get_flag(random) + if key.find("%d" % n) >= 0: + return True, "Nice work!" + return False, "Nope." \ No newline at end of file diff --git a/phunkypython1/problem.yml b/phunkypython1/problem.yml new file mode 100644 index 0000000..449ec04 --- /dev/null +++ b/phunkypython1/problem.yml @@ -0,0 +1,6 @@ +author: blockingthesky +title: Phunky Python I +category: Reversing +autogen: true +programming: false +value: 30 \ No newline at end of file diff --git a/phunkypython2/description.md b/phunkypython2/description.md new file mode 100644 index 0000000..9704c6c --- /dev/null +++ b/phunkypython2/description.md @@ -0,0 +1 @@ +We stumbled across another phunky Python file. Can you find the redacted value of jkx that makes [this program](${phunky2_py}) print `True`? \ No newline at end of file diff --git a/phunkypython2/grader.py b/phunkypython2/grader.py new file mode 100644 index 0000000..c8bbec5 --- /dev/null +++ b/phunkypython2/grader.py @@ -0,0 +1,27 @@ +from cStringIO import StringIO + +def get_flag(random): + n = random.randint(10**16, 10**19) + return n + +def generate_phunky(random): + n = get_flag(random) + n *= n - 1 + n = [int(u) for u in str(n)] + primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173] + big = 1 + for i in range(len(n)): + big *= primes[i] ** n[i] + prog = 'import operator\njkx = 0 # REDACTED\npork = ((12*jkx+44)/4)-(1234/617)*jkx-sum([1, 4, 7])\njkx *= pork\npp = filter(lambda g: not any(g % u == 0 for u in range(2, g)), range(2, 10000))\nb = reduce(operator.mul, (pp[i] ** int(str(jkx)[i]) for i in range(len(str(jkx)))))\nprint b == {}'.format(str(big)) + return StringIO(prog) + +def generate(random): + return dict(files={ + "phunky2.py": generate_phunky + }) + +def grade(random, key): + n = get_flag(random) + if key.find("%d" % n) >= 0: + return True, "Nice work!" + return False, "Nope." \ No newline at end of file diff --git a/phunkypython2/problem.yml b/phunkypython2/problem.yml new file mode 100644 index 0000000..1095691 --- /dev/null +++ b/phunkypython2/problem.yml @@ -0,0 +1,6 @@ +author: blockingthesky +title: Phunky Python II +category: Reversing +autogen: true +programming: false +value: 115 \ No newline at end of file