code wiki / _hdl_build / nx_ssh_recon.nx
nx_ssh_recon.nx source
↩ module page · 29 lines · 2117 B
1// nx_ssh_recon.nx -- READ-ONLY recon over the sovereign SSH client: learn how nishifamily.com is served
2// (which daemon, which port, which doc root / route model) BEFORE any deploy. No writes. Password from
3// /tmp/nxpw (written + deleted by the runner). license_tier: ORIGINAL
4import "nx_syscalls.nx"
5import "nx_ssh_lib.nx"
6
7func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } return n }
8
9func main() -> i64 {
10 let pwbox: *i64 = sys_mmap(16) as *i64
11 let pw: *u8 = sys_read_file("/tmp/nxpw" as *u8, pwbox)
12 if (pw as i64) == 0 { ssh_puts("no /tmp/nxpw\n" as *u8); return 1 }
13 var pwlen: i64 = pwbox[0]
14 while pwlen > 0 { if pw[pwlen-1] == 10 as u8 { pwlen = pwlen - 1 } else { if pw[pwlen-1] == 13 as u8 { pwlen = pwlen - 1 } else { break } } }
15
16 let st: *SshState = sys_mmap(SSH_STATE_BYTES) as *SshState
17 let rc: i64 = ssh_open_session(st, (192 << 24) | (168 << 16) | (8 << 8) | 227)
18 if rc != 0 { ssh_puts("session open failed\n" as *u8); return 2 }
19 ssh_puts("[1] KEX ok.\n" as *u8)
20 let ok: i64 = ssh_userauth_password(st, "elderwesto" as *u8, 10, pw, pwlen)
21 if ok != 1 { ssh_puts("[2] AUTH FAILED\n" as *u8); sys_close(st.fd); return 3 }
22 ssh_puts("[2] AUTH OK (sovereign client).\n[3] recon (read-only):\n--------\n" as *u8)
23
24 let cmd: *u8 = "echo ===R:home===; curl -sk https://localhost:8443/ -H 'Host: nishifamily.com' 2>/dev/null; echo; echo ===R:wiki===; curl -sk https://localhost:8443/wiki -H 'Host: nishifamily.com' 2>/dev/null; echo; echo ===R:wikistatus===; curl -sk https://localhost:8443/wiki/status -H 'Host: nishifamily.com' 2>/dev/null; echo; echo ===R:wikicomp===; curl -sk https://localhost:8443/wiki/components -H 'Host: nishifamily.com' 2>/dev/null; echo; echo ===R:andelin===; curl -sk https://localhost:8443/ -H 'Host: andelinwest.com' 2>/dev/null; echo; echo ===R:e404===; curl -sk https://localhost:8443/nonexistent-xyz -H 'Host: nishifamily.com' 2>/dev/null; echo; echo ===CAPTURE-END===" as *u8
25 ssh_exec(st, cmd, slen(cmd))
26 ssh_puts("--------\n[4] recon done.\n" as *u8)
27 sys_close(st.fd)
28 return 0
29}