LastPass Converter for 1Password 4

MrC
MrC
Volunteer Moderator
edited October 2014 in Mac

I've created a script to convert your LastPass data into a format that can be imported by 1Password 4. The script can be run on OS X or Windows.

Edit: this version of the converter has been obsoleted. The new and improved version is located here:

https://discussions.agilebits.com/discussion/30286/mrcs-convert-to-1password-utility/p1

«1

Comments

  • MrC
    MrC
    Volunteer Moderator

    I've posted an update which sets each items Created time to 1/1/2000 to help trigger WatchTower checks. This can be defeated with the --nowatchtower option. See the last Note in the Read Me file.

  • iDoug
    iDoug
    Community Member

    I am returning to 1Password. Tried the default LastPass import. Didn't like the results. This Perl script worked. Have only been using 1Password for an hour and am already impressed.

  • MrC
    MrC
    Volunteer Moderator

    Thanks for the feedback iDoug! And I'm sure the AgileBits folks are happy to hear you've returned.

    MrC

  • XIII
    XIII
    Community Member
    edited July 2014

    MrC, thank you very much!

    I was so disappointed with the LastPass import included in 1Password that I was thinking of trying to create such a script myself. This saves me a lot of time and instantly adds a lot of value to 1 Password!

    LastPass is still my primary password manager at the moment. I would like to import the login items from LastPass without the secure notes every week (I plan to manually improve the secure notes that I imported via your script).

    I have not programmed in Perl before, but is the following a quick hack to achieve what I want?

    Move

    push @{$Cards{$cardtype}}, \%card; $n++;

    into the

    if ($cardtype eq 'login') {

    part?

  • MrC
    MrC
    Volunteer Moderator

    Hi XIII,

    Thanks for the nice words.

    If by your request you mean that you only want to deal with LastPass' "Site" types (and ignore the Secure Note type), you can find this code in the import_csv() function:

            else {
                $cardtype = pull_fields_from_note(\%card, $notes);
            }
    

    and change it to:

            else {
                next;
                #$cardtype = pull_fields_from_note(\%card, $notes);
            }
    

    This would cause the Secure Note types to be skipped during import.

    If on the other hand you do want the automatic Secure Note to login conversion to also happen (when appropriate), you can add to the command line the --type (aka -t) option to specify the import type(s) you want:

       -t login
    
  • XIII
    XIII
    Community Member

    Yes, I indeed want to ignore the (already imported and improved) Secure Notes, so I'll try the first part at my next sync (this weekend).

    Thanks!

    Maybe something to add in a future version: a command line parameter to (only) sync items of type Site, Secure Note, or both (default)?

  • MrC
    MrC
    Volunteer Moderator
    edited July 2014

    Maybe something to add in a future version: a command line parameter to (only) sync items of type Site, Secure Note, or both (default)?

    Do you feel this is something that will be generally used the intended audience, that is, folks trying to move from LastPass to 1Password?

    Your use case seems rather unique, and the converter wasn't designed with that case in mind. Be sure to delete from 1P4 all your lastpass_to_1p4 script-generated logins before importing a subsequent batch. Each entry has a uniquely generated UUID, which is used to match imports. If you don't delete the old ones, you'll get duplicate entries.

  • XIII
    XIII
    Community Member

    Good points!

    I'm aware that my use case is most probably an edge case (LastPass as the primary password manager with the desire to keep 1Password in sync), so I was indeed wondering whether such a parameter would be useful in general.

    I was also wondering about the UUID, but since I was already regularly deleting my logins (on the Mac) before using 1Password's own import function I guess I can keep that "habit" for a while. Do I also need to remove them on my iOS devices before syncing them (via Wi-Fi sync)?

    With 1Password's own import function just deleting all entries on the Mac, importing them again on the Mac, and then (Wi-Fi) syncing to iOS devices seems to work fine.

  • MrC
    MrC
    Volunteer Moderator
    edited July 2014

    I believe the UUID is used as the matching token for WiFi sync as well, since it appears to be the primary key for records in 1P4. Since you're deleting these on the Mac (they get tossed into the Trash), upon sync, the matching IOS records will also sync to the Trash, leaving your newly-imported records as the main entries.

  • XIII
    XIII
    Community Member

    That makes sense. And is pretty nice for my use case. Cool!

  • Alienigena
    Alienigena
    Community Member

    Thank you very much, MrC, for your incredible work. I already mentioned it in other thread, but I think this is the right one.
    Everything went very smooth with your converter, as you said, except for the filling form profiles, which simply didn't work at all. But at least it imported something and detected one of the many fields of the form profiles, because the default converter of 1Password simply does nothing when considering these form profiles...

  • MrC
    MrC
    Volunteer Moderator

    You're welcome. Replied over here.

  • MrC
    MrC
    Volunteer Moderator

    I'm duplicating my reply in your other thread, since it is more relevant here. Please continue discussion regarding this topic here.

    In your other thread, I replied:


    That's correct. I didn't implement those, and until now, didn't even realize Form Profiles exported as a separate CSV file. I suppose I could support reading these, and converting them into Identity, Credit Card, and Bank Account. But where would the Custom Fields go and the Notes - under which card (Identity, Credit Card, and Bank Account). I assumed users would already have Credit Card and Bank Account entries in their LastPass Notes using the appropriate Notes subtype.

    If you can go through your profiles, and tell me exactly how you want the data on each of the Form Fill tabs converted (i.e. into Identity + notes, etc.), I'll take a look at the converter importing that CSV file. It would have to be a separate action, and it would create another 1PIF file, itself requiring import into 1P4.

    Thanks again for your comments.

  • MrC
    MrC
    Volunteer Moderator

    I've updated the script to version 1.02. It includes the new Form Fill Profile conversion. From the ReadMe file's introduction:

    The script lastpass_to_1p4.pl will convert a LastPass CSV text file export into a 1PIF format
    that can be imported into 1Password 4. It can convert either the LastPass CSV File or the
    Form Fill Profiles export, both of which are CSV files.

    and then the new optional step 7:

    7․ If you wish to import your LastPass Form Fill Profiles, repeat step 2, but this time select the
    menu item:

     Tools > Advanced Tools > Export To > Form Fill Profiles
    

    and save the file using the same name as above, and repeat steps 4 through 6. Each LastPass Form
    Fill Profile conversion may create Identity, Credit Card, Bank Account, and Social Security entries
    in 1Password. Notes and Custom Fields are placed into the notes section of the Identity entry.
    The LastPass fields that do not map into the stock 1Password entries, or those fields which could
    cause conversion or import failures, are also placed into the notes section of the Identity entry.

    I'll submit the request for AgileBits to post the update on their Git site once I've updated the ReadMe file to the new format.

    Much thanks @Alienigena for the excellent feedback and testing.

  • Pat Putnam
    Pat Putnam
    Community Member

    I am having a problem with running this script. In Safari Last Pass I go to Tools>advanced tools> Export to> LastPass CSV file.I end up with a webpage full of my passwords etc. But there is no option to save this to my desktop. In Chrome, I get the option to save but only as an html file. What am I doing wrong?

  • MrC
    MrC
    Volunteer Moderator
    edited October 2014

    I don't know why it doesn't offer to save the content as a page. Either way. Select all the text on that page and Copy. Open TextEdit, and go to Preferences, and under the New Document section, under Format, select Plain Text. Open a new document and Paste. Save as a UTF-8 document on your desktop.

    I have a better version for you to try. See this post, and replace splashid with lastpass where relevant. The test version does not yet have the form fill profiles completed, so it can only be used on the LastPass CSV export.

  • jrseaman
    jrseaman
    Community Member

    Hey guys I was having the same problem at Pat. Unfortunately chrome and safari don't have the right dialog to down load the file so you can to copy and paste it into a text editor. But TextEdit doesn't let you save into the right formate. I fixed all of this by using TaxtMate. You can see how I did it in this video - http://youtu.be/7mUGlL_RVmU

  • MrC
    MrC
    Volunteer Moderator

    But TextEdit doesn't let you save into the right formate

    Can you explain this - TextEdit does allow you to save as UTF-8:

  • Pat Putnam
    Pat Putnam
    Community Member

    ** Save as a UTF8 document on your desktop.**

    I don't have this option in Text Edit.

  • MrC
    MrC
    Volunteer Moderator

    Oh! Thanks for letting me know. Can I ask, which version of OS X is this? I want to update instructions for my converters, if necessary.

  • Pat Putnam
    Pat Putnam
    Community Member

    I am using 10.9.5
    No option to save as UTF-8 in this Text Edit.
    I will try Textmate suggestion.

  • MrC
    MrC
    Volunteer Moderator

    Ok, now I'm really confused since I'm using Mavericks (10.9.5) also.

    You are using File > Save right?

    I don't see how your version of TextEdit, which comes with OS X, would not have it, yet mine does.

  • Pat Putnam
    Pat Putnam
    Community Member

    Thank you MrC and Thank you jrseaman. Done.

  • MrC
    MrC
    Volunteer Moderator

    I'm no longer confused - I learned something about TextEdit. To get the UTF-8 choice, you have to first change Text Edit's preference: Text Edit > Preferences > New Document > Format and set Plain Text. Now open a new document, and Save will show the Plain Text Encoding choices pulldown.

    I've used Text Edit in plain text mode forever, so didn't realize this setting affected the encoding choices, but it make sense now.

  • maxaudet
    maxaudet
    Community Member

    Thanks a lot Mrc !! It gives better results than the built-in LP import of 1P.

  • MrC
    MrC
    Volunteer Moderator

    You're welcome, and thanks for the great feedback and kind words!

  • hsafer
    hsafer
    Community Member

    Dynamite MrC, thanks for the script!

  • JimRPh
    JimRPh
    Community Member

    Thanks MrC! Worked great for LastPass and eWallet.

  • MrC
    MrC
    Volunteer Moderator

    Fantastic! It's great to read that you had success X 2. Thanks for the feedback.

  • elbee
    elbee
    Community Member

    i am struggling to get this conversion working. i believe i've followed the directions correctly, but apparently not so well... i exported my lastpass data to a CSV file. after much confusion and effort i believe perl is installed correctly on my OSX 10.10.1 mac (it was not when i initially tried some of the commands nothing worked).

    i have the convert_1_1p4 folder on my desktop. using terminal i moved to that directory and executed the perl script. i tried many variations but they all come back saying the CSV file does not exist. using the ls command on the directory seems to confirm i am in the correct location and the file does exist (in fact two of them exist with different names. neither one works.)

    advice appreciated.

    thanks

    Lees-Mac-Pro:~ lmbuck$ cd Desktop/convert_to_1p4
    Lees-Mac-Pro:convert_to_1p4 lmbuck$ ls
    Changes.txt README.pdf convert_to_1p4.pl
    Converters TEXT lastpass_info.csv
    JSON UUID pm_export.txt
    README.md Utils
    Lees-Mac-Pro:convert_to_1p4 lmbuck$ perl5.18 convert_to_1p4.pl lastpass -v ../../pm_export.txt
    Use of my $_ is experimental at Converters/Lastpass.pm line 600 (#1)
    (S experimental::lexical_topic) Lexical $_ is an experimental feature and
    its behavior may change or even be removed in any future release of perl.
    See the explanation under "$_" in perlvar.

    Unable to open CSV file: ../../pm_export.txt
    No such file or directory

    Lees-Mac-Pro:convert_to_1p4 lmbuck$ perl convert_to_1p4.pl lastpass -v ../../pm_export.txt
    Use of my $_ is experimental at Converters/Lastpass.pm line 600 (#1)
    (S experimental::lexical_topic) Lexical $_ is an experimental feature and
    its behavior may change or even be removed in any future release of perl.
    See the explanation under "$_" in perlvar.

    Unable to open CSV file: ../../pm_export.txt
    No such file or directory

    Lees-Mac-Pro:convert_to_1p4 lmbuck$ perl5.16 convert_to_1p4.pl lastpass -v ../../pm_export.txt
    Unable to open CSV file: ../../pm_export.txt
    No such file or directory

    Lees-Mac-Pro:convert_to_1p4 lmbuck$ perl convert_to_1p4.pl lastpass -v ../../pm_export.txt
    Use of my $_ is experimental at Converters/Lastpass.pm line 600 (#1)
    (S experimental::lexical_topic) Lexical $_ is an experimental feature and
    its behavior may change or even be removed in any future release of perl.
    See the explanation under "$_" in perlvar.

    Unable to open CSV file: ../../pm_export.txt
    No such file or directory

    Lees-Mac-Pro:convert_to_1p4 lmbuck$

This discussion has been closed.