code wiki / (root) / nx_page_identity_gate.nx

nx_page_identity_gate.nx source

↩ module page · 33 lines · 2543 B

1import "nx_game_page_artifact_lib.nx" 2func main() -> i64 { 3 let literal: *u8="<html><head><meta name=\"nishi-release-sha256\" content=\"0000000000000000000000000000000000000000000000000000000000000000\"></head><body>beach</body></html>" as *u8 4 let n: i64=vw_slen(literal); let b: *u8=sys_mmap(n+1) 5 var i: i64=0; while i<n { b[i]=literal[i]; i=i+1 } 6 if gpa_seal(b,n)!=1 { return 1 } 7 let slot: i64=gpa_release_slot(b,n) 8 if gpa_same((b as i64+slot) as *u8,64,"05f46604dabc60f7fc256ccd96cf4ec065cf2febc072550952b71b3b24e37476" as *u8,64)!=1 { return 2 } 9 if gpa_seal(b,n)!=1 { return 3 } 10 if gpa_same((b as i64+slot) as *u8,64,"05f46604dabc60f7fc256ccd96cf4ec065cf2febc072550952b71b3b24e37476" as *u8,64)!=1 { return 4 } 11 b[n-8]=120 as u8 12 if gpa_seal(b,n)!=1 { return 5 } 13 if gpa_same((b as i64+slot) as *u8,64,"05f46604dabc60f7fc256ccd96cf4ec065cf2febc072550952b71b3b24e37476" as *u8,64)==1 { return 6 } 14 let duplicate: *u8="<meta name=\"nishi-release-sha256\" content=\"0000000000000000000000000000000000000000000000000000000000000000\"><meta name=\"nishi-release-sha256\" content=\"0000000000000000000000000000000000000000000000000000000000000000\">" as *u8 15 if gpa_seal(duplicate,vw_slen(duplicate))!=-1 { return 7 } 16 if gpa_seal("legacy" as *u8,6)!=0 { return 8 } 17 b[slot]=122 as u8 18 if gpa_seal(b,n)!=-1 { return 9 } 19 let wasm: *u8=sys_mmap(8) 20 wasm[0]=0 as u8; wasm[1]=97 as u8; wasm[2]=115 as u8; wasm[3]=109 as u8; wasm[4]=1 as u8 21 let original: *u8="<html><head><meta name=\"nishi-release-sha256\" content=\"0000000000000000000000000000000000000000000000000000000000000000\"></head><script>const B=\"YWJj\";</script></html>" as *u8 22 let expected: *u8="<html><head><meta name=\"nishi-release-sha256\" content=\"cfe1389c9e72ef77d29278aa5e2be304972280bc6208a5b009d5bde321cf7f4c\"></head><script>const B=\"AGFzbQEAAAA=\";</script></html>" as *u8 23 let out: *u8=sys_mmap(1024); let again: *u8=sys_mmap(1024) 24 let composed: i64=gpa_compose(original,vw_slen(original),wasm,8,out,1024) 25 if gpa_same(out,composed,expected,vw_slen(expected))!=1 { return 10 } 26 let repeated: i64=gpa_compose(out,composed,wasm,8,again,1024) 27 if gpa_same(out,composed,again,repeated)!=1 { return 11 } 28 out[0]=99 as u8 29 let bad: *u8="<html><head><meta name=\"nishi-release-sha256\" content=\"z000000000000000000000000000000000000000000000000000000000000000\"></head><script>const B=\"YWJj\";</script></html>" as *u8 30 if gpa_compose(bad,vw_slen(bad),wasm,8,out,1024)>=0 || out[0]!=99 as u8 { return 12 } 31 sys_write(1,"PAGE IDENTITY 12/12\n" as *u8,20) 32 return 0 33}