[求助]crackme算法求解
自己顶。随机字串可以参考字串3的生成方式。随机用户名的产生就不另代码实现了。当然keygen写的不完善。只是为了实现目标。
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
void main()
{
//--------------------------------------------------------------
int i,j,k,x,y,z,len1,len2,rs,pass;
srand(time(0));
char str1[10]="\0";
char str2[20]="\0";
char str3[10]="\0";
printf("请输入字符串%s\n",str1);
gets(str1);
len1=strlen(str1);
if(len1==7)
{
len2=len1*2+1;
}
else
{
len2=len1*2;
}
do
{
rs=len1+len2;
for(i=0;i<len1;i++)
{
printf("字符串1的ASC值是:%x\n",str1[i]);
}
printf("\n");
for(j=0;j<len1;j++)
{
do
str3[j]=rand()%95+32;
while(str3[j]%2!=0);
}
for(k=0;k<len1;k++)
{
printf("字符串2的ASC值是:%x\n",str3[k]);
}
printf("输出字符串长度%d\n",len1);
puts(str3);
for(x=0;x<len1;x++)
{
rs=rs+str1[x]*str3[x];
}
rs=rs/2;
}
while(rs%0x20!=0);
printf("\n");
printf("字符串2:%s\n",str3);
printf("字符串1与字符串2的乘积为:%x\n",rs);
//-------------------------------------------------------------
printf("以下为根据用户名推算口令\n");
strcpy(str2,str3);
printf("口令1:%s\n",str2);
printf("口令长度为:%d\n",len2);
printf("用户名长度为:%d\n",len1);
do
{
pass=0;
for(y=len1;y<len2;y++)
{
str2[y]=rand()%95+32;
}
printf("推算中的口令:%s\n",str2);
for(z=0;z<len2;z++)
{
pass=str2[z]+pass;
pass=pass^z;
pass=pass-len1-len2;
}
pass=pass*32;
pass=pass+0x1000;
printf("推算中的值:%x\n",pass);
}while(pass!=rs);
printf("最终的口令为:%s\n",str2);
}
附件是crackme小程序。初学者有兴趣的可以练习下 。