Beispiel #1
0
 private static string[] DecodeWithXor(byte[][] cipherTexts, byte[] xor)
 {
     return(cipherTexts
            .Select(x => Challenge2.XorBytes(x, xor))
            .Select(x => Encoding.ASCII.GetString(x))
            .ToArray());
 }
        public static void Run()
        {
            // "Encrypted" ciphertext
            byte[][] cipherTexts = CtrEncodeBase64Strings(Utility.GetResource("19.txt"));

            // We're treating decrypting as nothing more than applying a XOR; we deduced the value
            byte[] xor = CrackXor(cipherTexts);

            // Second pass, we looked at the output and tweaked it
            xor[0]  = 0xCA;
            xor[1]  = 0x88 ^ 0x07;
            xor[2]  = 0xF4;
            xor[3]  = 0x9a ^ 0x07;
            xor[4]  = 0xD9;
            xor[5]  = 0x89;
            xor[6]  = 0x09 ^ 0x02;
            xor[7]  = 0xAB;
            xor[8]  = 0x74;
            xor[9]  = 0xF5;
            xor[10] = 0x3A ^ 0x07;
            xor[11] = 0x75;
            xor[12] = 0x05;
            xor[13] = 0xF5;
            xor[14] = 0x09;
            xor[15] = 0xC8;
            xor[16] = 0x35;
            xor[17] = 0xEB;
            xor[18] = 0xCF;
            xor[19] = 0x1E;
            xor[20] = 0x3E;
            xor[21] = 0x8A;
            xor[22] = 0x43;
            xor[23] = 0x4D ^ 0x02;
            xor[24] = 0x54;
            xor[25] = 0x9C;
            xor[26] = 0xB9;
            xor[27] = 0xF4;
            xor[28] = 0xAA ^ 0x02;
            xor[29] = 0x00 ^ 0x02;
            xor[30] = 0xC6 ^ 0x1D;
            xor[31] = 0xFC ^ 0x16;
            xor[32] = 0x47 ^ ('x' ^ 'h');
            xor[33] = 0x99 ^ ('p' ^ 'e');
            xor[34] = 0x85 ^ ('l' ^ 'a');
            xor[35] = 0x84 ^ ('s' ^ 'd');
            xor[36] = 0x21 ^ ('l' ^ 'n');
            xor[37] = 0xc0 ^ ('n' ^ ',');

            byte[][] xoredCipherText = cipherTexts
                                       .Select(x => Challenge2.XorBytes(x, xor))
                                       .ToArray();

            for (int i = 0; i < xoredCipherText.Length; i++)
            {
                Console.WriteLine($"#{i:d2}: {Encoding.ASCII.GetString(xoredCipherText[i])}");
            }
        }
Beispiel #3
0
 static byte[] XorBytes(byte[] b1, byte[] b2)
 {
     return(Challenge2.XorBytes(b1, b2));
 }