• C#来做virus的设想


    偶不懂PE格式,不懂strongname应该如何处理,所以,下面是一个非常笨的方法,

    假设有一个exe,我现在要感染它,因为上面的原因决定,我只能选择一个迂回的路线。
    把exe用ildasm搞成.il代码,然后把我的il代码加进去,然后ilasm重新编译该il,呵呵。这样做,需要被感染的机器安装有ildasm(如果不装sdk,没这玩意儿)。

    简单的例子:我想输入hello,fqq!那么写一个最小的代码,如下:
    using System;

    namespace DebugDemo{
        
    public class Demo{
            
    public static void Main(){
                Console.WriteLine(
    "hello,fqq!");
            }

        }

    }

    然后用csc,ildasm,得到.il代码,main里面唯一的一行,会输出为:
    IL_0000:  ldstr      "hello,fqq!"
    IL_0005:  call       
    void [mscorlib]System.Console::WriteLine(string)

    然后,用ildasm 要感染的文件.exe  /output=tmp.il
    然后找到il中的.entrypoint,把上面两行插进去,并修改后面的il行号(是否需要修改?我没有试验过,不过我是都修改了),然后,用ilasm重新编译一次,把原来的文件覆盖即可。

    虽然着很滥,不过确实很直接的做法,呵呵。

    这是被感染文件,修改前的il代码:
         .entrypoint
          
    // Code size       25 (0x19)
          .maxstack  3
          .locals init (int32 V_0,
                   int32 V_1,
                   int32 V_2,
                   int32 V_3)
          IL_0000:  ldc.i4.s   
    10
          IL_0002:  stloc.
    0
          IL_0003:  ldc.i4.s   
    20
          IL_0005:  stloc.
    1
          IL_0006:  ldc.i4.s   
    30
          IL_0008:  stloc.
    2
          IL_0009:  ldloc.
    0
          IL_000a:  ldloc.
    1
          IL_000b:  ldloc.
    2
          IL_000c:  call       int32 DebugDemo.Demo::Sum(int32,
                                                         int32,
                                                         int32)
          IL_0011:  stloc.
    3
          IL_0012:  ldloc.
    3
          IL_0013:  call       
    void [mscorlib]System.Console::WriteLine(int32)
          IL_0018:  ret

    下面是被感染文件修改后的代码:
          .entrypoint
          
    // Code size       25 (0x19)
          .maxstack  3
          .locals init (int32 V_0,
                   int32 V_1,
                   int32 V_2,
                   int32 V_3)
          IL_0000:  ldstr      
    "hello,fqq!"
          IL_0005:  call       
    void [mscorlib]System.Console::WriteLine(string)
          IL_000a:  ldc.i4.s   
    10
          IL_000c:  stloc.
    0
          IL_000d:  ldc.i4.s   
    20
          IL_000f:  stloc.
    1
          IL_0010:  ldc.i4.s   
    30
          IL_0012:  stloc.
    2
          IL_0013:  ldloc.
    0
          IL_0014:  ldloc.
    1
          IL_0015:  ldloc.
    2
          IL_0016:  call       int32 DebugDemo.Demo::Sum(int32,
                                                         int32,
                                                         int32)
          IL_001b:  stloc.
    3
          IL_001c:  ldloc.
    3
          IL_001d:  call       
    void [mscorlib]System.Console::WriteLine(int32)
          IL_0022:  ret

    注意IL_0000和IL_0005两行,被我插入了。

    注意!!!这不是什么病毒教程,如果病毒要这么写,作者早就被人扁死了。
  • 相关阅读:
    Ext2.0布局类初探
    从DHTML、HTC、XHTML到AJAX
    我常用的一些ASP自定义函数
    Javascript的调试利器:Firebug使用详解
    ODBC的多线程应用
    召唤有丰富IOCP实践经验的同行
    欢迎
    关于.NET安装时的dotNETFXRedist_x86.msm
    所谓设计模式
    VC编程经验汇总(一)
  • 原文地址:https://www.cnblogs.com/juqiang/p/23797.html
Copyright © 2020-2023  润新知