Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: HOWTO: Convert Roboform to KeePassX

  1. #1
    Join Date
    Jun 2005
    Beans
    16

    Lightbulb HOWTO: Convert Roboform to KeePass(X)

    I've read a few methods on how to convert from one to other, all of which required a surplus of programs and none of which came remotely close to the accuracy I wanted. Using PassCrypt, you can import _some_ passwords from Roboform and export them to csv. From there you have to hack your way to get it to work with KeePass and then import it into KeePassX. I've done it this way, but the problem is that PassCrypt is not very good at finding your passwords in the Roboform export file.

    And thus, I present you with my simple python method. I migrated over 600 passwords with an estimated 95% accuracy.

    This guide is for KeePassX 0.30, but can also be used for regular KeePass (Follow the guide using KeePassX and save the database as a kdb file. Then just open the kdb in KeePass).

    To install this version, in a terminal type
    Code:
    sudo dpkg --install keepassx_0.3.0a-0ubuntu1~ppa1_amd64.deb
    1. On Windows, export your Roboform passwords to html. I used a 2-column layout but I do not believe this has any effect.

    2. Copy and paste the following into a file called KeePassX.py in the same directory as your Roboform html backup:
    Code:
    import re
    
    outputFilename = 'KeePass.xml'
    inputFilename = 'Roboform.html'
    
    def printHeader(out):
      out.write('<!DOCTYPE KEEPASSX_DATABASE>\r\n<database>\r\n<group>\r\n')
    
    def printFooter(out):
      out.write('</group>\r\n</database>\r\n')
    
    def makeOutput(out, desc, un, pw, url, comment):
      out.write('  <entry>\r\n')
      out.write('    <title>' + desc + '</title>\r\n')
      out.write('    <username>' + un + '</username>\r\n')
      out.write('    <password>' + pw + '</password>\r\n')
      out.write('    <url>' + url + '</url>\r\n')
      out.write('    <comment>' + comment + '</comment>\r\n')
      out.write('  </entry>\r\n')
    
    def inVarz(val, varz):
      for var in varz:
        if re.search(val, var[0], re.I) and len(var) > 1 and var[1] != '*':
          return var[1]
      return ''    
    
    def getVars(t):
      varz = []
      regTr = re.compile('<TR>(.*?)</TR>',re.S)
      regTd = re.compile('<TD>(.*?)</TD>',re.S)
      trs = regTr.findall(t)
      for tr in trs:
        tds = regTd.findall(tr)
        # Removes blank entires
        for td in tds:
          if td == '':
            tds.remove(td)
        varz.append(tds)
      return varz
    
    def getUn(varz):
      un = ''
      un = inVarz('username', varz)
      if un == '':
        un = inVarz('uname', varz)
      if un == '':
        un = inVarz('user', varz)
      if un == '':
        un = inVarz('log', varz)
      if un == '':
        un = inVarz('mail', varz)
      if un == '':
        un = inVarz('name', varz)
      if un == '':
        un = inVarz('account', varz)
      if un == '':
        un = inVarz('member', varz)
      if un == '':
        un = inVarz('uid', varz)
      if un == '':
        un = inVarz('nick', varz)
      if un == '':
        un = inVarz('id', varz)
      return un
    
    def getPw(varz):
      pw = ''
      pw = inVarz('pass', varz)
      if pw == '':
        pw = inVarz('pin', varz)
      if pw == '':
        pw = inVarz('key', varz)
      if pw == '':
        pw = inVarz('pw', varz)
      return pw
    
    def getEmail(varz):
      mail = ''
      mail = inVarz('mail', varz)
      return mail
    
    fin = open(inputFilename, "r")
    f = fin.read()
    fin.close()
    
    # Mine was in UTF-16 (?!) so I decided to
    # make a check incase yours was too
    # It should handle UTF-8 by default
    if ord(f[0]) == 255 and ord(f[1]) == 254:
      f = unicode(f, 'utf-16')
    # I wonder what would happen if your file
    # was ascii... Bah, no one would use ascii.
    
    f = f.replace('<WBR>', '')
    f = f.replace('<BR>','')
    f = re.sub('<TR[^>]*?>','<TR>',f)
    f = re.sub('<TD[^>]*?>','<TD>',f)
    
    p = re.compile('<TBODY>.*?</TBODY>',re.S)
    finds = p.findall(f)
    
    out = open(outputFilename, 'w')
    printHeader(out)
    i = 0
    for tbody in finds:
      varz = getVars(tbody)
      desc = varz[0][0]
      if len(desc)> 5 and desc.find('<TD>') != -1: #pmg hax...
        desc = desc[43:]
      url = varz[1][0]
      un = getUn(varz)
      pw = getPw(varz)
      email = getEmail(varz)
      makeOutput(out, desc, un, pw, url, email)
      i = i + 1
    
    printFooter(out)
    out.close()
    print 'Converted ' + str(i) + ' passwords'
    3. Edit the file and set the inputFilename to the html file you exported from Roboform.

    4. In a terminal run
    Code:
    python KeePassX.py
    5. Open KeePassX 0.30 and go to File > Import from > KeePassX XML

    6. Locate the xml file created by the python script and load it into KeePassX.

    Enjoy!
    Last edited by odie5533; April 20th, 2009 at 11:54 AM. Reason: added info for regular KeePass

  2. #2
    Join Date
    Oct 2007
    Beans
    2

    Talking Re: HOWTO: Convert Roboform to KeePassX

    Thank you, thank you, thank you

    Worked like a charm. You have just solved one of my last true frustrations with Linux - absolutely awesome! Thank you for sharing your script

  3. #3
    Join Date
    Sep 2008
    Beans
    12

    Re: HOWTO: Convert Roboform to KeePassX

    Thanx sooo much for this! - I really mean it, this has made transferring my 800+ logons from roboform really easy.


    *** Sharing is Caring ***


    Seriously, major thanx!

    ^_^

  4. #4
    Join Date
    May 2008
    Beans
    3

    Re: HOWTO: Convert Roboform to KeePassX

    Thank you very much, worked like a charm and Roboform was really one of the few programs I actually missed from windows so it's great to have something to replace it Thank you, thank you, thank you

  5. #5
    Join Date
    Jan 2009
    Beans
    1
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: HOWTO: Convert Roboform to KeePassX

    Worked Great! Thank you. I am now able to migrate fully from windows to Ubuntu.

  6. #6
    Join Date
    Mar 2009
    Location
    Ozone Park, NY
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Convert Roboform to KeePassX

    I tried this and terminal says no file name.

    python: can't open file 'KeePassX.py': [Errno 2] No such file or directory
    Last edited by avacomputers; July 16th, 2009 at 04:11 PM.

  7. #7
    Join Date
    Mar 2009
    Location
    Ozone Park, NY
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Convert Roboform to KeePassX

    Quote Originally Posted by avacomputers View Post
    I tried this and terminal says no file name.

    python: can't open file 'KeePassX.py': [Errno 2] No such file or directory
    NOw I get this.

    SyntaxError: invalid syntax
    >>> python KeePassX.py
    File "<stdin>", line 1
    python KeePassX.py
    ^
    SyntaxError: invalid syntax
    >>>

  8. #8
    Join Date
    Sep 2006
    Beans
    3,165
    Distro
    Ubuntu Karmic Koala (testing)

    Re: HOWTO: Convert Roboform to KeePassX

    Tried it on my friend's PC, and works great.Thanks

  9. #9
    Join Date
    Mar 2009
    Location
    Ozone Park, NY
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Convert Roboform to KeePassX

    Quote Originally Posted by binbash View Post
    Tried it on my friend's PC, and works great.Thanks
    That's great, but I followed the instructions exactly and it did not work for me. Any help (other than saying it worked) would be awesome.

  10. #10
    Join Date
    Mar 2009
    Location
    Ozone Park, NY
    Beans
    87
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Convert Roboform to KeePassX

    ANyone? I really need help with this.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •