<# FPS:Containers:DataResources:Private:Get-KeePass:OBSOLETE #>

 

function Get-KeePass {

 

 

<#

 

.DESCRIPTION

Module: DataResources

Public CmdLet: Get-KeePass.ps1

Dependencies: NA

 

This function retrieves the KeePass directory password.  Re-constituted in SN-OpenKP to retrieve access info.

   

Called when update may be need to be verified.  Should not be generally available to the general public. File

will be available on the FPS site but that may change over time. 

 

The default key/pwd is "QaHGt65VX79773io"/"[pwd]"

   

.EXAMPLE

if (Push-NeededFor Get-KeePass) { . (Get-ActiveFileNm -PS1 Get-KeePass) }

Get-KeePass

 

.CC

 

[2024.11.20 JD] Depricated when imagery was introduced for a more secure option.

[2024.11.08 JD] Logging added due to the importance of the utility.

[2024.10.19 JD] Original code release

 

.NOTES

 

The default key/pwd is "QaHGt65VX79773io"/"[pwd]".  It is suggested to replace this

value when implemented

 

#>

 

    [CmdletBinding()]

    param(

   

    )

 

    $overrideSrc, $overrideSnippet = '','' # Initialize override variables

    . (Get-ActiveFileNm -PS1 Initialize-DataResources-Locations)

    . (Get-ActiveFileNm -PS1 Load-DataResources-Dependencies)

 

    $Sev, $Module, $Element = "Info", "DataResources", "Get-KeePass"

    $Buffer = "KP Default DB Entry Used by "+$global:pro_CI.SvcAcct

    Update-Log -Sev $Sev -Module $Module -Element $Element -Buffer $Buffer -LogFile (Mount-Path($drcLoc_Logs))

 

    $encryptedPasswordFromFile, $encryptedKeyFromFile, $secureDecryptedPassword= "","",""

    $BSTR1, $BSTR2 = "",""

 

    $encryptedKeyFromFile = Get-Content $drcLoc_KeyPath

    $encryptedPasswordFromFile = Get-Content $drcLoc_PassPath

    $secureDecryptedKey = ConvertTo-SecureString $encryptedKeyFromFile -Key (1..16)

    $secureDecryptedPassword = ConvertTo-SecureString  $encryptedPasswordFromFile -SecureKey $secureDecryptedKey

 

    $BSTR1 = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureDecryptedPassword)

    $textPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR1)

 

    $BSTR2 = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureDecryptedKey)

    $key = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR2)

 

    Write-Host "Key: $key"

    Write-Host "Text Password: $textPassword"

 

    Write-Host "Encrypted Password: $encryptedPasswordFromFile"

    Write-Host "Encrypted Key: $encryptedKeyFromFile"

 

}