Skip to content

Commit 1f69d51

Browse files
authored
Created Decrypter.cs
1 parent c8576a5 commit 1f69d51

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

Decrypter.cs

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

0 commit comments

Comments
 (0)