From 4a01b258678313bb37b703c67906192fe4cec9a6 Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Wed, 10 Jul 2024 21:28:52 +0200 Subject: [PATCH] fix code and add otp support --- extract_pass.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/extract_pass.sh b/extract_pass.sh index 2910dea..0c59806 100755 --- a/extract_pass.sh +++ b/extract_pass.sh @@ -14,11 +14,23 @@ convert_pass() { name=$1 mapfile -t lines < <(pass show "$name") url=$(basename "$name") - username=$(echo "${lines[1]}" | sed 's/^.*: //') + username=$(basename "$name") # Benutzername ist der Dateiname password=${lines[0]} folder=$(dirname "$name") - notes=$(printf "%s\n" "${lines[@]:2}") - echo "$folder,,login,$url,$notes,,$url,$username,$password," >> "$OUTPUT_FILE" + notes="" + totp="" + + # Notizen und TOTP überprüfen + for line in "${lines[@]:1}"; do + if [[ $line == otpauth* ]]; then + totp=$line + else + notes+="$line\n" + fi + done + + # CSV-Zeile hinzufügen + echo "$folder,,login,$url,$notes,,$folder,$username,$password,$totp" >> "$OUTPUT_FILE" } # Alle Passwortdateien finden und konvertieren