MrC's Convert to 1Password Utility

14345474849

Comments

  • edited September 18

    Hi, Mrc:

    When I tried to use GetSafariPasswords, it said:

    "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."

    How should I solve this?

    BTW, my Safari just updated to 12.0. Not sure whether this is the reason.

  • MrCMrC Community Moderator
    edited September 18

    @Barrowland ,

    Please see my reply a few posts back....

    https://discussions.agilebits.com/discussion/comment/461398/#Comment_461398

    There is a work around posted by another user following my reply, if you can't wait.

  • Oh, I see.
    I made a mistake, and now nickhass's code works.
    But I am using High Sierra, that's why I thought GetSafariPasswords should work.

  • MrCMrC Community Moderator

    @Barrowland ,

    I'll take a look later today. Thanks for bringing this to my attention.

  • MrCMrC Community Moderator

    @Barrowland @nickhass @infinus1 ,

    The problem GetSafariPasswords is seeing is not a Mojave issue, but with Safari 12. It has changed the Passwords dialog such that the row data is no longer select-able, and instead, a pop-up edit dialog appears. In Safari < 12, you could edit each item in the row - this is no longer the case.

    I'll have to spend some time on this.

  • @MrC
    I noticed that might be the reason as well.
    Thanks for your kindness!

  • infinus1infinus1
    edited September 20

    No worries @MrC ! Thanks for all your time making these conversion utilities! Without them I’d probably never be able to make the jump to 1password!

    I noticed that it does have a right click option to copy website, username, and password as separate entries. Can these be leveraged into the script? Cmd+c seems to copy only the password field for me. Also copy website only copies 1 of the entries which would be a limitation.

    Other thought, is it possible to temporarily downgrade safari to the version that worked with the script?

  • @MrC
    I had problems with the Safari password to TextEdit script on Safari 12 and 10.13.
    I spent about 15 minutes looking for a script to give me a context menu to walk through, but then I would need to move the mouse each time until the bottom line was reached. As an alternative I noticed that I could still grab the username and password by script, and given that I only had 120 odd passwords left in Safari, I wrote a script that relied on me manually right clicking and copying one password website at a time, and then letting the script paste that into TextEdit and grab the username and password without my intervention. The cursor then scrolled to the next line, I hit copy then run and so on. It took about 10 minutes to grab all the passwords this way. I did then edit the login description in Numbers which added about another 15 minutes but this step was optional. I include my script here in case it is useful to you or another reader... (I realise some keystrokes could be combined but copy-paste was quicker;)
    The import into 1Password7 was perfect.

    (*
    1. Open the Safari passwords window in Safari Preferences and position this window directly above this open script window. Close other Safari windows and finder windows.

    1. Have an open TextEdit doc window ready to accept the exported password info
      (Save it first as a .csv. Format->Make plain text. Save-> "myExport.csv").

    2. Unlock your Safari passwords if necessary and right click on the line you wish to export, choosing "Copy Website" to copy the website to the clipboard. Immediately click the play button at the top of this script window. The website you just copied will be pasted in, followed by the username and password.

      The selection will then scroll down one line, and you repeat step 3 until all desired passwords have been copied to the TextEdit file. Save the TextEdit file on completion and import it into 1Password as a csv file.

    ** NOTE 1: By default this script will also save the website name also as the login title in 1Password. (For quicker renaming, before importing to 1Password, you can open the saved TextEdit file in Numbers, rename the websites in the first column to desired login titles, and export this modified file from Numbers as a csv. This new csv is then the one imported to 1Password)
    ** NOTE 2: If you are missing a user name in your Safari passwords, (as sometimes happens when passwords are saved in Safari), the website will also be pasted in the username position.
    *)

    tell application "TextEdit"
    activate
    delay 0.4
    tell application "System Events" to keystroke "\""
    tell application "System Events" to keystroke "v" using command down
    tell application "System Events" to keystroke "\","
    tell application "System Events" to keystroke "\""
    tell application "System Events" to keystroke "v" using command down
    tell application "System Events" to keystroke "\","
    end tell

    tell application "Safari"
    activate
    delay 0.4
    tell application "System Events" to keystroke return
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke "c" using command down
    end tell

    tell application "TextEdit"
    activate
    delay 0.4
    tell application "System Events" to keystroke "\""
    tell application "System Events" to keystroke "v" using command down
    tell application "System Events" to keystroke "\","
    end tell

    tell application "Safari"
    activate
    delay 0.4
    tell application "System Events" to keystroke tab
    tell application "System Events" to keystroke "c" using command down
    end tell

    tell application "TextEdit"
    activate
    delay 0.4
    tell application "System Events" to keystroke "\""
    tell application "System Events" to keystroke "v" using command down
    tell application "System Events" to keystroke "\","
    tell application "System Events" to keystroke return
    end tell

    tell application "Safari"
    activate
    delay 0.4
    tell application "System Events" to keystroke return
    tell application "System Events" to key code 125
    end tell

  • I updated the original script to work with Mojave, with the caveat that it requires an external tool, "MouseTools", to be placed in your home directory. It works similar to the above, but it will handle copy/paste of each row's URL as well, and will iterate through all the contents rather than you having to step through one by one manually. I'll post the info here once I have a chance to test it more and make sure there aren't any big issues!

  • MrCMrC Community Moderator

    @bpengu1n ,

    FYI: I'm working on updating my script for Mojave at this moment.

    I'm going advise against suggesting users download / use an external compiled program for this sensitive data, since the binary executable isn't readily viewable by users, and users shouldn't have to compile any code to ensure safety. This breaks one of the basic premises I've had for any of my tools - that there be no binary executables and that all code be script-only.

  • MrCMrC Community Moderator
    edited November 15

    Edit: please see this post instead.


    @bpengu1n @pken @Barrowland @nickhass @infinus1

    I've created a Safari 12 specific version of the GetSafariPasswords script.

    Instructions

    Get the script named GetSafariPasswords_Safari12 available in Testing Bits mentioned in the the first post of this converter suite thread.

    The instructions for using GetSafariPasswords_Safari12 are the same as those I posted previously.

    I still have not updated the README.pdf instructions for this version (or the original version - I suspected Mojave or a new Safari would cause issues). The only differences from what I wrote previously should be that it will be a bit slower since it has to expand each password entry in the Passwords list, and that it cannot know the protocol in the URL since only the host address is available (the dialog no longer allows direct editing of that field, nor displays the protocol).

    I'd be interested in any feedback or issues.

  • edited October 5

    I wrote an updated script with the help of MrC, pken and nickhass. This one functions the same way as pken's script above, but automates it further and doesn't require any external tools like MouseTools. It even logs into the Safari Password Preferences screen for you.If I knew more about Mac OS X UI Elements, I'm sure I could automate opening Safari, going to Preferences, choosing the Password tab and logging in, etc. However, this works and it's still fairly easy to execute. Takes about 8 seconds per URL/username/password combo to run. The 206 I had took approximately 30 minutes to run.

    1. Open Safari, go to Preferences and click on the Password tab.
    2. Open TextEdit, go to Format menu and click "Make Plain Text".
    3. Open Script Editor (Applications -> Utilities -> Script Editor). Start a new document and paste in the following script text.
    4. Replace PASSWORD with your actual password for the Mac.
    5. Look for the line that says "repeat while (x ≤ 207)" and replace the 207 with whatever you are comfortable with. If you have an iPhone or iPad running iOS 12, you can go to Settings -> "Passwords & Accounts". To the right of "Website & App Passwords", you'll see the number you have saved in there. You can replace 207 with that number PLUS 1. So, if it says you have 10, type 11 instead.
    6. Click the Play button in script editor and you should be off and running.

    I've noticed that sometimes it won't put in the password because the field isn't highlighted. If that happens, stop the script, empty the TextEdit file and click on one of the other Preferences tabs and then click back on the Passwords tab and try running the script again.

    If I had more knowledge of the UI elements or could script to get a list of them, we could ensure that the password field gets highlighted and is ready to accept the password that the script is trying to pass into it. With a few tweaks, this could literally open Safari, go to the right screen, put in your iCloud password and begin pulling logins all on its' own.

    1. Save the text file and rename it to WhatEverYouWant.csv and it should be importable into 1Password immediately.
    > -- OPEN SAFARI. GOTO PREFERENCES. CLICK PASSWORDS TAB --
    -- THIS FIRST REPEAT SECTION IS JUST TO GET TO THE PASSWORDS SCREEN AND LOGIN TO ICLOUD --
    repeat 1 times
        tell application "Safari"
            activate
            delay 0.5
            tell application "System Events"
                -- Ensure Password Field Selected --
                keystroke tab
                delay 0.2
                -- Type your password for you --
                keystroke "PASSWORD"
                delay 0.2
                -- Hit enter to login --
                keystroke return
                delay 0.2
            end tell
        end tell
    end repeat
    
    -- START GRABBING PASSWORDS - SET REPEAT VALUE TO NUMBER OF PASSWORDS --
    set x to 1
    repeat while (x ≤ 207)
        -- Switch To Safari --
        tell application "Safari"
            activate
            delay 0.5
            tell application "System Events"
                -- Switch from search field to password list field (Only needs to be done once) --
                if (x = 1) then
                    keystroke tab
                    delay 0.2
                end if
                -- Select first password in list (Field selected. but nothing highlighted) --
                key code 125
                delay 0.2
                -- Open Right-click Menu -- 
                tell application process "Safari"
                    set _selection to value of attribute "AXFocusedUIElement"
                    tell _selection to perform action "AXShowMenu"
                end tell
                -- Down arrow once to choose/highlight "Copy Website" --
                key code 125
                delay 0.2
                -- Copy Website/URL data --
                keystroke return
                delay 0.2
            end tell
        end tell
        -- Switch To TextEdit
        tell application "TextEdit"
            activate
            delay 0.5
            tell application "System Events"
                -- Print a double quote --
                keystroke "\""
                delay 0.2
                -- Paste "Website/URL" data to text file --
                keystroke "v" using command down
                delay 0.2
                -- Print ending double quote and a comma for CSV --
                keystroke "\","
                delay 0.2
                -- Print a double quote --
                keystroke "\""
                delay 0.2
                -- Paste "Websites" data to text file again (For "Title" field in 1Password) --
                keystroke "v" using command down
                delay 0.2
                -- Print ending double quote and a comma for CSV --
                keystroke "\","
                delay 0.2
            end tell
        end tell
        -- Switch To Safari --
        tell application "Safari"
            activate
            delay 0.5
            tell application "System Events"
                -- Open Window containing "User Name", "Password" and "Websites" fields --
                keystroke return
                delay 0.2
                -- Move to "User Name" field --
                keystroke tab
                delay 0.2
                -- Copy data from "User Name" field --
                keystroke "c" using command down
                delay 0.2
            end tell
        end tell
        -- Switch To TextEdit --
        tell application "TextEdit"
            activate
            delay 0.5
            tell application "System Events"
                -- Print a double quote --
                keystroke "\""
                delay 0.2
                -- Paste "User Name" data to text file --
                keystroke "v" using command down
                delay 0.2
                -- Print ending double quote and a comma for CSV --
                keystroke "\","
                delay 0.2
            end tell
        end tell
        -- Switch To Safari --
        tell application "Safari"
            activate
            delay 0.5
            tell application "System Events"
                -- Move to "Password" field --
                keystroke tab
                delay 0.2
                -- Copy from "Password" field --
                keystroke "c" using command down
                delay 0.2
            end tell
        end tell
        -- Switch To TextEdit --
        tell application "TextEdit"
            activate
            delay 0.5
            tell application "System Events"
                -- Print a double quote --
                keystroke "\""
                delay 0.2
                -- Paste "Websites" data to text file --
                keystroke "v" using command down
                delay 0.2
                -- Print ending double quote and start a new line --
                keystroke "\""
                keystroke return
            end tell
        end tell
        -- Switch To Safari --
        tell application "Safari"
            activate
            delay 0.5
            tell application "System Events"
                -- Click "Done" button --
                keystroke return
                delay 0.2
            end tell
        end tell
        set x to (x + 1)
    end repeat
    end run
    
  • brentybrenty

    Team Member
    edited October 5

    @Joseph Rees: I've added ``` before and after the script to keep its formatting. Let me know if that's correct, or if some other change is needed. If it's easier for you, just repost and I can delete that one. Thank you for your efforts, and for sharing this with the community! :)

  • edited October 5

    @brenty Awesome! That was my first post and I couldn't figure out how to do that. The buttons on the page for codes and spoilers only seemed to do the start and not the close tags. So, I wasn't able to guess it. I tried a single ` at the beginning and at the end to no avail.

    Glad to help out and I hope others find this useful.

  • brentybrenty

    Team Member

    Hey, you did all the work. I just added some backticks. :lol: :+1:

  • MrC, thanks for your hard work and help with the CSV import of mSecure data.

    It works well, as instructed... however, it just so happens that my password filed in mSecure was custom made in a different field, so my logins have everything come in EXCEPT the actual password ! Ironic I know. :-)

    Is there any way I can manipulate the import somehow to swap fields, so that they align with what 1Password expects ? I have far too many mSecure records to just go and tweak them all.

    Any help greatly appreciated (and why mSecure doesn't allow tweaking the CSV export is super annoying. I remember when I first moved from SplashID to mSecure the export import was completely reasonable to adjust (if I recall correctly, it was on SplashID's side)... although that may also be why my passwords are now one field below where they might be expected ?

    thanks for consideration.

    • Mark
  • MrCMrC Community Moderator
    edited October 23

    Hi Mark / @MDP123 ,

    You are welcome.

    Yes, we can probably adjust the converter, customizing it for your needs. I'll need to understand the data format. Let's do this offline. My email is at the top of the convert_to_1p4.pl file. Drop me a line, and I'll explain what the msecure converter expects, and we can continue from there. Also, let me know what platform you exported / converted on, and your mSecure version.

  • Many thanks for your work, MrC! Your script saved me hours of manually migrating OS X keychains.

    I had to fix an issue when running the latest scripts, since both the Stable and the Testing Bits failed during migration with:

    Uncaught exception from user code:
        Error parsing time at /System/Library/Perl/5.18/darwin-thread-multi-2level/Time/Piece.pm line 469.
        Time::Piece::strptime('Time::Piece', '<NULL>', '%Y-%m-%d %H:%M:%S') called at /Users/xxx/Desktop/convert_to_1p4/./Converters/Keychain.pm line 361
        Converters::Keychain::parse_date_string('<NULL>') called at /Users/xxx/Desktop/convert_to_1p4/./Converters/Keychain.pm line 369
        Converters::Keychain::date2epoch('<NULL>') called at /Users/xxx/Desktop/convert_to_1p4/./Converters/Keychain.pm line 284
        Converters::Keychain::do_import('/Users/xxx/Library/Keychains/yyy.keychain-db', undef) called at convert_to_1p4.pl line 139
    

    I changed the Keychain converter to just to ignore datetime parse exceptions, since it seemed to handle null datetimes similarly (and I did not care about keeping them anway). So I rewrote the date2epoch function to

    368 sub date2epoch {
    369   eval {
    370     my $t = parse_date_string @_;
    371     return undef if not defined $t;
    372     return defined $t->year ? 0 + timelocal($t->sec, $t->minute, $t->hour, $t->mday, $t->mon - 1, $t->year): $_[0];
    373   }
    374   or do {
    375     return undef;
    376   }
    377 }
    

    Did the trick for me, but I guess there's some nicer way to fix this.

    The script ran on macOS Mojave v10.14.1

    Again, many thanks for your work!

  • MrCMrC Community Moderator
    edited November 3

    @rsto ,

    You're welcome.

    So it appears you have an empty or unexpected date in the entry? Is that what you see in the exported file?

    Can you reply with that line from the export? Just the date line.

    I generally don't place eval's around the converter code, because I need users to see the errors, and report them. You all are my eyes.

  • @MrC I've uploaded an anonymized debug log output for the failing entry to pastebin: https://pastebin.com/1g44VuAE

    The paste will expire in 1 day. If you happen to miss it, ping me on this forum and I'll upload a new one.

    Hope it helps. I won't be able rerun the scripts, because I'll wipe my macOS installation (exporting my keychains was the last missing step :) ).

  • MrCMrC Community Moderator

    @rsto

    Go it, thanks. I'll take care of this.

  • Hi
    I am getting a error trying to import some splashID data

    C:\Users\rob\Desktop\convert_to_1p4>perl convert_to_1p4.pl splashid -v xx.vid
    Uncaught exception from user code:
    Error parsing time at C:/myperl/perl/lib/Time/Piece.pm line 583, <$io> line 123.
    Time::Piece::strptime("Time::Piece", " 00,0000", "%B %d,%Y") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 337
    Converters::Splashid::parse_date_string(" 00, 0000") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 345
    Converters::Splashid::date2epoch(" 00, 0000") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 289
    Converters::Splashid::do_import("xx.vid", undef) called at convert_to_1p4.pl line 139

    Perl version:

    _This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x64-multi-thread

    Copyright 1987-2018, Larry Wall
    _

    As you can see it is running on Windozes.. Version is Windows 10.

    Any suggestions as to what is going wrong and how to fix the problem ?

    Thanks in advance !

    Rob

  • MrCMrC Community Moderator
    edited November 5

    Hi @rob_4x4 ,

    Which version of SplashID is this?

    The values being passed into my date conversion routine don't make sense - typically SplashID dates will look like:

    "October 04, 2014"

    or

    10/14

    for expiration dates. The converter is parsing " 00,0000" as one of your date values.

    Can you enable debugging and see what you notice just before the code dies? Add the -d option to enable debugging output.

  • Hi @MrC .
    Thanks for the quick response!. I am using SplashID 7.2.4.760 (April 29 2014) running on WIndows 10.

    This is the section of the debug output with the error with debug on ...

    do_import           :   field: Field 5 => F5
    do_import           :   field: Field 6 => F6
    do_import           :   field: Field 7 => F7
    do_import           :   field: Field 8 => F8
    do_import           :   field: Field 9 => F9
    do_import           :   field: Date Mod =>  00, 0000
    Uncaught exception from user code:
            Error parsing time at C:/myperl/perl/lib/Time/Piece.pm line 583, <$io> line 123.
            Time::Piece::strptime("Time::Piece", " 00,0000", "%B %d,%Y") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 337
            Converters::Splashid::parse_date_string(" 00, 0000") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 345
            Converters::Splashid::date2epoch(" 00, 0000") called at C:/Users/rob/Desktop/convert_to_1p4/./Converters/Splashid.pm line 289
            Converters::Splashid::do_import("./xx.vid", undef) called at convert_to_1p4.pl line 139
    
  • Hi @MrC .
    It looks like a corrupt data problem in the splashID database. I edited the splashID export file with notepad and removed the string " 00, 0000" from the data (28 occurrences out of 90 records). Your tool then worked without any errors !

    Thanks for the help !!

  • MrCMrC Community Moderator

    Excellent @rob_4x4,

    I'd never seen that sort of issue before, so its good to read that you were able to resolve it the way you did. Please let me know if you see any other issues with your converted data. It's possible that sometimes SplashID exports what is essentially an empty value for the date, and that's the only issue. If so, I can code around that and just ignore those date values.

    Enjoy 1Password!

  • Hi MRC,
    I tried the scrip GetSafariPassword and I get the following error :

    error "Erreur dans System Events :it is impossible to get window 1 of application process \"Safari\". Index not valid." number -1719 from window 1 of application process "Safari"

    Could you help me ?
    I am on MAC OS X El Capitan with Safari 11.

    In advance,Thank,
    Doudoune31

  • MrCMrC Community Moderator

    Hi @Doudoune31 ,

    Use the AppleScript_Convsion_Helper instead. When it presents a list of converters, select OS X Keychain. It will natively decrypt your keychain data, which includes Safari data. Just follow its instructions.

    The GetSafariPassword scripts were written to support the changes made for High Sierra and Mojave (Safari 12).

  • Hi, I am looking how to export from enpass before purchasing 1password and I tried @MrC script but it detect every login as a secure note resulting on a wrong categorie import, I had read the Readme pdf and used the --help option but I am unable to do a success convertion at all regarding the login categorie. For theLicence software categorie it does not even detect it (I can do this manually, not so much licenses no big deal) and regarding credit cards and servers it does the job quite well . Is there any other method (or modifier for the script that I didn't notice) that can export the right way for an espass csv (or txt). Thanks

  • MrCMrC Community Moderator
    edited November 13

    Hello @ivory

    Enpass is a little tricky.

    Did you set the language to English as per the README.pdf ?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file