2011-10-22 20:31:38 +08:00
|
|
|
|
/*
|
2013-01-02 00:03:16 +08:00
|
|
|
|
Copyright (C) 2011-2013 de4dot@gmail.com
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
|
|
|
|
This file is part of de4dot.
|
|
|
|
|
|
|
|
|
|
de4dot is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
de4dot is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with de4dot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2012-03-14 03:27:41 +08:00
|
|
|
|
using System;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2012-12-20 09:06:09 +08:00
|
|
|
|
using dnlib.DotNet;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
using de4dot.blocks;
|
2013-09-28 20:55:29 +08:00
|
|
|
|
using de4dot.blocks.cflow;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
2011-12-09 16:02:06 +08:00
|
|
|
|
namespace de4dot.code.deobfuscators.CryptoObfuscator {
|
|
|
|
|
public class DeobfuscatorInfo : DeobfuscatorInfoBase {
|
2011-11-04 03:03:32 +08:00
|
|
|
|
public const string THE_NAME = "Crypto Obfuscator";
|
2011-11-12 18:31:07 +08:00
|
|
|
|
public const string THE_TYPE = "co";
|
2013-11-18 22:43:08 +08:00
|
|
|
|
const string DEFAULT_REGEX = @"!^(get_|set_|add_|remove_)?[A-Z]{1,3}(?:`\d+)?$&!^(get_|set_|add_|remove_)?c[0-9a-f]{32}(?:`\d+)?$&" + DeobfuscatorBase.DEFAULT_ASIAN_VALID_NAME_REGEX;
|
2011-10-23 00:13:13 +08:00
|
|
|
|
BoolOption removeTamperProtection;
|
2012-07-11 08:18:01 +08:00
|
|
|
|
BoolOption decryptConstants;
|
2013-09-28 20:55:29 +08:00
|
|
|
|
BoolOption inlineMethods;
|
2013-09-29 01:07:03 +08:00
|
|
|
|
BoolOption fixLdnull;
|
2011-10-23 00:13:13 +08:00
|
|
|
|
|
2011-10-22 20:31:38 +08:00
|
|
|
|
public DeobfuscatorInfo()
|
2011-11-04 03:03:32 +08:00
|
|
|
|
: base(DEFAULT_REGEX) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
removeTamperProtection = new BoolOption(null, MakeArgName("tamper"), "Remove tamper protection code", true);
|
|
|
|
|
decryptConstants = new BoolOption(null, MakeArgName("consts"), "Decrypt constants", true);
|
2013-09-28 20:55:29 +08:00
|
|
|
|
inlineMethods = new BoolOption(null, MakeArgName("inline"), "Inline short methods", true);
|
2013-09-29 01:07:03 +08:00
|
|
|
|
fixLdnull = new BoolOption(null, MakeArgName("ldnull"), "Restore ldnull instructions", true);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 03:03:32 +08:00
|
|
|
|
public override string Name {
|
|
|
|
|
get { return THE_NAME; }
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Type {
|
2011-11-12 18:31:07 +08:00
|
|
|
|
get { return THE_TYPE; }
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override IDeobfuscator CreateDeobfuscator() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
return new Deobfuscator(new Deobfuscator.Options {
|
2013-11-18 23:28:44 +08:00
|
|
|
|
ValidNameRegex = validNameRegex.Get(),
|
|
|
|
|
RemoveTamperProtection = removeTamperProtection.Get(),
|
|
|
|
|
DecryptConstants = decryptConstants.Get(),
|
|
|
|
|
InlineMethods = inlineMethods.Get(),
|
|
|
|
|
FixLdnull = fixLdnull.Get(),
|
2011-10-22 20:31:38 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
protected override IEnumerable<Option> GetOptionsInternal() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
return new List<Option>() {
|
2011-10-23 00:13:13 +08:00
|
|
|
|
removeTamperProtection,
|
2012-07-11 08:18:01 +08:00
|
|
|
|
decryptConstants,
|
2013-09-28 20:55:29 +08:00
|
|
|
|
inlineMethods,
|
2013-09-29 01:07:03 +08:00
|
|
|
|
fixLdnull,
|
2011-10-22 20:31:38 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Deobfuscator : DeobfuscatorBase {
|
|
|
|
|
Options options;
|
2012-04-08 17:36:24 +08:00
|
|
|
|
string obfuscatorName = DeobfuscatorInfo.THE_NAME;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
bool foundCryptoObfuscatorAttribute = false;
|
|
|
|
|
bool foundObfuscatedSymbols = false;
|
2012-03-14 03:27:41 +08:00
|
|
|
|
bool foundObfuscatorUserString = false;
|
2013-09-28 20:55:29 +08:00
|
|
|
|
bool startedDeobfuscating = false;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
2012-08-21 21:11:14 +08:00
|
|
|
|
MethodsDecrypter methodsDecrypter;
|
2012-05-29 17:13:39 +08:00
|
|
|
|
ProxyCallFixer proxyCallFixer;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
ResourceDecrypter resourceDecrypter;
|
|
|
|
|
ResourceResolver resourceResolver;
|
|
|
|
|
AssemblyResolver assemblyResolver;
|
2011-10-22 23:13:28 +08:00
|
|
|
|
StringDecrypter stringDecrypter;
|
2011-10-23 00:13:13 +08:00
|
|
|
|
TamperDetection tamperDetection;
|
|
|
|
|
AntiDebugger antiDebugger;
|
2012-07-11 08:18:01 +08:00
|
|
|
|
ConstantsDecrypter constantsDecrypter;
|
|
|
|
|
Int32ValueInliner int32ValueInliner;
|
|
|
|
|
Int64ValueInliner int64ValueInliner;
|
|
|
|
|
SingleValueInliner singleValueInliner;
|
|
|
|
|
DoubleValueInliner doubleValueInliner;
|
2013-09-28 20:55:29 +08:00
|
|
|
|
InlinedMethodTypes inlinedMethodTypes;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
|
|
|
|
internal class Options : OptionsBase {
|
2011-10-23 00:13:13 +08:00
|
|
|
|
public bool RemoveTamperProtection { get; set; }
|
2012-07-11 08:18:01 +08:00
|
|
|
|
public bool DecryptConstants { get; set; }
|
2013-09-28 20:55:29 +08:00
|
|
|
|
public bool InlineMethods { get; set; }
|
2013-09-29 01:07:03 +08:00
|
|
|
|
public bool FixLdnull { get; set; }
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Type {
|
2011-11-12 18:31:07 +08:00
|
|
|
|
get { return DeobfuscatorInfo.THE_TYPE; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string TypeLong {
|
2011-11-04 03:03:32 +08:00
|
|
|
|
get { return DeobfuscatorInfo.THE_NAME; }
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name {
|
|
|
|
|
get { return obfuscatorName; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-28 20:55:29 +08:00
|
|
|
|
protected override bool CanInlineMethods {
|
|
|
|
|
get { return startedDeobfuscating ? options.InlineMethods : true; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<IBlocksDeobfuscator> BlocksDeobfuscators {
|
|
|
|
|
get {
|
|
|
|
|
var list = new List<IBlocksDeobfuscator>();
|
|
|
|
|
if (CanInlineMethods)
|
|
|
|
|
list.Add(new CoMethodCallInliner(inlinedMethodTypes));
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-22 20:31:38 +08:00
|
|
|
|
public Deobfuscator(Options options)
|
|
|
|
|
: base(options) {
|
|
|
|
|
this.options = options;
|
2011-10-23 15:07:47 +08:00
|
|
|
|
StringFeatures = StringFeatures.AllowStaticDecryption | StringFeatures.AllowDynamicDecryption;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void Initialize(ModuleDefMD module) {
|
|
|
|
|
base.Initialize(module);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
protected override int DetectInternal() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
int val = 0;
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
int sum = ToInt32(methodsDecrypter.Detected) +
|
|
|
|
|
ToInt32(stringDecrypter.Detected) +
|
|
|
|
|
ToInt32(tamperDetection.Detected) +
|
|
|
|
|
ToInt32(proxyCallFixer.Detected) +
|
|
|
|
|
ToInt32(constantsDecrypter.Detected);
|
2012-02-29 07:13:57 +08:00
|
|
|
|
if (sum > 0)
|
|
|
|
|
val += 100 + 10 * (sum - 1);
|
2012-03-14 03:27:41 +08:00
|
|
|
|
if (foundCryptoObfuscatorAttribute || foundObfuscatedSymbols || foundObfuscatorUserString)
|
2011-10-23 19:43:32 +08:00
|
|
|
|
val += 10;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
protected override void ScanForObfuscator() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
foreach (var type in module.Types) {
|
|
|
|
|
if (type.FullName == "CryptoObfuscator.ProtectedWithCryptoObfuscatorAttribute") {
|
|
|
|
|
foundCryptoObfuscatorAttribute = true;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
AddAttributeToBeRemoved(type, "Obfuscator attribute");
|
|
|
|
|
InitializeVersion(type);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-19 20:03:57 +08:00
|
|
|
|
if (CheckCryptoObfuscator())
|
2011-10-22 20:31:38 +08:00
|
|
|
|
foundObfuscatedSymbols = true;
|
2011-10-22 23:13:28 +08:00
|
|
|
|
|
2013-09-28 20:55:29 +08:00
|
|
|
|
inlinedMethodTypes = new InlinedMethodTypes();
|
2012-08-21 21:11:14 +08:00
|
|
|
|
methodsDecrypter = new MethodsDecrypter(module);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
methodsDecrypter.Find();
|
2012-05-29 17:13:39 +08:00
|
|
|
|
proxyCallFixer = new ProxyCallFixer(module);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
proxyCallFixer.FindDelegateCreator();
|
2011-10-22 23:13:28 +08:00
|
|
|
|
stringDecrypter = new StringDecrypter(module);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
stringDecrypter.Find();
|
2011-10-23 00:13:13 +08:00
|
|
|
|
tamperDetection = new TamperDetection(module);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
tamperDetection.Find();
|
2013-09-25 07:37:53 +08:00
|
|
|
|
constantsDecrypter = new ConstantsDecrypter(module, initializedDataCreator);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
constantsDecrypter.Find();
|
2012-11-09 05:24:13 +08:00
|
|
|
|
foundObfuscatorUserString = Utils.StartsWith(module.ReadUserString(0x70000001), "\u0011\"3D9B94A98B-76A8-4810-B1A0-4BE7C4F9C98D", StringComparison.Ordinal);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void InitializeVersion(TypeDef attr) {
|
|
|
|
|
var s = DotNetUtils.GetCustomArgAsString(GetAssemblyAttribute(attr), 0);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
if (s == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var val = Regex.Match(s, @"^Protected with (Crypto Obfuscator.*)$");
|
|
|
|
|
if (val.Groups.Count < 2)
|
|
|
|
|
return;
|
|
|
|
|
obfuscatorName = val.Groups[1].ToString();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
bool CheckCryptoObfuscator() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
int matched = 0;
|
|
|
|
|
foreach (var type in module.Types) {
|
|
|
|
|
if (type.Namespace != "A")
|
|
|
|
|
continue;
|
2012-11-09 05:24:13 +08:00
|
|
|
|
if (Regex.IsMatch(type.Name.String, "^c[0-9a-f]{32}$"))
|
2011-10-22 20:31:38 +08:00
|
|
|
|
return true;
|
2012-11-09 05:24:13 +08:00
|
|
|
|
else if (Regex.IsMatch(type.Name.String, "^A[A-Z]*$")) {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
if (++matched >= 10)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateBegin() {
|
|
|
|
|
base.DeobfuscateBegin();
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
2011-12-21 13:39:56 +08:00
|
|
|
|
resourceDecrypter = new ResourceDecrypter(module, DeobfuscatedFile);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
resourceResolver = new ResourceResolver(module, resourceDecrypter);
|
2011-10-22 20:53:24 +08:00
|
|
|
|
assemblyResolver = new AssemblyResolver(module);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
resourceResolver.Find();
|
2013-09-29 01:43:05 +08:00
|
|
|
|
assemblyResolver.Find(DeobfuscatedFile);
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
DecryptResources();
|
|
|
|
|
stringDecrypter.Initialize(resourceDecrypter);
|
2011-11-06 22:24:30 +08:00
|
|
|
|
if (stringDecrypter.Method != null) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
staticStringInliner.Add(stringDecrypter.Method, (method, gim, args) => {
|
|
|
|
|
return stringDecrypter.Decrypt((int)args[0]);
|
2011-10-22 23:13:28 +08:00
|
|
|
|
});
|
2013-01-19 20:03:57 +08:00
|
|
|
|
DeobfuscatedFile.StringDecryptersAdded();
|
2011-10-22 23:13:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-29 01:51:25 +08:00
|
|
|
|
methodsDecrypter.Decrypt(resourceDecrypter, DeobfuscatedFile);
|
2012-08-21 21:11:14 +08:00
|
|
|
|
|
|
|
|
|
if (methodsDecrypter.Detected) {
|
|
|
|
|
if (!assemblyResolver.Detected)
|
2013-09-29 01:43:05 +08:00
|
|
|
|
assemblyResolver.Find(DeobfuscatedFile);
|
2012-08-21 21:11:14 +08:00
|
|
|
|
if (!tamperDetection.Detected)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
tamperDetection.Find();
|
2012-08-21 21:11:14 +08:00
|
|
|
|
}
|
2011-10-23 00:13:13 +08:00
|
|
|
|
antiDebugger = new AntiDebugger(module, DeobfuscatedFile, this);
|
2013-01-19 20:03:57 +08:00
|
|
|
|
antiDebugger.Find();
|
2011-10-23 00:13:13 +08:00
|
|
|
|
|
2012-07-11 08:18:01 +08:00
|
|
|
|
if (options.DecryptConstants) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
constantsDecrypter.Initialize(resourceDecrypter);
|
2012-07-11 08:18:01 +08:00
|
|
|
|
int32ValueInliner = new Int32ValueInliner();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
int32ValueInliner.Add(constantsDecrypter.Int32Decrypter, (method, gim, args) => constantsDecrypter.DecryptInt32((int)args[0]));
|
2012-07-11 08:18:01 +08:00
|
|
|
|
int64ValueInliner = new Int64ValueInliner();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
int64ValueInliner.Add(constantsDecrypter.Int64Decrypter, (method, gim, args) => constantsDecrypter.DecryptInt64((int)args[0]));
|
2012-07-11 08:18:01 +08:00
|
|
|
|
singleValueInliner = new SingleValueInliner();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
singleValueInliner.Add(constantsDecrypter.SingleDecrypter, (method, gim, args) => constantsDecrypter.DecryptSingle((int)args[0]));
|
2012-07-11 08:18:01 +08:00
|
|
|
|
doubleValueInliner = new DoubleValueInliner();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
doubleValueInliner.Add(constantsDecrypter.DoubleDecrypter, (method, gim, args) => constantsDecrypter.DecryptDouble((int)args[0]));
|
|
|
|
|
AddTypeToBeRemoved(constantsDecrypter.Type, "Constants decrypter type");
|
|
|
|
|
AddResourceToBeRemoved(constantsDecrypter.Resource, "Encrypted constants");
|
2012-07-11 08:18:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
AddModuleCctorInitCallToBeRemoved(resourceResolver.Method);
|
|
|
|
|
AddModuleCctorInitCallToBeRemoved(assemblyResolver.Method);
|
|
|
|
|
AddCallToBeRemoved(module.EntryPoint, tamperDetection.Method);
|
|
|
|
|
AddModuleCctorInitCallToBeRemoved(tamperDetection.Method);
|
|
|
|
|
AddCallToBeRemoved(module.EntryPoint, antiDebugger.Method);
|
|
|
|
|
AddModuleCctorInitCallToBeRemoved(antiDebugger.Method);
|
|
|
|
|
AddTypeToBeRemoved(resourceResolver.Type, "Resource resolver type");
|
|
|
|
|
AddTypeToBeRemoved(assemblyResolver.Type, "Assembly resolver type");
|
|
|
|
|
AddTypeToBeRemoved(tamperDetection.Type, "Tamper detection type");
|
|
|
|
|
AddTypeToBeRemoved(antiDebugger.Type, "Anti-debugger type");
|
|
|
|
|
AddTypeToBeRemoved(methodsDecrypter.Type, "Methods decrypter type");
|
|
|
|
|
AddTypesToBeRemoved(methodsDecrypter.DelegateTypes, "Methods decrypter delegate type");
|
|
|
|
|
AddResourceToBeRemoved(methodsDecrypter.Resource, "Encrypted methods");
|
|
|
|
|
|
|
|
|
|
proxyCallFixer.Find();
|
|
|
|
|
|
|
|
|
|
DumpEmbeddedAssemblies();
|
2013-09-28 20:55:29 +08:00
|
|
|
|
|
|
|
|
|
startedDeobfuscating = true;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateMethodEnd(Blocks blocks) {
|
|
|
|
|
proxyCallFixer.Deobfuscate(blocks);
|
2012-07-11 08:18:01 +08:00
|
|
|
|
if (options.DecryptConstants) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
int32ValueInliner.Decrypt(blocks);
|
|
|
|
|
int64ValueInliner.Decrypt(blocks);
|
|
|
|
|
singleValueInliner.Decrypt(blocks);
|
|
|
|
|
doubleValueInliner.Decrypt(blocks);
|
2013-09-25 07:37:53 +08:00
|
|
|
|
constantsDecrypter.Deobfuscate(blocks);
|
2012-07-11 08:18:01 +08:00
|
|
|
|
}
|
2013-01-19 20:03:57 +08:00
|
|
|
|
base.DeobfuscateMethodEnd(blocks);
|
2011-10-23 19:43:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateEnd() {
|
2013-09-29 01:07:03 +08:00
|
|
|
|
if (options.FixLdnull)
|
|
|
|
|
new LdnullFixer(module, inlinedMethodTypes).Restore();
|
2013-01-19 20:03:57 +08:00
|
|
|
|
RemoveProxyDelegates(proxyCallFixer);
|
2012-02-21 23:56:29 +08:00
|
|
|
|
if (CanRemoveStringDecrypterType) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
AddResourceToBeRemoved(stringDecrypter.Resource, "Encrypted strings");
|
|
|
|
|
AddTypeToBeRemoved(stringDecrypter.Type, "String decrypter type");
|
2012-02-21 23:56:29 +08:00
|
|
|
|
}
|
2013-09-29 01:07:03 +08:00
|
|
|
|
AddTypesToBeRemoved(inlinedMethodTypes.Types, "Inlined methods type");
|
2013-01-19 20:03:57 +08:00
|
|
|
|
base.DeobfuscateEnd();
|
2011-10-23 19:43:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void DecryptResources() {
|
|
|
|
|
var rsrc = resourceResolver.MergeResources();
|
2011-10-22 23:13:28 +08:00
|
|
|
|
if (rsrc == null)
|
|
|
|
|
return;
|
2013-01-19 20:03:57 +08:00
|
|
|
|
AddResourceToBeRemoved(rsrc, "Encrypted resources");
|
2011-10-22 23:13:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void DumpEmbeddedAssemblies() {
|
2011-10-22 20:31:38 +08:00
|
|
|
|
foreach (var info in assemblyResolver.AssemblyInfos) {
|
2013-01-19 20:03:57 +08:00
|
|
|
|
DumpEmbeddedFile(info.resource, info.assemblyName, ".dll", string.Format("Embedded assembly: {0}", info.assemblyName));
|
2011-10-22 20:31:38 +08:00
|
|
|
|
|
|
|
|
|
if (info.symbolsResource != null)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
DumpEmbeddedFile(info.symbolsResource, info.assemblyName, ".pdb", string.Format("Embedded pdb: {0}", info.assemblyName));
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
void DumpEmbeddedFile(EmbeddedResource resource, string assemblyName, string extension, string reason) {
|
|
|
|
|
DeobfuscatedFile.CreateAssemblyFile(resourceDecrypter.Decrypt(resource.GetResourceStream()), Utils.GetAssemblySimpleName(assemblyName), extension);
|
|
|
|
|
AddResourceToBeRemoved(resource, reason);
|
2011-10-22 23:13:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override IEnumerable<int> GetStringDecrypterMethods() {
|
2012-02-25 13:25:40 +08:00
|
|
|
|
var list = new List<int>();
|
2011-11-06 22:24:30 +08:00
|
|
|
|
if (stringDecrypter.Method != null)
|
2012-11-02 22:57:11 +08:00
|
|
|
|
list.Add(stringDecrypter.Method.MDToken.ToInt32());
|
2011-10-22 23:13:28 +08:00
|
|
|
|
return list;
|
2011-10-22 20:31:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|