Skip to content

Instantly share code, notes, and snippets.

@bmulholland
Last active February 10, 2023 16:04
Show Gist options
  • Save bmulholland/595163c19b2b0be2c110cd29f4b08920 to your computer and use it in GitHub Desktop.
Save bmulholland/595163c19b2b0be2c110cd29f4b08920 to your computer and use it in GitHub Desktop.
Export Lastpass field data, which they are currently holding hostage. Requires the lastpass cli. Will include lots of noise; manual parsing will be needed.
#!/bin/bash
# Inspired by https://github.com/mindrunner/lastpass-attachment-exporter
filename="lastpass-fields-export.txt"
# Clear the file first
echo "" > $filename
echo -n "Checking accounts"
# List all accounts and parse their IDs
for id in `lpass ls | sed -E -n "s/^.*id:[[:space:]]*([0-9]*).*$/\1/p"`; do
echo -n "."
entry=`lpass show ${id}`
# Get the extra fields by filtering out the most common fields
extrafields=`echo "${entry}" | grep -viE "\[id:[[:space:]]|^password:|^username:|^url:|^Generated Pasword for|^email:|^remember:|user:|passwd:|login_email:|login_password:|rem:|email_address:"`
# If there are any non-standard fields left
if [ ! -z "$extrafields" ]; then
# Output the password's information
echo `echo "${entry}" | grep -iE "\[id: "` >> $filename
# And the extra fields
printf "%s\n\n" "${extrafields}" >> $filename
fi
done
printf "\nDone! Results in %s\n" "$filename"
@bmulholland
Copy link
Author

I wouldn't be surprised if they're actively making this harder, the whole company is pretty shady about exports

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