top of page
Search

Jailbreaking a Cloud-Locked Wireless NVR: Freeing 8 Cameras from the App

selcukgenc
45 minutes ago
4 min read

I bought a cheap 8-camera wireless NVR kit (a SMONET / JUAN K9608-2W). It worked fine — as long as I used the vendor's phone app and their cloud. No open RTSP, no ONVIF, nothing my own home server could point at. This is the story of how I freed all eight cameras so they stream to my machine — live and recorded, no cloud in the path — and how I made the whole setup survive reboots, worn flash, and even a dead USB stick.


Animated cover: a root shell, the boot-hook steps, then eight cameras switching from app-only to mine

The big picture


Here is where I ended up before I explain how I got there. The cameras never leave the NVR's own private WiFi; a relay on the NVR hands their video to my server over the wired LAN; my server does the rest.


Figure 1 — End-to-end path: cameras to NVR relay to home server to browser. No vendor cloud anywhere.
Figure 1 — End-to-end path: cameras to NVR relay to home server to browser. No vendor cloud anywhere.

The device


  • Model: SMONET / JUAN K9608-2W, an 8-channel wireless NVR.

  • SoC: HiSilicon Hi3520D, running HiLinux with BusyBox v1.20.2.

  • Cameras: eight WiFi cameras that talk to the NVR over its own built-in access point, on a fixed internal subnet (172.20.14.30–.37). They speak a proprietary “bubble” protocol carrying H.264 — not RTSP.

  • The catch: the box only exposes its streams through the vendor app and cloud. From my LAN: nothing useful.


Getting root


The shipped firmware had telnet locked down. But an older firmware image for the same chip left telnetd reachable. So I flashed the older firmware, connected to telnet on port 23, and got a root shell.


That shell is a stripped BusyBox — no base64, no gzip, no nc. That detail matters a lot later. But the first win was real: a Linux root shell on a camera box that was supposed to be a sealed appliance.


The admin lockout


The NVR's own management API (gw.cgi, a credentialed XML endpoint) is what the app uses, and I wanted to drive it myself. The problem: the admin account kept locking out.


Reverse-engineering the config partition in flash (mtd3) with capstone, I found a USER table: a CRC16/X-25 checksum, the username, a plaintext password field, and some validity flags. Two unpleasant surprises came with it:


  • The firmware rewrites and erases this table on every boot, so any change I made by hand was gone after a reboot.

  • The admin login degrades over uptime until it hard-locks — the API starts returning errno 4 and only a reboot clears it.

  • Writing to the character device /dev/mtd3 commits; writing to /dev/mtdblock3 silently does nothing. That one cost me hours.


A persistent admin that heals itself


The fix is a USB boot-hook. A small flag file on a USB stick makes the NVR bind-mount my wrapper script over its main binary at boot. From then on, every power-on runs my code first:


Figure 2 — The boot-hook chain. Every reboot re-establishes a known admin password and an open root shell.
Figure 2 — The boot-hook chain. Every reboot re-establishes a known admin password and an open root shell.

  • Start telnetd — a permanent root shell, every boot.

  • Start the eight camera relays (more on those next).

  • Chain into a tiny program that writes a known-good admin blob straight to /dev/mtd3.

  • Finally exec a patched copy of the main binary, with an 8-byte NOP that skips the routine which would otherwise reset the admin account.


The result: however worn the flash gets, every reboot comes back up with a known admin password and an open shell. Self-healing by design.


Bypassing the cloud: the camera relay


The cameras live on the NVR's private WiFi, so my server can't reach them directly — but the NVR can. So I put eight tiny TCP relays on the NVR (nvrelay, ports :8030–:8037), each forwarding to one camera's port 80. From my server I connect to those relays and speak the camera's own language.


Figure 3 — Pulling one camera's stream: a 3-step bubble handshake, then raw H.264.
Figure 3 — Pulling one camera's stream: a 3-step bubble handshake, then raw H.264.

The “bubble” protocol is a 3-step handshake followed by raw H.264 for the main stream. A small Python demuxer unwraps the framing and pipes the H.264 into ffmpeg, and from there into go2rtc.


Live and recorded, on my own server


  • go2rtc republishes every camera as WebRTC — instant, low-latency live view in a browser and on my phone.

  • Recorders capture each camera to .mkv, with a 30-day retention timer that cleans up old footage automatically.

  • A small web UI (CamView) ties it together: a live grid, playback, and even playback from the NVR's own hard drive.

  • There is no vendor cloud anywhere in the path.


Making it bulletproof


Backup. The NVR has no easy export — no base64/gzip/nc, and even BusyBox od rejects the usual flags. So I pulled every file off the box over telnet, hex-encoded with hexdump (with a newline every 16 bytes — otherwise a multi-megabyte file buffers as one giant line and stalls), and md5-verified each copy on the server. A dead USB stick is now a two-minute restore, not a re-hack.


Auto-recovery. A watchdog on my server probes the gw.cgi API every 15 minutes. After three consecutive hard-locks (errno 4) it telnets in and reboots the NVR, with a 6-hour brake so it can never fall into a reboot loop. The API self-heals without me touching anything.


What I learned


  • Cheap “cloud” cameras are often just Linux boxes with the doors locked, not welded shut.

  • Root was the easy part. The hard part was persistence against firmware that actively undoes your changes on every boot.

  • Know your flash. A block device silently eating writes while the char device accepts them is the kind of bug that eats an evening.

  • A constrained BusyBox toolset forces creative transfers — hexdump as a stand-in for base64 got every binary off the box.


Code and resources


Everything is on GitHub, fully sanitized — no real IP addresses, no passwords, no WiFi details (credentials are read from environment variables):



It includes a telnet shell helper, the file-puller, the admin-recovery deploy script, and the API watchdog, plus a full write-up and diagrams.


It took a while, but the result is exactly what I wanted: eight cameras, fully mine, no cloud, self-healing. The app can stay uninstalled.

Comments


bottom of page