使用cecil 完成 code injection
来源:互联网 发布:不可抗力网络电影 编辑:程序博客网 时间:2024/06/16 02:13
1. 安装Mono.Cecil
2. 创建一个测试项目:
添加测试方法:
这个方法的返回值会被动态重写.
public class Class1 { public static string Test() { return "ok"; } }
3. code Injection 代码:
var path = @"\XX\bin\Debug\ClassLibrary1.dll"; var assembly = AssemblyDefinition.ReadAssembly (path); var type =assembly.MainModule.GetType("ClassLibrary1.Class1"); var foundMethod = type.GetMethods().First(m => m.Name =="Test");////清空当前方法指令 foundMethod.Body.Instructions.Clear();////获得当前IL的指令执行器 var worker = foundMethod.Body.GetILProcessor();////修改返回值 Instruction ins1 = worker.Create(OpCodes.Ldstr, "will be changed onnext time run"); Instruction ins2 = worker.Create(OpCodes.Ret); worker.Append(ins1); worker.Append(ins2);////保存DLL文件 assembly.Write(path); ////下次调用就会看到(因为新保存的DLL下次才能加载到) Console.WriteLine(Class1.Test()); Console.Read();
4. 运行查看结果
0 0
- 使用cecil 完成 code injection
- Encryptpe v2 Code injection
- Code Injection 代码注入
- Plesk PHP Code Injection
- IronPython中使用Cecil类库指南
- IronPython中使用Cecil类库指南
- 使用Mono.Cecil改变访问级别
- 使用Mono.Cecil对MSIL进行注入
- 使用Mono.Cecil对MSIL进行注入
- 使用Mono.Cecil对MSIL进行注入
- OBSIDIUM V1.25 Code Injection
- Learning PHP Code injection 【I】
- Learning PHP Code injection 【II】
- 使用MOno Cecil 的相关开源项目
- Mono.Cecil使用示例之获取源文件路径
- Git Review + Gerrit 安装及使用完成 Code-Review
- acsess sql injection code by c
- microsoft source code analyzer for sql injection
- Unity3D 解析泛型集合使用
- 【数据结构】链表的基本操作
- ActionScript3.0 socket获取http响应头
- 综合类文章书籍收集
- 解决:flex跨域访问的安全沙箱问题
- 使用cecil 完成 code injection
- 关于Yii中findBySql的查询
- Android生存指南:Eclipse快捷键
- c++虚指针及相应对象的数据结构
- stm8-----falsh ICP and IAP学习笔记
- C++ 写法do{...}while(0)的意义和用法
- 根文件系统制作
- canvas.save() canvas.restore() 作用
- 2-Asp.net核心对象