Compare commits

...

3 Commits
1.0 ... main

Author SHA1 Message Date
Li a441bfe929 Fix spelling of behavior 2024-02-28 14:01:08 +13:00
Li 9a8acbdd1d Add support for new ent format 2024-01-24 09:23:02 +13:00
Li e0d10ff685 Fix Galaxilite 2023-07-16 00:32:15 +12:00
7 changed files with 116 additions and 78 deletions

View File

@ -1,5 +0,0 @@
All code is hereby entered into the Public Domain
- Abolish Interlectual Property -

View File

@ -1,9 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace McCrypt
{
@ -129,35 +131,23 @@ namespace McCrypt
contentList.Add(content);
}
private static void readReceipt(string receiptData)
private static void handleEntitlements(dynamic entitlements, byte[] userKey)
{
dynamic recData = Utils.JsonDecodeCloserToMinecraft(receiptData);
string userId = recData.Receipt.EntityId;
string deviceId = "";
if (recData.Receipt.ReceiptData != null)
deviceId = recData.Receipt.ReceiptData.DeviceId;
if (deviceId == "" || deviceId == null)
deviceId = lastDeviceId;
if (deviceId == "" || deviceId == null)
return;
lastDeviceId = deviceId;
byte[] userKey = deriveUserKey(userId, deviceId);
// Derive content keys
int totalEntitlements = recData.Receipt.Entitlements.Count;
int totalEntitlements = entitlements.Count;
for (int i = 0; i < totalEntitlements; i++)
{
try
{
string friendlyId = recData.Receipt.Entitlements[i].FriendlyId;
string contentKeyB64 = recData.Receipt.Entitlements[i].ContentKey;
string friendlyId = entitlements[i].FriendlyId;
if (friendlyId == null)
friendlyId = entitlements[i].PackId;
if (friendlyId == null) continue;
string contentKeyB64 = entitlements[i].ContentKey;
if (contentKeyB64 == null)
continue;
@ -169,7 +159,38 @@ namespace McCrypt
}
catch (Exception) { continue; }
}
}
private static void readInnerReceipt(dynamic recData)
{
string userId = recData.EntityId;
string deviceId = "";
if (recData.ReceiptData != null)
deviceId = recData.ReceiptData.DeviceId;
if (deviceId == "" || deviceId == null)
deviceId = lastDeviceId;
if (deviceId == "" || deviceId == null)
return;
lastDeviceId = deviceId;
byte[] userKey = deriveUserKey(userId, deviceId);
if (recData.Entitlements != null)
handleEntitlements(recData.Entitlements, userKey);
else
handleEntitlements(recData.EntitlementReceipts, userKey);
}
private static void readReceipt(string receiptData)
{
dynamic recData = Utils.JsonDecodeCloserToMinecraft(receiptData);
if (recData.Receipt != null)
readInnerReceipt(recData.Receipt);
else
readInnerReceipt(recData);
}
public static void ReadOptionsTxt(string optionsTxtPath)
@ -246,29 +267,36 @@ namespace McCrypt
}
catch (Exception) { return; }
string receiptB64 = entData.Receipt;
string receiptB64 = entData.GetValue("Receipt", StringComparison.InvariantCultureIgnoreCase);
if (receiptB64 == null)
return;
string receiptData = null;
if (receiptB64.Split('.').Length <= 1)
receiptData = Encoding.UTF8.GetString(Utils.ForceDecodeBase64(receiptB64));
else
receiptData = Encoding.UTF8.GetString(Utils.ForceDecodeBase64(receiptB64.Split('.')[1]));
if (receiptData == null)
return;
string receiptData = Encoding.UTF8.GetString(Utils.ForceDecodeBase64(receiptB64.Split('.')[1]));
readReceipt(receiptData);
int totalItems = entData.Items.Count;
for (int i = 0; i < totalItems; i++)
if(entData.Items != null)
{
string b64Data = entData.Items[i].Receipt;
int totalItems = entData.Items.Count;
for (int i = 0; i < totalItems; i++)
{
string b64Data = entData.Items[i].Receipt;
if (b64Data == null)
continue;
if (b64Data == null)
continue;
if (b64Data.Split('.').Length <= 1)
continue;
if (b64Data.Split('.').Length <= 1)
continue;
string recept = Encoding.UTF8.GetString(Utils.ForceDecodeBase64(b64Data.Split('.')[1]));
readReceipt(recept);
string recept = Encoding.UTF8.GetString(Utils.ForceDecodeBase64(b64Data.Split('.')[1]));
readReceipt(recept);
}
}
}
public static void ReadKeysDb(string keyFile)

View File

