Dump out all the encrypted data.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 18 Dec 2013 00:24:01 -0500
changeset 6 b7f19e0599db
parent 5 6f80cd157c13
child 7 682d7ea1e7f3
Dump out all the encrypted data.
1pass.lua
--- a/1pass.lua	Wed Dec 18 00:23:35 2013 -0500
+++ b/1pass.lua	Wed Dec 18 00:24:01 2013 -0500
@@ -42,6 +42,12 @@
     end
 end
 
+local function load_json_str(str, desc)
+    local retval = JSON:decode(str)
+    dumptable("JSON " .. desc, retval)
+    return retval
+end
+
 local function load_json(fname)
     local f = io.open(fname, "rb")
     if (f == nil) then
@@ -51,9 +57,7 @@
     local str = f:read("*all")
     f:close()
 
-    local retval = JSON:decode(str)
-    dumptable("JSON " .. fname, retval)
-    return retval
+    return load_json_str(str, fname)
 end
 
 
@@ -107,6 +111,11 @@
 end
 
 
+function loadContents(basedir)
+    return load_json(basedir .. "/contents.js");
+end
+
+
 -- Mainline!
 
 local basedir = "1Password/1Password.agilekeychain/data/default"  -- !!! FIXME
@@ -120,7 +129,18 @@
     os.exit(1)
 end
 
-
+items = loadContents(basedir)
+for i,v in ipairs(items) do
+    if v[2] ~= "system.Tombstone" then  -- I guess those are dead items?
+        local metadata = load_json(basedir .. "/" .. v[1] .. ".1password")
+        if metadata ~= nil then
+            local plaintext = decryptBase64UsingKey(metadata.encrypted, loadKey(basedir, metadata.securityLevel, password))
+            if plaintext ~= nil then
+                local secure = load_json_str(plaintext, v[1])
+            end
+        end
+    end
+end
 
 -- end of 1pass.lua ...