【综合】简单加解密——寻找序列号
下面文字对你可能有用(复制+粘贴):
#include <stdlib.h>
#include <string.h>
#include “malloc.h”
#define MaxPass 66 // 最多66段密文
#define NumbPwdTable 5 // 密码表的份数
#define SizePwdTable 0x210 // 每份密码表占用字节数
struct PassStru // 密码表结构: 编移(4字节),密文长度(2字节),钥匙(1字节)。 结构体长度此处须为 4的倍数
{unsigned int Offset; unsigned short int Size; unsigned char Key; char cJiangYou;} // cJiangYou打酱油
char MsgErr[]=“Wrong Key!”,MsgSn[]="Serial No.: ",MsgMD9[]="MD9: ";
文件下载
话说这些文件被我放在我的“图床”里了哈哈哈,有人能get到我的笑点吗
VxCrp2018A1.VDF
VxCrp2018A2.VDF
VxCrp2018A3.VDF
VxCrp2018A4.VDF
VxCrp2018A5.VDF
VxCrp2018A6.VDF
VxCrp2018A7.VDF
思路
真的很简单就是按照题目模拟就行了,没有特别的,这道题的文件结构很简单也用不到KMP,所以就不多解释了
代码
#include <stdio.h>
#include <string.h>
struct key{
unsigned int offset;
unsigned short size;
unsigned char K;
}table;
int main(){
char pos[20],ciph[10000];
int N,i,j = 1,s,m;
scanf("%s\n%d",pos,&N);
FILE *fp = fopen(pos,"rb");
for(i = 0;i < 5;i++){
fseek(fp,(N-1)*8+i*0x210,0);
fread(&(table.offset),7,1,fp);
fseek(fp,table.offset,0);
fread(ciph,table.size,1,fp);
ciph[0] += table.K;
if(ciph[0] == 'W') continue;
else
{
while(j < table.size)
{
ciph[j] += table.K;
if(ciph[j] == 'e' && ciph[j - 1] == 'S') s = j - 1;
if(ciph[j] == 'D' && ciph[j - 1] == 'M') m = j - 1;
j ++;
}
break;
}
}
printf("XH: %02d\n",N);
printf("SN: %.19s\n",ciph + s + 12);
printf("M9: %.32s\n",ciph + m + 5);
}
或者
#include <stdio.h>
#include <string.h>
struct key{
unsigned int offset;
unsigned short size;
unsigned char K;
}table;
int main(){
char pos[20],ciph[10000];
int N,i;
scanf("%s\n%d",pos,&N);
FILE *fp = fopen(pos,"rb");
for(int i = 0;i < 5;i++){
fseek(fp,(N-1)*8+i*0x210,0);
fread(&(table.offset),7,1,fp);
fseek(fp,table.offset,0);
fread(ciph,table.size,1,fp);
for(int j = 0;j < table.size;j++) ciph[j] += table.K;
if(!strncmp(ciph,"Wrong Key!",9)) continue;
else break;
}
printf("XH: %02d\n",N);
for(i = 0;;i++){
if(strncmp(ciph+i,"Serial No.: ",11)==0){
printf("SN: %.19s\n",ciph + i + 12);
break;
}
}
for(;;i++){
if(strncmp(ciph+i,"MD9: ",4)==0){
printf("M9: %.32s\n",ciph + i + 5);
break;
}
}
}