Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
build/
dist/
__pycache__/
ghunt.egg-info/
ghunt.egg-info/
.opencode/
graphify-out/
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion ghunt/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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"
6 changes: 5 additions & 1 deletion ghunt/helpers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 => ")
Expand Down
21 changes: 21 additions & 0 deletions ghunt/helpers/utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down