HackBrowserData/cmd/hack-browser-data/main.go

77 lines
2.5 KiB
Go
Raw Normal View History

2022-04-12 05:48:03 +00:00
package main
import (
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
"log/slog"
2022-04-12 05:48:03 +00:00
"os"
2022-04-12 10:23:02 +00:00
"github.com/urfave/cli/v2"
2023-03-10 06:52:26 +00:00
"github.com/moond4rk/hackbrowserdata/browser"
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
"github.com/moond4rk/hackbrowserdata/logger"
"github.com/moond4rk/hackbrowserdata/utils/fileutil"
2022-04-12 05:48:03 +00:00
)
var (
2022-04-14 15:36:11 +00:00
browserName string
outputDir string
outputFormat string
verbose bool
compress bool
profilePath string
2023-03-11 09:51:40 +00:00
isFullExport bool
2022-04-12 05:48:03 +00:00
)
func main() {
Execute()
}
func Execute() {
2022-04-12 10:23:02 +00:00
app := &cli.App{
2022-04-14 15:36:11 +00:00
Name: "hack-browser-data",
2023-07-27 13:08:07 +00:00
Usage: "Export passwords|bookmarks|cookies|history|credit cards|download history|localStorage|extensions from browser",
UsageText: "[hack-browser-data -b chrome -f json -dir results --zip]\nExport all browsing data (passwords/cookies/history/bookmarks) from browser\nGithub Link: https://github.com/moonD4rk/HackBrowserData",
Version: "0.4.5",
2022-04-12 10:23:02 +00:00
Flags: []cli.Flag{
&cli.BoolFlag{Name: "verbose", Aliases: []string{"vv"}, Destination: &verbose, Value: false, Usage: "verbose"},
&cli.BoolFlag{Name: "compress", Aliases: []string{"zip"}, Destination: &compress, Value: false, Usage: "compress result to zip"},
2023-03-10 06:52:26 +00:00
&cli.StringFlag{Name: "browser", Aliases: []string{"b"}, Destination: &browserName, Value: "all", Usage: "available browsers: all|" + browser.Names()},
2022-04-14 15:36:11 +00:00
&cli.StringFlag{Name: "results-dir", Aliases: []string{"dir"}, Destination: &outputDir, Value: "results", Usage: "export dir"},
2023-07-27 13:08:07 +00:00
&cli.StringFlag{Name: "format", Aliases: []string{"f"}, Destination: &outputFormat, Value: "csv", Usage: "output format: csv|json"},
2022-04-15 19:57:19 +00:00
&cli.StringFlag{Name: "profile-path", Aliases: []string{"p"}, Destination: &profilePath, Value: "", Usage: "custom profile dir path, get with chrome://version"},
2023-03-11 09:51:40 +00:00
&cli.BoolFlag{Name: "full-export", Aliases: []string{"full"}, Destination: &isFullExport, Value: true, Usage: "is export full browsing data"},
2022-04-12 10:23:02 +00:00
},
HideHelpCommand: true,
Action: func(c *cli.Context) error {
if verbose {
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
logger.Default.SetVerbose()
logger.Configure(logger.Default)
2022-04-12 10:23:02 +00:00
}
2023-03-10 06:52:26 +00:00
browsers, err := browser.PickBrowsers(browserName, profilePath)
2022-04-12 05:48:03 +00:00
if err != nil {
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
slog.Error("pick browsers error", "err", err)
2022-04-12 05:48:03 +00:00
}
2022-04-12 10:23:02 +00:00
for _, b := range browsers {
2023-03-11 09:51:40 +00:00
data, err := b.BrowsingData(isFullExport)
2022-04-12 10:23:02 +00:00
if err != nil {
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
slog.Error("get browsing data error", "err", err)
continue
2022-04-12 10:23:02 +00:00
}
data.Output(outputDir, b.Name(), outputFormat)
2022-04-12 10:23:02 +00:00
}
2023-03-11 09:51:40 +00:00
2022-04-12 10:23:02 +00:00
if compress {
2022-04-17 16:47:39 +00:00
if err = fileutil.CompressDir(outputDir); err != nil {
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
slog.Error("compress error: ", "err", err)
2022-04-12 10:23:02 +00:00
}
feat: refactor logger to standard library (#280) * refactor: Refactor logging to use structured slog package. - Remove `gookit` dependencies from `go.sum` - Improve error logging in multiple packages by replacing `log` with `log/slog` - Update dependencies in `go.mod` - Add new `logger` package with test cases - Refactor logging statements in multiple packages to use `slog` instead of `log` - Change logging format and level in multiple packages for better structured logging * refactor: Refactor logger package and add handler interface - Refactor logger package - Rename `defaultHandler` to `DefaultLogger` - Move `ReplaceAttr` function to `Logger` struct - Implement `LogHandler` struct with `slog.Handler` interface - Add new `Logger` methods for configuration - Add `SetMaxLevel`, `SetJSONHandler`, `SetTextHandler`, `SetOutput`, `SetVerbose`, `SetReplaceAttrFunc` - Add verbose flag to `cmd/hack-browser-data/main.go` to increase logging * refactor: Refactor logger package to use simplified handler initialization. - Refactor logger package to use Default instead of DefaultLogger - Update `NewHandler` method to correctly reference `Default` logger and simplify handler initialization - Update tests for logger to reflect changes in Default usage - Rename `DefaultLogger` to `Default` and update comments to better reflect its purpose - Update function calls in hack-browser-data main.go to reflect logger package updates * refactor: Refactor logging in Chromium implementation Refactor logging and simplify decryption in chromium files - Replace logger package import with shared slog package - Change logging messages to use slog instead of logger - Simplify decryption process by removing first 5 characters of encrypted key - Refactor error logging in linux file to use shared slog package - Replace string concatenation with formatted string in linux error message
2024-01-16 06:06:13 +00:00
slog.Info("compress success")
2022-04-12 10:23:02 +00:00
}
return nil
},
}
err := app.Run(os.Args)
if err != nil {
2022-10-30 04:58:35 +00:00
panic(err)
2022-04-12 05:48:03 +00:00
}
}