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:
parent
c58518a65f
commit
4c2c218a72
1 changed files with 8 additions and 3 deletions
|
@ -395,6 +395,8 @@ namespace Steamless.Unpacker.Variant21.x86
|
||||||
// Save the code section index for later use..
|
// Save the code section index for later use..
|
||||||
this.CodeSectionIndex = this.File.GetSectionIndex(mainSection);
|
this.CodeSectionIndex = this.File.GetSectionIndex(mainSection);
|
||||||
|
|
||||||
|
uint encryptedSize = 0;
|
||||||
|
|
||||||
// Determine if we are using encryption on the section..
|
// Determine if we are using encryption on the section..
|
||||||
var flags = BitConverter.ToUInt32(this.PayloadData.Skip(this.SteamDrmpOffsets[0]).Take(4).ToArray(), 0);
|
var flags = BitConverter.ToUInt32(this.PayloadData.Skip(this.SteamDrmpOffsets[0]).Take(4).ToArray(), 0);
|
||||||
if ((flags & (uint)DrmFlags.NoEncryption) == (uint)DrmFlags.NoEncryption)
|
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 aesKey = this.PayloadData.Skip(this.SteamDrmpOffsets[5]).Take(32).ToArray();
|
||||||
var aesIv = this.PayloadData.Skip(this.SteamDrmpOffsets[6]).Take(16).ToArray();
|
var aesIv = this.PayloadData.Skip(this.SteamDrmpOffsets[6]).Take(16).ToArray();
|
||||||
var codeStolen = this.PayloadData.Skip(this.SteamDrmpOffsets[7]).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..
|
// Restore the stolen data then read the rest of the section data..
|
||||||
codeSectionData = new byte[encryptedSize + codeStolen.Length];
|
codeSectionData = new byte[encryptedSize + codeStolen.Length];
|
||||||
|
@ -434,8 +436,11 @@ namespace Steamless.Unpacker.Variant21.x86
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the section data..
|
// Merge the code section data..
|
||||||
this.CodeSectionData = codeSectionData;
|
var sectionData = this.File.SectionData[this.CodeSectionIndex];
|
||||||
|
Array.Copy(codeSectionData, sectionData, encryptedSize);
|
||||||
|
|
||||||
|
this.CodeSectionData = sectionData;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue