Skip to content

Commit

Permalink
Don't statically decrypt strings if dynamic decryption is enabled, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Mar 18, 2018
1 parent 82c24c9 commit e9f938a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions de4dot.code/deobfuscators/dotNET_Reactor/v4/Deobfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,10 @@ public override void DeobfuscateBegin() {
proxyCallFixer.FindDelegateCreator();
proxyCallFixer.Find();

stringDecrypter.Initialize(peImage, fileData, DeobfuscatedFile);
if (!stringDecrypter.Detected)
bool decryptStrings = Operations.DecryptStrings == OpDecryptString.Static;
if (decryptStrings)
stringDecrypter.Initialize(peImage, fileData, DeobfuscatedFile);
if (!stringDecrypter.Detected || !decryptStrings)
FreePEImage();
booleanDecrypter.Initialize(fileData, DeobfuscatedFile);
booleanValueInliner = new BooleanValueInliner();
Expand All @@ -459,15 +461,17 @@ public override void DeobfuscateBegin() {
});
}

foreach (var info in stringDecrypter.DecrypterInfos) {
staticStringInliner.Add(info.method, (method2, gim, args) => {
return stringDecrypter.Decrypt(method2, (int)args[0]);
});
}
if (stringDecrypter.OtherStringDecrypter != null) {
staticStringInliner.Add(stringDecrypter.OtherStringDecrypter, (method2, gim, args) => {
return stringDecrypter.Decrypt((string)args[0]);
});
if (decryptStrings) {
foreach (var info in stringDecrypter.DecrypterInfos) {
staticStringInliner.Add(info.method, (method2, gim, args) => {
return stringDecrypter.Decrypt(method2, (int)args[0]);
});
}
if (stringDecrypter.OtherStringDecrypter != null) {
staticStringInliner.Add(stringDecrypter.OtherStringDecrypter, (method2, gim, args) => {
return stringDecrypter.Decrypt((string)args[0]);
});
}
}
DeobfuscatedFile.StringDecryptersAdded();

Expand Down

0 comments on commit e9f938a

Please sign in to comment.