MCPcopy Create free account
hub / github.com/Hiro420/NikkeTools / FileDecryptor

Class FileDecryptor

StaticData/NikkeStaticData/Program.cs:10–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace NikkeStaticData;
9
10public static class FileDecryptor
11{
12 static HttpClient client = new HttpClient();
13 private static readonly string url = "https://global-lobby.nikke-kr.com/v1/get-static-data-pack-info-mpk";
14
15 static async Task Main(string[] args)
16 {
17 Console.WriteLine($"Fetching url...");
18 byte[] encodedBytes = await GetProtoBytes();
19 ResStaticDataPackInfo resStaticDataPackInfo = ResStaticDataPackInfo.ParseFrom(encodedBytes);
20
21 Console.WriteLine($"Got response, latest version is {resStaticDataPackInfo.Version}");
22
23 Console.WriteLine($"Downloading StaticData.pack...");
24 byte[] fileBytes = await GetStaticDataBytes(resStaticDataPackInfo.Url);
25
26 byte[] password = Convert.FromBase64String(
27 "y8Icb/P1B/UFusrUmCiEH/DROMdh39bmZJqFEz4aagxoDivE33L4xlXkexQ2GDun0SCBItGpGIRlEwvtowDl2Q=="
28 );
29
30 byte[] key1 = new Rfc2898DeriveBytes(password, resStaticDataPackInfo.Salt1, 10000, HashAlgorithmName.SHA256).GetBytes(32);
31 byte[] key2 = new Rfc2898DeriveBytes(password, resStaticDataPackInfo.Salt2, 10000, HashAlgorithmName.SHA256).GetBytes(32);
32
33 Console.WriteLine($"Got keys, decrypting (part 1)...");
34 byte[] part1 = DecryptData(fileBytes, key2);
35 byte[] innerEncrypted;
36 using (var part1Stream = new MemoryStream(part1))
37 using (var zip = new ZipArchive(part1Stream, ZipArchiveMode.Read))
38 {
39 var entry = zip.Entries.First(e => e.Name == "data"); // or whatever the file is named
40 using var entryStream = entry.Open();
41 using var ms = new MemoryStream();
42 entryStream.CopyTo(ms);
43 innerEncrypted = ms.ToArray();
44 }
45
46 Console.WriteLine($"Got keys, decrypting (part 2)...");
47 byte[] finalZipBytes = DecryptData(innerEncrypted, key1, ctr: true);
48
49 Console.WriteLine($"Decrypted! Saving...");
50 File.WriteAllBytes($"StaticData.zip", finalZipBytes);
51 Console.WriteLine($"Done.");
52 }
53
54 static async Task<byte[]> GetStaticDataBytes(string url)
55 {
56 using var httpClient = new HttpClient();
57 var fileBytes = await httpClient.GetByteArrayAsync(url).ConfigureAwait(false);
58 return fileBytes;
59 }
60
61 static async Task<byte[]> GetProtoBytes()
62 {
63 var handler = new SocketsHttpHandler
64 {
65 ConnectCallback = async (context, cancellationToken) =>
66 {
67 var socket = new Socket(SocketType.Stream, ProtocolType.Tcp) { NoDelay = true };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected