-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathTokIntel.py
More file actions
342 lines (271 loc) Β· 10.1 KB
/
Copy pathTokIntel.py
File metadata and controls
342 lines (271 loc) Β· 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
import requests
import argparse
import json
import time
import os
import random
import string
from dotenv import load_dotenv
from datetime import datetime, UTC
from colorama import Fore, init, Style
init(autoreset=True)
# ==============================
# CONFIG
# ==============================
RETRIES = 3
TIMEOUT = 10
DELAY = 1
# ==============================
# BANNER
# ==============================
def print_banner():
cyan = Fore.CYAN
magenta = Fore.MAGENTA
white = Fore.WHITE
bright = Style.BRIGHT
banner = f"""
{cyan}βββββββββββββββ
{magenta}βββββββββββββββ
{cyan}βββββββββββββββ
{magenta}βββββββββββββββ
{cyan}βββββββββββββββ
{magenta}βββββββββββββββ
{cyan}βββββββββββββββ
{magenta}βββββββββββββββ
{white}{bright}TokIntel - TikTok OSINT Framework
{white}{bright}by Hack Underway π
"""
print(banner)
# ==============================
# SETUP API
# ==============================
def setup_api_key():
print(Fore.YELLOW + "π Initial configuration required\n")
api_key = input("π Enter your RapidAPI Key: ").strip()
with open(".env", "w") as f:
f.write(f"RAPIDAPI_KEY={api_key}\n")
print(Fore.GREEN + "β
API Key saved in .env\n")
return api_key
# ==============================
# LOAD ENV
# ==============================
load_dotenv()
API_KEY = os.getenv("RAPIDAPI_KEY")
# ==============================
# API CLASS
# ==============================
class TikTokChecker:
def __init__(self, api_key):
self.url = "https://tiktok-email-phone-lookup.p.rapidapi.com/api/v1/tiktok-checker/"
self.headers = {
"x-rapidapi-key": api_key,
"x-rapidapi-host": "tiktok-email-phone-lookup.p.rapidapi.com",
"Content-Type": "application/json",
"Accept": "application/json"
}
def check(self, target):
payload = {"target": target}
for attempt in range(RETRIES):
try:
r = requests.post(
self.url,
json=payload,
headers=self.headers,
timeout=TIMEOUT
)
if r.status_code == 200:
return r.json()
elif r.status_code in [429, 500]:
print(Fore.YELLOW + f" β οΈ Retry {attempt+1}/{RETRIES}")
time.sleep(2)
else:
return {"error": f"http_{r.status_code}", "response": r.text}
except Exception:
if attempt < RETRIES - 1:
time.sleep(2)
else:
return {"error": "timeout_or_blocked"}
return {"error": "max_retries_exceeded"}
# ==============================
# UTILITIES
# ==============================
def load_targets(file):
with open(file, "r", encoding="utf-8") as f:
return [line.strip() for line in f if line.strip()]
def is_phone(value):
return value.replace("+", "").isdigit()
def format_phone(number):
number = number.strip().replace(" ", "")
if number.startswith("+"):
return number
if number.startswith("51"):
return f"+{number}"
if number.startswith("9") and len(number) == 9:
return f"+51{number}"
return number
def format_date(ts):
try:
return datetime.fromtimestamp(ts, UTC).strftime('%Y-%m-%d')
except:
return None
def extract_info(data):
profile = data.get("tiktok_profile", {})
extra = profile.get("additional_info", {})
return {
"username": profile.get("username"),
"full_name": profile.get("full_name"),
"followers": extra.get("follower_count"),
"likes": extra.get("heart_count"),
"private": extra.get("private_account"),
"created": format_date(extra.get("create_time"))
}
def generate_filename(prefix):
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
rand = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
return f"{prefix}_{timestamp}_{rand}.json"
def ensure_reports_folder():
if not os.path.exists("reports"):
os.makedirs("reports")
def save_report(data, filename):
path = os.path.join("reports", filename)
with open(path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
return path
# ==============================
# TXT REPORT
# ==============================
def save_txt_report(report, filename):
path = os.path.join("reports", filename)
with open(path, "w", encoding="utf-8") as f:
f.write("TokIntel Report\n")
f.write("=" * 40 + "\n\n")
summary = report["summary"]
f.write(f"Total : {summary['total']}\n")
f.write(f"Hits : {summary['hits']}\n")
f.write(f"Misses : {summary['misses']}\n")
f.write(f"Errors : {summary['errors']}\n")
f.write("\n" + "=" * 40 + "\n\n")
for r in report["results"]:
f.write(f"π― Target : {r['target']}\n")
f.write(f"π Status : {r['status'].upper()}\n\n")
if r["status"] == "hit" and r["raw"]:
profile = r["raw"].get("tiktok_profile", {})
extra = profile.get("additional_info", {})
f.write("π€ Profile Info\n")
f.write("-" * 40 + "\n")
f.write(f"Username : {profile.get('username')}\n")
f.write(f"Name : {profile.get('full_name')}\n")
f.write(f"Bio : {extra.get('signature')}\n")
f.write(f"Language : {extra.get('language')}\n")
f.write(f"Verified : {extra.get('verified')}\n")
f.write(f"Private : {extra.get('private_account')}\n\n")
f.write("π Stats\n")
f.write("-" * 40 + "\n")
f.write(f"Followers : {extra.get('follower_count')}\n")
f.write(f"Following : {extra.get('following_count')}\n")
f.write(f"Likes : {extra.get('heart_count')}\n")
f.write(f"Videos : {extra.get('video_count')}\n")
f.write(f"Friends : {extra.get('friend_count')}\n\n")
f.write("π Links\n")
f.write("-" * 40 + "\n")
f.write(f"Profile URL: {profile.get('profile_url')}\n")
f.write(f"Avatar URL : {profile.get('avatar_url')}\n\n")
created = extra.get("create_time")
if created:
created_date = datetime.fromtimestamp(created, UTC).strftime('%Y-%m-%d')
f.write(f"π
Created : {created_date}\n\n")
f.write("=" * 40 + "\n\n")
return path
# ==============================
# MAIN
# ==============================
def main():
global API_KEY
print_banner()
parser = argparse.ArgumentParser(description="TikTok OSINT Checker PRO")
parser.add_argument("--input", help="Single email or phone number")
parser.add_argument("--file", help="TXT file with targets")
parser.add_argument("--set-api", action="store_true", help="Set or update API Key")
parser.add_argument("--donate", action="store_true", help="Support the project")
args = parser.parse_args()
if args.donate:
print(Fore.MAGENTA + "\nπ Support TokIntel\n")
print(Fore.CYAN + "β https://buymeacoffee.com/HackUnderway")
print(Fore.WHITE + "π Thank you for supporting the project!\n")
return
if args.set_api:
API_KEY = setup_api_key()
return
if not API_KEY:
API_KEY = setup_api_key()
if args.input:
targets = [args.input]
prefix = "phone" if is_phone(args.input) else "email"
elif args.file:
targets = load_targets(args.file)
prefix = "file"
else:
parser.print_help()
return
print(Fore.CYAN + f"\n[+] Targets: {len(targets)}\n")
checker = TikTokChecker(API_KEY)
results, hits, misses, errors = [], [], [], []
for i, target in enumerate(targets, 1):
print(Fore.WHITE + f"[{i}/{len(targets)}] Checking: {target}")
if is_phone(target):
target = format_phone(target)
data = checker.check(target)
if "error" in data:
print(Fore.YELLOW + f" β οΈ ERROR: {data['error']}")
errors.append(target)
status = "error"
info = None
else:
profile = data.get("tiktok_profile")
if profile and profile.get("full_name"):
info = extract_info(data)
print(Fore.MAGENTA + f" π₯ HIT -> @{info['username']}")
print(f" π€ {info['full_name']}")
print(f" π₯ Followers: {info['followers']}")
print(f" β€οΈ Likes: {info['likes']}")
hits.append(target)
status = "hit"
else:
print(Fore.RED + " β MISS")
misses.append(target)
status = "miss"
info = None
results.append({
"target": target,
"status": status,
"info": info,
"raw": data
})
time.sleep(DELAY)
ensure_reports_folder()
report = {
"summary": {
"total": len(results),
"hits": len(hits),
"misses": len(misses),
"errors": len(errors)
},
"results": results
}
# JSON
json_filename = generate_filename(f"report_{prefix}")
json_path = save_report(report, json_filename)
# TXT
txt_filename = json_filename.replace(".json", ".txt")
txt_path = save_txt_report(report, txt_filename)
print(Fore.GREEN + "\nβ
Finished")
print(f" Total: {len(results)}")
print(f" Hits: {len(hits)}")
print(f" Misses: {len(misses)}")
print(f" Errors: {len(errors)}")
print(Fore.CYAN + "\nπ Reports:")
print(f" JSON: {json_path}")
print(f" TXT : {txt_path}")
# ==============================
if __name__ == "__main__":
main()