import from Firefox

vector
KPX user
Posts: 2
Joined: 17 Dec 2009, 03:37

import from Firefox

Postby vector » 17 Dec 2009, 03:53

Sorry if discussed elsewhere, I have searched but there seems to be confusing info.
Firstly my first database went well ..that is until I went to re open it... its telling me the database is either corrupted or key is incorrect.. not happy about that but life goes on lets try again.

Obviously I dont want to type it all back in again so I went looking for a solution to export the firefox passwords so I could import them into freepass.

Im running freepassx 0.4.1 in windows (and will be at home under linux)

I installed the firefox password exporter and exported an xml, so far so good.
Now this is where it gets confusing, keepass 1.x and 2.x and importing the xml

the keepassx dropdown import menu has three options keepass xml, pwrmanager and kwallet. I expected to seea firefox xml?

whats my next step


went thru this
http://lifehacker.com/248702/how-to-imp ... to-keepass
longwinded groovy conversion routine but keepassx would not import. not a valid keepassx file


thanks

vector
KPX user
Posts: 2
Joined: 17 Dec 2009, 03:37

Re: import from Firefox

Postby vector » 17 Dec 2009, 06:06

got around this by cutting n pasting text inside an xml editor to resemble the keepassx format

im sure there is an easier way :cry:

digsim
KPX user
Posts: 1
Joined: 18 Feb 2010, 22:23

Re: import from Firefox

Postby digsim » 18 Feb 2010, 22:30

I hacked to script to work for keepassX. Basically it just creates an adapted xml-strucutre. For the title field i strip:
http://
https://
.com
.org
.ch
www.
Here is the code

Code: Select all

/**
2007 Matias Bjarland - Iteego (mbjarland@yahoo.com)

Groovy script to convert passwords exported from
FireFox into format readable by KeePass password safe

You can change, distribute, modify, trash this file to your hearts
content.

Prerequisites:
  Java 1.5 (J2SE)
                  available at http://java.sun.com/products/archive/index.html
  Groovy Scripting Language
                  available at http://groovy.codehaus.org/
  Password export/import extension to FireFox
                  available at https://addons.mozilla.org/firefox/2848/

Modification History

Date        Who        Bug            Description
______________________________________________________________________________
2007.Jan.19 mbjarland                 Initial Version
2010.Feb.18 digsim                      Adapted to keepassx
**/

import groovy.xml.MarkupBuilder;
import java.util.UUID;

//This is the folder in KeePass where the passwords will be imported to,
//it will be created if it doesn't already exist
def DEFAULT_GROUP = "Firefox Imported";

//need to specify both in- and outfile
if (this.args.length != 2) {
  println("");
  println("Usage: groovy ConvertFirefoxPasswords.groovy <infile> <outfile>");
  println("");
  println("Where: ");
  println("       infile  - XML file exported from firefox using plugin at https://addons.mozilla.org/firefox/2848/");
  println("       outfile - XML file to write to, this file can then be imported in KeePass using ");
  println("                 File -> Import From -> Import Keepass XML   ");
  println("");
  println("");
 
  System.exit(1);
}

//create file objects and check that infile is readable
def inFile = new File(this.args[0]);
def outFile = new File(this.args[1]);
if (!inFile.exists() || !inFile.canRead()) {
  println("Unable to read file '${inFile}'");
  System.exit(1);
}

//Groovy handles reading/writing markup beautifully...
//Walk trough each of the entries in the Firefox export and create KeePass
//format output
def inXml  = new groovy.util.XmlParser().parseText(inFile.getText());
def markup = new groovy.xml.MarkupBuilder(new FileWriter(outFile));
markup.database {
    group{
   title("Internet")
   icon("1")
  inXml.entries.entry.each() { inEntry ->
    entry {
      //group(DEFAULT_GROUP)
      def name = inEntry["@host"].replace('http:/', '');
      name = name.replace('https:/', '');
      name = name.replace('/', '');
      name = name.replace('.com', '');
      name = name.replace('.ch', '');
      name = name.replace('.org', '');
      name = name.replace('www.', '');
      title(name + " | " + inEntry["@user"])
      username(inEntry["@user"])
      password(inEntry["@password"])
      url(inEntry["@host"])
      comment()
      icon("0")
      creation("2010-02-18T21:04:23")
      lastaccess("2010-02-18T21:04:23")
      lastmod("2010-02-18T21:04:23")
      //expire("Jamais")
      //create a random UUID to fake a KeePass UUID...there IS an infinitesimal (yea, that means
      //REALLY small) chance that this fails :). If so, re-run the conversion...
      //uuid(UUID.randomUUID().toString().replace('-', ''))
    }
  }
  }
  group{
   title("eMail")
   icon("19")
  }
}

println("");
println("    --> Converted file saved at: '${outFile.getCanonicalPath()}'");
println("");

System.exit(0);



And the instructions from http://lifehacker.com/248702/how-to-imp ... to-keepass
Save the above code as ConvertFirefoxPasswords.groovy
Export your Firefox passwords to XML using PasswordExporter
Install Groovy
run
groovy ConvertFirefoxPasswords.groovy password-export-2010-02-18 kp.xml

doctorwhite
KPX user
Posts: 1
Joined: 09 Mar 2010, 06:59

Re: import from Firefox

Postby doctorwhite » 09 Mar 2010, 22:50

I've successfully converted the FF XML file using digsim's script but when I import it into keypassx it closes my open DB and prompts me to create a new master key for the imported DB. I want it to import it into the existing DB. Any ideas?


Return to “General Help”

Who is online

Users browsing this forum: No registered users and 1 guest