usharik.dev

← All articles

Taking apart a cheap Wi-Fi camera: how cloud P2P cams really work

Published · · 11 min read

I have a small robot project — a tracked chassis with an ESP32 that I drive over Wi-Fi. It needed eyes. On the shelf was a tiny Chinese Wi-Fi camera, the kind sold for a few dollars under a dozen interchangeable names (mine was labelled Model M5), controlled from a phone app. The plan was simple: point the robot's software at the camera's video stream on my own network, done.

It was not simple. What started as "find the RTSP URL" turned into a full teardown of the device, its phone app, its home-grown network protocol and its encryption — and ended with a clear picture of how this entire class of camera is engineered. Short version: there is no local stream, by design, the security is close to theatre, and the only honest route to a local feed runs through the chip, not the software.

Everything below was done on my own camera, my own phone and my own LAN. None of it is an attack on anyone else's device; it is a teardown of a thing I own, and the conclusions are about how these products are built.

What the thing is

The label gave a model (M5) and an FCC ID. The app it wanted was JXLPRO (com.xcthings.jxlpro.google); inside the app the camera reported model Y0A9, firmware 3.00.21, and a device ID — a PP… string that turns out to be the camera's identity in the vendor cloud. The MAC address belonged to Beken, a Chinese Wi-Fi SoC maker, and the camera's hostname was rtthread.home — so: a Beken BK72xx chip running the RT-Thread RTOS. This is one of the cheapest camera platforms that exists.

That combination — Beken + RT-Thread + a PP… device ID + a "scan the QR, use our app" onboarding — is the signature of a P2P cloud camera. "P2P" here does not mean the camera talks to your phone directly. It means the vendor runs a rendezvous service that lets two devices behind two different home routers find each other, and falls back to relaying the video through its own servers when they can't. The camera is a client of that service. Your phone is another client. The cloud is always in the middle, at least for the handshake.

Looking at it from the network

The first thing you do with a camera you want to stream locally is scan it. A full TCP port scan of the camera returned exactly one open port: 20190. No 554 (RTSP), no 8899 (ONVIF), no HTTP, no web page — none of the standard ways a camera offers video. Port 20190 accepts a connection and then closes the moment you send anything it doesn't recognise. It does not answer the usual LAN-discovery broadcasts either, even while the phone app is actively showing live video.

So I tried to watch the traffic instead. On a switched/Wi-Fi network you can't just sniff another device's packets, so I used ARP spoofing to put my machine in the middle. Two findings, both telling:

  • The camera ignores ARP spoofing entirely. Its own traffic never crossed my machine. The RT-Thread network stack (or the router) simply didn't accept the poisoned ARP, so the camera-to-internet path stayed invisible.
  • When I did capture the phone during a live view, there were zero packets between the phone and the camera on the LAN. None. The two devices are two metres apart on the same Wi-Fi, and the video does not travel between them locally. It goes out to the internet and comes back.

That answers the obvious question — surely it just sends the video over my own network? — with a flat no. The phone's traffic went to Alibaba Cloud endpoints and a STUN server (the classic NAT-traversal signalling used to set up peer-to-peer or, failing that, relayed connections). Pull the camera's internet access and it doesn't fall back to local streaming; it reboots, over and over, because it can't reach its cloud.

So how does it phone home with no IP address burned into it? Not through the astral plane — through DNS. The firmware has hostnames, not addresses: it looks up names like …glbs.xcthings.com (a "global load balancer" that hands back the nearest gateway), then …iotgw.xcthings.com for the control channel, then connects to whatever relay servers the cloud nominates (I saw hosts on Alibaba and on Linode). Change the DNS answers and you change where it connects. That is the entire mechanism: names resolved at boot, then a custom protocol on top.

Inside the app

If the stream only exists over the cloud, the only place the protocol is written down is the phone app. So I pulled the APK apart.

JXLPRO is a Flutter app, but the camera logic isn't in the Dart code. It lives in a 34 MB Go library (libgojni.so) built with gomobile — the whole P2P client is written in Go and bolted onto the Java/Flutter app through JNI. The Go packages (recovered from the binary, because Go keeps a function table inside the executable) spell out the architecture plainly:

  • a connection manager that tries, in order, LAN-direct → P2P hole-punching → cloud relay → UPnP;
  • a custom RPC transport the vendor calls pprpc, carrying protobuf command messages;
  • a packets layer with AVPacket (audio/video), CmdPacket (commands) and their own Pack/Unpack/Decrypt;
  • a small crypto package: AES in CBC and CFB modes, MD5, PKCS5 padding.

Note the first entry: a LAN-direct path exists in the code. The camera just never answers the discovery probe that would trigger it, so in practice every connection falls through to relay. The capability is built and then left unreachable.

The crypto, and the one number that matters

The interesting part is how AVPacket is encrypted. Disassembling the decrypt routine shows the scheme in full:

per-packet AES key = MD5( baseKey + ",AVSeq:%d-TT:%d-AVChannel:%d" )

Each video packet is encrypted with AES (CBC-no-padding or CFB, chosen by a field in the packet), and the key for that packet is the MD5 of a base key concatenated with a few counters — the sequence number, a timestamp, the channel. Those counters are sent in the clear in every packet's header. So if you capture the traffic, you already know everything that goes into the key except one value: baseKey. Recover baseKey once and you can decrypt the stream offline with a few lines of code.

