-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecrypter.cs
More file actions
57 lines (48 loc) · 1.98 KB
/
Decrypter.cs
File metadata and controls
57 lines (48 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// This code is for forking.
// This does not have encryption.
// If you're gonna fork this, change InputPath ah to your actual file names and change OutpathPath to whatever you want.
using System.Buffers.Text;
using System.ComponentModel.DataAnnotations;
using System.IO.Compression;
using System.Text;
using System.Xml.Serialization;
class Program
{
static void Main()
{
// Explained at the start.
string InputPath = "CCGameManager.dat";
string OutputPath = "output.xml";
// Read raw data of file.
byte[] rawBytes = File.ReadAllBytes(InputPath);
// XOR bytes with key 11.
for (int i = 0; i < rawBytes.Length; i++)
{
rawBytes[i] ^= 11;
}
// Get string from the rawbytes and trim null bytes to not cause problems with base64 decode (if any).
string base64 = Encoding.ASCII.GetString(rawBytes).TrimEnd('\0');
// Change from url-safe to non url-safe. This is because base64 decode requests a non-url safe base64 string.
base64 = base64.Replace("-", "+").Replace("_", "/");
// Convert the base64 decoded result to bytes.
byte[] compressedBytes = Convert.FromBase64String(base64);
// Get the string from the bytes.
string xml = GZipDecompress(compressedBytes);
// Write the string to a file with the OutputPath
File.WriteAllText(OutputPath, xml);
Console.WriteLine("Over Finally!");
}
// Helper function
static string GZipDecompress(byte[] data)
{
// Create a MemoryStream to store the bytes for the GZipStream to read from
using (MemoryStream input = new MemoryStream(data))
// Decompress the data from the memory stream
using (GZipStream gzip = new GZipStream(input, CompressionMode.Decompress))
// Read the data as it gets decompressed
using (StreamReader reader = new StreamReader(gzip, Encoding.UTF8))
{
return reader.ReadToEnd();
}
}
}