static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Args: <source> <dest>"); return; } string source = args[0]; string destination = args[1]; if (!File.Exists(source)) { Console.WriteLine("Error: file not found: {0}", source); return; } if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } // init the replay file Replay replay = new Replay(source); // handle the entries within the replay file while (replay.ReadEntry()) { Console.WriteLine(replay.PayloadEntry); // write the payload out to disk File.WriteAllBytes(string.Format(@"{0}\{1}-{2}-{3}.bin", destination, replay.PayloadHeader.GameId, replay.PayloadEntry.ID, replay.PayloadEntry.Type), replay.PayloadEntry.Data); } }
public ReplayPayloadEntry(Replay p_replay, FileStream p_stream, int p_payloadDataStartOffset) { using (BinaryReader r = new BinaryReader(p_stream, Encoding.UTF8, true)) { m_id = r.ReadInt32(); m_type = r.ReadByte(); m_length = r.ReadInt32(); m_nextChunkId = r.ReadInt32(); m_offset = r.ReadInt32(); } // seek to the entry's data location p_stream.Seek(p_payloadDataStartOffset + m_offset, SeekOrigin.Begin); // init the byte array to appropriate length m_data = new byte[m_length]; // the entry data chunk p_stream.Read(m_data, 0, m_length); // store the decrypted data m_data = GetDecryptedData(p_replay, m_data); }
private byte[] GetDecryptedData(Replay p_replay, byte[] p_data) { // string represenation of the game id string gameId = Convert.ToString(p_replay.PayloadHeader.GameId); // obtaining the chunk encryption key byte[] chunkEncryptionKey = DepadBytes(DecryptBytes(Encoding.UTF8.GetBytes(gameId), p_replay.PayloadHeader.EncryptionKey)); // obtaining the decrypted chunk byte[] decryptedChunk = DepadBytes(DecryptBytes(chunkEncryptionKey, p_data)); return DecompressBytes(decryptedChunk); }