来,放源码,大家一起玩
本帖最后由 海风月影 于 2014-11-9 21:42 编辑保护手段:特殊版的编译器,clang.exe cm.c,生成出来的bin,就是比赛用的
编译方式:普通编译器也可以编译,注释掉一行编译选项:cl.exe cm.c即可
下面放的源码是跨平台的,其实也可以做个Android版本,不过为了降低难度,只做了Windows版本
把源码里面关于Windows平台代码注释去掉,编译出来,就是比赛放出去的版本
说明一下,你们自己的编译器如果报错,注释掉下面一行就行了
// 这行是特殊版编译器的选项,普通编译器编译,注释掉就行了
#pragma obfuscate on
源码如下:
//#include <windows.h>
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793238462643383279
#define EPLISON 0.00001
#define R1 -0.1666665668e+0
#define R2 0.8333025139e-2
#define R3 -0.1980741872e-3
#define R4 0.2601903036e-5
#define INVSPI 0.31830988618379067153776752674508
#define HALFPI (PI / 2)
#define C1 3.140625
#define C2 9.67653589793e-4
#define hashkey1 0xB4B2F8C2
#define hashkey2 0x2FF54B62
#define hashkey3 0x9639CE42
#define hashkey4 0x58ECCC20
// 这行是特殊版编译器的选项,普通编译器编译,注释掉就行了
#pragma obfuscate on
char key = {0}; //48位的key
char name = "";
int vaild();
int main(int argc, char *argv[])
{
//HANDLE hd = GetStdHandle(STD_OUTPUT_HANDLE);
//SetConsoleTitle("52Pojie CrackMe Contest 2014");
//SetConsoleTextAttribute(hd, 0xF);
printf(" 52Pojie CrackMe Contest 2014\n");
printf(" http://www.52pojie.cn\n\n");
printf(" Author: 海风月影\n\n");
printf("Useage: \ncm \n");
printf("\n");
if(argc < 2)
{
printf("Please Input Name (length = ): ");
scanf("%32s", name);
printf("Please Input Key (length = 48): ");
scanf("%48s", key);
printf("\n\n\n");
}
else
{
strncpy(name, argv, 32);
strncpy(key, argv, 48);
}
printf("Your name: %s\nYour key: %s\nChecking...", name, key);
//SetConsoleTextAttribute(hd, 12);
vaild();
//SetConsoleTextAttribute(hd, 0xF);
{
char tmp = {'D', 'o', 'n', 'e', '!', 0};
printf("\n%s\n", tmp);
}
getchar();
return 0;
}
int vaild()
{
unsigned int namelen;
unsigned int keylen;
unsigned char *pk;
unsigned int k;
unsigned int hash1 = 0;
unsigned int hash2 = 0;
unsigned int hash3 = 0;
unsigned int hash4 = 0;
float y;
float y1;
float y2;
float y3;
double x0;
float x1;
float x2;
float x4;
float *x;
unsigned int *xx;
unsigned int crc32;
unsigned char *lpData;
unsigned int i, j;
unsigned int n;
unsigned int sign;
unsigned int crcTable;
float xn, f, g, rg, result;
unsigned int rem;
unsigned int root;
unsigned int divisor;
unsigned int a;
unsigned short *d;
int B, C;
unsigned int ddd;
char szGood;
namelen = strlen(name);
keylen = strlen(key);
if (namelen < 3 || namelen > 32 || keylen != 48)
{
return 6;
}
szGood = 'c';
for(i = 0; i < namelen; i++)
{
hash1 += hash1 * name * (name << 1) + hashkey1;
hash2 += hash2 * name * (name >> 2) + hashkey2;
hash3 += hash3 * name * (name << 3) + hashkey3;
hash4 += hash4 * name * (name << 5) + hashkey4;
}
hash1 = ((hash1 & 0x00FFFFFF) ^ (unsigned int)0x3E000000);
hash2 = ((hash2 & 0x00FFFFFF) ^ (unsigned int)0x3F000000);
hash3 = ((hash3 & 0x00FFFFFF) ^ (unsigned int)0x40000000);
szGood = '!';
for(i = 0; i < keylen; i+= 8)
sscanf((char*)&key, "%08X", &ddd);
szGood = '\x0';
for( i = 0; i < 256; i ++ )
{
crc32 = i;
for( j = 0; j < 8; j ++ )
{
if(crc32 & 1)
crc32 = (crc32 >> 1) ^ 0xEDB88320UL;
else
crc32 >>= 1;
}
crcTable = crc32;
}
szGood = 'e';
crc32 = ~hash4;
lpData = &ddd;
for(i = 0; i < 24; i ++)
{
crc32 = (crc32 >> 8) ^ crcTable[ (crc32 ^ lpData) & 0xFF ];
}
szGood = 'r';
crc32 = ~crc32;
for(i = 0; i < 6; i ++)
{
ddd ^= crc32;
}
szGood = 't';
xx = (unsigned int*)&y2;
y1 = 0.0;
x0 = 1.0;
y2 = x0;
x1 = *(float*)&ddd;
x2 = *(float*)&ddd;
x4 = x1;
for(i = 1; i <= 100000; i++)
{
sign = (x4 < 0);
x4 = sign?(-x4):x4;
n = (int) ((x4 * INVSPI) + 0.5);
xn = (double) n;
sign ^= n % 2;
f = (x4 - xn * C1) - xn * C2;
g = f * f;
rg = (((R4 * g + R3) * g + R2) * g + R1) * g;
result = f + f * rg;
result = sign ? -result : result;
y1 += result / i;
x0 *= x2;
y2 += x0;
x4 += x1;
}
x = (float*)&hash1;
if(fabs(*x - y1) > EPLISON || fabs(y2 - *(float*)&hash2) > EPLISON)
{
szGood = '\x0';
return 3;
}
szGood = 'C';
x0 = 1.0;
y3 = 0.0;
x1 = *(float*)&ddd;
x4 = x1;
for(i = 1; i < 8000; i++)
{
x4 = (x4 > 0)?(x4):(-x4);
n = (int) (((x4 + HALFPI) * INVSPI) + 0.5);
xn = (double)n - 0.5;
sign = n % 2;
f = (x4 - xn * C1) - xn * C2;
g = f * f;
rg = (((R4 * g + R3) * g + R2) * g + R1) * g;
result = f + f * rg;
result =sign ? -result : result;
y3 += x0 * result / (i * i);
x0 = -x0;
x4 += x1;
}
y3 = y3 * 4 + PI * PI / 3 * 2;
x = (float*)&hash3;
if(fabs(*x - y3) > EPLISON)
{
szGood = '\x0';
return 1;
}
k = 0;
szGood = 'o';
d = (unsigned short*)&ddd;
for(i = 0; i < 4; i++)
{
B = (int)d;
if(B >= 0x8000)
{
B = (B * 2) & 0xFFFF;
C = B + 1;
}
else
C = B + 2;
rem = 0;
root = 0;
divisor = 0;
a = C * C - B * B;
for(j = 0; j < 16; j++)
{
root <<= 1;
rem = ((rem << 2) + (a >> 30));
a <<= 2;
divisor = (root << 1) + 1;
if(divisor <= rem)
{
rem -= divisor;
root ++;
}
}
k = k | ((unsigned char)(root - 3)) << (i * 8);
}
if(k == hash4)
{
szGood = 'r';
;;;
printf("%s", szGood);
;
}
;
return 2;
}
@Kido 比赛源代码按规则应该发布了,正好放到之前帖子里把。 开始以为是易语言的,进来一看晕了,膜拜大神,求大神带我开挂,带我飞{:1_932:}{:1_931:} 好前排啊~~~~~~~第一次离大神这么近距离!!!!!!!!!好激动~ 我也是啊 楼上的 大神牛XXX沾神力 学习了,简直膜拜 我来支持楼这的实际行动 不明觉厉啊