code wiki / (root) / nx_video_sniff.nx

nx_video_sniff.nx

buildroot/runtime/nx_video_sniff.nx

26634 B473 linesdepth 8pulls 26 transitivereach 25 importersview sourcekind librarytopic video
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_js_eval.nx nx_media_jsexec.nx nx_yt_basejs.nx nx_yt_nsolve.nx nx_video_sniff.nx nx_cleanserve_resolve.nx nx_cleanview.nx nx_cleanwatch_serve.nx nx_click_test.nx nx_domseed_test.nx nx_jq_locate.nx nx_jq_realpage.nx nx_jq_run.nx nx_jq_test.nx nx_jq_tree.nx

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

26const VSK_MAGIC_2048: i64 = 2048
27const VSK_MAGIC_2047: i64 = 2047
28const VSK_MAGIC_2560: i64 = 2560
29const VSK_MAGIC_8589934592: i64 = 8589934592
30const VSK_MAGIC_8192: i64 = 8192
31const VSK_MAGIC_4096: i64 = 4096
32const VSK_MAGIC_262144: i64 = 262144
33const VSK_MAGIC_1048576: i64 = 1048576
35const VSK_KILLED: i64 = 0 - 1 // the guard tripped: the page's JS was runaway/hostile and got killed
36const VSK_NONE: i64 = 0
37const VSK_HLS: i64 = 1 // .m3u8 -> nx_hls_get
38const VSK_DASH: i64 = 2 // .mpd -> DASH downloader (future rung; nx_hls_get is HLS-only)
39const VSK_DIRECT: i64 = 3 // .mp4/.webm/.mkv/.mov -> nx_video_get
40const VSK_SEGMENT: i64 = 4 // .ts/.m4s alone (no manifest) -> incomplete without the playlist

functions

43func vs_url_kind(u: *u8, ul: i64) -> i64
called by 2: vs_sniffvs_sniff_dom calls 1: mjx_contains
56func vs_kind_rank(k: i64) -> i64
64func vs_route_name(k: i64) -> *u8
71func 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 }
72func 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 }
73func 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
74func vs_find(hay: *u8, hl: i64, needle: *u8, nl: i64) -> i64
called by 1: vs_result_json
81func 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
87func vs_result_json(kind: i64, plan: *u8, out: *u8, cap: i64) -> i64
110func vs_query_url(q: *u8, qlen: i64, out: *u8, cap: i64) -> i64
called by 2: mainchk_query calls 1: vs_hexval
150func vs_solve_n(basejs: *u8, bl: i64, nval: *u8, nl: i64, out: *u8, cap: i64) -> i64
159func vs_sniff(js: *u8, jslen: i64, listbuf: *u8, listcap: i64, planbuf: *u8, plancap: i64) -> i64
202func vs_sniff_dom(js: *u8, jslen: i64, dochtml: *u8, doclen: i64, listbuf: *u8, listcap: i64, planbuf: *u8, plancap: i64) -> i64
249func vs_sniff_guarded(js: *u8, jslen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64
296func vs_sniff_guarded_dom(js: *u8, jslen: i64, dochtml: *u8, doclen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64
338func vs_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c }
called by 1: vs_ci_at
339func vs_ci_at(buf: *u8, pos: i64, hlen: i64, lit: *u8, litlen: i64) -> i64
349func vs_extract_scripts(html: *u8, hlen: i64, out: *u8, cap: i64) -> i64
377func vs_script_src(html: *u8, ts: i64, hlen: i64, out: *u8, urlcap: i64, endbox: *i64) -> i64
called by 1: vs_extract_script_srcs calls 1: vs_ci_at
413func vs_extract_script_srcs(html: *u8, hlen: i64, out: *u8, cap: i64) -> i64
438func vs_sniff_page(html: *u8, hlen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64
447func vs_sniff_page_bundled(html: *u8, hlen: i64, extjs: *u8, extlen: i64, planbuf: *u8, plancap: i64, cpu_secs: i64) -> i64
460func 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