-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofinder.py
More file actions
79 lines (68 loc) · 2.42 KB
/
profinder.py
File metadata and controls
79 lines (68 loc) · 2.42 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
#!/usr/bin/env python3
import os
import config
import argparse
import time
import json
from telethon import TelegramClient, events
from dotenv import load_dotenv
from processing import Profinder
from colorama import init
init(autoreset=True)
from colorama import Fore, Back
# load api id and api hash from .env
load_dotenv()
try:
api_id = os.environ.get('API_ID')
api_hash = os.environ.get('API_HASH')
except:
print('API_ID or API_HASH envar isn\'t set!')
exit(0)
parser = argparse.ArgumentParser(description="Profinder")
parser.add_argument('-n', '--names', default=None, help='File with names')
parser.add_argument('-g', '--groups', default=None, help='File with groups')
parser.add_argument('-d', '--dump', default=None, help='Use dump of users from chats')
parser.add_argument('-M', '--more', action='store_true', help='More combinations (may produce a lot of useless results) [for files]')
parser.add_argument('-s', '--sleep', type=int, default=None, help='Sleep for n seconds between each chat users dumping')
parser.add_argument('-o', '--outfile', default=None, help='File to save results')
parser.add_argument('-sd', '--save_dump', default=None, help='File to save users dump from chats')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose mode')
args = parser.parse_args()
# parse files if passed
if args.names:
names = {}
with open(args.names, 'r') as f:
for n in f:
ns = n.strip().split(' ')
if len(ns) > 2:
ns = ns[:2]
name = ' '.join(ns)
if not args.more:
ns = [' '.join(ns)]
else:
ns = [' '.join(ns), ns[0]]
names[name] = ns
config.names = names
if args.groups:
groups = []
with open(args.groups, 'r') as f:
for g in f:
groups.append(g.strip())
config.groups = groups
client = TelegramClient('Profinder', api_id, api_hash)
client.start()
p = Profinder(client, config.groups, save_dump=args.save_dump, dump=args.dump, sleep=args.sleep)
matches = {}
for test in config.names.keys():
m = p.findUser(config.names[test])
if args.verbose:
print(Fore.BLUE + f'Name {test}:')
print(Fore.BLUE + str(m))
matches[test] = m
data = json.dumps(matches, ensure_ascii=False).encode('utf8')
data = data.decode()
print(Fore.GREEN + data)
if args.outfile:
with open(args.outfile, 'w') as f:
f.write(data)
client.disconnect()