nx_video_sniff.nx
buildroot/runtime/nx_video_sniff.nx
about
nx_video_sniff.nx -- the DISCOVERY->DOWNLOAD bridge for JS-hardened video sites. Runs a page's JS on the
sovereign engine (via nx_media_jsexec), captures the stream/media URLs its obfuscated code CONSTRUCTS and
fetches, RANKS them (a manifest beats a raw segment beats nothing), and emits a DOWNLOAD PLAN routing the
best target to the EXISTING X-DLP engine: .m3u8 -> nx_hls_get (handles master/variant + #EXT-X-KEY AES-128
decrypt + TS->fMP4), .mp4/.webm -> nx_video_get. This is the "sniff the video URL" step a browser
video-download extension does, made native.
HONEST CAPABILITY LINE (what this + the X-DLP engine actually beat, and what they don't):
* OBFUSCATION -> BEATEN by EXECUTING the bundle (we run its JS) rather than reading it. The URL the code
builds at runtime surfaces regardless of how the source is mangled.
* SIGNED/TOKENED URLs -> captured WHEN the page builds them client-side from page data (id/hash/consts).
If a signed URL requires a SERVER round-trip (fetch config -> server returns signed manifest), round-1
pending-capture does NOT have it -> that needs the MULTI-ROUND real-network capture (next rung; here the
fetches PEND, no network). Named honestly, not overclaimed.
* #EXT-X-KEY AES-128 HLS encryption -> BEATEN (nx_hls_get + nx_aes_cbc, NIST-KAT'd, live-verified).
* WIDEVINE / PLAYREADY / FAIRPLAY EME DRM -> the REAL WALL. Content is decrypted by a closed CDM blob with
keys from a license server; decrypted frames never touch JS. NOT defeatable natively (needs a CDM) and
legally fraught. (ClearKey EME, which puts keys in JS, is the one EME variant that IS reachable -- a
later rung.) A site with genuine Widevine is out of reach no matter how good discovery is; MANY sites
that LOOK DRM'd are actually just obfuscation + signing + AES-128 = fully in reach.
dependencies 5 imports · 23 importers
diagram shows first 10 each side; +0 more imports, +13 more importers in the complete lists below.
imports: nx_syscalls.nxnx_js_eval.nxnx_media_jsexec.nxnx_yt_basejs.nxnx_yt_nsolve.nx
imported by: nx_cleanserve_resolve.nxnx_cleanview.nxnx_cleanwatch_serve.nxnx_click_test.nxnx_domseed_test.nxnx_jq_locate.nxnx_jq_realpage.nxnx_jq_run.nxnx_jq_test.nxnx_jq_tree.nxnx_media_sniff_daemon.nxnx_pre_test.nxnx_sniff_net_cli.nxnx_sniff_nsolve_gate.nxnx_video_sniff_api_gate.nxnx_video_sniff_cli.nxnx_video_sniff_fetch.nxnx_video_sniff_gate.nxnx_video_sniff_guard_gate.nxnx_video_sniff_page_gate.nxnx_video_sniff_wire_gate.nxnx_vk_js.nxnx_wdoc_test.nx
structs
| none |
consts
| 26 | const VSK_MAGIC_2048: i64 = 2048 |
| 27 | const VSK_MAGIC_2047: i64 = 2047 |
| 28 | const VSK_MAGIC_2560: i64 = 2560 |
| 29 | const VSK_MAGIC_8589934592: i64 = 8589934592 |
| 30 | const VSK_MAGIC_8192: i64 = 8192 |
| 31 | const VSK_MAGIC_4096: i64 = 4096 |
| 32 | const VSK_MAGIC_262144: i64 = 262144 |
| 33 | const VSK_MAGIC_1048576: i64 = 1048576 |
| 35 | const VSK_KILLED: i64 = 0 - 1 // the guard tripped: the page's JS was runaway/hostile and got killed |
| 36 | const VSK_NONE: i64 = 0 |
| 37 | const VSK_HLS: i64 = 1 // .m3u8 -> nx_hls_get |
| 38 | const VSK_DASH: i64 = 2 // .mpd -> DASH downloader (future rung; nx_hls_get is HLS-only) |
| 39 | const VSK_DIRECT: i64 = 3 // .mp4/.webm/.mkv/.mov -> nx_video_get |
| 40 | const VSK_SEGMENT: i64 = 4 // .ts/.m4s alone (no manifest) -> incomplete without the playlist |
functions
| 43 | func vs_url_kind(u: *u8, ul: i64) -> i64 |
| 56 | func vs_kind_rank(k: i64) -> i64 |
| 64 | func vs_route_name(k: i64) -> *u8 |
| 71 | func vs_puts(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off] = s[i]; off = off + 1; i = i + 1 } return off } |
| 72 | func vs_putn(dst: *u8, off: i64, v: i64) -> i64 { var m: i64 = v; if m == 0 { dst[off] = 48 as u8; return off + 1 } let t: *u8 = sys_mmap(24); var k: i64 = 0; while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var j: i64 = 0; while j < k { dst[off] = t[k - 1 - j]; off = off + 1; j = j + 1 } return off } |
| 73 | func vs_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: vs_result_json |
| 74 | func vs_find(hay: *u8, hl: i64, needle: *u8, nl: i64) -> i64 called by 1: vs_result_json |
| 81 | func vs_hexval(c: i64) -> i64 { if c >= 48 { if c <= 57 { return c - 48 } } if c >= 97 { if c <= 102 { return c - 87 } } if c >= 65 { if c <= 70 { return c - 55 } } return 0 } called by 1: vs_query_url |
| 87 | func vs_result_json(kind: i64, plan: *u8, out: *u8, cap: i64) -> i64 |
| 110 | func vs_query_url(q: *u8, qlen: i64, out: *u8, cap: i64) -> i64 |
| 150 | func vs_solve_n(basejs: *u8, bl: i64, nval: *u8, nl: i64, out: *u8, cap: i64) -> i64 |
| 159 | func vs_sniff(js: *u8, jslen: i64, listbuf: *u8, listcap: i64, planbuf: *u8, plancap: i64) -> i64 called by 2: vs_sniff_guardedrun_vs calls 6: sys_mmapmjx_harvest_jsvs_url_kindvs_kind_rankvs_putsvs_route_name |
| 202 | func vs_sniff_dom(js: *u8, jslen: i64, dochtml: *u8, doclen: i64, listbuf: *u8, listcap: i64, planbuf: *u8, plancap: i64) -> i64 called by 1: vs_sniff_guarded_dom calls 6: sys_mmapmjx_harvest_js_domvs_url_kindvs_kind_rankvs_putsvs_route_name |
| 249 | func vs_sniff_guarded(js: *u8, jslen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64 |
| 296 | func vs_sniff_guarded_dom(js: *u8, jslen: i64, dochtml: *u8, doclen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64 |
| 338 | func vs_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: vs_ci_at |
| 339 | func vs_ci_at(buf: *u8, pos: i64, hlen: i64, lit: *u8, litlen: i64) -> i64 |
| 349 | func vs_extract_scripts(html: *u8, hlen: i64, out: *u8, cap: i64) -> i64 |
| 377 | func vs_script_src(html: *u8, ts: i64, hlen: i64, out: *u8, urlcap: i64, endbox: *i64) -> i64 |
| 413 | func vs_extract_script_srcs(html: *u8, hlen: i64, out: *u8, cap: i64) -> i64 called by 4: ncv_url_safevsf_sniff_urlvsf_sniff_url_prerun_ss calls 3: sys_mmapvs_ci_atvs_script_src |
| 438 | func vs_sniff_page(html: *u8, hlen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64 |
| 447 | func vs_sniff_page_bundled(html: *u8, hlen: i64, extjs: *u8, extlen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64 called by 3: ncv_url_safevsf_sniff_urlrun_wb calls 3: sys_mmapvs_extract_scriptsvs_sniff_guarded_dom |
| 460 | func vs_sniff_page_bundled_pre(preamble: *u8, plen: i64, html: *u8, hlen: i64, extjs: *u8, extlen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64 |