Skip to content

Commit

Permalink
browser done(i guess)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugrakocabay committed Jun 2, 2023
1 parent 68b8693 commit cae60f4
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 71 deletions.
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.
20 changes: 10 additions & 10 deletions pkg/browser/chromium.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
121 changes: 61 additions & 60 deletions pkg/browser/firefox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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
}

0 comments on commit cae60f4

Please sign in to comment.