使用 C 代码从 DFRWS 2007 数据集中检索 PPT 文件

问题描述

我需要使用 C 代码从 DFRWS 2007 数据集中雕刻(偏移和聚类)和检索 PPT 文件。我设法使用 C 代码中 PPT 文件标题幻数从 DFRWS 2007 中雕刻(获取偏移和群集)PPT 文件,但我无法从 DFRWS 2007 中检索 PPT 文件。我不知道哪一部分去了错误的。我从 here 获得了图像偏移量和文件扇区偏移量。这是文件数据类型 here 的布局。谁能帮我找出错误在哪里?

C 编码是从 DFRWS 2007 数据集雕刻出 PPT 文件

#include <stdio.h>
#include <conio.h>


int main()
{
    FILE *file_input,*file_output;
    
    unsigned char magicNumber1 = 0x0;
    unsigned char magicNumber2 = 0x0;
    unsigned char magicNumber3 = 0x0;
    unsigned char magicNumber4 = 0x0;
    unsigned char magicNumber5 = 0x0;
    unsigned char magicNumber6 = 0x0;
    unsigned char magicNumber7 = 0x0;
    unsigned char magicNumber8 = 0x0;
    long int curPos1=0L,curPos2=0L;
    long int offset=0L;
    long int saizFail;
    long int cluster=0L,found=0L;
    
    if((file_input = fopen("C:\\Users\\HP\\Downloads\\dfrws-2007-challenge.img","rb"))==NULL)
        printf("File cannot be opened");
        
    if((file_output = fopen("C:\\Users\\HP\\Downloads\\offset.txt","wb"))==NULL)
        printf("TXT cannot be opened");
        
    fseek(file_input,0L,SEEK_END);
    saizFail = ftell(file_input);
    rewind(file_input);
    
    while(offset<saizFail)
    {
        curPos1=ftell(file_input);
        printf("\ncurPos1: Offset before fgetc MagicNumber1 = %ld",curPos1);
        
        magicNumber1 = fgetc(file_input);
        magicNumber2 = fgetc(file_input);
        magicNumber3 = fgetc(file_input);
        magicNumber4 = fgetc(file_input);
        magicNumber5 = fgetc(file_input);
        magicNumber6 = fgetc(file_input);
        magicNumber7 = fgetc(file_input);
        magicNumber8 = fgetc(file_input);
        
        if((magicNumber1==0xD0) && (magicNumber2==0xCF) && (magicNumber3==0x11) && (magicNumber4==0xE0) && (magicNumber5==0xA1) && (magicNumber6==0xB1) && (magicNumber7==0x1A) && (magicNumber8==0xE1))
        {
            
            cluster = (curPos1) / 512;
            found++;
            
            printf("\n\nt>>PPT Header [#%ld] FOUND at >> OFFSET %ld (CLUSTER %ld)<<\n",found,curPos1,cluster);
            fprintf(file_output,"%ld\n",curPos1); //Offset
        }
        offset = offset +512;
        fseek(file_input,offset,SEEK_SET);
    }
    fclose(file_input);
    fclose(file_output);
    getch();
        
}

C 编码是从 DFRWS 2007 数据集中检索 PPT 文件

#include <stdio.h>
#include <conio.h>

main()
{
    FILE *file_input1,*file_input2,*file_output;
    unsigned char ppt_char=0x0;
    unsigned char magicNumber1 = 0x0;
    unsigned char magicNumber2 = 0x0;
    unsigned char magicNumber3 = 0x0;
    unsigned char magicNumber4 = 0x0;
    unsigned char magicNumber5 = 0x0;
    unsigned char magicNumber6 = 0x0;
    unsigned char magicNumber7 = 0x0;
    unsigned char magicNumber8 = 0x0;
    long int curPos1=0L,curPos2=0L;
    long int counter=0L;
    long int saizFail,curPos=0L,current=0L;
    long int offset=0L;
    long int cluster=0L,found=0L;
    long int address_hdr=0L;
    
    if((file_input1 = fopen("C:\\Users\\HP\\Downloads\\dfrws-2007-challenge.img","rb"))==NULL)
        printf("File cannot be opened");
        
    if((file_input2 = fopen("C:\\Users\\HP\\Downloads\\offset.txt","rb"))==NULL)
        printf("TXT cannot be opened");
        
    if((file_output = fopen("C:\\Users\\HP\\Downloads\\recover_file.ppt","wb"))=NULL)
        printf("PPT cannot be opened");
        
    fseek(file_input1,SEEK_END);
    saizFail=ftell(file_input1);
    rewind(file_input1);
    
    printf("\n>>Carve non-fragmented PPT<<\n");
    fscanf(file_input2,"%ld",&address_hdr);
    
    fseek(file_input1,address_hdr,SEEK_SET);
    cluster = address_hdr / 512;
    
    curPos1=ftell(file_input1);
    printf("\ncurPos1: Offset before fgetc MagicNumber1 = %ld",curPos1);
    
    magicNumber1 = fgetc(file_input1);
    magicNumber2 = fgetc(file_input1);
    magicNumber3 = fgetc(file_input1);
    magicNumber4 = fgetc(file_input1);
    magicNumber5 = fgetc(file_input1);
    magicNumber6 = fgetc(file_input1);
    magicNumber7 = fgetc(file_input1);
    magicNumber8 = fgetc(file_input1);
    
    curPos2=ftell(file_input1);
    printf("\ncurPos2: Offset after MagicNumber8 = %ld",curPos2);
    
    fseek(file_input1,SEEK_SET);
    offset = address_hdr;
    printf("\n%ld",address_hdr);
    while(offset <= 50000000L)
    {
        ppt_char=fgetc(file_input1);
        fputc(ppt_char,file_output);
        offset++;
    }
    
    fclose(file_input1);
    fclose(file_input2);
    fclose(file_output);
    
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)