Created
November 14, 2017 00:01
-
-
Save Jadd/51749a2fb7ee127a60dd0877da8713a7 to your computer and use it in GitHub Desktop.
Albion asset decryption, validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Albion Online version 1.0.340.102503. | |
public static byte[] ReadAsset(string fileName) { | |
using (var file = File.OpenRead(fileName)) | |
return ReadAsset(file); | |
} | |
/* Reference: | |
* Albion.Common | |
* 0x060017CD ne.b(string) | |
*/ | |
public static byte[] ReadAsset(Stream asset) { | |
var assetKey = new byte[] { 0x30, 0xEF, 0x72, 0x47, 0x42, 0xF2, 0x04, 0x32 }; | |
var assetIV = new byte[] { 0x0E, 0xA6, 0xDC, 0x89, 0xDB, 0xED, 0xDC, 0x4F }; | |
var des = new DESCryptoServiceProvider(); | |
var decryptor = des.CreateDecryptor(assetKey, assetIV); | |
using (var crypto = new CryptoStream(asset, decryptor, CryptoStreamMode.Read)) | |
using (var archive = new GZipStream(crypto, CompressionMode.Decompress)) | |
return archive.ToArray(); | |
} | |
/* Reference: | |
* Albion.Common | |
* 0x060010E7 hn.bs() | |
*/ | |
public static byte[] GetAssetValidationHash(string assetsPath) { | |
var digest = new MD5Cng(); | |
var validationAssets = new[] { | |
"gamedata.bin", "buildings.bin", "characters.bin", "mobs.bin", | |
"spells.bin", "items.bin", "accessrights.bin", "worldsettings.bin", | |
"world.bin", "achievements.bin", "agents.bin", "factions.bin", | |
"missions.bin", "emotes.bin", "expeditions.bin", "expeditioncategories.bin", | |
"expeditionagents.bin", "itemroles.bin", "orbtypes.bin", "matchtypes.bin" | |
}; | |
using (var stream = new MemoryStream()) { | |
foreach (var asset in validationAssets) { | |
var fileName = Path.Combine(assetsPath, asset); | |
var fileHash = digest.ComputeHash(ReadAsset(fileName)); | |
stream.Write(fileHash); | |
} | |
// Result is a hash of all hashes combined. | |
return digest.ComputeHash(stream.ToArray()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment