我想知道目前是否有任何方法可以将 lastpass 密码导入 keepass/keepassx?我找到了 lastpass2keepass.py 程序,但它似乎不再起作用了(lastpass 更新了他们的 csv 字段?)。
答案1
嗯,好像没有,所以我编写了一个快速的 php 脚本来完成它。
如果其他人需要这样做。运行此脚本,将导出的 csv 粘贴到文本区域中,然后将输出的 csv 文件输入到 keepass。
<?php
if (isset($_POST["submit"]))
{
//Loop through, build a multi array;
$parsedCSV = array();
//Columns (in order) to parse out.
$ColumnAssociation = array("%%name%%","%%username%%","%%password%%","%%url%%","%%extra%%"); //The xml strings to use for output, replace %%COLUMNNAME%% with COLUMNVALUE
$LastPassHeaders = array();
$inQuotes = false;
$quoteType = '';
$curColumn = 0;
//My epic parser, I know, deal with it (it wasn't meant to be modified)
$first = true;
$curLine = 0;
foreach (explode("\n",$_POST["csvinput"]) as $line)
{
if (empty($line)) //I do this instead of searching for \r\n, because linux just uses \n (I think :/)
continue;
$letters = str_split($line);
//print_r( $letters);
for ($i = 0; $i < count($letters); $i++)
{
/*if ($first) //get lastpass's headers (they are the first row
{
}*/
//Set inQuotes
if (!$inQuotes && $letters[$i] == "'" && ($i - 1 < 0 || $letters[$i - 1] != '\\')) //Not Inquotes, matching singlequote, not prefixed with escape character
{
$inQuotes = true;
$quoteType = "'";
continue;
}
else if (!$inQuotes && $letters[$i] == '"' && ($i - 1 < 0 || $letters[$i - 1] != '\\')) //Not Inquotes, matching doublequote, not prefixed with escape character
{
$inQuotes = true;
$quoteType = '"';
continue;
}
else if ($inQuotes && $letters[$i] == $quoteType && ($i - 1 < 0 || $letters[$i - 1] != '\\')) //Inquotes, is the endquote, and isn't prefixed with an escape character
{
$inQuotes = false;
$quoteType = '';
continue;
}
//Finished with quotes
if (!$inQuotes && $letters[$i] == ',' && ($i - 1 < 0 || $letters[$i - 1] != '\\'))
{
$curColumn++;
continue;
/*if ($curColumn > count($ColumnAssociation))
throw new Exception("TO MANY COLUMNS FTW");*/
}
//Well, because lastpass doesn't incapsulate their stuff, I guess I'll just wing it
if (!$first) //If not headers, parse normally
{
if (!isset($parsedCSV[$curLine][$LastPassHeaders[$curColumn]]))
$parsedCSV[$curLine][$LastPassHeaders[$curColumn]] = "";
$parsedCSV[$curLine][$LastPassHeaders[$curColumn]] .= $letters[$i];
}
else if ($first)
{
if (!isset($LastPassHeaders[$curColumn]))
$LastPassHeaders[$curColumn] = '';
$LastPassHeaders[$curColumn] .= $letters[$i];
}
}
if ($inQuotes)
throw new Exception('Error, Unexpected end of line (Check quotes)');
$curColumn = 0;
if ($first)
$first = false;
else
$curLine++; //Put this here so it only adds to the column number if the current row wasn't the first row (header)
}
//print_r($parsedCSV);
//print_r($LastPassHeaders);
$output = '"Account","Login Name","Password","Web Site","Comments"'."\r\n";
//Alright, now reprint in xml format
foreach ($parsedCSV as $row)
{
//print_r($row);
//Don't output Generated passwords?
if (isset($_POST["rgp"]) && $_POST["rgp"] && stristr($row['name'],'Generated Password for '))
continue;
//$output .= "<pwentry>\r\n";
foreach ($ColumnAssociation as $xmlstring) //first loop through each xml string
{
$nxml = $xmlstring;
foreach ($LastPassHeaders as $name) //then loop through each possible variable in the string
if (isset($row[$name])) //because if a column is empty, it isn't even set in the array
$nxml = str_replace('%%'.$name.'%%',$row[$name],$nxml); //then replace found variables
else
$nxml = str_replace('%%'.$name.'%%','',$nxml); //just because it isn't set, doesn't mean it isn't a real variable, hide it
$output .= '"'.$nxml.'",';
}
$output = substr($output,0,-1); //remove end ,
//$output .= "</pwentry>\r\n";
$output .= "\r\n";
}
header("Content-type:application/csv");
// It will be called lastpass-export.csv
header("Content-Disposition:attachment;filename=lastpass-export.csv");
echo $output;
}
else
{
?>
<html>
<body>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<textarea name="csvinput" cols="100" rows="20"></textarea><BR />
Remove Generated Passwords? <input type="checkbox" name="rgp"/ ><BR/>
<input type="submit" name="submit" value="Generate" />
</form>
Created By Mazzzzz
</body>
</html>
<?php
}
?>
答案2
自 2012 年 12 月 19 日起https://github.com/anirudhjoshi/lastpass2keepass脚本确实有效。
只需将您的 LastPass 数据导出为 CSV 格式,然后通过 python 脚本运行它,然后将其导入 KeePass(我使用了 KeePassX)
答案3
将您的 LastPass 密码导出到 CSV 文件。单击 LastPass 浏览器图标,转到Tools
> Export to
> LastPass CSV file
。
接下来,在 KeePass 中转到File
> Import
> Generic CSV file
。这将导入密码。
答案4
从 KeePassX 2.0.2 开始lastpass2keeppass2014 年 10 月 23 日,不是无法将 XML 或 CSV 导入 KeePassX。
没有这样的按钮(仅kdb
提供导入)。
有任何已知的解决方法吗?
是的,它就是KeePassXC- 删除转换步骤并直接进入 CSV 导入(检查第一行作为字段名称)。