-
-
[已解决][求助]一段小算法的逆向求值
-
发表于:
2010-1-26 22:05
4532
-
[B]#include <Windows.h>
#include <stdio.h>
__int64 GetDwordValue (__int64 cs)
{
__int64 ret = 0;
[COLOR="DarkGreen"]//cs 参数是任意传入的值
//ret 是返回值
/*-----------------------------------------------
ret 是结果,将做为返回值
问题: 如果已知 ret 的值, 逆向求出 cs 的值
------------------------------------------------*/
[/COLOR]
__int64 c1 = 0x1E389FB; [COLOR="DarkGreen"]//常量1[/COLOR]
__int64 c2 = 0x160F; [COLOR="DarkGreen"]//常量2[/COLOR]
__int64 mod = 0; [COLOR="DarkGreen"]//余数[/COLOR]
__int64 divn = 0; [COLOR="DarkGreen"]//商[/COLOR]
__int64 jc = 1;
do
{
mod = c2 % 2;
if (!mod)
{
do
{
divn = c2 / 2;
c2 = divn;
ret = cs * cs % c1;
cs = ret;
mod = c2 % 2;
} while ( mod == 0 );
}
c2--;
ret = cs * jc % c1;
jc = ret ;
}while(c2 > 0);
return ret;
}
void main()
{
__int64 test = GetDwordValue(13137657);
printf("%X\n",test);[/B]}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!