2025-05-12 18:03:39 +08:00
|
|
|
|
using dnlib.DotNet;
|
2025-05-13 11:37:07 +08:00
|
|
|
|
using Obfuz.Utils;
|
2025-05-12 18:03:39 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2025-05-12 22:07:27 +08:00
|
|
|
|
namespace Obfuz
|
2025-05-12 18:03:39 +08:00
|
|
|
|
{
|
|
|
|
|
public class NotObfuscatedMethodWhiteList
|
|
|
|
|
{
|
2025-05-13 11:37:07 +08:00
|
|
|
|
private bool ShouldBeIgnoredByCustomAttribute(IHasCustomAttribute obj)
|
|
|
|
|
{
|
|
|
|
|
return MetaUtil.HasObfuzIgnoreAttribute(obj) || MetaUtil.HasCompilerGeneratedAttribute(obj);
|
|
|
|
|
}
|
2025-05-12 18:03:39 +08:00
|
|
|
|
|
|
|
|
|
public bool IsInWhiteList(ModuleDef module)
|
|
|
|
|
{
|
|
|
|
|
string modName = module.Assembly.Name;
|
|
|
|
|
if (modName == "Obfuz.Runtime")
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-13 11:37:07 +08:00
|
|
|
|
if (ShouldBeIgnoredByCustomAttribute(module))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-12 18:03:39 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsInWhiteList(MethodDef method)
|
|
|
|
|
{
|
|
|
|
|
if (IsInWhiteList(method.DeclaringType))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-13 11:37:07 +08:00
|
|
|
|
if (ShouldBeIgnoredByCustomAttribute(method))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-12 18:03:39 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsInWhiteList(TypeDef type)
|
|
|
|
|
{
|
|
|
|
|
//if (type.Name.StartsWith("$Obfuz$"))
|
|
|
|
|
//{
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
if (IsInWhiteList(type.Module))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-13 11:37:07 +08:00
|
|
|
|
if (ShouldBeIgnoredByCustomAttribute(type))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-12 22:07:27 +08:00
|
|
|
|
if (type.FullName == "Obfuz.EncryptionVM.GeneratedEncryptionVirtualMachine")
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2025-05-12 18:03:39 +08:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|