我正在尝试对 .net 恶意 EXE 进行逆向工程,但它在其内存中加载了一个 DLL。我曾尝试使用名为 SharpDllLoader 和 dnspy 的工具调试此 DLL,但我有两个问题:
第一:
(无法创建抽象类。)我稍微搜索了一下,发现 DLL 中的类是static.
第二个:
修改类类型后,又出现了一个问题(没有为这个对象定义无参构造函数)
我不是 C# 专家,但这些问题在执行后出现 CreateInstance
private static void Main(string[] args)
{
ParserResult<Options> result = Parser.Default.ParseArguments<Options>(args);
if (result.Tag != ParserResultType.Parsed)
{
Environment.Exit(1);
return;
}
Options options = ((Parsed<Options>)result).Value;
string filepath = options.Dll;
string ns = options.Namespace;
string c = options.Class;
string i = options.Method;
string[] arguments = null;
if (options.Args != null)
{
arguments = options.Args.Split(new char[0]);
}
Assembly assembly = Assembly.LoadFile(filepath);
Type type;
if (ns == null)
{
type = assembly.GetType(c);
}
else
{
type = assembly.GetType(ns + "." + c);
}
if (!(type != null))
{
Console.WriteLine("Class or namespace not found");
return;
}
object cl = Activator.CreateInstance(type); //Here
解决方案
我尝试了另一种方法来获取此对象的实例,而无需使用
FormatterServices.GetUninitializedObject(type).