public function loadKeePass($userId, $path, $pass)
 {
     $arr = array();
     KeePassPHP::init(true);
     $key = new CompositeKey();
     $key->addKey(new KeyFromPassword(utf8_encode($pass)));
     $kdbx = new KdbxImporter($path, $key);
     $entries = $kdbx->parseEntries();
     foreach ($entries as $entry => $value) {
         //$creationDate;
         //$creationTime;
         list($creationDate, $creationTime) = split($value['CreationTime'] . '[TZ]', 2);
         $array = array("id" => 4, "user_id" => $userId, "loginname" => $value['UserName'], "website" => $value['Title'], "address" => "", "pass" => $kdbx->getPassword($entry), "notes" => $value['Notes'], "creation_date" => $value['CreationTime']);
         array_push($arr, $array);
     }
     return $arr;
 }
예제 #2
0
$pwd = KphpUI::getString("mainPwd", $_POST);
$usePwdForCK = KphpUI::getString("usePwdForCK", $_POST, "0") != "0";
$otherPwd = KphpUI::getString("openPwd1", $_POST);
$ui = new AjaxUI(AjaxUI::FAIL);
if (strlen($dbid) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("dbid");
} elseif (strlen($pwd) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("mainPwd");
} elseif (!$usePwdForCK && strlen($otherPwd) == 0) {
    $ui->setResult(AjaxUI::SOMETHING_EMPTY);
    $ui->setHTML("openPwd1");
} else {
    require_once KEEPASSPHP_LOCATION;
    KeePassPHP::init(KEEPASSPHP_DEBUG);
    if (KeePassPHP::exists($dbid)) {
        $db = KeePassPHP::get($dbid, $pwd, $usePwdForCK ? $pwd : $otherPwd);
        if ($db != null && $db->tryLoad()) {
            require_once "kphpui/htmlformat.php";
            if ($isPwd) {
                $pwd = $db->getPassword($uuid);
                if ($pwd != null) {
                    $ui->setResult(AjaxUI::SUCCESS);
                    $ui->addHTML(HTMLFormat::formatPassword($pwd));
                } else {
                    $ui->setResult(AjaxUI::PASSWORD_NOT_FOUND);
                    $ui->addHTML(HTMLFormat::PASSWORD_NOT_FOUND);
                }
            } else {
                $ui->setResult(AjaxUI::SUCCESS);
예제 #3
0
    }
}
$answer = new AjaxAnswer();
$dbid = KPHPUI::getPost("dbid");
$mainPwd = KPHPUI::getPost("main_pwd");
$usePwdInKey = KPHPUI::getPost("use_pwd_in_key") == "true";
$otherPwd = KPHPUI::getPost("open_other_pwd");
if (empty($dbid)) {
    $answer->set(AjaxAnswer::SOMETHING_EMPTY, "dbid");
} elseif (empty($mainPwd)) {
    $answer->set(AjaxAnswer::SOMETHING_EMPTY, "main_pwd");
} elseif (!$usePwdInKey && empty($otherPwd)) {
    $answer->set(AjaxAnswer::SOMETHING_EMPTY, "open_other_pwd");
} else {
    require_once KEEPASSPHP_LOCATION;
    KeePassPHP::init(dirname(KEEPASSPHP_LOCATION), KEEPASSPHP_DEBUG);
    if (KeePassPHP::exists($dbid)) {
        $db = KeePassPHP::get($dbid, $mainPwd, $usePwdInKey ? $mainPwd : $otherPwd);
        if ($db != null) {
            $uuid = KPHPUI::getPost("uuid");
            if (!empty($uuid)) {
                $pwd = $db->getPassword($uuid);
                if ($pwd != null) {
                    $answer->set(AjaxAnswer::SUCCESS, '<input type="text" class="verysmall selectOnFocus form-control" value="' . KPHPUI::htmlify($pwd) . '" style="font-size:3px !important;"/>');
                } else {
                    $answer->set(AjaxAnswer::PASSWORD_NOT_FOUND, '<span class="label label-danger">' . KPHPUI::l(KPHPUI::LANG_SEE_PWD_DOES_NOT_EXIST) . '</span>');
                }
            } else {
                $s = '<table class="table table-hover form-inline"><thead><tr><th> </th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_TITLE) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_URL) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_USERNAME) . '</th><th>' . KPHPUI::l(KPHPUI::LANG_SEE_ENTRY_PASSWORD) . '</th></tr></thead><tbody>';
                foreach ($db->getEntries() as $uuid => $entry) {
                    $icon = $entry[Database::KEY_CUSTOMICON];