2011-09-22 10:55:30 +08:00
|
|
|
|
/*
|
2012-01-10 06:02:47 +08:00
|
|
|
|
Copyright (C) 2011-2012 de4dot@gmail.com
|
2011-09-22 10:55:30 +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-02-25 13:25:40 +08:00
|
|
|
|
using System.Collections.Generic;
|
2011-10-05 23:22:56 +08:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
2011-12-09 16:02:06 +08:00
|
|
|
|
namespace de4dot.code.deobfuscators.Unknown {
|
|
|
|
|
public class DeobfuscatorInfo : DeobfuscatorInfoBase {
|
2011-11-04 03:03:32 +08:00
|
|
|
|
public const string THE_NAME = "Unknown";
|
2011-11-12 18:31:07 +08:00
|
|
|
|
public const string THE_TYPE = "un";
|
2011-09-22 10:55:30 +08:00
|
|
|
|
public DeobfuscatorInfo()
|
2011-11-04 03:03:32 +08:00
|
|
|
|
: base() {
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 03:03:32 +08:00
|
|
|
|
public override string Name {
|
|
|
|
|
get { return THE_NAME; }
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Type {
|
2011-11-12 18:31:07 +08:00
|
|
|
|
get { return THE_TYPE; }
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IDeobfuscator createDeobfuscator() {
|
|
|
|
|
return new Deobfuscator(new Deobfuscator.Options {
|
|
|
|
|
RenameResourcesInCode = false,
|
|
|
|
|
ValidNameRegex = validNameRegex.get(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Deobfuscator : DeobfuscatorBase {
|
2011-10-09 01:33:12 +08:00
|
|
|
|
string obfuscatorName;
|
2011-10-05 23:22:56 +08:00
|
|
|
|
|
2011-09-22 10:55:30 +08:00
|
|
|
|
internal class Options : OptionsBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Name {
|
2011-10-09 01:33:12 +08:00
|
|
|
|
get { return obfuscatorName ?? "Unknown Obfuscator"; }
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-14 19:27:03 +08:00
|
|
|
|
protected override bool KeepTypes {
|
|
|
|
|
get { return true; }
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-09 16:02:06 +08:00
|
|
|
|
internal Deobfuscator(Options options)
|
2011-09-22 10:55:30 +08:00
|
|
|
|
: base(options) {
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 01:33:12 +08:00
|
|
|
|
void setName(string name) {
|
|
|
|
|
if (obfuscatorName == null && name != null)
|
|
|
|
|
obfuscatorName = name;
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
2011-10-05 23:22:56 +08:00
|
|
|
|
|
2011-10-09 01:33:12 +08:00
|
|
|
|
public override int earlyDetect() {
|
|
|
|
|
setName(earlyScanTypes());
|
|
|
|
|
return obfuscatorName != null ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string earlyScanTypes() {
|
|
|
|
|
foreach (var type in module.Types) {
|
|
|
|
|
if (type.FullName == "ConfusedByAttribute")
|
|
|
|
|
return "Confuser";
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 20:29:12 +08:00
|
|
|
|
protected override int detectInternal() {
|
2011-10-09 01:33:12 +08:00
|
|
|
|
setName(scanTypes());
|
|
|
|
|
return 1;
|
2011-10-05 23:22:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 20:29:12 +08:00
|
|
|
|
protected override void scanForObfuscator() {
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-05 23:22:56 +08:00
|
|
|
|
string scanTypes() {
|
|
|
|
|
foreach (var type in module.Types) {
|
|
|
|
|
if (type.FullName == "ZYXDNGuarder")
|
|
|
|
|
return "DNGuard HVM";
|
2011-10-06 16:33:13 +08:00
|
|
|
|
if (type.Name.Contains("();\t"))
|
|
|
|
|
return "Manco .NET Obfuscator";
|
|
|
|
|
if (Regex.IsMatch(type.FullName, @"^EMyPID_\d+_$"))
|
2011-10-07 23:30:41 +08:00
|
|
|
|
return "BitHelmet Obfuscator";
|
2011-10-07 14:45:40 +08:00
|
|
|
|
if (type.FullName == "YanoAttribute")
|
|
|
|
|
return "Yano Obfuscator";
|
2011-10-05 23:22:56 +08:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2012-02-25 13:25:40 +08:00
|
|
|
|
|
|
|
|
|
public override IEnumerable<int> getStringDecrypterMethods() {
|
|
|
|
|
return new List<int>();
|
|
|
|
|
}
|
2011-09-22 10:55:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|