From 6027f91c9c1f80750735159f07a842a7cf29a3ec Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Wed, 10 Jul 2024 20:02:43 +0200 Subject: [PATCH] add script to extract passwords from unix password manager --- extract_pass.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 extract_pass.sh diff --git a/extract_pass.sh b/extract_pass.sh new file mode 100755 index 0000000..2910dea --- /dev/null +++ b/extract_pass.sh @@ -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."