IDAPro权威指南全代码.zip


IDAPro权威指南全实例代码.zip
资源截图
代码片段和文件信息
/*
   Source for ida_patcher
   Copyright (c) 2006 Chris Eagle cseagle at gmail.com
      
   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the Free
   Software Foundation; either version 2 of the License or (at your option) 
   any later version.
   
   This program is distributed in the hope that it will be useful but WITHOUT
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
   FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 
   more details.
   
   You should have received a copy of the GNU General Public License along with 
   this program; if not write to the Free Software Foundation Inc. 59 Temple 
   Place Suite 330 Boston MA 02111-1307 USA
*/

/*
 * This program reads an Ida Pro generated .dif file and applies
 * the differences to the original binary to create a patched binary
 * The program will infer the name of the binary from the content of 
 * the dif file or take the name as a command line option.
 * CAUTION: The program transforms the input binary so if you wish
 * to preserve the original binary make sure you make a copy and
 * transform the copy.
 */

#include 

int main(int argc char **argv) {
   char line[256];
   FILE *patch = stdin;
   FILE *input = NULL;
   unsigned int offset;
   int orig;
   int newval;
  
   int i;
  
   for (i = 1; i < argc; i += 2) {
      if (!strcmp(argv[i] “-p“)) {
         if ((i + 1) < argc) {
            FILE *f = fopen(argv[i+1] “r“);
            if (f) {
               patch = f;
            }
            else {
               fprintf(stderr “Failed to open patch file %s
“ argv[i+1]);
               exit(0);
            }
         }
      }
      else if (!strcmp(argv[i] “-i“)) {
         if ((i + 1) < argc) {
          fprintf(stderr “Opening %s
“ argv[i+1]);
            input = fopen(argv[i+1] “rb+“);
            if (input == NULL) {
               fprintf(stderr “Failed to open input file %s
“ argv[i+1]);
               exit(0);
            }
         }
      }
      else {
         fprintf(stderr “usage:
%s [-i ] [-p ]
“ argv[0]);
         fprintf(stderr “ %s [-p ]
“ argv[0]);
         fprintf(stderr “ %s [-i ] < 
“ argv[0]);
         fprintf(stderr “ %s < 
“ argv[0]);
         exit(0);
      }
   }

   if (patch == stdin) {
      fprintf(stderr “Reading patch data from stdin.
“);
   }
   fgets(line sizeof(line) patch); /* eat dif file intro line */
   fgets(line sizeof(line) patch); /* eat blank line */
   
   if (input == NULL) {
      fprintf(stderr “Inferring input file name from patch file data.
“);
   fscanf(patch “%256s“ line);
      input = fopen(line “rb+“);
      if (input == NULL) {
         fprintf(stderr “Failed to open input file %s
“ line);
         exit(0);
      }
   }
   else { /* don‘t need input file name but 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-06-27 05:06  the_idapro_book_code-master
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercode
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech1
     文件       47616  2017-06-27 05:06  the_idapro_book_code-mastercodech1listing_1-1_and_1-2.exe
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech14
     文件        3436  2017-06-27 05:06  the_idapro_book_code-mastercodech14ida_patcher.c
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech15
     文件        1532  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_1.idc.txt
     文件        1310  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_2.idc.txt
     文件        1483  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_3.idc.txt
     文件        1413  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_4.idc.txt
     文件        1558  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_5.idc.txt
     文件        1811  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_6.idc.txt
     文件        4479  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_6_extended.idc.txt
     文件        1038  2017-06-27 05:06  the_idapro_book_code-mastercodech15listing_15_7.idc.txt
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech17
     文件        2537  2017-06-27 05:06  the_idapro_book_code-mastercodech17Listing_17_1.txt
     文件        2418  2017-06-27 05:06  the_idapro_book_code-mastercodech17Listing_17_2.txt
     文件        3321  2017-06-27 05:06  the_idapro_book_code-mastercodech17Listing_17_3.txt
     文件        5630  2017-06-27 05:06  the_idapro_book_code-mastercodech17ask_using_form.cpp
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech18
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech18pcap
     文件        1173  2017-06-27 05:06  the_idapro_book_code-mastercodech18pcapMakefile
     文件        7775  2017-06-27 05:06  the_idapro_book_code-mastercodech18pcappcap_loader.cpp
     文件        2125  2017-06-27 05:06  the_idapro_book_code-mastercodech18pcappcap_loader.h
     目录           0  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpleton
     文件        1163  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpletonMakefile
     文件         626  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpletonsimpleton.asm
     文件         109  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpletonsimpleton.bin
     文件        4998  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpletonsimpleton.cpp
     文件         790  2017-06-27 05:06  the_idapro_book_code-mastercodech18simpletonsimpleton.idc
............此处省略86个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)