|
算法来源于GhoHash,由shuax写成了C语言的,方便集成到自己的程序中,收藏备用.- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- unsigned short table[256];
- int FillTable(int a, short b, int c)
- {
- int d = a << 8;
- for ( int i = 8; i > 0 ; --i)
- {
- if ( (c ^ d) & 0x8000)
- {
- c = b ^ (2 * c);
- }
- else
- {
- c *= 2;
- }
- d *= 2;
- }
- return c;
- }
-
- void decrypt(unsigned char *buf, int len, int key)
- {
- for(int i=0;i<len;i++)
- {
- unsigned short temp = table[buf[i] ^ (key>>8) ] ^ (key<<8);
- buf[i] = buf[i] ^ key;
- key = temp;
- }
- }
- int main(int argc,char *argv[])
- {
- if(argc<2)
- {
- printf("使用方法:GetGhoPwd.exe ghost.gho");
- }
- else
- {
- //
- for (int i=0;i<256;i++)
- {
- table[i] = FillTable(i, 4129, 1954);
- }
-
- //
- FILE * fp = fopen(argv[1],"rb");
- if(fp)
- {
- fseek(fp, 11, SEEK_SET);
- char flag = fgetc(fp);
- if(flag)
- {
- unsigned char encrypted1[15];
- unsigned char encrypted2[10];
- fread(encrypted1,1,15,fp);
- fread(encrypted2,1,10,fp);
-
- //
- int key = 0;
- while(1)
- {
- unsigned char temp[15];
- memcpy(temp, encrypted1, 15);
-
- decrypt(temp, 15, key);
-
- if( memcmp(temp,"BinaryResearch",15) ==0 )
- {
- break;
- }
-
- key++;
- }
-
- //
- decrypt(encrypted2, 10, key);
- printf("此文件的密码是:%s", encrypted2);
- }
- else
- {
- printf("此文件没有密码保护。");
- }
- fclose(fp);
- }
- }
- getchar();
- return 0;
- }
复制代码 |
3389, 打印机, 诺德尔, 网吧, 网吧版, 网吧系统, ndeer, 极速版, 诺德尔, 极速版, 诺德尔, QQ空间, QQ签名, QQ空间, QQ签名, 绿茶, QQ签名, 服务器, 论坛, 3389, 免费, 3389, 打印机, 主机, QQ空间, QQ签名, 矮哨兵, 网吧, ta
|