-
-
Notifications
You must be signed in to change notification settings - Fork 855
Expand file tree
/
Copy pathFlip-CryptoUnlocker.ps1
More file actions
37 lines (27 loc) · 1.21 KB
/
Flip-CryptoUnlocker.ps1
File metadata and controls
37 lines (27 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Flip-CryptoUnlocker.ps1
function Decrypt-File {
param (
[Parameter(Mandatory=$true)]
[string]$Path,
[Parameter(Mandatory=$true)]
[string]$Password
)
$AES = New-Object System.Security.Cryptography.AesCryptoServiceProvider
$AES.IV = New-Object byte[]($AES.IV.Length)
$AES.Key = [System.Text.Encoding]::UTF8.GetBytes($Password.PadRight($AES.Key.Length, '0'))
$EncryptedContent = Get-Content -Path $Path -Encoding Byte
$DecryptedContent = $AES.CreateDecryptor().TransformFinalBlock($EncryptedContent, 0, $EncryptedContent.Length)
Set-Content -Path $Path -Value $DecryptedContent -Encoding Byte
}
# Fixed password for decryption (it should be the same one used for encryption)
$Password = "D3m0P@ssw0rd"
# Detect the user's documents folder
$DocumentsFolder = [Environment]::GetFolderPath("MyDocuments")
# Get all the files in the documents folder
$Files = Get-ChildItem -Path $DocumentsFolder -File
# Decrypt each file
foreach ($File in $Files) {
Decrypt-File -Path $File.FullName -Password $Password
Write-Host "File decrypted: $($File.Name)"
}
Write-Host "All files in the documents folder have been decrypted!"