moonD4rk / HackBrowserData

Extract and decrypt browser data, supporting multiple data types, runnable on various operating systems (macOS, Windows, Linux).
MIT License
11.19k stars 1.57k forks source link

feat: refactor firefox get master key retrieval and decryption functions. #300

Closed moonD4rk closed 10 months ago

moonD4rk commented 10 months ago

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