mirror of
https://github.com/mxrch/GHunt.git
synced 2025-12-22 13:47:07 +00:00
use distinct exit codes for intentional exits
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
@@ -8,7 +10,8 @@ from ghunt.helpers.gmail import is_email_registered
|
|||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
if not sys.argv[1:]:
|
if not sys.argv[1:]:
|
||||||
exit("Please give an email address.")
|
print("Please give an email address.")
|
||||||
|
exit(os.EX_IOERR)
|
||||||
|
|
||||||
as_client = httpx.AsyncClient() # Async Client
|
as_client = httpx.AsyncClient() # Async Client
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@@ -6,7 +7,7 @@ def main():
|
|||||||
if (version < (3, 10)):
|
if (version < (3, 10)):
|
||||||
print('[-] GHunt only works with Python 3.10+.')
|
print('[-] GHunt only works with Python 3.10+.')
|
||||||
print(f'Your current Python version : {version.major}.{version.minor}.{version.micro}')
|
print(f'Your current Python version : {version.major}.{version.minor}.{version.micro}')
|
||||||
sys.exit(1)
|
sys.exit(os.EX_SOFTWARE)
|
||||||
|
|
||||||
from ghunt.cli import parse_and_run
|
from ghunt.cli import parse_and_run
|
||||||
from ghunt.helpers.banner import show_banner
|
from ghunt.helpers.banner import show_banner
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
import os
|
||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
@@ -195,7 +196,8 @@ def auth_dialog() -> Tuple[Dict[str, str], str] :
|
|||||||
master_token = input(f"Master token => ").strip('" ')
|
master_token = input(f"Master token => ").strip('" ')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exit("Please choose a valid choice. Exiting...")
|
print("Please choose a valid choice. Exiting...")
|
||||||
|
exit(os.EX_IOERR)
|
||||||
|
|
||||||
return oauth_token, master_token
|
return oauth_token, master_token
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from ghunt import globals as gb
|
from ghunt import globals as gb
|
||||||
from ghunt.apis.vision import VisionHttp
|
from ghunt.apis.vision import VisionHttp
|
||||||
|
|
||||||
@@ -20,7 +22,8 @@ async def detect_face(vision_api: VisionHttp, as_client: httpx.AsyncClient, imag
|
|||||||
break
|
break
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
else:
|
else:
|
||||||
exit("\n[-] Vision API keeps rate-limiting.")
|
print("\n[-] Vision API keeps rate-limiting.")
|
||||||
|
exit(os.EX_UNAVAILABLE)
|
||||||
|
|
||||||
if are_faces_found:
|
if are_faces_found:
|
||||||
if len(faces_results.face_annotations) > 1:
|
if len(faces_results.face_annotations) > 1:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
@@ -45,7 +46,8 @@ def run(server_class=HTTPServer, handler_class=Server, port=60067):
|
|||||||
break
|
break
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit("[-] Exiting...")
|
print("[-] Exiting...")
|
||||||
|
exit(os.CLD_KILLED)
|
||||||
else:
|
else:
|
||||||
if handler_class.data_bridge.data:
|
if handler_class.data_bridge.data:
|
||||||
print("[+] Received cookies !")
|
print("[+] Received cookies !")
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from ghunt.helpers.utils import *
|
from ghunt.helpers.utils import *
|
||||||
from ghunt.objects.base import DriveExtractedUser, GHuntCreds
|
from ghunt.objects.base import DriveExtractedUser, GHuntCreds
|
||||||
from ghunt.apis.drive import DriveHttp
|
from ghunt.apis.drive import DriveHttp
|
||||||
@@ -38,7 +40,8 @@ async def hunt(as_client: httpx.AsyncClient, file_id: str, json_file: bool=Path)
|
|||||||
drive = DriveHttp(ghunt_creds)
|
drive = DriveHttp(ghunt_creds)
|
||||||
file_found, file = await drive.get_file(as_client, file_id)
|
file_found, file = await drive.get_file(as_client, file_id)
|
||||||
if not file_found:
|
if not file_found:
|
||||||
exit("[-] The file wasn't found.")
|
print("[-] The file wasn't found.")
|
||||||
|
exit(os.EX_IOERR)
|
||||||
|
|
||||||
is_folder = file.mime_type == "application/vnd.google-apps.folder"
|
is_folder = file.mime_type == "application/vnd.google-apps.folder"
|
||||||
file_type = drive_knownledge.mime_types.get(file.mime_type)
|
file_type = drive_knownledge.mime_types.get(file.mime_type)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from ghunt import globals as gb
|
from ghunt import globals as gb
|
||||||
from ghunt.helpers.utils import get_httpx_client
|
from ghunt.helpers.utils import get_httpx_client
|
||||||
from ghunt.objects.base import GHuntCreds
|
from ghunt.objects.base import GHuntCreds
|
||||||
@@ -24,7 +26,8 @@ async def hunt(as_client: httpx.AsyncClient, email_address: str, json_file: Path
|
|||||||
# vision_api = VisionHttp(ghunt_creds)
|
# vision_api = VisionHttp(ghunt_creds)
|
||||||
is_found, target = await people_pa.people_lookup(as_client, email_address, params_template="max_details")
|
is_found, target = await people_pa.people_lookup(as_client, email_address, params_template="max_details")
|
||||||
if not is_found:
|
if not is_found:
|
||||||
exit("[-] The target wasn't found.")
|
print("[-] The target wasn't found.")
|
||||||
|
exit(os.EX_DATAERR)
|
||||||
|
|
||||||
if json_file:
|
if json_file:
|
||||||
json_results = {}
|
json_results = {}
|
||||||
@@ -37,7 +40,8 @@ async def hunt(as_client: httpx.AsyncClient, email_address: str, json_file: Path
|
|||||||
print(f"- {container.title()}")
|
print(f"- {container.title()}")
|
||||||
|
|
||||||
if not "PROFILE" in containers:
|
if not "PROFILE" in containers:
|
||||||
exit("[-] Given information does not match a public Google Account.")
|
print("[-] Given information does not match a public Google Account.")
|
||||||
|
exit(os.EX_DATAERR)
|
||||||
|
|
||||||
container = "PROFILE"
|
container = "PROFILE"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from ghunt import globals as gb
|
from ghunt import globals as gb
|
||||||
from ghunt.objects.base import GHuntCreds
|
from ghunt.objects.base import GHuntCreds
|
||||||
from ghunt.apis.peoplepa import PeoplePaHttp
|
from ghunt.apis.peoplepa import PeoplePaHttp
|
||||||
@@ -24,7 +26,8 @@ async def hunt(as_client: httpx.AsyncClient, gaia_id: str, json_file: Path=None)
|
|||||||
# vision_api = VisionHttp(ghunt_creds)
|
# vision_api = VisionHttp(ghunt_creds)
|
||||||
is_found, target = await people_pa.people(as_client, gaia_id, params_template="max_details")
|
is_found, target = await people_pa.people(as_client, gaia_id, params_template="max_details")
|
||||||
if not is_found:
|
if not is_found:
|
||||||
exit("[-] The target wasn't found.")
|
print("[-] The target wasn't found.")
|
||||||
|
exit(os.EX_DATAERR)
|
||||||
|
|
||||||
if json_file:
|
if json_file:
|
||||||
json_results = {}
|
json_results = {}
|
||||||
@@ -37,7 +40,8 @@ async def hunt(as_client: httpx.AsyncClient, gaia_id: str, json_file: Path=None)
|
|||||||
print(f"- {container.title()}")
|
print(f"- {container.title()}")
|
||||||
|
|
||||||
if not "PROFILE" in containers:
|
if not "PROFILE" in containers:
|
||||||
exit("[-] Given information does not match a public Google Account.")
|
print("[-] Given information does not match a public Google Account.")
|
||||||
|
exit(os.EX_DATAERR)
|
||||||
|
|
||||||
container = "PROFILE"
|
container = "PROFILE"
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
from ghunt import globals as gb
|
from ghunt import globals as gb
|
||||||
from ghunt.helpers.utils import get_httpx_client
|
from ghunt.helpers.utils import get_httpx_client
|
||||||
from ghunt.apis.geolocation import GeolocationHttp
|
from ghunt.apis.geolocation import GeolocationHttp
|
||||||
@@ -16,12 +18,14 @@ async def main(as_client: httpx.AsyncClient, bssid: str, input_file: Path, json_
|
|||||||
body = None
|
body = None
|
||||||
if input_file:
|
if input_file:
|
||||||
if not input_file.exists():
|
if not input_file.exists():
|
||||||
exit(f"[-] The input file \"{input_file}\" doesn't exist.")
|
print(f"[-] The input file \"{input_file}\" doesn't exist.")
|
||||||
|
exit(os.EX_IOERR)
|
||||||
with open(input_file, "r", encoding="utf-8") as f:
|
with open(input_file, "r", encoding="utf-8") as f:
|
||||||
try:
|
try:
|
||||||
body = json.load(f)
|
body = json.load(f)
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
exit("[-] The input file is not a valid JSON file.")
|
print(f"[-] The input file \"{input_file}\" is not a valid JSON file.")
|
||||||
|
exit(os.EX_IOERR)
|
||||||
|
|
||||||
if not as_client:
|
if not as_client:
|
||||||
as_client = get_httpx_client()
|
as_client = get_httpx_client()
|
||||||
@@ -31,7 +35,8 @@ async def main(as_client: httpx.AsyncClient, bssid: str, input_file: Path, json_
|
|||||||
geo_api = GeolocationHttp(ghunt_creds)
|
geo_api = GeolocationHttp(ghunt_creds)
|
||||||
found, resp = await geo_api.geolocate(as_client, bssid=bssid, body=body)
|
found, resp = await geo_api.geolocate(as_client, bssid=bssid, body=body)
|
||||||
if not found:
|
if not found:
|
||||||
exit("[-] The location wasn't found.")
|
print("[-] The location wasn't found.")
|
||||||
|
exit(os.EX_DATAERR)
|
||||||
|
|
||||||
geolocator = Nominatim(user_agent="nominatim")
|
geolocator = Nominatim(user_agent="nominatim")
|
||||||
location = geolocator.reverse(f"{resp.location.latitude}, {resp.location.longitude}", timeout=10)
|
location = geolocator.reverse(f"{resp.location.latitude}, {resp.location.longitude}", timeout=10)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from typing import *
|
from typing import *
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
@@ -22,7 +23,7 @@ async def check_and_login(as_client: httpx.AsyncClient, clean: bool=False) -> No
|
|||||||
print(f"[+] Credentials file at {creds_path} deleted !")
|
print(f"[+] Credentials file at {creds_path} deleted !")
|
||||||
else:
|
else:
|
||||||
print(f"Credentials file at {creds_path} doesn't exists, no need to delete.")
|
print(f"Credentials file at {creds_path} doesn't exists, no need to delete.")
|
||||||
exit()
|
exit(os.EX_OK)
|
||||||
|
|
||||||
if not as_client:
|
if not as_client:
|
||||||
as_client = get_httpx_client()
|
as_client = get_httpx_client()
|
||||||
@@ -59,7 +60,7 @@ async def check_and_login(as_client: httpx.AsyncClient, clean: bool=False) -> No
|
|||||||
if new_gen_inp == "y":
|
if new_gen_inp == "y":
|
||||||
oauth_token, master_token = auth.auth_dialog()
|
oauth_token, master_token = auth.auth_dialog()
|
||||||
else:
|
else:
|
||||||
exit()
|
exit(os.EX_OK)
|
||||||
|
|
||||||
ghunt_creds.android.authorization_tokens = {} # Reset the authorization tokens
|
ghunt_creds.android.authorization_tokens = {} # Reset the authorization tokens
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user