本帖最后由 zapline 于 2009-7-27 20:12 编辑
CM地址:http://bbs.52pojie.cn/thread-28917-1-1.html
有朋友让我写写过程 所以我简单的写一些
CM 无壳, VC编写,另外还有一个名为 mima 的文件
打开该文件 , 可以看到里面是一段加密数据
用IDA,载入CM,在主函数的地方按一下F5
(不知写这个CM的怎么想的,里面很多重复无用的代码)
下面是F5出来的int __cdecl main_0()
{
size_t v1; // eax@1
int v2; // eax@3
FILE *v3; // eax@7
size_t v4; // eax@13
int v5; // eax@15
size_t v6; // eax@19
int v7; // eax@21
size_t v8; // eax@25
int v9; // eax@27
char v10; // [sp+Ch] [bp-438h]@1
char Buffer[500]; // [sp+24Ch] [bp-1F8h]@1
size_t v12; // [sp+50h] [bp-3F4h]@1
signed int v13; // [sp+54h] [bp-3F0h]@1
signed int v14; // [sp+4Ch] [bp-3F8h]@3
FILE *File; // [sp+440h] [bp-4h]@7
char Str2; // [sp+58h] [bp-3ECh]@10
memset(&v10, -858993460, 0x438u);
printf("请输入密码:");
gets(Buffer);
v12 = strlen(Buffer);
v1 = strlen(Buffer);
sub_401A30(v1);
v13 = 23;
while ( v13 < 684 )
{
v2 = rand();
sub_401A30(v2);
v14 = 0;
while ( v14 < (signed int)v12 )
Buffer[v14++] += rand();
v13 += 2;
}
v3 = fopen("mima", L"r");
File = v3;
if ( !v3 )
{
printf("文?);
exit(1);
}
fgets(&Str2, 500, File);
if ( strcmp(Buffer, &Str2) )
printf("密码错?);
else
printf("密码?);
v12 = strlen(Buffer);
v4 = strlen(Buffer);
sub_401A30(v4);
v13 = 23;
while ( v13 < 684 )
{
v5 = rand();
sub_401A30(v5);
v14 = 0;
while ( v14 < (signed int)v12 )
Buffer[v14++] += rand();
v13 += 2;
}
v12 = strlen(Buffer);
v6 = strlen(Buffer);
sub_401A30(v6);
v13 = 23;
while ( v13 < 684 )
{
v7 = rand();
sub_401A30(v7);
v14 = 0;
while ( v14 < (signed int)v12 )
Buffer[v14++] += rand();
v13 += 2;
}
v12 = strlen(Buffer);
v8 = strlen(Buffer);
sub_401A30(v8);
v13 = 23;
while ( v13 < 684 )
{
v9 = rand();
sub_401A30(v9);
v14 = 0;
while ( v14 < (signed int)v12 )
Buffer[v14++] += rand();
v13 += 2;
}
fclose(File);
printf("按任意?);
sub_40D300();
return _chkesp();
}
有用的就前面一些了 printf("请输入密码:");
gets(Buffer);
v12 = strlen(Buffer);
v1 = strlen(Buffer);
sub_401A30(v1);
v13 = 23;
while ( v13 < 684 )
{
v2 = rand();
sub_401A30(v2);
v14 = 0;
while ( v14 < (signed int)v12 )
Buffer[v14++] += rand();
v13 += 2;
}
v3 = fopen("mima", L"r");
File = v3;
if ( !v3 )
{
printf("文?);
exit(1);
}
fgets(&Str2, 500, File);
if ( strcmp(Buffer, &Str2) )
printf("密码错?);
else
printf("密码?);
它是把输入的字符串加密后,再与密文进行比较
根据rand函数想像一下,或者看过srand函数的就可以判断出sub_401A30其实是srand函数了
不知道是srand也没关系,可以像发CM那个帖子里我写的那段代码那样,自己写两个函数
加密算法如下:len = strlen(the_input);
srand(len);
n = 23;
while ( n < 684 )
{
x = rand();
srand(x);
num = 0;
while ( num < len )
{
the_string[num++] += rand();
}
n += 2;
}
所以,解密算法就是将the_string[num++] += rand();处的加号改成减号
完整的解密源码如下:#include "stdio.h"
#include "windows.h"
#include "string.h"
void main()
{
char a[500]="";
unsigned x,num,n,len;
FILE *fp;
fp = fopen("mima", "r");
fgets(a, 500, fp);
printf("%s\n",a);
len = strlen(a);
srand(len);
n = 23;
while ( n < 684 )
{
x = rand();
srand(x);
num = 0;
while ( num < len )
{
a[num++] -= rand();
}
n += 2;
}
printf("%s\n",a);
}
|