Comments (2)
Hello, I would like to take a stab at this.
I'd like to propose using a single map and a key of the folder.
First, we modify the original "walk" function to get rid of the if
statements which cause obscurity. This eliminates one map and established a directory of composite keys, which are much faster to look up than re-traversing.
func chromiumWalkFunc(items []item.Item, itemPaths map[string]map[item.Item]string) filepath.WalkFunc {
return func(path string, info fs.FileInfo, err error) error {
if !isValidItem(path, info, items) {
return nil
}
profileFolder := fileutil.ParentBaseDir(path)
if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") {
profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", ""))
}
for _, v := range items {
if info.Name() == v.Filename() {
itemPaths[composeKey(profileFolder, v)] = path
break
}
}
return nil
}
}
func composeKey(profileFolder string, item item.Item) string {
return fmt.Sprintf("%s|%s", profileFolder, item.Filename())
}
We then write up a function to test if the item is what we're looking for:
func isValidItem(path string, info fs.FileInfo, items []item.Item) bool {
if info.IsDir() || strings.Contains(path, "System Profile") {
return false
}
for _, v := range items {
if info.Name() == v.Filename() {
return true
}
}
return false
}
I have not bench marked this yet but present it here as a possible alternative to your original idea.
from hackbrowserdata.
Thanks for your suggestion @rowingdude, The following structure is defined in the new version. Use the KeyFile of Chromium to determine the location of RootPath
.
There are still some bugs that need to be fixed. I will submit the code in the next few days and look forward to your review at that time.
type BrowserProfile struct {
// Name name like 'Default', 'BrowserProfile 1', etc.
Name string
// Path to the master key file (e.g., 'Local State', 'key4.db',
KeyPath string
// MasterKey is the key used to decrypt the browser data.
MasterKey []byte
// Map of data types to file paths
DataFiles map[types.DataType][]string
}
func (bd *BrowserData) findChromiumProfiles(rootPath string, dataTypes []types.DataType) (map[string]*BrowserProfile, error) {
profiles := make(map[string]*BrowserProfile)
var sharedKeyPath string
err := filepath.WalkDir(rootPath, func(path string, entry fs.DirEntry, err error) error {
if err != nil {
return err
}
normalizedPath := filepath.ToSlash(path)
// Skip directories that should not be included
if entry.IsDir() && skipDirs(normalizedPath, defaultExcludeDirs) {
return fs.SkipDir
}
for _, dataType := range dataTypes {
if entry.Name() != dataType.Filename() {
continue
}
// Calculate relative path from Chrome baseDir path
profileName := extractProfileNameFromPath(rootPath, path)
// handle shard key
if profileName == "" && dataType == types.ChromiumKey {
sharedKeyPath = path
}
if profileName == "" {
continue
}
if _, exists := profiles[profileName]; !exists {
profiles[profileName] = newProfile(profileName)
profiles[profileName].DataFiles[dataType] = []string{path}
} else {
profiles[profileName].DataFiles[dataType] = append(profiles[profileName].DataFiles[dataType], path)
}
}
return nil
})
// Assign the shared key path to all profileNames
for _, profile := range profiles {
profile.KeyPath = sharedKeyPath
}
return profiles, err
}
from hackbrowserdata.
Related Issues (20)
- Feature Request: Reduce the size of binary files and remove the net module.
- Feature Request: Add more golangcilint linters
- Feature Request: Add github actions for typo check linter
- [BUG] Unable to export Chrome passwords in macOS Time Machine backup. HOT 7
- Feature Request: Optimize the templates for bug reports and feature requests to support yml.
- Feature Request: Provide multiple drivers for sqlite3, controlled through golang compilation options. HOT 1
- Feature Request: Add error handling when entering the system password incorrectly on macOS.
- Feature Request: Increase unit testing for folders walk.
- Feature Request: Handle the Firefox masterkey in the same way as initializing chromium. HOT 1
- Feature Request: Add encryption and testcase for crypto
- Feature Request: Increase the running speed of Github Actions runner.
- Bug: When failing to obtain the chromium masterkey, it is not possible to export unencrypted data.
- Feature Request: Provide the function to obtain system information or browser information.
- Older operating systems! HOT 1
- Feature Request: make exported Chrome passwords can be imported into other browsers
- Feature Request: Add autofill data
- Accessing Chrome Data On Mac Without Having to Enter Password HOT 1
- Feature Request: Add dependent bot interval check for CI/CD
- Feature Request: Format output data file struct, access a backup of a different browser
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hackbrowserdata.