Skip to content

Conversation

@moonD4rk
Copy link
Owner

@moonD4rk moonD4rk commented Jan 24, 2024

Proposed changes

Process masterkey when init firefox instance

// GetMasterKey returns master key of Firefox. from key4.db
func (f *Firefox) GetMasterKey() ([]byte, error) {
	tempFilename := item.FirefoxKey4.TempFilename()

	// Open and defer close of the database.
	keyDB, err := sql.Open("sqlite", tempFilename)
	if err != nil {
		return nil, fmt.Errorf("open key4.db error: %w", err)
	}
	defer os.Remove(tempFilename)
	defer keyDB.Close()

	globalSalt, metaBytes, err := queryMetaData(keyDB)
	if err != nil {
		return nil, fmt.Errorf("query metadata error: %w", err)
	}

	nssA11, nssA102, err := queryNssPrivate(keyDB)
	if err != nil {
		return nil, fmt.Errorf("query NSS private error: %w", err)
	}

	return processMasterKey(globalSalt, metaBytes, nssA11, nssA102)
}

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit, build tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

…ons.

- Simplify variable names and functions in browsingdata/password/password.go
- Modify Decrypt function for each PBE type to have only one parameter named globalSalt in crypto/crypto.go
- Implement functions to retrieve master key from Firefox's key4.db file and query metadata and private NSS data in browser/firefox/firefox.go
@moonD4rk moonD4rk changed the base branch from main to dev January 24, 2024 08:05
- Add go-sqlmock and github.com/kisielk/sqlstruct dependencies
- Add tests for Firefox package metadata and nssPrivate query
- Add test for Firefox's processMasterKey function (currently commented out)
- Remove unused test function in firefox_test.go file
- Clean up code by removing unnecessary changes
- Simplify file structure for easier maintenance and readability
@moonD4rk moonD4rk merged commit 3633c8c into dev Jan 24, 2024
@moonD4rk moonD4rk deleted the feat/firefox-key branch January 27, 2024 14:31
moonD4rk added a commit that referenced this pull request Jan 27, 2024
…ons. (#300)

* refactor: Simplify Firefox master key retrieval and decryption functions.

- Simplify variable names and functions in browsingdata/password/password.go
- Modify Decrypt function for each PBE type to have only one parameter named globalSalt in crypto/crypto.go
- Implement functions to retrieve master key from Firefox's key4.db file and query metadata and private NSS data in browser/firefox/firefox.go

* chore: Add dependencies and tests to Firefox package.

- Add go-sqlmock and github.com/kisielk/sqlstruct dependencies
- Add tests for Firefox package metadata and nssPrivate query
- Add test for Firefox's processMasterKey function (currently commented out)

* refactor: Refactor Firefox test functions, remove unused code

- Remove unused test function in firefox_test.go file
- Clean up code by removing unnecessary changes
- Simplify file structure for easier maintenance and readability
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

Successfully merging this pull request may close these issues.

2 participants