-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathXor-File.ps1
More file actions
44 lines (33 loc) · 1.04 KB
/
Xor-File.ps1
File metadata and controls
44 lines (33 loc) · 1.04 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
38
39
40
41
42
43
44
param
(
[Parameter (Mandatory=$true)] [string] $input_file,
[Parameter (Mandatory=$true)] [string] $output_file,
[Parameter (Mandatory=$true)] [byte] $byte_key
)
if ((test-path $input_file) -eq $false)
{
Write-Host "[-] ERROR: wrong input file" -ForegroundColor Red
exit
}
if ((test-path $output_file) -eq $true)
{
Write-Host "[*] WARNING: File" (resolve-path $output_file) "already exists. Override file? [Y]: " -ForegroundColor red -NoNewline
$answer = Read-Host
if ($answer -ne "Y") {exit}
}
Set-Content $output_file -Value "" -NoNewline
$input_bytes = Get-Content -Path $input_file -Encoding Byte
try
{
foreach ($byte in $input_bytes)
{
[byte]$xored_byte = ($byte -bxor $byte_key)
Add-Content -Value $xored_byte -Path $output_file -Encoding Byte
}
Write-host "[+] File" (Resolve-Path $output_file) "created successfully :)"
}
catch
{
Write-Host "[-] ERROR: Could not write to output file :(" -ForegroundColor Red
exit
}