Skip to content

Commit

Permalink
Improve browserbiometrics setup
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 30, 2023
1 parent 81298aa commit 1383428
Showing 1 changed file with 59 additions and 16 deletions.
75 changes: 59 additions & 16 deletions browserbiometrics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ import (
"github.com/quexten/goldwarden/browserbiometrics/logging"
)

var chromiumPaths = []string{
"~/.config/google-chrome/",
"~/.config/google-chrome-beta/",
"~/.config/google-chrome-unstable/",
"~/.config/chromium/",
"~/.config/BraveSoftware/Brave-Browser/",
"~/.config/thorium/",
"~/.config/microsoft-edge-beta/",
"~/.config/microsoft-edge-dev/",
}
var mozillaPaths = []string{"~/.mozilla/", "~/.librewolf/", "~/.waterfox/"}

const appID = "com.quexten.bw-bio-handler"

var transportKey []byte

func Main(rtCfg *config.RuntimeConfig) {
if os.Args[1] == "install" {
var err error
err = detectAndInstallBrowsers(".config")
if err != nil {
panic("Failed to detect browsers: " + err.Error())
}
err = detectAndInstallBrowsers(".mozilla")
if err != nil {
panic("Failed to detect browsers: " + err.Error())
}
return
}

logging.Debugf("Starting browserbiometrics")
transportKey = generateTransportKey()
logging.Debugf("Generated transport key")
Expand All @@ -38,13 +37,57 @@ func Main(rtCfg *config.RuntimeConfig) {

func DetectAndInstallBrowsers() error {
var err error

// first, ensure the native messaging hosts dirs exist
for _, path := range chromiumPaths {
path = strings.ReplaceAll(path, "~", os.Getenv("HOME"))
_, err = os.Stat(path)
if err != nil {
continue
}

_, err = os.Stat(path + "NativeMessagingHosts/")
if err == nil {
fmt.Println("Native messaging host directory already exists: " + path + "NativeMessagingHosts/")
continue
}
err = os.MkdirAll(path+"NativeMessagingHosts/", 0755)
if err != nil {
fmt.Println("Error creating native messaging host directory: " + err.Error())
} else {
fmt.Println("Created native messaging host directory: " + path + "NativeMessagingHosts/")
}
}
for _, path := range mozillaPaths {
path = strings.ReplaceAll(path, "~", os.Getenv("HOME"))
_, err = os.Stat(path)
if err != nil {
continue
}

_, err = os.Stat(path + "native-messaging-hosts/")
if err == nil {
fmt.Println("Native messaging host directory already exists: " + path + "native-messaging-hosts/")
continue
}
err = os.MkdirAll(path+"native-messaging-hosts/", 0755)
if err != nil {
fmt.Println("Error creating native messaging host directory: " + err.Error())
} else {
fmt.Println("Created native messaging host directory: " + path + "native-messaging-hosts/")
}
}

err = detectAndInstallBrowsers(".config")
if err != nil {
return err
}
err = detectAndInstallBrowsers(".mozilla")
if err != nil {
return err
for _, path := range mozillaPaths {
path = strings.ReplaceAll(path, "~/", "")
err = detectAndInstallBrowsers(path)
if err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 1383428

Please sign in to comment.