Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to open the database #2

Closed
vaygr opened this issue Apr 17, 2024 · 11 comments
Closed

Unable to open the database #2

vaygr opened this issue Apr 17, 2024 · 11 comments
Assignees

Comments

@vaygr
Copy link

vaygr commented Apr 17, 2024

Hi,

thanks for this tool! I'm having a couple of issues with database opening:

  1. Can not open the database if the database doesn't have a key (only password protection)
  2. Can not open the database if it's encrypted with Twofish
@robertranjan
Copy link
Owner

I don't think, we can update the tool to work without a keyfile as it depends on another module that creates the db and that need both keyfile and password.

Thanks for the issue but I can't help, sorry,

@robertranjan
Copy link
Owner

As per this code block, this tool will return nil and exit.

	if d.Options.Key == "" || d.Options.Database == "" {
		fmt.Printf("%v"+`   --keyfile and --database are required arguments.
	If you are trying, run below commands:
	1. kpcli createdb
	2. kpcli ls`+"%v\nHere is usage:\n%v", colorYellow, colorGreen, colorReset)
		cli.ShowAppHelpAndExit(app, 0)
		return nil
	}

@vaygr
Copy link
Author

vaygr commented Apr 17, 2024

@robertranjan as per example on the main page at https://github.com/tobischo/gokeepasslib I see you can just use gokeepasslib.NewPasswordCredentials() without the key.

@robertranjan
Copy link
Owner

robertranjan commented Apr 18, 2024

@vaygr, thanks for the pointer.
Implemented this feature. Please verify.

@robertranjan
Copy link
Owner

bin/kpcli \
  --database ${KDBX_DATABASE} \
  --pass ${KDBX_PASSWORD} \
  --nokey \
  create

bin/kpcli \
  --database ${KDBX_DATABASE} \
  --pass ${KDBX_PASSWORD} \
  --nokey \
  ls

@vaygr
Copy link
Author

vaygr commented Apr 18, 2024

Thanks! This line prevents ls from running:

https://github.com/robertranjan/kpcli/blob/main/cmd/runner.go#L154

But once I fix it, as I mentioned, there's another issue: it cannot decode Twofish-encrypted database, even though the underlying library supports it:

https://github.com/tobischo/gokeepasslib/blob/master/header.go#L71

Here's the error message I'm getting:

time="2024-04-18T06:57:48-07:00" level=error msg="failed to decode dbfile: db.kdbx err:gzip: invalid header" func="github.com/robertranjan/kpcli/cmd.(*db).Unlock" file="kpcli/cmd/ls.go:28"
failed to unlock dbfile: db.kdbx, err: gzip: invalid header
execution failed with err: gzip: invalid header

@vaygr
Copy link
Author

vaygr commented Apr 18, 2024

Seems Twofish issue is related to the library. I opened tobischo/gokeepasslib#109. So only the line in ls I mentioned above remains.

@robertranjan
Copy link
Owner

@vaygr there were some changes done, please reverify and update if there are any issues. we can close it otherwise.

@robertranjan robertranjan self-assigned this Apr 19, 2024
@vaygr
Copy link
Author

vaygr commented Apr 19, 2024

@robertranjan I see this line is still unchanged: https://github.com/robertranjan/kpcli/blob/main/cmd/cmd.go#L428 so the issue remains.

Also regarding Twofish: it was fixed in the upstream library, could you pull in 3.6.0 that contains the fix?

@robertranjan
Copy link
Owner

upgraded gokeepasslib version to 3.6.

@vaygr
Copy link
Author

vaygr commented Apr 25, 2024

Thank you!

@vaygr vaygr closed this as completed Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants