diff --git a/.gitignore b/.gitignore index 167b02d7..47139bcc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ build/ dist/ __pycache__/ -ghunt.egg-info/ \ No newline at end of file +ghunt.egg-info/ +.opencode/ +graphify-out/ \ No newline at end of file diff --git a/README.md b/README.md index 9999ce9d..abd4dbac 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,10 @@ Choice => Then, use GHunt Companion to complete the login. -The extension is available on the following stores :\ -\ -[![Firefox](https://files.catbox.moe/5g2ld5.png)](https://addons.mozilla.org/en-US/firefox/addon/ghunt-companion/)   [![Chrome](https://developer.chrome.com/static/docs/webstore/branding/image/206x58-chrome-web-bcb82d15b2486.png)](https://chrome.google.com/webstore/detail/ghunt-companion/dpdcofblfbmmnikcbmmiakkclocadjab) +The extension is available on Firefox here :\ +[![Firefox](https://files.catbox.moe/5g2ld5.png)](https://addons.mozilla.org/en-US/firefox/addon/ghunt-companion/) + +> The GHunt Companion extension is no longer available on the Chrome Web Store, so the login flow is done with Firefox. ## Modules diff --git a/ghunt/config.py b/ghunt/config.py index 353d8429..eb53d75b 100644 --- a/ghunt/config.py +++ b/ghunt/config.py @@ -26,4 +26,7 @@ # Cookies default_consent_cookie = "YES+cb.20220118-08-p0.fr+FX+510" -default_pref_cookie = "tz=Europe.Paris&f6=40000000&hl=en" # To set the lang settings to english \ No newline at end of file +default_pref_cookie = "tz=Europe.Paris&f6=40000000&hl=en" # To set the lang settings to english + +# Page opened in Firefox when using the Companion login (listening mode) +login_companion_url = "https://accounts.google.com" \ No newline at end of file diff --git a/ghunt/helpers/auth.py b/ghunt/helpers/auth.py index 64c1dc87..f808488b 100644 --- a/ghunt/helpers/auth.py +++ b/ghunt/helpers/auth.py @@ -171,7 +171,7 @@ def auth_dialog() -> Tuple[Dict[str, str], str] : Launch the dialog that asks the user how he want to generate its credentials. """ - choices = ("You can facilitate configuring GHunt by using the GHunt Companion extension on Firefox, Chrome, Edge and Opera here :\n" + choices = ("You can facilitate configuring GHunt by using the GHunt Companion extension on Firefox here :\n" "=> https://github.com/mxrch/ghunt_companion\n\n" "[1] (Companion) Put GHunt on listening mode (currently not compatible with docker)\n" "[2] (Companion) Paste base64-encoded authentication\n" @@ -184,6 +184,10 @@ def auth_dialog() -> Tuple[Dict[str, str], str] : choice = input(choices) if choice in ["1", "2"]: if choice == "1": + if not within_docker(): + print("[+] Opening Firefox to complete the login...") + if not open_browser(gb.config.login_companion_url): + print("[!] Firefox not found, please open a browser manually.") received_data = listener.run() elif choice == "2": received_data = input("Paste the encoded credentials here => ") diff --git a/ghunt/helpers/utils.py b/ghunt/helpers/utils.py index ce03d60b..629bf82d 100644 --- a/ghunt/helpers/utils.py +++ b/ghunt/helpers/utils.py @@ -1,6 +1,10 @@ from pathlib import Path from PIL import Image import hashlib +import os +import shutil +import subprocess +import webbrowser from typing import * from time import time from datetime import datetime, timezone @@ -19,6 +23,23 @@ from ghunt.lib.httpx import AsyncClient +def open_browser(url: str) -> bool: + """ + Opens the given URL in Firefox (the GHunt Companion extension is + only available on Firefox, so Chrome is never used). + + Returns True if Firefox was launched, False otherwise. + """ + browser = os.environ.get("GHUNT_BROWSER") + candidates = [browser] if browser else ["firefox", "firefox-esr"] + for name in candidates: + path = shutil.which(name) + if path: + subprocess.Popen([path, url]) + return True + webbrowser.open(url) + return False + def get_httpx_client() -> httpx.AsyncClient: """ Returns a customized to better support the needs of GHunt CLI users.