add phunkypython1 and 2
This commit is contained in:
parent
c72dc03b96
commit
8777cfeafe
6 changed files with 67 additions and 0 deletions
5
phunkypython1/description.md
Normal file
5
phunkypython1/description.md
Normal file
|
@ -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})
|
22
phunkypython1/grader.py
Normal file
22
phunkypython1/grader.py
Normal file
|
@ -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."
|
6
phunkypython1/problem.yml
Normal file
6
phunkypython1/problem.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
author: blockingthesky
|
||||||
|
title: Phunky Python I
|
||||||
|
category: Reversing
|
||||||
|
autogen: true
|
||||||
|
programming: false
|
||||||
|
value: 30
|
1
phunkypython2/description.md
Normal file
1
phunkypython2/description.md
Normal file
|
@ -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`?
|
27
phunkypython2/grader.py
Normal file
27
phunkypython2/grader.py
Normal file
|
@ -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."
|
6
phunkypython2/problem.yml
Normal file
6
phunkypython2/problem.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
author: blockingthesky
|
||||||
|
title: Phunky Python II
|
||||||
|
category: Reversing
|
||||||
|
autogen: true
|
||||||
|
programming: false
|
||||||
|
value: 115
|
Loading…
Reference in a new issue