code wiki / _hdl_build / nx_sniff_net_cli.nx
nx_sniff_net_cli.nx source
↩ module page · 36 lines · 1958 B
1// nx_sniff_net_cli.nx -- `nx_sniff_net <page-url>`: the NETWORK-IN-THE-LOOP sniff. Fetches the page + bundles,
2// runs the DOM-seeded JS, and services each fetch/XHR with a REAL response (sovereign TLS + cookie jar) across
3// bounded rounds so the page's own player logic resolves the stream (vk API, javxxx wps ajax). Prints the plan.
4// NOTE: runs untrusted JS WITH network directly (no fork guard) -- fine for a CLI probe on legal content.
5import "nx_syscalls.nx"
6import "nx_x509_trust_store.nx"
7import "nx_trust_store_load_from_certdata.nx"
8import "nx_video_sniff.nx"
9import "nx_video_sniff_fetch.nx"
10import "nx_surrogate.nx"
11const K_MAGIC_4194304: i64 = 4194304
12const K_MAGIC_16384: i64 = 16384
13const K_MAGIC_2560: i64 = 2560
14
15func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
16func cslen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
17
18func main(argc: i64, argv: *i64) -> i64 {
19 if argc < 2 { cw("usage: nx_sniff_net <page-url>\n" as *u8); sys_exit(2); return 2 }
20 let url: *u8 = argv[1] as *u8
21 let ulen: i64 = cslen(url)
22 let r: i64 = nx_trust_store_load_from_certdata("data/mozilla_certdata.txt" as *u8, 512, K_MAGIC_4194304)
23 if r <= 0 { cw("SNIFF: certdata load failed (run from nxc2 root)\n" as *u8); sys_exit(1); return 1 }
24 let store: *TrustStore = r as *TrustStore
25 let sgt: *i64 = sg_new(); sg_seed(sgt)
26 let preamble: *u8 = sys_mmap(K_MAGIC_16384)
27 let pre_len: i64 = sg_build_preamble(sgt, preamble, K_MAGIC_16384)
28 cw("== nx_sniff_net ==\npage: " as *u8); cw(url); cw("\n" as *u8)
29 let planbuf: *u8 = sys_mmap(K_MAGIC_2560)
30 let kind: i64 = vsf_sniff_url_net(url, ulen, store, preamble, pre_len, planbuf, K_MAGIC_2560, 4)
31 cw("\n--- DOWNLOAD PLAN ---\n" as *u8)
32 cw(planbuf); cw("\n" as *u8)
33 if kind == VSK_NONE { cw("(no stream surfaced even after multi-round network capture)\n" as *u8) }
34 sys_exit(0)
35 return 0
36}