MrC's Convert to 1Password Utility (mrc-converter-suite)

1414244464752

Comments

  • MrC
    MrC
    Volunteer Moderator
    edited July 2018

    @scottypa ,

    Ok, sorry for the inconvenience.

    Can you try this for me and let me know if it works out?

    Launch the portableshell.bat as instructed in the README. Then run the command:

    cpanm install Date::Calc
    

    exactly as typed and hit Enter.

    If that succeeds, continue following the instructions from step 3d in the README.pdf.

  • scottypa
    scottypa
    Community Member

    Thank you. The Date::Calc module installed successfully and my test import into 1Password also was successful.

    One last remaining question before we perform the real import. As you know, Keepass2 entries can be hierarchical and this is how we have organized all of our content. Is there any way for the converter to read the "path" of the entry and store that in 1Password, perhaps with a tag or section label (whatever is the least amount of work for you)? I'm not sure if you have something for this already but anything we can pull across to help with organizing in 1Password would be of benefit. Thanks for your help, time & consideration.

  • MrC
    MrC
    Volunteer Moderator
    edited July 2018

    @scottypa ,

    That's great news, thanks!

    The full path of a Group in keepass2 is already captured, but the separator I'd chosen a long time ago was double-colon ::. I've just posted version 1.11 in Testing Bits which changes this to a forward slash, so that you get:

    Testing Bits is mentioned in the first post of the converter suite thread.

  • scottypa
    scottypa
    Community Member

    Excellent! I'll use Testing Bits v1.11. Thanks.

  • scottypa
    scottypa
    Community Member

    Not seeing the keepass2 group paths as tags in 1P. Here's the sequence of events I performed.
    1. deleted directory c:\myperl
    2. extracted StrawberryPerl v5.24 to c:\myperl
    3. downloaded Testing Bits v1.11; extracted; copied the convert_to_1p4 directory to the desktop
    4. C:\myperl\portableshell.bat
    5. %userprofile%\desktop\convert_to_1p4\install_modules.bat (all looked successful)
    6. changed working dir to %userprofile%\desktop\convert_to_1p4
    7. perl convert_to_1p4.pl keepass2 -v <path_to_my_keepass_export.txt>

    The .1pif import file generates without issue, imports into 1P without issue and all entries are present. I have tags that show the imported timestamp, but no tag for the keepass2 group paths.

  • MrC
    MrC
    Volunteer Moderator
    edited July 2018

    @scotty321 ,

    FYI: you don't need to run the install_modules.bat script again - you ran it after you installed Strawberry Perl, and those installed modules remain installed.

    Do you see in your Keepass2 XML export a <Group> hierarchy such the image below shows for my example above?

    and the debug output with -d would show:

  • scottypa
    scottypa
    Community Member

    Thank you! I was testing my KeePass exports by only exporting a small subset of data, in this case, one folder (group) containing three entries. Your last post about running the conversion in debug helped me to see that get_group_path was returning null for all three entries. When I experimented by exporting one level above the folder I originally selected, I then saw that get_group_path was returning the group name for any child groups. So in the end, everything actually was working; it was my limited test data that led me to believe it was not working. Now that I have imported my production data, everything looks great. Not only are all of my KeePass group names intact in 1Password tags, but I did not expect the tags to nest based on the "/" separator! That's awesome. You did a great job on this converter. And the fact that you developed this with several conversion sources for all to use without charge is very cool. We would like to contribute to your efforts. Do you have a Patreon?

  • MrC
    MrC
    Volunteer Moderator

    @scottypa,

    That's great news.

    It's my pleasure to help, and your Thanks is sufficient payment for me.

    Enjoy 1Password!

  • kabo
    kabo
    Community Member

    Hi there,
    I'm not sure if this has been answered (all I found was a mention of how difficult Apple has made it to copy iCloud keychain items), but I can't copy my keychain items from iCloud to local-cloud. I get this error code:

    "An error has occurred. Unable to add an item to the current keychain. One or more parameters passed to a function were not valid."

    If I use the iCloud password (as opposed to the local keychain password) I get the following error:

    "An error has occurred. Unable to add an item to the current keychain. The contents of this item cannot be retrieved."

    I can't think of anything else - where am I going wrong?

  • MrC
    MrC
    Volunteer Moderator

    Hi @kabo,

    It seems there is no good way anymore to copy directly the iCloud keychain to a local keychain.

    An earlier poster suggested an AppleScript could be written to copy Safari passwords directly from Safari's prefs, but I have not had the time to look into this.

  • kabo
    kabo
    Community Member

    Hey @MrC,

    thanks for the quick answer. I'll just hang out and wait until that one's figured out :) I really do not want to have to manually enter 400 passwords (how on earth did I collect that many???)

  • MrC
    MrC
    Volunteer Moderator

    Maybe later next week I can look at an AppleScript solution @kabo

  • Commander86
    Commander86
    Community Member

    Master MrC, we are waiting you impatiently, for the AppleScript for Safari.
    can we export all keychain passwords

  • fathertime
    fathertime
    Community Member

    Hi MrC,
    I am trying to copy my iCloud Keychain into my newly created local-icloud keychain just how the the guide says but am having trouble.

    When I paste it into local-icloud I get a prompt which says 'Keychain Access wants to use the "Local Items" keychain' which requests a password. However once I enter it says ' An error has occurred. Unable to add an item to the current keychain. One or more parameters passed to a function were not valid.'

    Im not entirely sure why since I am entering the password. I've even tried other passwords but none of them are working. I am even able to unlock both the keychains. What should I do?

  • MrC
    MrC
    Volunteer Moderator

    @fathertime ,

    See my post from Jul 22 above.

  • Commander86
    Commander86
    Community Member

    MrC we are waiting you

  • MrC
    MrC
    Volunteer Moderator
    edited November 2018

    Edit: please see this post instead.


    Hi @Commander86 @fathertime @kabo @ppeepp @matan

    Your wait is over....

    Edit: Safari 12 users please also see this post

    In Testing Bits, mentioned in the first post of this converter suite thread, is an Applescript named GetSafariPasswords. You can copy it to your system to use. You can open and examine it with Script Editor.

    Once I've worked out any kinks, I'll incorporate it into the AppleScript_Conversion_Helper. But for now, here are your steps:

    1. Open the script with Script Editor
    2. Launch Safari
    3. Open Safari's preferences and navigate to the Passwords tab
    4. Unlock the dialog so your list of credentials is visible
    5. Switch back to Script Editor and hit its Run button

    If all is successful, it will cycle through your rows of login credentials, and export them to a file on your Desktop named pm_export.csv. It will close Safari's preferences dialog and open a dialog that tells you the export is complete. You can now convert that pm_export.csv file with the csv converter in version 1.11 of the conversion suite (also in Testing Bits).

    Let me know if there are any issues.

    Note - you may need to allow Script Editor to access Safari's UI elements. To do this, find the Security & Privacy area in System Preferences and allow Script Editor to control your computer:

  • Commander86
    Commander86
    Community Member

    thank you @MrC I'm grateful to you. i do it, i copied 474 line succesful :) (i had get just one error. yandex requested account permission at the last line and it caused to restart. if someone will use this first get yandex permission then start. for get this permission just click the yandex line ). my english is not well, i cant understand the converting csv to txt or another version, can i convert easily csv to excel file? thank you very much again :)))

  • Commander86
    Commander86
    Community Member

    Thank you again @MrC i do it with Numbers app now it is xlsx i hope you will go to heaven :)

  • MrC
    MrC
    Volunteer Moderator
    edited August 2018

    @Commander86 ,

    That’s pretty good news for a start! Thanks for the feedback, and sorry for the delay.

    I am curious about the Yandex error. Can you give me any more details about this (nothing confidential, of course)?

    A CSV file is just a text file, that can be opened by any text editor, or more usefully, any spreadsheet program.

    Hopefully I will remain on planet Earth for at least the foreseeable future.

  • MrC
    MrC
    Volunteer Moderator
    edited August 2018

    I've updated the GetSafariPasswords script to:

    1. Clean up the Title (remove the protocol, and anything after the first / character).
    2. Ensure capture of the full URI as viewed when the cell is focused (vs the unfocused sanitized version shown with under non-focused/non-edit circumstances).

    Due to (2) above, the script runs a bit slower, as each cell element now has to be focused to get the actual (vs. sanitized) values.

  • moxiefrog
    moxiefrog
    Community Member
    edited September 2018

    First off, my sincere thanks to @MrC to maintaining this forum and helping out everyone that asks!
    I tried the AppleScript earlier in the thread, but failed with the error that does not allow iCould Keychain items to a local keychain "An error has occurred. Unable to add an item to the current keychain. One or more parameters passed to a function were not vaild." I was almost ready to give up, but I had 400+ items in my keychain I needed to move over; I didn't relish the idea of recreating each from within 1Password.

    Soooooo, long story shorter: after struggling with this for days I was finally able to copy out each of the iCould Keychain items using Automator. I created a script that opens each Keychain item one at a time, unlocks it, and copies/pastes each field out to TextEdit. From there I converted to csv and imported into 1Password. What a pain. Here is the code in case anyone else wants to use this as a starting point.

    Notes:

    1. You must have TextEdit open on a new document and ready to receive the pasted info from the keychain.
    2. You must have the iCloud Keychain unlocked and sorted in whatever order you want to copy/paste.
    3. Update the "password" on line 73 to match yours.
    4. Add/update the keystroke order in the script to add more/less fields to each copy/paste action. I chose to the first field, username, and password to export. You might want more/less fields.
    5. You might have some instances where the delay's are not perfect, so pay attention to the output in TexEdit to make sure the data is coming across correctly.
    6. Once you get it the way you like it an are confident, increase the repeat value on line 1 to something like 50. I would not recommend more than that.
    7. Use at your own risk. If you know how to use AppleScript and Automator, then you might be just dangerous enough to screw things up. Good Luck!
    repeat 1 times
     delay 0.2
     tell application "Keychain Access"
         activate
         
         tell application "System Events"
             delay 0.2
             keystroke return
             
             -- Press ⌘C to copy item title
             delay 0.2
             keystroke "c" using command down
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Type a comma
             delay 0.2
             keystroke ","
             
         end tell
     end tell
     
     --Switch to Keychain
     tell application "Keychain Access"
         activate
         tell application "System Events"
             -- Press Tab x2 
             delay 0.1
             keystroke tab
             delay 0.1
             keystroke tab
             
             -- Press ⌘C
             delay 0.2
             keystroke "c" using command down
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Type ','
             delay 0.2
             keystroke ","
         end tell
     end tell
     
     --Switch to Keychain
     tell application "Keychain Access"
         activate
         tell application "System Events"
             -- Click the “Show password:” checkbox.
             delay 0.2
             keystroke "c" using {shift down, command down}
             
             -- Type password - update to yours
             delay 0.5
             keystroke "password"
             delay 0.2
             keystroke return
             
             -- Close keychain item window
             delay 0.3
             keystroke "w" using command down
             
             -- Go to next keychain item
             delay 0.2
             key code 125
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Press Return
             delay 0.2
             keystroke return
         end tell
     end tell
    end repeat
    end run
    
  • MrC
    MrC
    Volunteer Moderator
    edited August 2018

    @moxiefrog ,

    Thanks for the kind words.

    Had you seen the GetSafariPasswords Applescript post above yours? It grabs Safari's passwords. Do you have many in iCloud Keychain that are not from Safari?

  • moxiefrog
    moxiefrog
    Community Member

    @MrC, I had very few Safari/Opera/Chrome saved passwords (<10). Most (450+ were in iCloud Keychain). Thanks again!

  • adamabbate
    adamabbate
    Community Member

    Just wanted to say thank you @MrC for making these scripts available. Using your instructions, I was very easily able to convert a KeePass2 file.

  • MrC
    MrC
    Volunteer Moderator

    @adamabbate ,

    You are very welcome - enjoy 1Password!

  • infinus1
    infinus1
    Community Member

    On Mojave 10.14 when using the GetSafariPasswords script I get the following error despite having the passwords open an unlocked in safari: System Events got an error: Can’t get text field 1 of row 1 of table 1 of scroll area 1 of group 1 of group 1 of window 1 of application process "Safari". Invalid index.

  • MrC
    MrC
    Volunteer Moderator

    Thanks @infinus1 ,

    As soon as I get Mojave installed next week, I'll take a look. I was afraid the update was going to break the script. It might be a quick fix, or it might need a more substantial update. Apple has been making automation harder and harder.

  • nickhass
    nickhass
    Community Member
    edited September 2018

    Thanks @MrC for your work with all this, very kind of you to be willing to do so without even asking for donation.

    Seems I've jumped into this into a time of transition with the new Mojave update – I wanted to take my iCloud Keychain passwords, export them from Safari/Keychain Access and plonk them into 1Password.

    I've taken @moxiefrog 's script and tweaked it a tad so that it will work under macOS Mojave to export items from your iCloud Keychain to TextEdit so you can save as a CSV file and then import to 1Password. I think Mojave changed the order in which the Keychain Access application displays the item data? Anyways, run the script attached to the end of this post with the same instructions from @moxiefrog 's post from August 19 to export items from your iCloud Keychain to TextEdit under Mojave. From there, you can save the plain text file as a CSV and import the items into 1Password. This script copies the item name, url, username and password (so it can be used to autofill from 1Password once imported). I'll copy and past the instructions from @moxiefrog 's post just to make it easier:

    1. You must have TextEdit open on a new document and ready to receive the pasted info from the keychain.
    2. You must have the iCloud Keychain unlocked and sorted in whatever order you want to copy/paste.
    3. Update the "password" field on the line that's 33 lines from bottom of the script to match your password.
    4. You might have some instances where the delay's are not perfect, so pay attention to the output in TexEdit to make sure the data is coming across correctly.
    5. Once you get it the way you like it and are confident, increase the repeat value on line 1 to something like 50. I would not recommend more than that.
    6. Use at your own risk. If you know how to use AppleScript and Automator, then you might be just dangerous enough to screw things up. Good Luck!

    Thanks @moxiefrog for making the script!
    (Just for reference, I copied 74 items and it took about 5 minutes)

    repeat 1 times
     delay 0.2
     tell application "Keychain Access"
         activate
         
         tell application "System Events"
             delay 0.2
             keystroke return
             
             -- Press ⌘C to copy item title
             delay 0.2
             keystroke "c" using command down
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Type a comma
             delay 0.2
             keystroke ","
             
         end tell
     end tell
     
     --Switch to Keychain
     tell application "Keychain Access"
         activate
         tell application "System Events"
             -- Press Tab x3 to get to item url 
             delay 0.1
             keystroke tab
             delay 0.1
             keystroke tab
             delay 0.1
             keystroke tab
             
             -- Press ⌘C
             delay 0.2
             keystroke "c" using command down
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Type ','
             delay 0.2
             keystroke ","
         end tell
     end tell
     
     --Switch to Keychain
     tell application "Keychain Access"
         activate
         tell application "System Events"
             -- Press Shift-Tab to get to item account name
             delay 0.1
             keystroke tab using shift down
             
             -- Press ⌘C
             delay 0.2
             keystroke "c" using command down
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Type ','
             delay 0.2
             keystroke ","
         end tell
     end tell
     
     --Switch to Keychain
     tell application "Keychain Access"
         activate
         tell application "System Events"
             -- Click the “Show password:” checkbox.
             delay 0.2
             keystroke "c" using {shift down, command down}
             
             -- Type password - update to yours
             delay 0.5
             keystroke "password"
             delay 0.2
             keystroke return
             
             -- Close keychain item window
             delay 0.3
             keystroke "w" using command down
             
             -- Go to next keychain item
             delay 0.2
             key code 125
         end tell
     end tell
     
     --Switch to TextEdit
     delay 0.2
     tell application "TextEdit"
         activate
         tell application "System Events"
             -- Press ⌘V
             delay 0.2
             keystroke "v" using command down
             
             -- Press ',' to end the item
             delay 0.2
             keystroke ","
             
             -- Press Return to start new item line
             delay 0.1
             keystroke return
         end tell
     end tell
    end repeat
    end run
    
  • MrC
    MrC
    Volunteer Moderator

    @nickhass ,

    You're welcome. Good to hear you've made some progress. I'll get right on the script early next week.

    I'd originally used the copy/delay/paste method, but found it very unreliable with out a very long delay for each item, so wanted to find another way which was far quicker (and didn't involve user's having to potentially adjust delay times, multiple times to get the script to work reliably). And of course directly accessing the elements is the better, reliable method... so long as Apple doesn't adjust the interface! Doh.

This discussion has been closed.