2011-12-31 20:14:02 +08:00
|
|
|
|
/*
|
2015-10-30 05:45:26 +08:00
|
|
|
|
Copyright (C) 2011-2015 de4dot@gmail.com
|
2011-12-31 20:14:02 +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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2012-12-20 09:06:09 +08:00
|
|
|
|
using dnlib.DotNet;
|
2011-12-31 20:14:02 +08:00
|
|
|
|
using de4dot.blocks;
|
|
|
|
|
|
|
|
|
|
namespace de4dot.code.deobfuscators.Skater_NET {
|
|
|
|
|
public class DeobfuscatorInfo : DeobfuscatorInfoBase {
|
|
|
|
|
public const string THE_NAME = "Skater .NET";
|
|
|
|
|
public const string THE_TYPE = "sk";
|
2013-11-18 22:43:08 +08:00
|
|
|
|
const string DEFAULT_REGEX = @"!`[^0-9]+&" + DeobfuscatorBase.DEFAULT_ASIAN_VALID_NAME_REGEX;
|
2012-02-29 05:24:08 +08:00
|
|
|
|
|
2011-12-31 20:14:02 +08:00
|
|
|
|
public DeobfuscatorInfo()
|
2012-02-29 05:24:08 +08:00
|
|
|
|
: base(DEFAULT_REGEX) {
|
2011-12-31 20:14:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name {
|
|
|
|
|
get { return THE_NAME; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Type {
|
|
|
|
|
get { return THE_TYPE; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override IDeobfuscator CreateDeobfuscator() {
|
2011-12-31 20:14:02 +08:00
|
|
|
|
return new Deobfuscator(new Deobfuscator.Options {
|
2013-11-18 23:28:44 +08:00
|
|
|
|
ValidNameRegex = validNameRegex.Get(),
|
2011-12-31 20:14:02 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Deobfuscator : DeobfuscatorBase {
|
|
|
|
|
Options options;
|
|
|
|
|
|
|
|
|
|
StringDecrypter stringDecrypter;
|
|
|
|
|
EnumClassFinder enumClassFinder;
|
|
|
|
|
|
|
|
|
|
internal class Options : OptionsBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Type {
|
|
|
|
|
get { return DeobfuscatorInfo.THE_TYPE; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string TypeLong {
|
|
|
|
|
get { return DeobfuscatorInfo.THE_NAME; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name {
|
|
|
|
|
get { return DeobfuscatorInfo.THE_NAME; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Deobfuscator(Options options)
|
|
|
|
|
: base(options) {
|
|
|
|
|
this.options = options;
|
|
|
|
|
StringFeatures = StringFeatures.AllowNoDecryption | StringFeatures.AllowStaticDecryption;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
protected override int DetectInternal() {
|
2011-12-31 20:14:02 +08:00
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
|
|
if (stringDecrypter.Detected)
|
|
|
|
|
val += 100;
|
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
protected override void ScanForObfuscator() {
|
2011-12-31 20:14:02 +08:00
|
|
|
|
stringDecrypter = new StringDecrypter(module);
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
if (HasAssemblyRef("Microsoft.VisualBasic"))
|
|
|
|
|
stringDecrypter.Find();
|
2011-12-31 20:14:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
bool HasAssemblyRef(string name) {
|
2012-11-07 00:15:11 +08:00
|
|
|
|
foreach (var asmRef in module.GetAssemblyRefs()) {
|
2011-12-31 20:14:02 +08:00
|
|
|
|
if (asmRef.Name == name)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateBegin() {
|
|
|
|
|
base.DeobfuscateBegin();
|
2011-12-31 20:14:02 +08:00
|
|
|
|
|
|
|
|
|
enumClassFinder = new EnumClassFinder(module);
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
stringDecrypter.Initialize(DeobfuscatedFile);
|
2011-12-31 20:14:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateMethodEnd(Blocks blocks) {
|
2012-02-21 23:56:29 +08:00
|
|
|
|
if (CanRemoveStringDecrypterType)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
stringDecrypter.Deobfuscate(blocks);
|
|
|
|
|
enumClassFinder.Deobfuscate(blocks);
|
|
|
|
|
base.DeobfuscateMethodEnd(blocks);
|
2011-12-31 20:14:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
public override void DeobfuscateEnd() {
|
2012-02-19 07:50:08 +08:00
|
|
|
|
if (Operations.DecryptStrings != OpDecryptString.None && stringDecrypter.CanRemoveType)
|
2013-01-19 20:03:57 +08:00
|
|
|
|
AddTypeToBeRemoved(stringDecrypter.Type, "String decrypter type");
|
|
|
|
|
FixEnumTypes();
|
2011-12-31 20:14:02 +08:00
|
|
|
|
|
2013-01-19 20:03:57 +08:00
|
|
|
|
base.DeobfuscateEnd();
|
2011-12-31 20:14:02 +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-12-31 20:14:02 +08:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|