两个km的算法貌似一样,不过真的只能用牛X来形容了。hard加了大量的混淆代码,看了两眼放弃了。easy的简单很多,但也不容易啊。
附keygen代码,代码有点烂
[Asm] 纯文本查看 复制代码 #include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void keygen(unsigned char* key);
void tablegen(unsigned char* key,unsigned int * out,int len);
void decrytion(unsigned char* src,unsigned int * table,int len);
int main(int argc, char const *argv[])
{
unsigned char result[0x1a];
memset(result,0,0x1a);
srand((unsigned)time(NULL));
keygen(result);
printf("%s\n",result);
return 0;
}
void keygen(unsigned char* key){
unsigned char code[0x1a];
unsigned int foureight;
unsigned char out [5];
unsigned int* table;
unsigned char result [0x0012] =
{
0xf7, 0x42, 0x91, 0xf8, 0x0e, 0xac, 0xd6, 0x7a, 0x3c, 0xdd, 0x46, 0x10, 0xc3, 0xdf, 0xd1, 0x12,
0xbb, 0x00
};
for (int i = 0; i < 4; ++i)
{
code[i]=rand() % 26 + 0x41;
}
code[4]=0;
foureight = *(unsigned int *)code * (*(unsigned int *)code + 16 * *(unsigned int *)code + 3) + 0x3F3;
for (int i = 0; i < 4; ++i)
{
code[i+4]=*((unsigned char *)&foureight +i)%0x1a+0x41;
}
code[8]=0;
table=(unsigned int *)malloc(1024);
memset(table,0,1024);
tablegen(code,table,8);
decrytion(result,table,sizeof(result)-1);
free(table);
for(int i=0;i<sizeof(result)-1;i++){
code[8+i]=result[i]%0x1a+0x41;
}
code[0x19]=0;
for (int i = 0; i < 0x1a; ++i)
{
key[i]=code[i];
}
}
void tablegen(unsigned char* key,unsigned int* out,int len){
int n;
int p;
int on;
int c;
out[0] = 255;
n=0;
do
{
out[n+1] = (0x2AB * out[n] + 0x151) % 256;
++n;
}
while ( n < 255 );
on = 0;
p = 0;
n = 0;
c = 0;
do
{
on = out[n];
p = (unsigned char)(p+on + *(c + key));
out[n] = out[p];
out[p] = on;
++n;
if ( ++c >= len ){
c=0;
}
}
while ( n < 256);
}
void decrytion(unsigned char* src,unsigned int * table,int len){
int p;
int n;
int tc;
int tp;
int tmp;
int c;
n=0;
c=0;
p=0;
if(len>0){
do
{
p++;
tp = table[p];
tc = (unsigned char)(n + tp + 1);
tmp = table[tc];
table[p] = tmp;
table[tc] = tp;
*(unsigned char*)(c++ + src) ^= (unsigned char)(table[tp ^ (unsigned char)(tmp + tp)]);
n=tc;
}
while ( c < len );
}
} |