Skip to content

Instantly share code, notes, and snippets.

@a-mcf
Last active January 4, 2023 03:26
Show Gist options
  • Save a-mcf/43a60c1352b88ec9a8ca5eb176ac88fe to your computer and use it in GitHub Desktop.
Save a-mcf/43a60c1352b88ec9a8ca5eb176ac88fe to your computer and use it in GitHub Desktop.
PowerShell Lastpass Encrypted Vault Viewer
<#
Quick script to make a LastPass vault export easier to parse, as requested on
Security Now #904.
Requires an XML file downloaded as per Wladimir Palant's blog and referenced by
the show notes:
- https://palant.info/2022/12/24/what-data-does-lastpass-encrypt/#downloading-your-lastpass-data
You should proably just use this instead:
- https://github.com/cfbao/lastpass-vault-parser
Example:
.\Format-LastPassVault.ps1 -LastPassXmlPath .\DownloadedLastPassVaultXML.xml
#>
param(
[Parameter(
Mandatory = $true,
Position = 0)]
[ValidateScript({$true})]
[String]
$LastPassXmlPath
)
[xml] $LastPassXml = Get-Content $LastPassXmlPath
# stole this from here
# https://stackoverflow.com/questions/17229866/powershell-hex-to-string-conversion
function ConvertFrom-Hex
{
param($HexString)
$converted = for($i=0; $i -lt $HexString.length; $i+=2)
{
[char][int]::Parse($HexString.substring($i,2),'HexNumber')
}
-join $converted
}
foreach ($a in $LastPassXml.response.accounts.account)
{
[PSCustomObject] @{
Name = $a.name
UrlId = $a.urlid
Id = $a.id
Url = ConvertFrom-Hex -HexString $a.url
M = $a.m
Http = [bool][int] $a.http
Favorite = [bool][int] $a.fav
favico = $a.favico
AutoLogin = [bool][int] $a.autologin
BasicAuthSite = [bool][int] $a.basic_auth
group = $a.group
FiId = $a.fiid
AutoGeneratedPW = [bool][int] $a.genpw
NoteData = $a.extra
IsBookMark = [bool][int] $a.isbookmark
NeverAutoFill = [bool][int] $a.never_autofill
LastTouched = (Get-Date 01.01.1970).AddSeconds($a.last_modified)
LastModified = (Get-Date 01.01.1970).AddSeconds($a.last_touched)
IsSecureNote = [bool][int] $a.sn
Realm = $a.realm
SharedFromId = $a.sharedfromaid
PWRepRompt = [bool][int] $a.pwprotect
LaunchCount = $a.launch_count
UserName = $a.username
GroupId = $a.groupid
Login = $a.login
}
}
@a-mcf
Copy link
Author

a-mcf commented Jan 4, 2023

This wasn't tested overly much, but shouldn't hurt your machine. It probably makes more sense to just use the linked project instead, but this is good if you want to play with the fields on the PowerShell CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment