使用 Ildasm, ILasm, Peverify 来 Crack 别人写的应用程序。

博客展示了使用Ildasm、ILasm、Peverify来Crack应用程序的示例代码。给出了一个验证用户ID的程序,包含Main方法和IsValid方法,还展示了IL代码,并对IsValid方法进行修改,使其直接返回true。
昨天画了半个多小时把 SQLDBCompare 这个.NET 程序给破解了一下,本来只有15天的试用期,破解以后就没有这个问题了,hoho。

现在我写一个简单的实例程序来提一下使用.NET SDK 中的几个有用的工具来修改别人的代码逻辑。比如拿掉注册信息,等等。当然这里只是一个学习用途。 emsmiled.gif

比如我有个程序,用户输入一个 ID,如果大于100 则改用户是合法的用户,否则就是非法的。程序比较简单,主要是 Demo
我希望修改一下输入任何 ID,都是合法用户。

为了方面,我们直接用记事本写一个简单的程序。

None.gif using  System;
None.gif
None.gif
public   class  DemoCrack
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public static void  Main()
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        System.Console.WriteLine(
"Enter your ID");
InBlock.gif        
string s=Console.ReadLine();
InBlock.gif        
int j=System.Int32.Parse(s);
InBlock.gif        
if(IsValid(j)==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Console.WriteLine(
"You are valid User");
ExpandedSubBlockEnd.gif            }

InBlock.gif        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Console.WriteLine(
"Invalid user");
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif    }

InBlock.gif
InBlock.gif    
public static  bool IsValid(int i)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
if(i>100)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return true;
ExpandedSubBlockEnd.gif            }

InBlock.gif        
else
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return false;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

文件另存为 DemoCrack.cs

然后编译这个应用程序,为了让大家容易读懂 中间代码,我加入调试信息。
运行
csc DemoCrack.cs /debug+

DemoCrack.exe 就编译好了。 而这个 Exe 一般就是我们通常拿到别人写的组件或者应用
运行这个exe

DemoCrack.exe

Enter your ID
12
Invalid user

Enter your ID
120
You are valid User


假设我们现在只有 DemoCrack.exe 这个文件,我希望用户输入任何ID 都是合法的用户,接下来就是我们使用三个工具的时候了:)

你可以使用reflector 看一下这个源代码,一看就知道如何去修改代码逻辑,希望把 IsInvalid 这个函数永远返回true 就可以了。


我们首先拿到中间代码:为了让大家读懂il,我把源代码作为注释放在il 种了

运行

ildasm /source DemoCrack.exe /out:crack.il

crack.il 就是我们的中间代码了,hoho。 接下来我们对他做稍微的修改

文件中 关于IsInvalid 的大概逻辑是:

None.gif   .method  public  hidebysig  static   bool   IsValid(int32 i) cil managed
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif    
// Code size       15 (0xf)
InBlock.gif
    .maxstack  2
InBlock.gif    .locals init ([
0bool CS$00000003$00000000)
InBlock.gif
//000019: 
InBlock.gif
//000020:     public static  bool IsValid(int i)
InBlock.gif
//000021:     {
InBlock.gif
//000022:         if(i>100)
InBlock.gif
    IL_0000:  ldarg.0
InBlock.gif    IL_0001:  ldc.i4.s   
100
InBlock.gif    IL_0003:  ble.s      IL_0009
InBlock.gif
InBlock.gif
//000023:             {
InBlock.gif
//000024:                 return true;
InBlock.gif
    IL_0005:  ldc.i4.1
InBlock.gif    IL_0006:  stloc.
0
InBlock.gif    IL_0007:  br.s       IL_000d
InBlock.gif
InBlock.gif
//000025:             }
InBlock.gif
//000026:         else
InBlock.gif
//000027:             {
InBlock.gif
//000028:                 return false;
InBlock.gif
    IL_0009:  ldc.i4.0
InBlock.gif    IL_000a:  stloc.
0
InBlock.gif    IL_000b:  br.s       IL_000d
InBlock.gif
InBlock.gif
//000029:             }
InBlock.gif
//000030:     }
InBlock.gif
    IL_000d:  ldloc.0
InBlock.gif    IL_000e:  ret
ExpandedBlockEnd.gif  }
  //  end of method DemoCrack::IsValid


这几个指令足够简单了吧,我把他替换为
None.gif   .method  public  hidebysig  static   bool   IsValid(int32 i) cil managed
ExpandedBlockStart.gifContractedBlock.gif  
dot.gif {
InBlock.gif    
// Code size       15 (0xf)
InBlock.gif
    .maxstack  2
InBlock.gif    .locals init ([
0bool CS$00000003$00000000)
InBlock.gif
//000019: 
InBlock.gif
//000020:     public static  bool IsValid(int i)
InBlock.gif
//000021:     {
InBlock.gif
//                return true;
InBlock.gif
    IL_0000:  ldc.i4.1
InBlock.gif    IL_0001:  stloc.
0
InBlock.gif 
InBlock.gif
InBlock.gif    IL_0002:  ldloc.
0
InBlock.gif    IL_0003:  ret
ExpandedBlockEnd.gif  }
  //  end of method DemoCrack::IsValid

然后保存一下这个文件。

接下来就是编译成exe
运行

Ilasm crack.il 为了演示,我就不修改其图标等其他设资了。

然后确认一下我们改的 il 没有问题
调用

PEVerify Crack.exe

一切OK 的话,就大功告成了。

接下来运行 Crack.exe
Enter your ID
12
You are valid User

PS. 简单的一个 Demo,不用用于非法用途。

接下来你可以考虑一下,如何不让别人来Crack 自己的应用程序,如果是你,你会增么做。
不要仅仅是代码搅乱之类的,hoho





转载于:https://www.cnblogs.com/montaque/archive/2005/01/10/89464.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值