.net程序破解入门(ildasm) 之hello world

工具:ildasm,ilasm,vs2005

做为Helloworld,为方面大家理解il语言与c#(为例)之间的对应关系,我们破解自己写的Hello world

 S1:    使用vs2005建一个控件库UserControl1,里面有一个显示版权信息的函数:

         /// <summary>
        
/// 如果没有通过版本校验,提示用户需要注册
        
/// </summary>
        
/// <param name="regest">是否通过版权校验</param>

         private   void  PaintInfo( bool  regest)
        
{
            
this.label1.Text = "";
            
if (!regest)
            
{
                
this.label1.Text = "需要注册";
            }
            
        }

S2: 编译生成DLL

S3:使用ildasm将dll打开,后转存为一个il文件。用记事本打开,在里面会找到

 .method  private  hidebysig instance  void  
          PaintInfo() cil managed
  
{
    
// 代码大小       48 (0x30)
    .maxstack  2
    .locals init (
bool V_0)
    IL_0000:  nop
    IL_0001:  ldarg.
0
    IL_0002:  ldfld      
class [System.Windows.Forms]System.Windows.Forms.Label Demo.UserControl1::label1
    IL_0007:  ldstr      
""
    IL_000c:  callvirt   instance 
void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
    IL_0011:  nop
    IL_0012:  ldarg.
0
    IL_0013:  ldfld      
bool Demo.UserControl1::regest
    IL_0018:  stloc.
0
    IL_0019:  ldloc.
0
    IL_001a:  brtrue.s   IL_002f    // 关键的来了

    IL_001c:  nop
    IL_001d:  ldarg.
0
    IL_001e:  ldfld      
class [System.Windows.Forms]System.Windows.Forms.Label Demo.UserControl1::label1
    IL_0023:  ldstr      bytearray (
00 97 81 89 E8 6C 8C 51 )                         // .....l.Q
    IL_0028:  callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_Text(string)
    IL_002d:  nop
    IL_002e:  nop
    IL_002f:  ret
  }
  //  end of method UserControl1::PaintInfo

简简单单的把IL_001a:  brtrue.s   IL_002f 。。。改成IL_001a:  brfalse.s   IL_002f    。保存

s4: 使用命令ilasm xxx /dll    再次编译成Dll

OK,保证成功!

过程就这么简单!师兄们自己去体会知识点!

  

 

   

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值