code wiki / _hdl_build / nx_ssh_recon_docroot.nx
nx_ssh_recon_docroot.nx source
↩ module page · 28 lines · 2102 B
1// nx_ssh_recon_docroot.nx -- READ-ONLY recon: find where the live daemon serves /wiki/*.html from, and
2// where charter.html / devlog.html / nist_stem.html physically live. No writes. Password from /tmp/nxpw.
3// 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 let ok: i64 = ssh_userauth_password(st, "elderwesto" as *u8, 10, pw, pwlen)
20 if ok != 1 { ssh_puts("AUTH FAILED\n" as *u8); sys_close(st.fd); return 3 }
21 ssh_puts("AUTH OK; recon:\n--------\n" as *u8)
22
23 let cmd: *u8 = "echo ===CHARTER_PHYS===; find /volume1/homes/elderwesto/nishihost -name charter.html 2>/dev/null; echo ===DEVLOG_PHYS===; find /volume1/homes/elderwesto/nishihost -name devlog.html 2>/dev/null; echo ===NIST_PHYS===; find /volume1/homes/elderwesto/nishihost -name nist_stem.html 2>/dev/null; echo ===WIKI_DIR_LS===; ls -la /volume1/homes/elderwesto/nishihost/wiki/ 2>/dev/null; echo ===LOCAL_FETCH_NIST===; curl -sk 'https://localhost:8443/wiki/nist_stem.html' -H 'Host: nishifamily.com' 2>/dev/null | head -c 120; echo; echo ===LOCAL_FETCH_CHARTER_HEAD===; curl -sk 'https://localhost:8443/wiki/charter.html' -H 'Host: nishifamily.com' 2>/dev/null | head -c 120; echo; echo ===RUNNING_DAEMON===; ps -ef 2>/dev/null | grep -i 'daemon\\|sites\\|8443' | grep -v grep; echo ===CAPTURE-END===" as *u8
24 ssh_exec(st, cmd, slen(cmd))
25 ssh_puts("--------\n[done]\n" as *u8)
26 sys_close(st.fd)
27 return 0
28}