Wednesday, September 13, 2006

Brute Force Wins


I mentioned earlier that I accidentally mangled the super-seekrit code for my first purchase of Microsoft Monopoly Money. After much scrutinizing with a magnifying glass and a bright light source, I concluded that there were four characters which were most in doubt. One could have been a 'C' or an 'O'. Another could have been a 'P' or an 'F'. And so on... Holding all the other characters constant and generating all the permutations meant that there were 24 possible matches.




I wrote up a quick program in Python to generate all the possible strings, then sat down and started trying them, one after another. On try number 11, I succeeded! Glad I only had to try less than half the combos, since 'typing' with a game controller sucks.




Just for chuckles, here's the Python 'brute force' program, with the fake 'constant' characters to protect the innocent:




def gen_stuff():

ONE = "PX"
TWO = "MN "
THR = "EF"
FOU = "G 12345 67890 HIJ"
FIV = "Z"

for ONE_ in ["C", "O"]:
for TWO_ in ["P", "F"]:
for THR_ in ["E", "F", "P"]:
for FOU_ in ["E", "F"]:
print ''.join([ONE, ONE_, TWO, TWO_, THR, THR_, FOU, FOU_, FIV])

gen_stuff()



The bonus of this geeky little exercise is that I -- all unawares -- turned a problem into a 'problem', and got a giggly little boost instead of a headache!

Update




I decided I liked the example program better with 'real' letters, so I amended my sample above with substitutes. That allows me to inflict the result on you:




PXCMN PEFEG 12345 67890 HIJEZ
PXCMN PEFEG 12345 67890 HIJFZ
PXCMN PEFFG 12345 67890 HIJEZ
PXCMN PEFFG 12345 67890 HIJFZ
PXCMN PEFPG 12345 67890 HIJEZ
PXCMN PEFPG 12345 67890 HIJFZ
PXCMN FEFEG 12345 67890 HIJEZ
PXCMN FEFEG 12345 67890 HIJFZ
PXCMN FEFFG 12345 67890 HIJEZ
PXCMN FEFFG 12345 67890 HIJFZ
PXCMN FEFPG 12345 67890 HIJEZ <== TeH Winx0rz!!
PXCMN FEFPG 12345 67890 HIJFZ
PXOMN PEFEG 12345 67890 HIJEZ
PXOMN PEFEG 12345 67890 HIJFZ
PXOMN PEFFG 12345 67890 HIJEZ
PXOMN PEFFG 12345 67890 HIJFZ
PXOMN PEFPG 12345 67890 HIJEZ
PXOMN PEFPG 12345 67890 HIJFZ
PXOMN FEFEG 12345 67890 HIJEZ
PXOMN FEFEG 12345 67890 HIJFZ
PXOMN FEFFG 12345 67890 HIJEZ
PXOMN FEFFG 12345 67890 HIJFZ
PXOMN FEFPG 12345 67890 HIJEZ
PXOMN FEFPG 12345 67890 HIJFZ



Yeah, something like that.




No comments:

Post a Comment