Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/modules/gaia.py
252 views
1
import os
2
3
from ghunt import globals as gb
4
from ghunt.objects.base import GHuntCreds
5
from ghunt.apis.peoplepa import PeoplePaHttp
6
from ghunt.apis.vision import VisionHttp
7
from ghunt.helpers import gmaps, auth, ia
8
from ghunt.helpers.knowledge import get_user_type_definition
9
from ghunt.helpers.utils import get_httpx_client
10
11
import httpx
12
13
from typing import *
14
from pathlib import Path
15
16
17
async def hunt(as_client: httpx.AsyncClient, gaia_id: str, json_file: Path=None):
18
if not as_client:
19
as_client = get_httpx_client()
20
21
ghunt_creds = await auth.load_and_auth(as_client)
22
23
#gb.rc.print("\n[+] Target found !", style="spring_green3")
24
25
people_pa = PeoplePaHttp(ghunt_creds)
26
# vision_api = VisionHttp(ghunt_creds)
27
is_found, target = await people_pa.people(as_client, gaia_id, params_template="max_details")
28
if not is_found:
29
print("[-] The target wasn't found.")
30
exit(os.EX_DATAERR)
31
32
if json_file:
33
json_results = {}
34
35
containers = target.sourceIds
36
37
if len(containers) > 1 or not "PROFILE" in containers:
38
print("[!] You have this person in these containers :")
39
for container in containers:
40
print(f"- {container.title()}")
41
42
if not "PROFILE" in containers:
43
print("[-] Given information does not match a public Google Account.")
44
exit(os.EX_DATAERR)
45
46
container = "PROFILE"
47
48
gb.rc.print("🙋 Google Account data\n", style="plum2")
49
50
# if container in target.names:
51
# print(f"Name : {target.names[container].fullname}\n")
52
53
if container in target.profilePhotos:
54
if target.profilePhotos[container].isDefault:
55
print("[-] Default profile picture")
56
else:
57
print("[+] Custom profile picture !")
58
print(f"=> {target.profilePhotos[container].url}")
59
60
# await ia.detect_face(vision_api, as_client, target.profilePhotos[container].url)
61
print()
62
63
if container in target.coverPhotos:
64
if target.coverPhotos[container].isDefault:
65
print("[-] Default cover picture\n")
66
else:
67
print("[+] Custom cover picture !")
68
print(f"=> {target.coverPhotos[container].url}")
69
70
# await ia.detect_face(vision_api, as_client, target.coverPhotos[container].url)
71
print()
72
73
print(f"Last profile edit : {target.sourceIds[container].lastUpdated.strftime('%Y/%m/%d %H:%M:%S (UTC)')}\n")
74
75
print(f"Gaia ID : {target.personId}\n")
76
77
if container in target.profileInfos:
78
print("User types :")
79
for user_type in target.profileInfos[container].userTypes:
80
definition = get_user_type_definition(user_type)
81
gb.rc.print(f"- {user_type} [italic]({definition})[/italic]")
82
83
gb.rc.print(f"\n📞 Google Chat Extended Data\n", style="light_salmon3")
84
85
#print(f"Presence : {target.extendedData.dynamiteData.presence}")
86
print(f"Entity Type : {target.extendedData.dynamiteData.entityType}")
87
#print(f"DND State : {target.extendedData.dynamiteData.dndState}")
88
gb.rc.print(f"Customer ID : {x if (x := target.extendedData.dynamiteData.customerId) else '[italic]Not found.[/italic]'}")
89
90
gb.rc.print(f"\n🌐 Google Plus Extended Data\n", style="cyan")
91
92
print(f"Entreprise User : {target.extendedData.gplusData.isEntrepriseUser}")
93
#print(f"Content Restriction : {target.extendedData.gplusData.contentRestriction}")
94
95
if container in target.inAppReachability:
96
print("\n[+] Activated Google services :")
97
for app in target.inAppReachability[container].apps:
98
print(f"- {app}")
99
100
gb.rc.print("\n🗺️ Maps data", style="green4")
101
102
err, stats, reviews, photos = await gmaps.get_reviews(as_client, target.personId)
103
gmaps.output(err, stats, reviews, photos, target.personId)
104
105
if json_file:
106
if container == "PROFILE":
107
json_results[f"{container}_CONTAINER"] = {
108
"profile": target,
109
"maps": {
110
"photos": photos,
111
"reviews": reviews,
112
"stats": stats
113
}
114
}
115
else:
116
json_results[f"{container}_CONTAINER"] = {
117
"profile": target
118
}
119
120
if json_file:
121
import json
122
from ghunt.objects.encoders import GHuntEncoder;
123
with open(json_file, "w", encoding="utf-8") as f:
124
f.write(json.dumps(json_results, cls=GHuntEncoder, indent=4))
125
gb.rc.print(f"\n[+] JSON output wrote to {json_file} !", style="italic")
126
127
await as_client.aclose()
128