1
0
Fork 0
mirror of https://github.com/atom0s/Steamless.git synced 2024-12-19 23:07:41 +01:00

Unpacker: (variant21.x86) Fixed AES decryption not properly handling the code section, leading to junk data being copied into unpacked file.

Unpacker: (variant21.x86) Fixed AES decryption not properly preserving non-encrypted data.
This commit is contained in:
atom0s 2024-03-29 22:04:12 -07:00
parent c58518a65f
commit 4c2c218a72
No known key found for this signature in database
GPG key ID: 37D5FD3494D79AF8

View file

@ -395,6 +395,8 @@ namespace Steamless.Unpacker.Variant21.x86
// Save the code section index for later use..
this.CodeSectionIndex = this.File.GetSectionIndex(mainSection);
uint encryptedSize = 0;
// Determine if we are using encryption on the section..
var flags = BitConverter.ToUInt32(this.PayloadData.Skip(this.SteamDrmpOffsets[0]).Take(4).ToArray(), 0);
if ((flags & (uint)DrmFlags.NoEncryption) == (uint)DrmFlags.NoEncryption)
@ -415,7 +417,7 @@ namespace Steamless.Unpacker.Variant21.x86
var aesKey = this.PayloadData.Skip(this.SteamDrmpOffsets[5]).Take(32).ToArray();
var aesIv = this.PayloadData.Skip(this.SteamDrmpOffsets[6]).Take(16).ToArray();
var codeStolen = this.PayloadData.Skip(this.SteamDrmpOffsets[7]).Take(16).ToArray();
var encryptedSize = BitConverter.ToUInt32(this.PayloadData.Skip(this.SteamDrmpOffsets[4]).Take(4).ToArray(), 0);
encryptedSize = BitConverter.ToUInt32(this.PayloadData.Skip(this.SteamDrmpOffsets[4]).Take(4).ToArray(), 0);
// Restore the stolen data then read the rest of the section data..
codeSectionData = new byte[encryptedSize + codeStolen.Length];
@ -434,8 +436,11 @@ namespace Steamless.Unpacker.Variant21.x86
}
}
// Store the section data..
this.CodeSectionData = codeSectionData;
// Merge the code section data..
var sectionData = this.File.SectionData[this.CodeSectionIndex];
Array.Copy(codeSectionData, sectionData, encryptedSize);
this.CodeSectionData = sectionData;
return true;
}