欢迎来到 嗅灵易学

零基础也能上手的脚本技术课,一对一答疑带你入门

我的破解心得(2) (2千字)

我的破解心得(2) (2千字)

破解对象:
  IrfanView32
破解者:
  chcw
  在上一节中,我们已经知道,只要将执行程序I_view32.exe在Offset=0x685处
的字节从0x94改为0x95即可破解IrfanView32。在这一节,我们将介绍如何为
IrfanView32写一个Patcher,它在执行时自动完成上述的修改任务。
--------------------- Patcher.c -----------------------
#include <stdio.h>
#include <stdlib.h>
void main()
{
    unsigned char patch=0x95;
        long offset=0x00000685;
    FILE *fp;
    
    printf("Crack for IrfanView32\n");
    printf("Written by Mr. Chcw\n");
    
        if ((fp=fopen("I_view32.exe", "r+"))==NULL) {
        printf("Error: Cannot find file I_view32.exe\n");
        exit(1);
    }
    
        fseek(fp,offset,SEEK_SET);
    fputc(patch,fp);
    
    printf("Patch successful\n");
}        
--------------------- End of Patcher.c ------------------
  Patcher.c程序先将可执行文件I_view32.exe读入,然后通过偏移地址定位
到要Patch的地方,再用机器码0x95改写该处的字节,就完成了Patch过程。
  当然,在实际应用中,待Patch的程序因版本的不同可能会产生Patch地址的
偏差或Patch代码的偏差,我们需要在Patch之前检查待Patch的程序的版本(如
根据程序的大小)和Patch处原机器码是否正确,以保证不会Patch错误。
  下面是一个改进的Patcher1.c程序:
----------------------- Patcher1.c ------------------------
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
void main()
{
    const long filesize=614912;    //614,912 bytes
    const unsigned char oldcode=0x94;
    
    unsigned char patchcode=0x95;
    long offset=0x00000685;
    FILE *fp;
    
    printf("Crack for IrfanView32\n");
    printf("Written by Mr. Chcw\n");
    
    if ((fp=fopen("I_view32.exe", "r+"))==NULL) {
        printf("Error: Cannot find file I_view32.exe\n");
        exit(1);
    }
    else if (filelength(fileno(fp))!=filesize) {
        printf("Error: Incorrect IrfanView32 version, cannot patch it\n");
        exit(2);
    }    
    
    fseek(fp,offset,SEEK_SET);
    if (fgetc(fp)!=oldcode) {
        printf("Error: The file I_view32.exe is corrupted\n");            
        exit(3);
    }        
    
    fseek(fp,offset,SEEK_SET);
    fputc(patchcode,fp);
    fclose(fp);
    printf("Patch successful\n");
}        
    
-------------------- End of Patcher1.c --------------------

注意:上传附件及图片大小不得大于30M。

⚠️ 版权声明:
本博客所有内容(含教程、源码、工具)仅供个人技术学习与研究交流使用,严禁商用、倒卖、二次分发及非法用途
未经作者书面授权,任何组织或个人不得转载、复制或用于其他平台,违者将追究相关责任。

0 0 0 举报
复制成功