跪拜 Guibai
← All articles
GitHub

Unlocking CapCut Pro Drafts on macOS: Call the App's Own Crypto Routines

By Herry项 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

This removes the last barrier for automating video editing on macOS: an AI agent can now generate a CapCut Pro project file that actually opens, without owning the encryption key. The approach is fragile across app updates, but the verification method (just decrypt and check JSON) keeps the risk manageable.

Summary

CapCut Pro on macOS encrypts all five draft files with AES-GCM, and the key never leaves the binary. A working bypass doesn't extract the key at all—the app's own C++ class `lvve::EncryptUtils` exposes encrypt/decrypt methods that can be called with `this=NULL` through `dlopen` + `dlsym`. The author ships a ~100-line C++ shim that loads the dylib, enables encryption, and round-trips plaintext to ciphertext, verified byte-for-byte for inputs of 50 bytes or more.

Calling those methods carries ABI traps: the `std::string` return uses sret, moving `this` from x0 to x1; `enable(NULL, true)` must run before encryption; the `param` argument is `"{}"`; and plaintext under 50 bytes makes `decrypt` throw `std::out_of_range`. The shim runs as a separate subprocess because the 170MB dylib is too fragile to load into Python's main process.

Writing drafts the app accepts is a separate battle. The strategy clones a real empty draft as a donor, replaces only the timeline content, re-encrypts all five files, registers the draft in `root_meta_info.json`, and copies any referenced media into `~/Movies` (the app's sandbox can't see `/tmp`). One silent killer: clip ranges must be `{start, duration}`, not `{start, end}`; the latter collapses every clip to one frame with no error. The app's watcher will later re-register and re-encrypt the draft, which is normal.

Takeaways
— All five CapCut Pro draft files (draft_info.json, draft_meta_info.json, template-2.tmp, and the Timeline files) are AES-GCM encrypted.
— The encryption key is embedded in the app's binary and never exported; it cannot be read from config.
— The app's `lvve::EncryptUtils` class has member functions that work with `this=NULL`, so `dlopen` + `dlsym` on `libvideoeditor.dylib` is enough—no object construction needed.
— Itanium ABI on arm64 uses sret for `std::string` returns, which shifts `this` to x1; calling without accounting for this returns garbage.
— Must call `enable(NULL, true)` before any encryption, and the `param` argument must be the string `"{}"`.
— `decrypt` throws `std::out_of_range` on plaintext shorter than 50 bytes; real drafts are over 500 bytes so this only bites unit tests.
— The shim runs as a separate subprocess (120s timeout, `DYLD_LIBRARY_PATH` set) to avoid loading a 170MB dylib into the main Python process.
— To write an acceptable draft, clone a real empty draft as a donor, replace only the timeline content, re-encrypt all five files, and register the draft in `root_meta_info.json`.
— Media referenced by the draft must live under `~/Movies` because the app is sandboxed; files in `/tmp` cause a 'media not supported' error.
— Clip time ranges must be `{start, duration}` in microseconds; using `{start, end}` silently collapses each clip to a single 33333µs frame at 30fps.
— After the app's watcher detects a new draft, it re-registers the draft with its own `draft_id` and re-encrypts on save—that's expected, not a corrupted write.
— To verify compatibility after an app update, run the shim decrypt on `draft_info.json`; if it yields readable JSON, the existing shim still works.
Conclusions

Calling the app's own crypto functions is a cleaner approach than reverse-engineering the key, because it stays correct even if the key rotates—only the ABI and symbol names matter each upgrade.

The 50-byte threshold is a classic landmine for test-driven development; anyone building on this will need to pad inputs to avoid a confusing `out_of_range` exception.

The decision to isolate the dylib in a subprocess is pragmatic: a 170MB binary with unknown dependencies is too risky to load in-process, and the performance cost is negligible for writing a few files.

The silent failure on `{start, end}` is a stark reminder that CapCut's draft format has no schema validation—malformed fields degrade gracefully into unusable output, so automation must be paranoid about exact field semantics.

Concepts & terms
sret (struct return)
In the Itanium C++ ABI, functions that return a non-trivial type like `std::string` pass a hidden pointer to the caller's storage in register x0 on arm64. This shifts the `this` pointer to x1, so a call that assumes the first argument is the method's data will read garbage.
Name mangling substitution
Itanium C++ name mangling abbreviates repeated standard library type names using `NSt3__1...` forms rather than the fully expanded `std::__1::basic_string<...>`. `dlsym` requires this exact substituted spelling, not the human-readable signature.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