Created
August 1, 2012 20:31
-
-
Save MEXAHOTABOP/3230457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
def _p2(b): | |
if len(b)==1: | |
return chr(int(b +"0",16)+1) | |
return chr(int(b[1] + b[0],16)+1) | |
def _p1(c): | |
a = [hex(ord(c[0])).replace("0x",""),hex(ord(c[1])).replace("0x",""),hex(ord(c[2])).replace("0x",""),hex(ord(c[3])).replace("0x","")] | |
return _p2(a[3]) + _p2(a[0]) + _p2(a[1]) + chr(ord(_p2(a[2]))-1) | |
def protect(inmap,outmap=""): | |
"""Implement Spazzler's protection to inmap + ".w3x" as a new map outmap + ".w3x". | |
If outmap is omitted, it will default to inmap + "_spaz". | |
If outmap begins with a plus sign (+) it will append outmap[1:] to inmap.""" | |
try: | |
mf = open(inmap + ".w3x","rb") | |
if outmap=="": | |
outmap = inmap + "_spaz" | |
if outmap[:1]=="+": | |
outmap = inmap + outmap[1:] | |
elif outmap[len(outmap)-1:]=="+": | |
outmap = outmap[:len(outmap)-1] + inmap | |
mi = [mf.read(512),mf.read(512),mf.read()] | |
mf.close() | |
x = mi[1] | |
c = _p1(x[28:32]) | |
mo = [mi[0],"","","",mi[2]] | |
mo[1] = "MPQ" + chr(0x1b) + chr(0x20) + chr(0x00) + chr(0x00) + chr(0x00) + x[8:12] + chr(0x01) + chr(0x00) + x[14:28] + c + x[32:] | |
mo[2] = "BN3" + chr(0x1a) + chr(0x20) + chr(0x00) + chr(0x00) + chr(0x00) + x[8:12] + chr(0x01) + chr(0x00) + x[14:28] + c + x[32:] | |
mo[3] = "MPQ" + chr(0x1a) + "SPAZZLER" + chr(0x01) + chr(0x00) + x[14:28] + c + x[32:] | |
po = open(outmap + ".w3x","wb") | |
for i in range(5): | |
po.write(mo[i]) | |
po.close() | |
print "Map successfully Spazzled." | |
except IOError: | |
print """File '""" + inmap + """.w3x' does not exist.""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is that ken's spazzler ;o