add script to extract passwords from unix password manager
This commit is contained in:
parent
4f278ad3ce
commit
6027f91c9c
1 changed files with 30 additions and 0 deletions
30
extract_pass.sh
Executable file
30
extract_pass.sh
Executable file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Pfad zum Passwortspeicher
|
||||||
|
PASSWORD_STORE_DIR="${HOME}/.password-store"
|
||||||
|
|
||||||
|
# CSV-Datei für den Export
|
||||||
|
OUTPUT_FILE="vaultwarden_export.csv"
|
||||||
|
|
||||||
|
# CSV-Header hinzufügen
|
||||||
|
echo "folder,favorite,type,name,notes,fields,login_uri,login_username,login_password,login_totp" > "$OUTPUT_FILE"
|
||||||
|
|
||||||
|
# Funktion zum Konvertieren eines Passworts
|
||||||
|
convert_pass() {
|
||||||
|
name=$1
|
||||||
|
mapfile -t lines < <(pass show "$name")
|
||||||
|
url=$(basename "$name")
|
||||||
|
username=$(echo "${lines[1]}" | sed 's/^.*: //')
|
||||||
|
password=${lines[0]}
|
||||||
|
folder=$(dirname "$name")
|
||||||
|
notes=$(printf "%s\n" "${lines[@]:2}")
|
||||||
|
echo "$folder,,login,$url,$notes,,$url,$username,$password," >> "$OUTPUT_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Alle Passwortdateien finden und konvertieren
|
||||||
|
find "$PASSWORD_STORE_DIR" -type f -name "*.gpg" | while read -r file; do
|
||||||
|
pass_name=$(echo "$file" | sed "s|^$PASSWORD_STORE_DIR/||" | sed 's/\.gpg$//')
|
||||||
|
convert_pass "$pass_name"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Export abgeschlossen. Die CSV-Datei wurde in $OUTPUT_FILE gespeichert."
|
Loading…
Reference in a new issue