温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

krypton系列4-7

发布时间:2020-07-03 21:27:19 来源:网络 阅读:1100 作者:strawdog 栏目:安全技术

level 4:Vigenere Cipher加密,可以对抗词频统计,需要知道密码,此题知道密钥长度6。

    http://www.simonsingh.net/The_Black_Chamber/crackingprinciple.html

    这个网站解释了如何破解Vigenere Cipher加密。

    http://smurfoncrack.com/pygenere/pygenere.php

    直接把密文拷贝到上面那个网页,可以猜知密码“FREKEY”。

    用此密码揭秘密文。



level 5:加密同level 4,但不知道密钥长度。

    利用level 4的解密网站,可以手工指定密钥长度进行测试。也可以使用下面的Vigenere Cipher解密工具网页,自动进行猜解:

    http://www.simonsingh.net/The_Black_Chamber/vigenere_square_tool.html

    密钥是:KEYLEN

    用密钥解密密文。



level 6:LFSR加密

    逆向加密算法:

            magic值的计算函数:flsr    cs:reg_2543 初始值为 1。

 public lfsr
 lfsr proc near
 var_2= word ptr -2
 push rbp
 mov rbp, rsp
 mov [rbp+var_2], 0
 movzx eax, cs:reg_2543
 mov edx, eax
 and edx, 1
 movzx eax, cs:reg_2543
 movzx eax, ax
 and eax, 2
 sar eax, 1
 xor eax, edx
 mov [rbp+var_2], ax
 movzx eax, cs:reg_2543
 shr ax, 1
 mov edx, eax
 movzx eax, [rbp+var_2]
 shl eax, 3
 or eax, edx
 mov cs:reg_2543, ax
 movzx eax, cs:reg_2543
 movzx eax, ax
 pop rbp
 retn
 lfsr end

     ELF x86_64的程序,加密算法是:c --> 大写 --> -0x41 --> +key[i](0-9循环) --> +magic --> -0x41 --> -0x1a 直到值<=0x19 --> +0x41 

    明文测试:

AAAAAAAAAABBBBBBBBBB          BBBBBBBBBBAAAAAAAAAA         ABABABABABABABABABAB

EICTDGYIYZLUIOTJSGYZ          FJDUEHZJZAKTHNSIRFXY         EJCUDHYJYAKUHOSJRGXZ

    可以发现同样的字符在不同的位置,密文不同,但是同样的字符在同样的位置密文相同。实际上就是[字母*位置]的一个二维密码表。

    解密可以用明文***,生成一个26*20的密码表,然后查表解密。

    也可以使用已知的算法,直接用程序解密:

#include <stdio.h>
short reg = 1;
char* a_en = "EICTDGYIYZLUIOTJSGYZ";
char* a_pl = "AAAAAAAAAABBBBBBBBBB";
char* b_en = "FJDUEHZJZAKTHNSIRFXY";
char* krypton7 = "PNUKLYLWRQKGKBE";
main()
{
        short a = 0;
        int b, c;
        int i, j;
        char *key[10];
        short magic[20];
        for(i=0, j=0; i<20; i++, j++)
        {
                //LFSR函数的算法模拟
                b = reg;
                b &= 1;
                c = reg;
                c &= 2;
                c = c >> 1;
                a = b ^ c;
                b = reg;
                b = b >> 1;
                c = a;
                c = c << 3;
                a = b | c;
//             printf("magic: %hx\n", a);
                reg = a;
                magic[i] = a;
                //计算key并进行验证
                if(j >= 10)
                        j = 0;
                key[j] = a_en[i] - a;
                while(key[j] < 0x41)
                        key[j] += 0x1A;
                key[j] -= a_pl[i];
                printf("magic: %hx\tkey[%d]: %hhx\n", a, j, key[j]);
        }
        //解密测试
        for(i=0, j=0; i<20; i++, j++)
        {
                if(j >= 10)
                        j = 0;
                b = b_en[i] - magic[i];
                while(b < 0x41)
                        b += 0x1A;
                b -= (int) key[j];
                while(b < 0x41)
                        b += 0x1A;
                printf("%c", b);
        }
        printf("\n");
        //解密krypton7
        for(i=0, j=0; i<strlen(krypton7); i++, j++)
        {
                if(j >= 10)
                        j = 0;
                b = krypton7[i] - magic[i];
                while(b < 0x41)
                        b += 0x1A;
                b -= (int) key[j];
                while(b < 0x41)
                        b += 0x1A;
                printf("%c", b);jia
        }
        printf("\n");
}




向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI