Exploit database

GH-8f5a087c3e78e77eb737a53d97193158

turretsec/u3000py

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-101053

1 source

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

Repository files1
turretsec/u3000pyRevision d4372401c930

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

scripts/smoke_test_cli.py

Python · 6,510 bytes
"""Smoke-test every non-admin u3000py CLI command against a real camera.

Invokes the actual installed `u3000py` command via subprocess. This
tests the real packaging/entry-point too, not just the importable
library. `admin` commands are deliberately excluded entirely; this is
for routine "did I break something" checks, not a destructive sweep.

A few commands are SKIPPED rather than tested automatically, on purpose:
- wifi rename-hotspot / wifi delete-ap: both take an INDEX, and we don't
  know what's actually stored at any given index without risking
  clobbering a real saved entry. Test these manually if you want to,
  with a known-safe index.

Usage:
    python smoke_test_cli.py --host <camera-ip> [--include-download]
"""

from __future__ import annotations

import argparse
import subprocess
import sys
import tempfile
from pathlib import Path

# Imported directly (not via the CLI) purely to discover a real, currently
# valid file path. Avoids hardcoding a filename that goes stale once
# continuous recording rotates it off the card.
from u3000py import ThinkLinkClient, VideoCategory


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser()
    parser.add_argument("--host", required=True, help="Camera IP address.")
    parser.add_argument(
        "--include-download", action="store_true",
        help="Also run a real file download. Slow (this camera's WiFi tops "
             "out at a few MB/s), skipped by default.",
    )
    return parser.parse_args()


def run_command(host: str, args: list[str]) -> subprocess.CompletedProcess:
    return subprocess.run(
        ["u3000py", "--host", host, *args],
        capture_output=True, text=True, timeout=120,
    )


def main() -> None:
    opts = parse_args()
    host = opts.host

    print(f"Discovering a real test file on {host} (cont_rec)...")
    test_file_path: str | None = None
    try:
        with ThinkLinkClient(host) as cam:
            existing = cam.list_files(VideoCategory.CONTINUOUS)
            if existing:
                test_file_path = existing[-1].path
                print(f"  using {test_file_path}")
            else:
                print("  no files found, ls/thumbnail/download tests will be skipped")
    except Exception as e:
        print(f"  could not connect to discover a test file: {e!r}")
        print("  ls/thumbnail/download tests will be skipped")

    download_dest = str(Path(tempfile.gettempdir()) / "u3000py_smoke_test.mp4")

    # (label, args, expect_success)
    # expect_success=False means the command is KNOWN to fail on this unit
    # right now. That's a documented finding, not a bug, so it's checked
    # for explicitly rather than flagged as a surprise.
    commands: list[tuple[str, list[str], bool]] = [
        ("info device", ["info", "device"], True),
        ("info system", ["info", "system"], True),
        ("info space", ["info", "space"], True),
        ("info gps", ["info", "gps"], True),
        ("info wifi", ["info", "wifi"], True),
        ("info liveview", ["info", "liveview"], True),
        ("info liveview-url", ["info", "liveview-url"], True),
        ("info hotspot", ["info", "hotspot"], True),
        ("info current-ap", ["info", "current-ap"], True),
        ("info ap", ["info", "ap"], False),         # known: ResourceBusyError in STA mode
        ("info wifi-scan", ["info", "wifi-scan"], False),  # same as above
        ("info modem", ["info", "modem"], True),    # type recognized, no data, not an error
        ("info parking-event", ["info", "parking-event"], True),
        ("info state-history", ["info", "state-history", "--index", "0"], True),
        ("config channel --front", ["config", "channel", "--front"], True),
        ("config audio --on", ["config", "audio", "--on"], True),
        ("config audio --off", ["config", "audio", "--off"], True),
        ("config rtsp --on", ["config", "rtsp", "--on"], True),
        ("config rtsp --off", ["config", "rtsp", "--off"], True),
        ("config dual-resolution --on", ["config", "dual-resolution", "--on"], True),
        ("config front-only --off", ["config", "front-only", "--off"], True),
        ("config sync-time", ["config", "sync-time"], True),
        (
            "config provisioning",
            ["config", "provisioning", "--language", "en", "--timezone", "UTC", "--locale-id", "us"],
            True,
        ),
        ("db lock", ["db", "lock"], False),    # known: ResourceBusyError while recording
        ("db unlock", ["db", "unlock"], False),  # same reason
        ("files list", ["files", "list", "--category", "cont_rec"], True),
        (
            "wifi add-hotspot (self-contained test entry)",
            ["wifi", "add-hotspot", "u3000py-smoke-test-DELETE-ME", "throwaway-password"],
            True,
        ),
        (
            "wifi delete-hotspot (removes the entry just added above)",
            ["wifi", "delete-hotspot", "u3000py-smoke-test-DELETE-ME", "throwaway-password"],
            True,
        ),
    ]

    if test_file_path:
        commands.append(("files ls (cont_rec)", ["files", "ls", "/tmp/SD0/cont_rec"], True))
        commands.append(("files thumbnail", ["files", "thumbnail", test_file_path], True))
        if opts.include_download:
            commands.append((
                "files download (real transfer, slow)",
                ["files", "download", test_file_path, "--dest", download_dest],
                True,
            ))

    print()
    results: list[tuple[str, bool, str]] = []
    for label, args, expect_success in commands:
        proc = run_command(host, args)
        succeeded = proc.returncode == 0
        if succeeded == expect_success:
            status = "PASS" if expect_success else "PASS (expected failure)"
            ok = True
        else:
            status = "UNEXPECTED FAIL" if expect_success else "UNEXPECTED SUCCESS"
            ok = False
        results.append((label, ok, status))
        print(f"[{status:24}] {label}")
        if not ok:
            print(f"    exit={proc.returncode}")
            print(f"    stdout: {proc.stdout.strip()[:200]}")
            print(f"    stderr: {proc.stderr.strip()[:200]}")

    print()
    failed = [r for r in results if not r[1]]
    print(f"{len(results) - len(failed)}/{len(results)} as expected.")
    if failed:
        print("Unexpected results:")
        for label, _, status in failed:
            print(f"  - {label}: {status}")
        sys.exit(1)


if __name__ == "__main__":
    main()