Skip to content

Instantly share code, notes, and snippets.

@grawity
Created June 2, 2011 05:39
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grawity/1003987 to your computer and use it in GitHub Desktop.
Save grawity/1003987 to your computer and use it in GitHub Desktop.
ADVENT magic mode script for TOPS-10-In-a-Box

This script was written for the TOPS-10-In-a-Box project. It calculates the passwords for Magic Mode in ADVENT, and is based on the one available at Zonadepruebas website.

Description copied from Zonadepruebas:

Don Woods, who deviced this authentication scheme 29 years ago, has given his kind permission to disclose it publically

'Advent' is reputedly the first text adventure game. It was originally created by William Crowthers, and later expanded by Don Woods. It was programmed in Fortran, on a DEC PDP-10 computer, and Woods' version dates from 1977. This first version has a maintenance feature called "Magic Mode". It was intended for administrators only, and involves a bizarre authentication process. After entering "MAGIC MODE" as first command in the game, the program will ask:

  1. "ARE YOU A WIZARD?", (replay "YES")
  2. "PROVE IT! SAY MAGIC WORD", (default is "DWARF")
  3. "THAT'S NOT WHAT I THOUGHT IT WAS. DO YOU KNOW WHAT I THOUGHT IT WAS?", (replay "NO")

A random five character challenge is then issued, and the correct response must be entered. This response is based on the challenge, a "magic number" (default is 11111), and PDP-10 system time (*). The form in the left will calculate the answer to this Magic Mode challenge. Once in Magic Mode it's possible to modify "Magic Word", "Magic Number", at what hours can unprivileged users play, message of the day...

Magic Mode was taken out of most versions of advent, so a real or emulated PDP system is needed to try it. There is an step by step guide to compiling advent on a PDP-10 emulator, but sadly is only available in Spanish: Emulando advent tal y como fue creada.

*: System time can be obtained with the operating system command "DAYTIME".

#!/usr/bin/env python
# Advent Magic Mode authentication
# Based on (read: ripped off) Zona de pruebas
# <http://www.zonadepruebas.com/magicmode_crack_en.html>
from __future__ import print_function
import sys
import getopt
import math
import re
import time
def usage():
print("Usage: %s [-m magic] [-t time] challenge" % sys.argv[0])
print("")
print("\t-m magic Magic number (default 11111)")
print("\t-t time Time in HH:MM format (default now)")
def calc(ch, ts, d):
if len(ch) == 5 and re.match(r"^[a-z]{5}$", ch, re.I):
ch = [ord(c) for c in ch.upper()]
else:
print("Challenge must be 5 letters", file=sys.stderr)
return None
try:
d = int(d)
except ValueError:
print("Magic must be an integer", file=sys.stderr)
return None
if ts is None:
ts = time.localtime()
else:
try:
ts = time.strptime(ts, "%H:%M")
except ValueError:
print("Invalid time (must be in HH:MM format)",
file=sys.stderr)
return None
t = ts.tm_hour*100 + math.floor(ts.tm_min/10)*10
s = ""
for y in range(5):
z = (y+1)%5
x = int(((abs(ch[y]-ch[z])*(d%10))+(t%10))%26+1)
s += chr(x+64)
t = math.floor(t/10)
d = math.floor(d/10)
return s
if __name__ == "__main__":
ch = None
ts = None
magic = "11111"
try:
opts, args = getopt.getopt(sys.argv[1:], "m:t:")
except getopt.error as e:
print("%s: %s" % (sys.argv[0], e), file=sys.stderr)
usage()
sys.exit(2)
for opt, optarg in opts:
if opt == "-m":
magic = optarg
elif opt == "-t":
ts = optarg
try:
ch = args[0]
except IndexError:
print("Challenge not specified", file=sys.stderr)
usage()
sys.exit(2)
res = calc(ch, ts, magic)
if res is None:
sys.exit(1)
else:
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment