wtujoxk 发表于 2025-1-20 12:59:23

.net 劫持 使用特征码一补丁通杀某标签软件所有版本

本帖最后由 wtujoxk 于 2025-1-20 18:16 编辑

通杀软件这里不再分析,软件的注册位置特征码没有变过
分析过程在这里:https://www.52pojie.cn/thread-851880-1-1.html
我们使用文章中的方法3修改内存地址,将十六进制16改为17这里主要使用.net特征码的形式对程序运行时的内存进行修改,从而达到注册的目的
使用到的 .net内存特征码搜索和内存修改在这里https://www.chinapyg.com/thread-157780-1-1.html既然使用劫持,肯定要写部分代码
首先使用Visual Studio新建一个 .net的类库工程,名称随意
我这里命名为versionusing System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace version
{
    public class Adm
    {

    }
}建立好工程以后,做一下基本的引用,将.net内存特征码搜索和内存修改文章里的PatchPattern.dll引入到工程
在Adm类里继承 AppDomainManagerusing System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace version
{
    public class Adm : AppDomainManager
    {

    }
}下面使用构造函数的原理进行编写劫持代码using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace version
{
    public class Adm : AppDomainManager
    {
      public Adm()
      {
            Debug.WriteLine("劫持进入……");
            AppDomain.CurrentDomain.AssemblyLoad += (sender, args) =>
            {
                if (args.LoadedAssembly.Location.Contains("Chen.dll"))
                {
                  Debug.WriteLine("Assembly loaded: " + args.LoadedAssembly.Location);

                  IntPtr hModule = Process.GetCurrentProcess().Handle;
                  ulong baseAddress = PatchPattern.Get_Assembly_Module_BaseAddress("Chen.dll");
                  ulong sizeOfImage = PatchPattern.Get_Moule_SizeOfImage(baseAddress);
                  string pattern = "16 2A 16 0A 02 28 52";
                  Debug.WriteLine("模块基址:0x" + baseAddress.ToString("X") + "----模块大小:0x" + sizeOfImage.ToString("X"));

                  List<ulong> retAddresses = PatchPattern.SundayPatternFind(hModule, baseAddress, baseAddress + sizeOfImage, pattern, 0);
                  retAddresses.ForEach(x => Debug.WriteLine("特征码地址:0x" + x.ToString("X")));
                  // 修改内存数据
                  retAddresses.ForEach(x => PatchPattern.WriteMemoryData(x, "17"));
                }
            };
      }
    }
}这样dll就编写完成了!如果不想多带一个dll,可以在工程里使用Costura.Fody编译为一个dll文件,Costura.Fody用法自己搜索既然有了dll,要怎样才能使程序加载自己编写的dll并执行呢,如果是.net4的版本,只要编写一个后缀为.config的配置文件即可,如我的程序名称为:xxx.exe,那么就在目录里添加一个xxx.exe.config文件,内容为<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup>
      <supportedRuntime version="v4.0" />
    </startup>
    <runtime>
      <appDomainManagerType value="version.Adm" />
      <appDomainManagerAssembly value="version" />
    </runtime>
</configuration>
注意:
appDomainManagerType value="version.Adm" 里的version为程序集
appDomainManagerAssembly value="version" 里的version为dll名称
supportedRuntime version="v4.0"里的版本如果有多个,这个一定要第一个
如文章中的软件自己就有.config,只需要更改就行,它有两个supportedRuntime,所以要将supportedRuntime version="v4.0"改到第一个<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
    <supportedRuntime version="v2.0.50727"/>   
    <!--requiredRuntime version="v1.0.3705" safemode="true"/-->
</startup>下面就是在runtime里添加两行就行,即<runtime>
    <!--解决“此实现不是 Windows 平台 FIPS 验证的加密算法的一部分”-->
    <enforceFIPSPolicy enabled="false"/>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
      <assemblyIdentity name="Chen" publicKeyToken="F7677E9EB01F20AD" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="5.66.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
      <assemblyIdentity name="Chen.DataLayers.Lable" publicKeyToken="F7677E9EB01F20AD" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="5.66.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
    <appDomainManagerType value="version.Adm" />
    <appDomainManagerAssembly value="version" />
</runtime>.config文件修改完成以后,将生成的version.dll拷贝到程序根目录未劫持修改前劫持修改后主要是说明.net的优雅劫持和通过特征码定位修改内存数据的方法,这里不提供软件和成品的dll,如果按以上操作一切顺利,应该能达到效果,祝成功……

super_king 发表于 2025-1-20 15:34:13

感谢发布原创作品,

halewandering 发表于 2025-1-20 16:41:32

原创作品,必须支持!

杨林 发表于 2025-1-21 01:20:07

感谢分享,学习了!

不破不立 发表于 2025-1-21 08:30:18

感谢发布原创作品,收藏学习

飞天梦 发表于 2025-1-22 07:16:10

谢谢分享

fzx118 发表于 2025-1-23 15:01:45

感觉牛逼哄哄

xingbing 发表于 4 天前

本帖最后由 xingbing 于 2025-2-11 16:30 编辑

“在runtime里添加两行。”
runtime这个在哪里?是不是安装目录有这个文件?
页: [1]
查看完整版本: .net 劫持 使用特征码一补丁通杀某标签软件所有版本