Added a problem (wao)
This commit is contained in:
parent
f27c6884ce
commit
8ab9981087
|
@ -1,4 +1,4 @@
|
|||
def grade(autogen, answer):
|
||||
if answer.find("edsger_wybe_dijkstra_was_a_happy_accident") != -1:
|
||||
return { "correct": True, "message": "Great Job! That's a tough one." }
|
||||
return { "correct": False, "message": "Nope, try again." }
|
||||
return True, "Great Job! That's a tough one."
|
||||
return False, "Nope, try again."
|
|
@ -1,4 +1,4 @@
|
|||
def grade(autogen, answer):
|
||||
if answer.find("d3let3d_f1l3z_r_k00l") != -1:
|
||||
return { "correct": True, "message": "Correct!" }
|
||||
return { "correct": False, "message": "Nope, try again." }
|
||||
return True, "Correct!"
|
||||
return False, "Nope, try again."
|
|
@ -1,4 +1,4 @@
|
|||
I've never seen such a cryptosystem before! It looks like a public key cryptosystem, though... Could you help me crack it?
|
||||
|
||||
[encrypt.sage](${encrypt_sage})
|
||||
[encrypt.sage](${encrypt_sage})
|
||||
[publickey_and_ciphertext.txt](${publickey_and_ciphertext_txt})
|
|
@ -1,4 +1,4 @@
|
|||
def grade(autogen, answer):
|
||||
if answer.find("i_actu4lly_d0nt_know_th3_name_of_th15_crypt0sy5tem") != -1:
|
||||
return { "correct": True, "message": "Correct!" }
|
||||
return { "correct": False, "message": "Nope, try again." }
|
||||
if answer.find("i_actu4lly_d0nt_know_th3_name_of_th15_crypt0sy5tem") != -1:
|
||||
return True, "Correct!"
|
||||
return False, "Nope, try again."
|
|
@ -1,2 +1,2 @@
|
|||
def grade(autogen, answer):
|
||||
return False, "This problem hasn't been released yet."
|
||||
return False, "This problem hasn't been released yet."
|
5
wayward-space-junk/description.md
Normal file
5
wayward-space-junk/description.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
I'm trying to destroy some space junk, but it won't stop moving!
|
||||
|
||||
`nc some_ip 8580`
|
||||
|
||||
Pilot Key: `${key}`
|
13
wayward-space-junk/grader.py
Normal file
13
wayward-space-junk/grader.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
def generate(random):
|
||||
key = "".join([random.choice("0123456789abcdef") for i in range(32)])
|
||||
return dict(variables={
|
||||
"key": key
|
||||
})
|
||||
|
||||
def grade(autogen, answer):
|
||||
key = "".join([autogen.choice("0123456789abcdef") for i in range(32)])
|
||||
autogen.seed("super%secretkeylalalala" % key)
|
||||
flag = "".join([random.choice("012456789abcdef") for i in range(32)])
|
||||
if answer.find(flag) != -1:
|
||||
return True, "Correct!"
|
||||
return False, "Nope, try again."
|
6
wayward-space-junk/problem.yml
Normal file
6
wayward-space-junk/problem.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
title: Wayward Space Junk
|
||||
hint: Try figuring out the trajectory of the junk.
|
||||
category: Programming
|
||||
autogen: true
|
||||
programming: false
|
||||
value: 300
|
71
wayward-space-junk/server.py
Normal file
71
wayward-space-junk/server.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
import SocketServer
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from math import sin, cos, pi, sqrt, atan
|
||||
|
||||
equations = [
|
||||
lambda constant, offset, amp, theta: amp * sin(constant * theta) + offset,
|
||||
lambda constant, offset, amp, theta: amp * cos(constant * theta) + offset,
|
||||
lambda constant, offset, amp, theta: amp * atan(constant * theta) + offset
|
||||
]
|
||||
|
||||
pattern = re.compile("\((\d+(?:.\d+)?),(?:\s+)?(\d+(?:.\d+)?)\)")
|
||||
|
||||
def dist(x1, y1, x2, y2):
|
||||
dx = x2 - x1
|
||||
dy = y2 - y1
|
||||
return sqrt(dx * dx + dy * dy)
|
||||
|
||||
def p2r(r, theta):
|
||||
return (r * cos(theta), r * sin(theta))
|
||||
|
||||
class RequestHandler(SocketServer.BaseRequestHandler):
|
||||
def handle(self):
|
||||
self.request.sendall("Please enter your pilot key: ")
|
||||
key = self.request.recv(1024).strip()
|
||||
|
||||
import random
|
||||
random.seed(key)
|
||||
|
||||
amplitude = random.uniform(5000, 10000)
|
||||
offset = random.uniform(5000, 10000)
|
||||
constant = random.uniform(0, 2 * pi)
|
||||
equation = random.choice(equations)
|
||||
period = random.uniform(400, 800)
|
||||
|
||||
current_time = time.time()
|
||||
self.request.sendall("The current time is: %s\n" % current_time)
|
||||
self.request.sendall("Please enter the coordinates (x, y) you would like to hit:\n")
|
||||
|
||||
theta = current_time
|
||||
while theta > period:
|
||||
theta -= period
|
||||
theta *= 2 * pi / period
|
||||
|
||||
coordinates = self.request.recv(1024).strip()
|
||||
match = pattern.match(coordinates)
|
||||
if not match:
|
||||
self.request.sendall("Sorry, you didn't enter valid coordinates.\n")
|
||||
return
|
||||
|
||||
x1, y1 = float(match.group(1)), float(match.group(2))
|
||||
x2, y2 = p2r(equation(constant, offset, amplitude, theta), theta)
|
||||
distance = dist(x1, y1, x2, y2)
|
||||
|
||||
if distance < 10:
|
||||
random.seed("super%secretkeylalalala" % key)
|
||||
flag = "".join([random.choice("012456789abcdef") for i in range(32)])
|
||||
self.request.sendall("Perfect!\n")
|
||||
self.request.sendall("Your flag is: easyctf{%s}\n" % flag)
|
||||
else:
|
||||
self.request.sendall("You missed. You were (%.3f, %.3f) off.\n" % (x2 - x1, y2 - y1))
|
||||
# self.request.sendall("[DEBUG] Actual coordinates: (%.3f, %.3f)\n" % (x2, y2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
HOST = os.getenv("HOST", "0.0.0.0")
|
||||
PORT = int(os.getenv("PORT", "8580"))
|
||||
server = SocketServer.TCPServer((HOST, PORT), RequestHandler)
|
||||
print "Listening on %s:%s" % (HOST, PORT)
|
||||
server.serve_forever()
|
Loading…
Reference in a new issue