Skip to main content
7 of 7
Commonmark migration

CPython 3.6

import sys,os, ctypes, __main__
f = open(__file__).read()
if f.count("__call__") > 1: sys.exit()
if len(f.splitlines()) != 21:ctypes.pythonapi.Py_AtExit(ctypes.pythonapi.Py_FatalError)
type(ctypes.pythonapi).repr = repr(ctypes.pythonapi)
def p(f,e,a):
 if e == 1 and a is not 2:
    try:3(f,e,a)
    finally:3(f,e,a)
wipe = __main__.__dict__.clear
c=p.__code__
c=type(c)(3, 0, c.co_nlocals, c.co_stacksize, c.co_flags, c.co_code,
                    (None, "c_call",wipe, p), c.co_names, c.co_varnames,
                    c.co_filename, c.co_name, c.co_firstlineno, c.co_lnotab)
p.__code__ = c
g=getattr
s=sys.setprofile
for mod in sys.modules.values():
    if g(mod,"__name__",None) != "__main__":mod.__dict__.clear()
s(p)
wipe()

(trailing newline at end)

Congratulations, Veedrac, zbw, and Dennis! You've cracked all three of my Python solutions. but now, can you crack them all together?! Input from STDIN, output to STDERR (which, per the rules, needs to be clean and not contain a Fatal Python error:, which the ctypes handler will print). The profile hook crashes by causing a recursion error handling a recursion error in order to make sure it isn't abused as an exit method. I wonder how long this will take to be cracked ...

The Fifth Marshal
  • 6.3k
  • 1
  • 25
  • 44