CTF stands for Capture The Flag. After all, what else could CTF stand for?
Many problems have long flavour texts that are 'interesting', 'fun to read', and 'help you understand the problem'. In this problem, we cut out the middleman and provide you with the checker directly.
from re import split as resplit
from dmoj.utils.unicode import utf8bytes
p=214238064473940577161148843517681397401577162942720015917832488958279841878112274555987828320908141828812662516906558446781640409819395195852573499605737385575325567430464769019455231219307534330918124782541045006801468006763289073960841802463048790554330204444651346374736096764913407024792878078531871
q=305074126591503996362868265450629448788273890579460845229843976039914772691131634908189692458338083855308239547414252832719113428223207403604887499086616442151905060456668262303760029741376520087657350441875023796855291451765685626141027315115570074695194069704744678759100368904071786505208703308063453
n = p * q
assert n >= 10 ** 600
e = 289
goal=46446758267700605789745903310042351975630318786832355444354583002481343641976658724327294175425299242107965470543191617985322597880133329908217631552223658379381500214411942838826154878654095605414346933981741998001811964853006859195284867465433085084817473354661264918888869046507299032469436209812650554879861032185256180284615041606288524842036317711557683912069331056623750972014396056602539359311149509394313255906085888890472749151318429260291299254115836911631334301909934711681403016263247285717078696463679912856524795697647258356855408935628463468364113760874474759564293017717718113593372194316
def is_valid(s):
if len(s) != 13:
return False
for c in s:
if not (32 <= c <= 127):
return False
return True
def check(process_output, judge_output, judge_input, **kwargs):
process_lines = list(filter(None, resplit(b'[\r\n]', utf8bytes(process_output))))
if len(process_lines) != 1:
return False
s = process_lines[0] #s is a byte string
if not is_valid(s):
return False
#Encryption Step
encoded = 0
for c in s:
encoded *= 256
encoded += c
assert encoded <= 256 ** 13 <= 10 ** 32
encrypted = pow(encoded, e, n)
return encrypted == goal
Comments