nx_printer_ports.nx source
↩ module page · 75 lines · 3301 B
1// nx_printer_ports.nx -- sovereign service-surface recon of the operator's OWN Brother on the OWN LAN:
2// a read-only TCP connect-probe of the ports that matter for print/scan, so the next rung targets the
3// protocol the HARDWARE ACTUALLY EXPOSES (hardware-rung-up). No data is sent -- just connect()/close().
4// never-brick #26 (read-only). Reuses nx_ipt_sockaddr from the proven transport. license_tier: ORIGINAL
5// genealogy_id: project-printer-management-ipp-sclass-2026-06-20
6
7import "nx_syscalls.nx"
8import "nx_connect.nx" // bounded connect: a raw sys_connect hangs ~127s on a black-holed host
9import "nx_ipp_transport.nx"
10const K_MAGIC_9100: i64 = 9100
11const K_MAGIC_5357: i64 = 5357
12
13func p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
14func pn(v: i64) -> i64 {
15 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
16 var m: i64 = v
17 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m }
18 let t: *u8 = sys_mmap(24); var k: i64 = 0
19 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
20 let b: *u8 = sys_mmap(24); var i: i64 = 0
21 while i < k { b[i] = t[k - 1 - i]; i = i + 1 }
22 sys_write(1, b, k); return 0
23}
24
25// connect-test one TCP port. 1 = open, 0 = refused/filtered.
26func try_port(a: i64, b: i64, c: i64, d: i64, port: i64) -> i64 {
27 let fd: i64 = sys_socket(AF_INET, SOCK_STREAM, 0)
28 if fd < 0 { return 0 }
29 sys_set_socket_timeout(fd, 2)
30 let dest: *u8 = sys_mmap(16)
31 nx_ipt_sockaddr(dest, a, b, c, d, port)
32 let r: i64 = nx_connect_bounded(fd, dest, 16, NX_CONN_DEFAULT_MS)
33 sys_close(fd)
34 if r == 0 { return 1 }
35 return 0
36}
37
38func report(a: i64, b: i64, c: i64, d: i64, port: i64, label: *u8) -> i64 {
39 let open: i64 = try_port(a, b, c, d, port)
40 p(" :"); pn(port)
41 if port < 1000 { p(" ") }
42 if port < 100 { p(" ") }
43 p(" "); p(label); p(" -> ")
44 if open == 1 { p("OPEN\n") } else { p("closed/filtered\n") }
45 return open
46}
47
48func main() -> i64 {
49 let a: i64 = 192
50 let b: i64 = 168
51 let c: i64 = 8
52 let d: i64 = 127
53 p("=== NISHI PRINTER SERVICE-SURFACE PROBE (read-only TCP connect) ===\n")
54 p("target "); pn(a); p("."); pn(b); p("."); pn(c); p("."); pn(d); p("\n")
55
56 let web: i64 = report(a, b, c, d, 80, "HTTP (web admin)")
57 let tls: i64 = report(a, b, c, d, 443, "HTTPS (eSCL-over-TLS candidate)")
58 let lpd: i64 = report(a, b, c, d, 515, "LPD (legacy print)")
59 let ipp: i64 = report(a, b, c, d, 631, "IPP (we print here)")
60 let raw: i64 = report(a, b, c, d, K_MAGIC_9100, "RAW (JetDirect print)")
61 let wsd: i64 = report(a, b, c, d, K_MAGIC_5357, "WSD (Web Services -- Windows scan)")
62
63 p("\n--- scan-path verdict ---\n")
64 if wsd == 1 {
65 p("WSD (:5357) is OPEN -> this Brother scans over Web Services. NEXT RUNG = WSD scan SOAP layer.\n")
66 } else {
67 if tls == 1 {
68 p(":443 is OPEN -> eSCL-over-TLS is possible; probe it next over the sovereign TLS-1.3 stack.\n")
69 } else {
70 p("no WSD (:5357) and no :443 -> network scan on THIS unit is likely Brother-proprietary only;\n")
71 p("eSCL R0 stays ready for modern scanners. (Honest: the hardware told us its surface.)\n")
72 }
73 }
74 sys_exit(0); return 0
75}