Skip to content

Commit dc7b3b0

Browse files
authored
Add files via upload
1 parent 10fe59c commit dc7b3b0

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Scripts/Remove-Secure.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Add-Type -AssemblyName System.Windows.Forms
2+
3+
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
4+
$OpenFileDialog.Filter = "Todos los archivos (*.*)|*.*"
5+
$OpenFileDialog.Multiselect = $false
6+
7+
if ($OpenFileDialog.ShowDialog() -eq 'OK') {
8+
$SelectedFilePath = $OpenFileDialog.FileName
9+
Write-Host "File selected: $SelectedFilePath" -ForegroundColor Green
10+
Write-Host " "
11+
} else {
12+
Write-Host "No se seleccionó ningún archivo." -ForegroundColor Yellow
13+
Write-Host " "
14+
}
15+
16+
17+
function Secure-DeleteFile {
18+
param (
19+
[string]$FilePath
20+
)
21+
22+
if (Test-Path $FilePath) {
23+
$size = (Get-Item $FilePath).length
24+
Write-Host "The file size is: $size" -ForegroundColor Yellow
25+
Write-Host " "
26+
$randomBytes = New-Object byte[] $size
27+
(New-Object Random).NextBytes($randomBytes)
28+
[System.IO.File]::WriteAllBytes($FilePath, $randomBytes)
29+
Write-Host "Processing file to Untraceable File..." -ForegroundColor Yellow
30+
Write-Host " "
31+
Remove-Item -Path $FilePath -Force
32+
Write-Host "File completely deleted from memory!" -ForegroundColor Green
33+
Write-Host " "
34+
} else {
35+
Write-Host "File does not exist: $FilePath" -ForegroundColor Red
36+
Write-Host " "
37+
}
38+
}
39+
40+
# Call function with the file selected
41+
Secure-DeleteFile -FilePath $SelectedFilePath

0 commit comments

Comments
 (0)