aboutsummaryrefslogtreecommitdiffstats
path: root/bitwarden-tools
diff options
context:
space:
mode:
Diffstat (limited to 'bitwarden-tools')
-rw-r--r--bitwarden-tools/README.md2
-rw-r--r--bitwarden-tools/bit2pass.py45
2 files changed, 47 insertions, 0 deletions
diff --git a/bitwarden-tools/README.md b/bitwarden-tools/README.md
new file mode 100644
index 0000000..9cb9ded
--- /dev/null
+++ b/bitwarden-tools/README.md
@@ -0,0 +1,2 @@
+(for now) just one script to handle importing Bitwarden data to UNIX
+pass
diff --git a/bitwarden-tools/bit2pass.py b/bitwarden-tools/bit2pass.py
new file mode 100644
index 0000000..47a64b0
--- /dev/null
+++ b/bitwarden-tools/bit2pass.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+"""
+bit2pass.py - grabs the bare minimum info from a bitwarden JSON export
+(unencrypted) to populate a UNIX pass datastore. This assumes you named
+your entry and gave it a password, otherwise, this script will yell at
+you.
+
+This does NOT grab notes or usernames. I find that in pass to be kind of
+useless since I rarely need to copy them. I use it purely for easy (and
+secure) copying of passwords. If a really need the notes, it's probably
+not something I'm going to be copying much. I also exclude anything
+that's not a login because, well that's what bitwarden's good for...
+Don't limit yourself to one tool
+
+
+Usage:
+0) (before running) Initialize a pass database:
+ pass init
+1) python bit2pass.py <your-file>
+"""
+import sys
+import subprocess
+import json
+with open(sys.argv[1]) as f:
+ data = json.load(f)
+
+folders = { x['id'] : x['name'] for x in data['folders'] }
+passwords = {
+ folders[x['folderId']] + '/' + x['name'] :
+ x['login']['password']
+ for x in data['items']
+ if x['type'] == 1
+ }
+print(passwords)
+
+for p in passwords:
+ echo = subprocess.run(["echo", passwords[p]],
+ check=True,
+ capture_output=True
+ )
+ pass2pass = subprocess.run(["pass", "insert", "-e", p],
+ input=echo.stdout,
+ capture_output=True
+ )
+ print(pass2pass.stdout)