-
Notifications
You must be signed in to change notification settings - Fork 3
/
auth.py
51 lines (43 loc) · 1.86 KB
/
auth.py
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
import requests
import argparse
import ivdiff
import time
def auth(phone, file):
d = "https://instantview.telegram.org/"
r = requests.get(d)
cookies = r.cookies
r = requests.post(d + "auth/request", cookies=cookies, data={"phone": phone}, headers={
"X-Requested-With": "XMLHttpRequest",
# BEZ PALEVA ( ͡° ͜ʖ ͡°)
"User-Agent": "Mozilla/5.0 (PlayStation 4 2.50) AppleWebKit/537.73 (KHTML, like Gecko)"
})
try:
temp_session = r.json()["temp_session"]
except Exception:
print("Error: {}".format(r.content.decode("utf-8")))
return
print("waiting for request approval...")
while r.content != b"true":
r = requests.post(d + "auth/login", cookies=cookies, data={"temp_session": temp_session}, headers={"X-Requested-With": "XMLHttpRequest"})
cookies = requests.cookies.merge_cookies(cookies, r.cookies).get_dict()
print("success! getting stel_ivs...")
stel_ivs = None
while stel_ivs is None:
print("getting stel_ivs...")
# Domain and url can be actually anything, just make sure it exists in the contest
r = ivdiff.getHtml("dotekomanie.cz", cookies, "dotekomanie.cz", 1)
if r is not None and "stel_ivs" in r[3]:
stel_ivs = r[3]
else:
time.sleep(10)
print(f"success! {stel_ivs}")
cookies = stel_ivs
with open(file, 'wb') as f:
for i, v in cookies.items():
f.write("{}={}; ".format(i, v).encode("utf-8"))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Auth to IV and get cookies.txt file')
parser.add_argument('phone', type=str, help='phone number')
parser.add_argument('--cookies', '-c', help='path to file to write cookies to (default is cookies.txt)', nargs='?', default="cookies.txt")
args = parser.parse_args()
auth(args.phone, args.cookies)