@ -224,6 +224,9 @@ namespace McCrypt
if (decKey == null)
continue;
if (Path.GetFileName(relPath).ToLowerInvariant() == "manifest.json")
continue;
Thread thrd = new Thread(() =>
{
string filePath = Path.Combine(baseDirectory, relPath); // Combine pack dir, with file relative path

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Text;
@ -8,7 +9,7 @@ namespace McCrypt
internal class Utils
{
internal static object JsonDecodeCloserToMinecraft(string json)
internal static Object JsonDecodeCloserToMinecraft(string json)
{
for (int i = json.Length; i > 0; i--)
{

View File

@ -64,7 +64,7 @@ namespace McDecryptor
searchModules.Add("skin_packs");
searchModules.Add("world_templates");
searchModules.Add("persona");
searchModules.Add("behaviour_packs");
searchModules.Add("behavior_packs");
searchModules.Add("resource");
}
private static void rebaseLocalData()

View File

@ -176,7 +176,7 @@ namespace McDecryptor
break;
}
catch (Exception) { }
catch (Exception e) { Console.WriteLine("Error: " + e.Message); }
}
@ -194,51 +194,62 @@ namespace McDecryptor
counter++;
}
new Thread(() =>
Console.WriteLine("Decrypting: " + cListing.Name);
Directory.CreateDirectory(outFolder);
CopyDirectory(cListing.Path, outFolder);
try
{
Console.WriteLine("Decrypting: " + cListing.Name);
Directory.CreateDirectory(outFolder);
CopyDirectory(cListing.Path, outFolder);
try
string levelDatFile = Path.Combine(outFolder, "level.dat");
string skinsJsonFile = Path.Combine(outFolder, "skins.json");
string oldSchoolZipe = Path.Combine(outFolder, "content.zipe");
Marketplace.DecryptContents(outFolder);
if (Config.CrackPacks)
{
string levelDatFile = Path.Combine(outFolder, "level.dat");
string skinsJsonFile = Path.Combine(outFolder, "skins.json");
string oldSchoolZipe = Path.Combine(outFolder, "content.zipe");
if (File.Exists(oldSchoolZipe))
Marketplace.CrackZipe(oldSchoolZipe);
Marketplace.DecryptContents(outFolder);
if (File.Exists(levelDatFile))
Marketplace.CrackLevelDat(levelDatFile);
if (Config.CrackPacks)
{
if (File.Exists(oldSchoolZipe))
Marketplace.CrackZipe(oldSchoolZipe);
if (File.Exists(levelDatFile))
Marketplace.CrackLevelDat(levelDatFile);
if (File.Exists(skinsJsonFile))
Marketplace.CrackSkinsJson(skinsJsonFile);
}
if (Config.ZipPacks)
{
string ext = "";
if (File.Exists(levelDatFile))
ext += ".mctemplate";
else
ext += ".mcpack";
ZipFile.CreateFromDirectory(outFolder, outFolder + ext, CompressionLevel.NoCompression, false);
Directory.Delete(outFolder, true);
}
if (File.Exists(skinsJsonFile))
Marketplace.CrackSkinsJson(skinsJsonFile);
}
catch (Exception)
if (Config.ZipPacks)
{
Console.Error.WriteLine("Failed to decrypt: " + cListing.Name);
Console.WriteLine("Zipping: " + cListing.Name);
string ext = "";
if (File.Exists(levelDatFile))
ext += ".mctemplate";
else if (false)
ext += ".mcaddon";
else
ext += ".mcpack";
string fname = outFolder + ext;
if (File.Exists(fname))
File.Delete(fname);
ZipFile.CreateFromDirectory(outFolder, fname, CompressionLevel.NoCompression, false);
Directory.Delete(outFolder, true);
}
}
catch (Exception e)
{
Console.Error.WriteLine("Failed to decrypt: " + cListing.Name+ " "+e.Message);
Directory.Delete(outFolder, true);
}
}).Start();
}
Console.WriteLine("Finished.");
Console.ReadKey();
}
}

View File

@ -28,17 +28,17 @@ RealmsPremiumCache: $LOCALCACHE\premiumcache
CrackThePacks: yes
# Should i zip packs to .mcpack/.mctemplate
ZipThePacks: no
ZipThePacks: yes
# Where to output the decrypted data, (deafult to install into the game)
OutputFolder: $LOCALSTATE\games\com.mojang
OutputFolder: $EXECDIR\output_packs
# You can also add more search locations ontop of the default ones.
# Do this by using AdditionalSearchDir and a path, it will look there
# for packs.
# You can use AdditionalModuleDir to add new folders to look for encrypted data inside of the search folders
# normally it'll just look inside say "resource_packs" "skin_packs" "persona" etc
# normally it'll just look inside say "resource_packs" "skin_packs" "persona", "behaviour packs" etc
#AdditionalSearchDir: C:\Some\Folder\With\ResourcePacks
#AdditionalSearchDir: C:\Some\Other\Folder\With\ResourcePacks