-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
507 lines (496 loc) · 32.3 KB
/
main.py
File metadata and controls
507 lines (496 loc) · 32.3 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
import base64
import hashlib
import json
import os
import re
import time
import threading
from urllib.parse import parse_qs, urlparse, urlencode
from flask import Flask
from bs4 import BeautifulSoup
import tls_client
from utils import load_accounts, log
import uuid
import html
import pkce
app = Flask(__name__)
email_data = []
# Define header_order globally to avoid NameError
header_order = [
"sec-ch-ua",
"sec-ch-ua-mobile",
"sec-ch-ua-platform",
"origin",
"upgrade-insecure-requests",
"content-type",
"user-agent",
"accept",
"sec-fetch-site",
"sec-fetch-mode",
"sec-fetch-user",
"sec-fetch-dest",
"accept-encoding",
"accept-language",
"cookie",
"priority"
]
class TMOutlook:
def __init__(self, account):
self.data = account
self.session = None
self.code_verifier = pkce.generate_code_verifier(length=43)
sha256_hash = hashlib.sha256(self.code_verifier.encode()).digest()
self.code_challenge = base64.urlsafe_b64encode(sha256_hash).decode().rstrip("=")
print(f"INIT - code_verifier: {self.code_verifier}")
print(f"INIT - code_challenge: {self.code_challenge}")
self.request_id = str(uuid.uuid4())
def run(self):
try:
self.session = tls_client.Session(
client_identifier="chrome_131",
force_http1=True,
random_tls_extension_order=True,
header_order=header_order,
supported_signature_algorithms=['TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384']
)
state_data = {"id": os.urandom(8).hex(), "meta": {"interactionType": "redirect"}}
state = base64.urlsafe_b64encode(json.dumps(state_data).encode()).decode()
nonce = str(uuid.uuid4())
print("code_verifier:", self.code_verifier)
print("state:", state)
print("nonce:", nonce)
self.login(self.data[0], self.data[1], state, nonce)
except Exception as e:
log(f"[ERROR] Exception occurred in run loop: {e}")
finally:
log("Close Tls Client Session...")
if self.session is not None:
self.session.close()
def login(self, username, password, state, nonce):
log(f"Trying to login... username:{username} password: {password}")
first_headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Referer': 'https://login.microsoftonline.com/',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"10.0.0"'
}
params = {
"client_id": "9199bf20-a13f-4107-85dc-02114787ef48",
"scope": "https://outlook.office.com/.default openid profile offline_access",
"redirect_uri": "https://outlook.live.com/mail/",
"response_type": "code",
"response_mode": "fragment",
"state": state,
"nonce": nonce,
"code_challenge": self.code_challenge,
"code_challenge_method": "S256",
"login_hint": username
}
print(f"Sending code_challenge: {self.code_challenge}")
auth_url = "https://login.live.com/oauth20_authorize.srf?" + urlencode(params)
print(f"Authorization URL: {auth_url}")
response = self.session.get("https://login.live.com/oauth20_authorize.srf", params=params, headers=first_headers)
print(f"Authorization response status: {response.status_code}")
print(f"Authorization response headers: {response.headers}")
with open('auth_response.html', 'w', encoding='utf-8') as file:
file.write(response.text)
if response.status_code == 200:
print("Go to next step")
with open('login.html', 'w', encoding='utf-8') as file:
file.write(response.text)
pass_headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://login.live.com',
'Referer': response.url,
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"10.0.0"'
}
ppft_input = re.search(r'name="PPFT"\s+id="[^"]*"\s+value="([^"]+)"', response.text)
if ppft_input:
ppft_value = ppft_input.group(1)
print("PPFT:", ppft_value)
match = re.search(r"urlPostMsa:\s*'([^']+)'", response.text)
if match:
url_post_msa = match.group(1)
print("urlPostMsa:", url_post_msa)
form_data = {
"ps": "2",
"psRNGCDefaultType": "",
"psRNGCEntropy": "",
"psRNGCSLK": "",
"canary": "",
"ctx": "",
"hpgrequestid": "",
"PPFT": ppft_value,
"PPSX": "Pas",
"NewUser": "1",
"FoundMSAs": "",
"fspost": "0",
"i21": "0",
"CookieDisclosure": "0",
"IsFidoSupported": "1",
"isSignupPost": "0",
"isRecoveryAttemptPost": "0",
"i13": "0",
"login": username,
"loginfmt": username,
"type": "11",
"LoginOptions": "3",
"lrt": "",
"lrtPartition": "",
"hisRegion": "",
"hisScaleUnit": "",
"passwd": password
}
pass_response = self.session.post(url_post_msa, headers=pass_headers, data=form_data)
print("pass_response.status_code", pass_response.status_code)
with open('password.html', 'w', encoding='utf-8') as file:
file.write(pass_response.text)
if pass_response.status_code == 200:
sErrTxt_match = re.search(r"sErrTxt:\s*'([^']+)'", pass_response.text)
if sErrTxt_match:
sErrTxt = sErrTxt_match.group(1)
if "incorrect account or password." in sErrTxt or "account or password is incorrect" in sErrTxt:
print("We can't sign you in")
else:
log(f"Successfully signed in with username :{username}")
match = re.search(r"sFT:\s*'([^']+)'", pass_response.text)
if match:
form_data = {
"PPFT": match.group(1),
"canary": "",
"LoginOptions": "3",
"type": "28",
"hpgrequestid": "",
"ctx": ""
}
ppsecure_headers = {
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"10.0.0"',
'Origin': 'https://login.live.com',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Accept-Language': 'en-US,en;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': pass_response.url
}
ppsecure_response = self.session.post(url_post_msa, headers=ppsecure_headers, data=form_data)
print(ppsecure_response.status_code)
if ppsecure_response.status_code == 200:
if "continue" in ppsecure_response.text:
print("Continuing")
soup = BeautifulSoup(ppsecure_response.text, 'html.parser')
data = {}
for input_tag in soup.find_all('input'):
name = input_tag.get('name')
value = input_tag.get('value')
data[name] = value
print(data)
final_headers = {
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Origin': 'https://login.live.com',
'Content-Type': 'application/x-www-form-urlencoded',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/scom/signed-exchange;v=b3;q=0.7',
'Sec-Fetch-Site': 'cross-site',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Dest': 'document',
'Referer': 'https://login.live.com/',
'Accept-Language': 'en-US,en;q=0.9',
'Priority': 'u=0, i'
}
final_response = self.session.post("https://login.microsoftonline.com/consumers/savestate", data=data, headers=final_headers)
if final_response.status_code == 302:
log("Successfully signed in to site")
print(final_response.text)
elif ppsecure_response.status_code == 302:
print("redirected", ppsecure_response.headers.get("Location"))
self.redirect_mail(ppsecure_response.headers.get("Location"))
else:
match_ppft = re.search(r'name="PPFT"\s+id="[^"]*"\s+value="([^"]+)"', pass_response.text)
if match_ppft:
log("You've tried to sign in too many times")
else:
soup = BeautifulSoup(pass_response.text, 'html.parser')
form = soup.find("form")
form_action = form.get("action")
form_data = {}
for input_tag in soup.find_all('input'):
name = input_tag.get('name')
value = input_tag.get('value')
form_data[name] = value
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'max-age=0',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://login.live.com',
'Priority': 'u=0, i',
'Referer': 'https://login.live.com/',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-site',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36'
}
response = self.session.post(form_action, headers=headers, data=form_data)
print(response.status_code)
with open('stay.html', 'w', encoding='utf-8') as file:
file.write(response.text)
if response.status_code == 200:
skip_url_match = re.search(r'"skipUrl"\s*:\s*"([^"]+)"', response.text)
if skip_url_match:
skip_url = html.unescape(skip_url_match.group(1))
print("skipUrl:", skip_url)
oauth_response = self.session.get(skip_url, headers=headers)
print(oauth_response.status_code)
with open('oauth.html', 'w', encoding='utf-8') as file:
file.write(oauth_response.text)
urlPost_match = re.search(r"urlPost:\s*'([^']+)'", oauth_response.text)
sFT_match = re.search(r"sFT:\s*'([^']+)'", oauth_response.text)
if urlPost_match and sFT_match:
urlPost = urlPost_match.group(1)
url_post_form_data = {
"PPFT": sFT_match.group(1),
"canary": "",
"LoginOptions": "3",
"type": "28",
"hpgrequestid": "",
"ctx": ""
}
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://login.live.com',
'Referer': oauth_response.url,
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"10.0.0"'
}
urlPost_response = self.session.post(urlPost, headers=headers, data=url_post_form_data)
print(urlPost_response.status_code)
print(urlPost_response.headers.get("Location"))
if urlPost_response.status_code == 302:
print("second redirect", urlPost_response.headers.get("Location"))
self.redirect_mail(urlPost_response.headers.get("Location"))
elif urlPost_response.status_code == 200:
with open('o_0auth.html', 'w', encoding='utf-8') as file:
file.write(urlPost_response.text)
else:
print("urlPost or sFT not found")
else:
print("skipUrl not found")
else:
print("urlPostMsa not found")
else:
print("PPFT input not found")
def redirect_mail(self, url):
print("redirect mail")
print(f"REDIRECT - code_verifier: {self.code_verifier}")
print(url)
print("code_verifier", self.code_verifier)
headers = {
'Cache-Control': 'max-age=0',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-ch-ua-platform-version': '"10.0.0"',
'Origin': 'https://login.live.com',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-User': '?1',
'Sec-Fetch-Dest': 'document',
'Accept-Language': 'en-US,en;q=0.9',
}
mail_response = self.session.get(url, headers=headers)
print(mail_response.status_code)
if mail_response.status_code == 200:
with open('mail_200.html', 'w', encoding='utf-8') as file:
file.write(mail_response.text)
log(f"Successfully logged in to mailbox with ${mail_response.status_code}")
elif mail_response.status_code == 302:
final_response = self.session.get(mail_response.headers.get("Location"), headers=headers, allow_redirects=True)
print(final_response.status_code)
with open('mail_302.html', 'w', encoding='utf-8') as file:
file.write(final_response.text)
log("Successfully logged in to mailbox")
fragment = urlparse(url).fragment
params = parse_qs(fragment)
code = params.get('code', [None])[0]
request_params = {"client-request-id": self.request_id}
payload = {
"client_id": "9199bf20-a13f-4107-85dc-02114787ef48",
"redirect_uri": "https://outlook.live.com/mail/",
"scope": "https://outlook.office.com/.default openid profile offline_access",
"code": code,
"code_verifier": self.code_verifier,
"grant_type": "authorization_code",
"client_info": "1"
}
refresh_headers = {
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'application/x-www-form-urlencoded;charset=utf-8',
'origin': 'https://outlook.live.com',
'priority': 'u=1, i',
'referer': 'https://outlook.live.com/',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'cross-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
}
print(f"Token request payload: {payload}")
refresh_token_response = self.session.post("https://login.live.com/oauth20_token.srf",
params=request_params,
data=payload,
headers=refresh_headers)
print(refresh_token_response.status_code)
print(f"Token response text: {refresh_token_response.text}")
if refresh_token_response.status_code == 200:
refresh_token_data = refresh_token_response.json()
refresh_token = refresh_token_data['refresh_token']
print("refresh_token", refresh_token)
elif refresh_token_response.status_code == 400:
try:
refresh_token_data = refresh_token_response.json()
print(f"Error: {refresh_token_data.get('error', '')}")
print(f"Description: {refresh_token_data.get('error_description', '')}")
except ValueError:
print(f"Error response: {refresh_token_response.text}")
def get_rules(self):
url = "https://outlook.live.com/owa/0/service.svc?action=GetInboxRule&app=Mail&n=79"
headers = {
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'action': 'GetInboxRule',
'authorization': 'MSAuth1.0 usertoken="EwAYBOl3BAAUcDnR9grBJokeAHaUV8R3+rVHX+IAAV2YTMXd9cuFj2UPIF7JAt1UppD9mTbRk1T8dIm6gFjwkbtG+e3d4x4NYtUjr61NmNMO3ihWjW+2iSObs2IQsHE2IFObUL6OsDGJ3tZfijK5Hh/nTu5sC64brt+h4gECbTfLETTnpr8t2EYUQFrc5lzdLb1+rXsGEkywy41vVDogJrbB7zBrLfnyZ+ouZNUtQxBUvieg2jOK0Cv5KJK1LecEJhmduDvISKKXzo/JdrMgmbFS2s2TQT1FG7NT5udnU82g9cye3/346/h8G3D2VpESDLWpb8okgRDOUOz2XDMchZADp7RgpDdCROOMzxUL/xBRVaf7tO0Lrg98W/EhiQcQZgAAEKlmzx0dZM/fVZ4cCsv+LzjgApbY5eOKopXVaSG8V1IEXXzwYkHkM2uHuZEFV3Z1plQoTt34AOU0ILDLs4xjkR/8H+PWNLXBn+X41PJSL5JrmzCyVGV+fCEB2p4mqQ18XGPy/fwifaa8H7JSZkL7RyHqFepX4JAbJpkz2SMA0taU1a82Oh/LYFqcRrz4HYdwWwnEuLeT4IlPxLGEea9DhpzJ8o5teXlT7pHN/GKQXfT6rGKxojGhd+KVPAwUjPvwKhnf0Nx5JVfkqTQvLHo+EEH6yurkaiU6r4fbxwaGXu7QxrB7zRJql8u3ced6nv3tqOxjLlksbM7DhCic8K2N0g10USUXOOAokk4q649b233GLHlByz8mQitOEE16JKhDXPy8CAzenH+ZJrcJEFFA8sltnw/xYUEGbMefh45utYJcr0H6hVbxShzFTLOD6mWzPCPme+TjTftAjGkGOi87i1puzgt0m/EU45cVbU+9g7i1g8YkpP1E1284iBkdZDeYCzoOAJhJGTQyZjXMg2xGVLo0dsv/Xovt4eatd4b0HH+751xbvtt2Bz+ZmtXtXCgQrV6oZUWyAun5KUOA3C8wkUvNyUbnkAHTZcDhqI6Uwfe2hzgScUtk35pT5il4tvysiHdBTF+ry9wdOwBtYH811ZPBvLKBhk+5SUsIIHpRo0OQeQuKjCMklLVBHYaHcePgotpn6fXs/uqRtyvnMVmXkdDM4voRoQdl8glMkRMuTYgNLC9aPgc78i4ZAOrc13SLnPHXYovpceZd1IA2NRirokhfS38f6ntoU1IJExMbcVjpzAu5gqB49/3dpHFQRQHJFf7SsICOmcsEijAN5LA4Ov25fAyXL83ovoAef+dJMqN/dYzHyzld3/9kPYDajK9ANZF30Dzf4Qf164B1DjGsALu+FJx/QxFr2DdAJjT39o+wopmcJIvNZHSAhW1hrnbYgAw==", type="MSACT"',
'content-length': '0',
'content-type': 'application/json; charset=utf-8',
'ms-cv': 'KuShXJ9KPtofsBEMa/qu+q.90',
'origin': 'https://outlook.live.com',
'prefer': 'exchange.behavior="IncludeThirdPartyOnlineMeetingProviders"',
'priority': 'u=1, i',
'referer': 'https://outlook.live.com/',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'x-anchormailbox': 'PUID:000640008EC8648E^@84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa',
'x-owa-correlationid': 'b35acd82-faca-c001-01f3-536153b9963b',
'x-owa-hosted-ux': 'false',
'x-owa-urlpostdata': '%7B%22__type%22%3A%22GetInboxRuleRequest%3A%23Exchange%22%2C%22Header%22%3A%7B%22__type%22%3A%22JsonRequestHeaders%3A%23Exchange%22%2C%22RequestServerVersion%22%3A%22V2018_01_08%22%2C%22TimeZoneContext%22%3A%7B%22__type%22%3A%22TimeZoneContext%3A%23Exchange%22%2C%22TimeZoneDefinition%22%3A%7B%22__type%22%3A%22TimeZoneDefinitionType%3A%23Exchange%22%2C%22Id%22%3A%22Belarus%20Standard%20Time%22%7D%7D%7D%2C%22UseServerRulesLoader%22%3Atrue%7D',
'x-req-source': 'Mail',
'x-tenantid': '84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa',
}
response = self.session.post(url, headers=headers)
print("get_rules")
print(response.status_code)
print(response.text)
if response.status_code == 200:
print(response.json())
def remove_rules(self):
url = "https://outlook.live.com/owa/0/service.svc?action=RemoveInboxRule&app=Mail&n=84"
headers = {
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'action': 'RemoveInboxRule',
'authorization': 'MSAuth1.0 usertoken="EwAYBOl3BAAUcDnR9grBJokeAHaUV8R3+rVHX+IAAV2YTMXd9cuFj2UPIF7JAt1UppD9mTbRk1T8dIm6gFjwkbtG+e3d4x4NYtUjr61NmNMO3ihWjW+2iSObs2IQsHE2IFObUL6OsDGJ3tZfijK5Hh/nTu5sC64brt+h4gECbTfLETTnpr8t2EYUQFrc5lzdLb1+rXsGEkywy41vVDogJrbB7zBrLfnyZ+ouZNUtQxBUvieg2jOK0Cv5KJK1LecEJhmduDvISKKXzo/JdrMgmbFS2s2TQT1FG7NT5udnU82g9cye3/346/h8G3D2VpESDLWpb8okgRDOUOz2XDMchZADp7RgpDdCROOMzxUL/xBRVaf7tO0Lrg98W/EhiQcQZgAAEKlmzx0dZM/fVZ4cCsv+LzjgApbY5eOKopXVaSG8V1IEXXzwYkHkM2uHuZEFV3Z1plQoTt34AOU0ILDLs4xjkR/8H+PWNLXBn+X41PJSL5JrmzCyVGV+fCEB2p4mqQ18XGPy/fwifaa8H7JSZkL7RyHqFepX4JAbJpkz2SMA0taU1a82Oh/LYFqcRrz4HYdwWwnEuLeT4IlPxLGEea9DhpzJ8o5teXlT7pHN/GKQXfT6rGKxojGhd+KVPAwUjPvwKhnf0Nx5JVfkqTQvLHo+EEH6yurkaiU6r4fbxwaGXu7QxrB7zRJql8u3ced6nv3tqOxjLlksbM7DhCic8K2N0g10USUXOOAokk4q649b233GLHlByz8mQitOEE16JKhDXPy8CAzenH+ZJrcJEFFA8sltnw/xYUEGbMefh45utYJcr0H6hVbxShzFTLOD6mWzPCPme+TjTftAjGkGOi87i1puzgt0m/EU45cVbU+9g7i1g8YkpP1E1284iBkdZDeYCzoOAJhJGTQyZjXMg2xGVLo0dsv/Xovt4eatd4b0HH+751xbvtt2Bz+ZmtXtXCgQrV6oZUWyAun5KUOA3C8wkUvNyUbnkAHTZcDhqI6Uwfe2hzgScUtk35pT5il4tvysiHdBTF+ry9wdOwBtYH811ZPBvLKBhk+5SUsIIHpRo0OQeQuKjCMklLVBHYaHcePgotpn6fXs/uqRtyvnMVmXkdDM4voRoQdl8glMkRMuTYgNLC9aPgc78i4ZAOrc13SLnPHXYovpceZd1IA2NRirokhfS38f6ntoU1IJExMbcVjpzAu5gqB49/3dpHFQRQHJFf7SsICOmcsEijAN5LA4Ov25fAyXL83ovoAef+dJMqN/dYzHyzld3/9kPYDajK9ANZF30Dzf4Qf164B1DjGsALu+FJx/QxFr2DdAJjT39o+wopmcJIvNZHSAhW1hrnbYgAw==", type="MSACT"',
'content-length': '0',
'content-type': 'application/json; charset=utf-8',
'ms-cv': 'KuShXJ9KPtofsBEMa/qu+q.95',
'origin': 'https://outlook.live.com',
'prefer': 'exchange.behavior="IncludeThirdPartyOnlineMeetingProviders"',
'priority': 'u=1, i',
'referer': 'https://outlook.live.com/',
'sec-ch-ua': '"Google Chrome";v="135", "Not-A.Brand";v="8", "Chromium";v="135"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
'x-anchormailbox': 'PUID:000640008EC8648E^@84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa',
'x-owa-correlationid': 'b26143f0-ded1-1c21-98c4-035d82d686c8',
'x-owa-hosted-ux': 'false',
'x-owa-sessionid': 'c460f0e3-7c5e-4452-8187-1b8eadba4d66',
'x-owa-urlpostdata': '%7B%22__type%22%3A%22RemoveInboxRuleRequest%3A%23Exchange%22%2C%22Header%22%3A%7B%22__type%22%3A%22JsonRequestHeaders%3A%23Exchange%22%2C%22RequestServerVersion%22%3A%22V2018_01_08%22%2C%22TimeZoneContext%22%3A%7B%22__type%22%3A%22TimeZoneContext%3A%23Exchange%22%2C%22TimeZoneDefinition%22%3A%7B%22__type%22%3A%22TimeZoneDefinitionType%3A%23Exchange%22%2C%22Id%22%3A%22Belarus%20Standard%20Time%22%7D%7D%7D%2C%22Identity%22%3A%7B%22DisplayName%22%3A%2200064000-8ec8-648e-0000-000000000000%5C%5C17388190521217777665%22%2C%22RawIdentity%22%3A%2200064000-8ec8-648e-0000-000000000000%5C%5C17388190521217777665%22%7D%7D',
'x-req-source': 'Mail',
'x-tenantid': '84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa',
}
response = self.session.post(url, headers=headers)
print(response.status_code)
if response.status_code == 200:
print(response.json())
@app.route('/')
def home():
return "Bot is running"
def start_bot():
data = load_accounts('email.txt')
for i in range(1):
tmoutlook = TMOutlook(account=data[i])
process = threading.Thread(target=tmoutlook.run, args=())
log(f'Starting Bot ')
process.start()
time.sleep(3)
if __name__ == "__main__":
# Start the bot in a separate thread
threading.Thread(target=start_bot, daemon=True).start()
# Start Flask server
port = int(os.environ.get("PORT", 10000))
app.run(host="0.0.0.0", port=port, debug=False)