mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
refactor: remove dead code and rename V2 files (#541)
* refactor: remove V1 dead code and rename V2 files
- Delete extractor/ package (V1 Extractor interface and registry)
- Delete browserdata/ package (V1 orchestrator, outputter, 9 sub-packages)
- Delete V1 browser implementations (chromium.go, chromium_{platform}.go, firefox.go)
- Delete types/types.go (V1 DataType enum) and utils/byteutil/
- Remove gocsv and go-sqlmock dependencies, demote x/text to indirect
- Upgrade keychainbreaker v0.1.0 → v0.2.5
- Rename chromium_new.go → chromium.go, firefox_new.go → firefox.go
* refactor: remove unused V1 utility functions
Remove functions no longer called by V2 code:
- fileutil: IsDirExists, CopyDir, BrowserName, ReadFile, CopyFile,
Filename, ParentDir, ParentBaseDir, BaseDir
- typeutil: Keys, IntToBool
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
package byteutil
|
||||
|
||||
var OnSplitUTF8Func = func(r rune) rune {
|
||||
if r == 0x00 || r == 0x01 {
|
||||
return -1
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -6,9 +6,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
cp "github.com/otiai10/copy"
|
||||
)
|
||||
|
||||
// IsFileExists checks if the file exists in the provided path
|
||||
@@ -23,72 +20,6 @@ func IsFileExists(filename string) bool {
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
// IsDirExists checks if the folder exists
|
||||
func IsDirExists(folder string) bool {
|
||||
info, err := os.Stat(folder)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return info.IsDir()
|
||||
}
|
||||
|
||||
// ReadFile reads the file from the provided path
|
||||
func ReadFile(filename string) (string, error) {
|
||||
s, err := os.ReadFile(filename)
|
||||
return string(s), err
|
||||
}
|
||||
|
||||
// CopyDir copies the directory from the source to the destination
|
||||
// skip the file if you don't want to copy
|
||||
func CopyDir(src, dst, skip string) error {
|
||||
s := cp.Options{Skip: func(info os.FileInfo, src, dst string) (bool, error) {
|
||||
return strings.HasSuffix(strings.ToLower(src), skip), nil
|
||||
}}
|
||||
return cp.Copy(src, dst, s)
|
||||
}
|
||||
|
||||
// CopyFile copies the file from the source to the destination
|
||||
func CopyFile(src, dst string) error {
|
||||
s, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = os.WriteFile(dst, s, 0o600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Filename returns the filename from the provided path
|
||||
func Filename(browser, dataType, ext string) string {
|
||||
replace := strings.NewReplacer(" ", "_", ".", "_", "-", "_")
|
||||
return strings.ToLower(fmt.Sprintf("%s_%s.%s", replace.Replace(browser), dataType, ext))
|
||||
}
|
||||
|
||||
func BrowserName(browser, user string) string {
|
||||
replace := strings.NewReplacer(" ", "_", ".", "_", "-", "_", "Profile", "user")
|
||||
return strings.ToLower(fmt.Sprintf("%s_%s", replace.Replace(browser), replace.Replace(user)))
|
||||
}
|
||||
|
||||
// ParentDir returns the parent directory of the provided path
|
||||
func ParentDir(p string) string {
|
||||
return filepath.Dir(filepath.Clean(p))
|
||||
}
|
||||
|
||||
// BaseDir returns the base directory of the provided path
|
||||
func BaseDir(p string) string {
|
||||
return filepath.Base(p)
|
||||
}
|
||||
|
||||
// ParentBaseDir returns the parent base directory of the provided path
|
||||
func ParentBaseDir(p string) string {
|
||||
return BaseDir(ParentDir(p))
|
||||
}
|
||||
|
||||
// CompressDir compresses the directory into a zip file
|
||||
func CompressDir(dir string) error {
|
||||
files, err := os.ReadDir(dir)
|
||||
|
||||
@@ -4,30 +4,6 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Keys returns a slice of the keys of the map. based with go 1.18 generics
|
||||
func Keys[K comparable, V any](m map[K]V) []K {
|
||||
r := make([]K, 0, len(m))
|
||||
for k := range m {
|
||||
r = append(r, k)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Signed is a constraint that permits any signed integer type.
|
||||
// If future releases of Go add new predeclared signed integer types,
|
||||
// this constraint will be modified to include them.
|
||||
type Signed interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64
|
||||
}
|
||||
|
||||
func IntToBool[T Signed](a T) bool {
|
||||
switch a {
|
||||
case 0, -1:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func Reverse[T any](s []T) []T {
|
||||
h := make([]T, len(s))
|
||||
for i := 0; i < len(s); i++ {
|
||||
|
||||
Reference in New Issue
Block a user