-
Notifications
You must be signed in to change notification settings - Fork 41
/
ConvertFrom-Bytes.ps1
44 lines (35 loc) · 1.45 KB
/
ConvertFrom-Bytes.ps1
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
function ConvertFrom-Bytes
{
<#
.SYNOPSIS
Script to convert master.key and hudson.util.secret from bytes format to file.
.DESCRIPTION
Script to convert master.key and hudson.util.secret from bytes format to file.
This is a technqiue to decrypt credentials and secrets stored with Jenkins. The technique is detailed
here: http://www.labofapenetrationtester.com/2015/11/week-of-continuous-intrusion-day-1.html
.PARAMETER ByteFile
Path to the file where bytes for one of the files are saved.
.PARAMETER KeyFile
Path where the key created.
.EXAMPLE
PS > ConvertFrom-Bytes -ByteFile C:\ContinuousIntrusion\master.txt -KeyFile C:\ContinuousIntrusion\master.key
Use above command to convert bytes of master.key back to the file.
.EXAMPLE
PS > ConvertFrom-Bytes -ByteFile C:\ContinuousIntrusion\hudson.util.Secret.txt -KeyFile C:\ContinuousIntrusion\hudson.util.Secret
Use above command to convert bytes of hudson.util.Secret back to the file.
.LINK
http://www.labofapenetrationtester.com/2015/11/week-of-continuous-intrusion-day-1.html
https://github.com/samratashok/nishang
#>
[CmdletBinding()] Param (
[Parameter(Position = 0, Mandatory = $True)]
[String]
$ByteFile,
[Parameter(Position = 1, Mandatory = $True)]
[String]$KeyFile
)
[String]$hexdump = get-content -path "$ByteFile"
[Byte[]] $temp = $hexdump -split ' '
[System.IO.File]::WriteAllBytes($KeyFile, $temp)
Write-Output "File written to $KeyFile"
}