Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mxrch
GitHub Repository: mxrch/GHunt
Path: blob/master/ghunt/modules/email.py
252 views
1
import os
2
3
from ghunt import globals as gb
4
from ghunt.helpers.utils import get_httpx_client
5
from ghunt.objects.base import GHuntCreds
6
from ghunt.apis.peoplepa import PeoplePaHttp
7
from ghunt.apis.vision import VisionHttp
8
from ghunt.helpers import gmaps, playgames, auth, calendar as gcalendar, ia
9
from ghunt.helpers.knowledge import get_user_type_definition
10
11
import httpx
12
13
from typing import *
14
from pathlib import Path
15
16
17
async def hunt(as_client: httpx.AsyncClient, email_address: 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("[+] Target found !", style="sea_green3")
24
25
people_pa = PeoplePaHttp(ghunt_creds)
26
# vision_api = VisionHttp(ghunt_creds)
27
is_found, target = await people_pa.people_lookup(as_client, email_address, 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
if target.sourceIds[container].lastUpdated:
74
print(f"Last profile edit : {target.sourceIds[container].lastUpdated.strftime('%Y/%m/%d %H:%M:%S (UTC)')}\n")
75
else:
76
gb.rc.print(f"Last profile edit : [italic]Not found.[/italic]\n")
77
78
if container in target.emails:
79
print(f"Email : {target.emails[container].value}")
80
else:
81
print(f"Email : {email_address}\n")
82
83
print(f"Gaia ID : {target.personId}")
84
85
if container in target.profileInfos:
86
print("\nUser types :")
87
for user_type in target.profileInfos[container].userTypes:
88
definition = get_user_type_definition(user_type)
89
gb.rc.print(f"- {user_type} [italic]({definition})[/italic]")
90
91
gb.rc.print(f"\nšŸ“ž Google Chat Extended Data\n", style="light_salmon3")
92
93
#print(f"Presence : {target.extendedData.dynamiteData.presence}")
94
print(f"Entity Type : {target.extendedData.dynamiteData.entityType}")
95
#print(f"DND State : {target.extendedData.dynamiteData.dndState}")
96
gb.rc.print(f"Customer ID : {x if (x := target.extendedData.dynamiteData.customerId) else '[italic]Not found.[/italic]'}")
97
98
gb.rc.print(f"\n🌐 Google Plus Extended Data\n", style="cyan")
99
100
print(f"Entreprise User : {target.extendedData.gplusData.isEntrepriseUser}")
101
#print(f"Content Restriction : {target.extendedData.gplusData.contentRestriction}")
102
103
if container in target.inAppReachability:
104
print("\n[+] Activated Google services :")
105
for app in target.inAppReachability[container].apps:
106
print(f"- {app}")
107
108
gb.rc.print("\nšŸŽ® Play Games data", style="deep_pink2")
109
110
player_results = await playgames.search_player(ghunt_creds, as_client, email_address)
111
if player_results:
112
player_candidate = player_results[0]
113
print("\n[+] Found player profile !")
114
print(f"\nUsername : {player_candidate.name}")
115
print(f"Player ID : {player_candidate.id}")
116
print(f"Avatar : {player_candidate.avatar_url}")
117
_, player = await playgames.get_player(ghunt_creds, as_client, player_candidate.id)
118
playgames.output(player)
119
else:
120
print("\n[-] No player profile found.")
121
122
gb.rc.print("\nšŸ—ŗļø Maps data", style="green4")
123
124
err, stats, reviews, photos = await gmaps.get_reviews(as_client, target.personId)
125
gmaps.output(err, stats, reviews, photos, target.personId)
126
127
gb.rc.print("\nšŸ—“ļø Calendar data\n", style="slate_blue3")
128
129
cal_found, calendar, calendar_events = await gcalendar.fetch_all(ghunt_creds, as_client, email_address)
130
131
if cal_found:
132
print("[+] Public Google Calendar found !\n")
133
if calendar_events.items:
134
if "PROFILE" in target.names:
135
gcalendar.out(calendar, calendar_events, email_address, target.names[container].fullname)
136
else:
137
gcalendar.out(calendar, calendar_events, email_address)
138
else:
139
print("=> No recent events found.")
140
else:
141
print("[-] No public Google Calendar.")
142
143
if json_file:
144
if container == "PROFILE":
145
json_results[f"{container}_CONTAINER"] = {
146
"profile": target,
147
"play_games": player if player_results else None,
148
"maps": {
149
"photos": photos,
150
"reviews": reviews,
151
"stats": stats
152
},
153
"calendar": {
154
"details": calendar,
155
"events": calendar_events
156
} if cal_found else None
157
}
158
else:
159
json_results[f"{container}_CONTAINER"] = {
160
"profile": target
161
}
162
163
if json_file:
164
import json
165
from ghunt.objects.encoders import GHuntEncoder;
166
with open(json_file, "w", encoding="utf-8") as f:
167
f.write(json.dumps(json_results, cls=GHuntEncoder, indent=4))
168
gb.rc.print(f"\n[+] JSON output wrote to {json_file} !", style="italic")
169
170
await as_client.aclose()
171
172