That reframes the whole problem into a single question: **where does baseKey come from?**

The app has a tantalising function, getFixScode, that derives a key purely from the device ID — no server, no secret, just MD5(deviceID + companyCode). If that were the base key, you could compute it from the label and be done. It is a dead end: the function exists in the binary but nothing ever calls it. It's leftover code.

The real answer is worse for anyone hoping to decrypt passively:

  • For the owner (the phone that first set up the camera), baseKey is a per-device key issued by the cloud over an authenticated TLS gRPC call, handed to the app together with cloud storage credentials. It's stable, but you can only get it by being the logged-in owner and intercepting that call.
  • For a shared viewer (any other phone the owner shares the camera with), the connection goes over relay, and each session negotiates a fresh, random session key during the handshake. There is no fixed per-device key at all. The key for today's session is exchanged, encrypted, inside today's session.

So fully passive, offline decryption of captured traffic is impossible for the shared path — the thing you'd need to decrypt the capture is itself only present inside the live session you were trying to avoid joining. This isn't a clever lock; it's just that the design happens to foreclose the passive route.

Getting the video anyway

Impossible-to-do-passively is not the same as impossible. The key is in plaintext somewhere on any device that's allowed to watch — specifically, right after the Go library decrypts a frame to hand it to the UI. So:

  1. Run the vendor app on a rooted Android emulator on my Mac.
  2. Make that emulator a legitimate shared viewer of the camera — the owner taps "share" once on the real phone. (A wrinkle worth knowing: the share has to be to an account in the same cloud region, or it fails with a cryptic "data record does not exist".)
  3. Attach Frida — a runtime instrumentation tool — and hook the exact Java method that returns the already-decrypted frame.

The Go functions themselves turn out to be un-hookable (Go's goroutine stack checks make the function prologues unsafe to patch), but the Java method at the boundary is ordinary and hooks fine. The moment the emulator shows live video, decrypted frames fall out of the hook. The "SD" stream is plain MJPEG — a sequence of JPEG images — about 10 frames a second. I reassembled them into a video and there was the room, recognisably.

It works, but look at what it costs: a rooted emulator, the vendor app, a cloud login, a shared-camera grant and a running instrumentation hook — a permanent, clunky bridge — to get a stream from a camera sitting on the same desk. That is the measure of how closed this design is.

How these cameras are actually engineered

Pulling it all together, a clear picture of the product emerges — and it generalises to the whole category, not just this one unit.

  • Cloud-locked by design, not by accident. The local-direct code path exists but is disabled; the camera won't stream to anything but the vendor's own app through the vendor's own servers. No internet, no camera — it reboots in a loop. You are not buying a camera, you are buying a subscription-shaped dependency with no subscription fee (yet).
  • The security is mostly for show. The encryption looks modern (AES, per-packet keys) but the key derivation is MD5(key + counters-you-can-read), and — far worse — the Go library writes extremely verbose debug logs to the phone's storage that leak the session keys, signing keys and account tokens in plaintext. Anything carefully locked in the protocol is left lying in a log file.
  • Ownership is first-come. The camera is claimed by whatever anonymous app account registers it first; there is no real authentication of the owner beyond "got there first."
  • It is privacy-hostile. Your video is encrypted to you but routed through servers you don't control, keyed by a cloud you can't audit, from a device that leaks its own secrets to local storage. This is not a camera to put anywhere you care about.

None of this is unique to JXLPRO. The Beken/RT-Thread + PP…-ID + "use our app" pattern is shared by a long list of rebranded cameras. If a cheap camera wants a QR code and a named app and shows you video "from anywhere," it is almost certainly built like this one.

The hardware is the way out

Here is the twist, and the genuinely good news. The thing that makes these cameras hostile is the firmware, and the firmware sits on a well-understood chip. The Beken BK7252 is a popular enough target that people have written open-source replacement firmware for cameras built on it — and that firmware does the obvious thing the vendor refused to: it serves video locally.

  • One project exposes a plain RTSP stream at rtsp://<camera-ip>:8554/stream — exactly what my robot wanted — with optional Home Assistant integration.
  • Another serves MJPEG over HTTP and, importantly, documents a full UART flashing procedure with a factory backup and restore, so you can put the original firmware back.

Flash one of these and the camera becomes a normal local device: no cloud, no app, no emulator-and-Frida contraption — just a URL your software can open. The catch for my specific unit is that its board is a variant (a 48-pin package) that these projects flag as not-yet-validated, and the only reliably-supported image sensor is a specific one — so for me it would mean opening the case, confirming the exact chip and sensor, and likely some board bring-up rather than a flash-and-go. But the path is real, and it's the first honest route to a local stream in this whole story.

What to take from this

If you just want a camera you can stream on your own network — for a robot, a homelab, a vision project — don't buy this class of camera. Buy one that speaks RTSP or ONVIF out of the box, or build one from an ESP32-CAM; either gives you a local URL in minutes and none of the above. The cheap P2P cams are only cheap until you want your own video.

If you already have one, treat it as what it is: a device that phones a vendor cloud and leaks its keys to its own logs. Keep it off any network you care about. And if you like a project, the chip underneath is hackable — there is open firmware that turns it into the honest local camera it could have been from the start.

The whole investigation was, in the end, a long way to confirm a simple rule of thumb: if a device can only be used through someone else's app and someone else's cloud, that's not a limitation of the hardware — it's a decision in the firmware. And decisions in firmware can be changed.