def get_file_contents(self, filename, keysize=0): with open(filename, 'rb') as f: data = f.read() if keysize: key = self.generate_key(keysize) rc4.rc4_setkey(key) data = key + rc4.rc4(data) return data
def generate_niraidata(self): print 'Generating niraidata' config = self.get_file_contents('../src/dependencies/config/release/en.prc') config += '\n\n' + self.get_file_contents('../src/dependencies/config/general.prc') key = self.generate_key(128) rc4.rc4_setkey(key) config = key + rc4.rc4(config) niraidata = 'CONFIG = %r' % config niraidata += '\nDC = %r' % self.get_file_contents('../src/dependencies/astron/dclass/crystal.dc', 128) self.add_module('niraidata', niraidata, compile=True)
def generate_niraidata(self): print 'Generating niraidata' config = self.get_file_contents('../dependencies/config/release/en.prc') config += '\n\n' + self.get_file_contents('../dependencies/config/general.prc') key = self.generate_key(128) rc4.rc4_setkey(key) config = key + rc4.rc4(config) niraidata = 'CONFIG = %r' % config niraidata += '\nDC = %r' % self.get_file_contents('../dependencies/astron/dclass/crystal.dc', 128) self.add_module('niraidata', niraidata, compile=True)
def process_modules(self): with open('base.dg', 'rb') as f: basesize, = struct.unpack('<I', f.read(4)) data = f.read() dg = Datagram() dg.addUint32(len(self.modules) + basesize) dg.appendData(data) for moduleName in self.modules: data, size = self.modules[moduleName] dg.addString(moduleName) dg.addInt32(size) dg.appendData(data) data = dg.getMessage() compressed = compressString(data, 9) key = self.generate_key(100) fixed = ''.join(chr((i ^ (5 * i + 7)) % ((i + 6) * 10)) for i in xrange(28)) rc4.rc4_setkey(key + fixed) data = rc4.rc4(compressed) return key + data
from panda3d.core import * import __builtin__, os import rc4 import niraidata # Config prc = niraidata.CONFIG key, prc = prc[:32], prc[32:] rc4.rc4_setkey(key) prc = rc4.rc4(prc) for line in prc.split('\n'): line = line.strip() if line: loadPrcFileData('nirai config', line) del prc # DC __builtin__.dcStream = StringStream() dc = niraidata.DC key, dc = dc[:32], dc[32:] rc4.rc4_setkey(key) dc = rc4.rc4(dc) dcStream.setData(dc) del dc rc4.rc4_setkey('\0\0\0\0')