mirror of
https://github.com/planetrenox/inzerosight.git
synced 2026-09-18 10:05:44 +00:00
56 lines
15 KiB
JavaScript
56 lines
15 KiB
JavaScript
(function(){"use strict";const I={3:{unifier:"",0:"",1:"",2:""},6:{unifier:"",0:"",1:"",2:"",3:"",4:"",5:""},8:{unifier:"",0:"",1:"",2:"",3:"",4:"",5:"",6:"",7:"\uFEFF"},encodeString:(s,e=3)=>Array.from(s,a=>a.codePointAt(0).toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),encodeNumberArray:(s,e=3)=>s.map(a=>a.toString(e).split("").map(d=>I[e][d]).join("")).join(I[e].unifier),decodeToString:(s,e=3)=>s.split(I[e].unifier).map(a=>String.fromCodePoint(parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))).join(""),decodeToNumberArray:(s,e=3)=>s.split(I[e].unifier).map(a=>parseInt(Array.from(a).map(d=>Object.keys(I[e]).find(p=>I[e][p]===d)).join(""),e))};function Y(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var U,H;function J(){if(H)return U;H=1;function s(e={}){const a=e.bits||16,d=e.rounds||22,p=e.rightRotations||7,b=e.leftRotations||2,c=2**a,r=c-1,i=(l,n)=>l>>n|l<<a-n&r,h=(l,n)=>l<<n&r|l>>a-n,w=(l,n,t)=>(l=i(l,p),l=l+n&r,l^=t,n=h(n,b),n^=l,[l,n]),k=(l,n,t)=>(n^=l,n=i(n,b),l^=t,l=l-n&r,l=h(l,p),[l,n]);function E(l,n){let t=l[0],u=l[1],o=n[0],g=n.slice(1);[u,t]=w(u,t,o);for(let m=0;m<d-1;m++){const y=m%g.length;[g[y],o]=w(g[y],o,m),[u,t]=w(u,t,o)}return[t,u]}function A(l,n){let t=l[0],u=l[1],o=n[0],g=n.slice(1);for(let m=0;m<d-1;m++){const y=m%g.length;[g[y],o]=w(g[y],o,m)}for(let m=0;m<d;m++){const y=(d-2-m)%g.length;[u,t]=k(u,t,o),[g[y],o]=k(g[y],o,d-2-m)}return[t,u]}function f(l){return(n,t)=>{const u=l([n/c|0,n&r],t);return u[0]*c+u[1]}}return{encrypt:f(E),decrypt:f(A),encryptRaw:E,decryptRaw:A}}return U=s,U}var Q=J();const L=Y(Q);var D,z;function M(){if(z)return D;z=1;const s="Input must be an string, Buffer or Uint8Array";function e(c){let r;if(c instanceof Uint8Array)r=c;else if(typeof c=="string")r=new TextEncoder().encode(c);else throw new Error(s);return r}function a(c){return Array.prototype.map.call(c,function(r){return(r<16?"0":"")+r.toString(16)}).join("")}function d(c){return(4294967296+c).toString(16).substring(1)}function p(c,r,i){let h=`
|
||
`+c+" = ";for(let w=0;w<r.length;w+=2){if(i===32)h+=d(r[w]).toUpperCase(),h+=" ",h+=d(r[w+1]).toUpperCase();else if(i===64)h+=d(r[w+1]).toUpperCase(),h+=d(r[w]).toUpperCase();else throw new Error("Invalid size "+i);w%6===4?h+=`
|
||
`+new Array(c.length+4).join(" "):w<r.length-2&&(h+=" ")}console.log(h)}function b(c,r,i){let h=new Date().getTime();const w=new Uint8Array(r);for(let E=0;E<r;E++)w[E]=E%256;const k=new Date().getTime();console.log("Generated random input in "+(k-h)+"ms"),h=k;for(let E=0;E<i;E++){const A=c(w),f=new Date().getTime(),l=f-h;h=f,console.log("Hashed in "+l+"ms: "+A.substring(0,20)+"..."),console.log(Math.round(r/(1<<20)/(l/1e3)*100)/100+" MB PER SECOND")}}return D={normalizeInput:e,toHex:a,debugPrint:p,testSpeed:b},D}var B,G;function Z(){if(G)return B;G=1;const s=M();function e(t,u,o){const g=t[u]+t[o];let m=t[u+1]+t[o+1];g>=4294967296&&m++,t[u]=g,t[u+1]=m}function a(t,u,o,g){let m=t[u]+o;o<0&&(m+=4294967296);let y=t[u+1]+g;m>=4294967296&&y++,t[u]=m,t[u+1]=y}function d(t,u){return t[u]^t[u+1]<<8^t[u+2]<<16^t[u+3]<<24}function p(t,u,o,g,m,y){const pe=h[m],be=h[m+1],he=h[y],ge=h[y+1];e(i,t,u),a(i,t,pe,be);let C=i[g]^i[t],S=i[g+1]^i[t+1];i[g]=S,i[g+1]=C,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=C>>>24^S<<8,i[u+1]=S>>>24^C<<8,e(i,t,u),a(i,t,he,ge),C=i[g]^i[t],S=i[g+1]^i[t+1],i[g]=C>>>16^S<<16,i[g+1]=S>>>16^C<<16,e(i,o,g),C=i[u]^i[o],S=i[u+1]^i[o+1],i[u]=S>>>31^C<<1,i[u+1]=C>>>31^S<<1}const b=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],r=new Uint8Array(c.map(function(t){return t*2})),i=new Uint32Array(32),h=new Uint32Array(32);function w(t,u){let o=0;for(o=0;o<16;o++)i[o]=t.h[o],i[o+16]=b[o];for(i[24]=i[24]^t.t,i[25]=i[25]^t.t/4294967296,u&&(i[28]=~i[28],i[29]=~i[29]),o=0;o<32;o++)h[o]=d(t.b,4*o);for(o=0;o<12;o++)p(0,8,16,24,r[o*16+0],r[o*16+1]),p(2,10,18,26,r[o*16+2],r[o*16+3]),p(4,12,20,28,r[o*16+4],r[o*16+5]),p(6,14,22,30,r[o*16+6],r[o*16+7]),p(0,10,20,30,r[o*16+8],r[o*16+9]),p(2,12,22,24,r[o*16+10],r[o*16+11]),p(4,14,16,26,r[o*16+12],r[o*16+13]),p(6,8,18,28,r[o*16+14],r[o*16+15]);for(o=0;o<16;o++)t.h[o]=t.h[o]^i[o]^i[o+16]}const k=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function E(t,u,o,g){if(t===0||t>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(u&&u.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(o&&o.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(g&&g.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const m={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:t};k.fill(0),k[0]=t,u&&(k[1]=u.length),k[2]=1,k[3]=1,o&&k.set(o,32),g&&k.set(g,48);for(let y=0;y<16;y++)m.h[y]=b[y]^d(k,y*4);return u&&(A(m,u),m.c=128),m}function A(t,u){for(let o=0;o<u.length;o++)t.c===128&&(t.t+=t.c,w(t,!1),t.c=0),t.b[t.c++]=u[o]}function f(t){for(t.t+=t.c;t.c<128;)t.b[t.c++]=0;w(t,!0);const u=new Uint8Array(t.outlen);for(let o=0;o<t.outlen;o++)u[o]=t.h[o>>2]>>8*(o&3);return u}function l(t,u,o,g,m){o=o||64,t=s.normalizeInput(t),g&&(g=s.normalizeInput(g)),m&&(m=s.normalizeInput(m));const y=E(o,u,g,m);return A(y,t),f(y)}function n(t,u,o,g,m){const y=l(t,u,o,g,m);return s.toHex(y)}return B={blake2b:l,blake2bHex:n,blake2bInit:E,blake2bUpdate:A,blake2bFinal:f},B}var N,q;function ee(){if(q)return N;q=1;const s=M();function e(f,l){return f[l]^f[l+1]<<8^f[l+2]<<16^f[l+3]<<24}function a(f,l,n,t,u,o){c[f]=c[f]+c[l]+u,c[t]=d(c[t]^c[f],16),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],12),c[f]=c[f]+c[l]+o,c[t]=d(c[t]^c[f],8),c[n]=c[n]+c[t],c[l]=d(c[l]^c[n],7)}function d(f,l){return f>>>l^f<<32-l}const p=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),b=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),c=new Uint32Array(16),r=new Uint32Array(16);function i(f,l){let n=0;for(n=0;n<8;n++)c[n]=f.h[n],c[n+8]=p[n];for(c[12]^=f.t,c[13]^=f.t/4294967296,l&&(c[14]=~c[14]),n=0;n<16;n++)r[n]=e(f.b,4*n);for(n=0;n<10;n++)a(0,4,8,12,r[b[n*16+0]],r[b[n*16+1]]),a(1,5,9,13,r[b[n*16+2]],r[b[n*16+3]]),a(2,6,10,14,r[b[n*16+4]],r[b[n*16+5]]),a(3,7,11,15,r[b[n*16+6]],r[b[n*16+7]]),a(0,5,10,15,r[b[n*16+8]],r[b[n*16+9]]),a(1,6,11,12,r[b[n*16+10]],r[b[n*16+11]]),a(2,7,8,13,r[b[n*16+12]],r[b[n*16+13]]),a(3,4,9,14,r[b[n*16+14]],r[b[n*16+15]]);for(n=0;n<8;n++)f.h[n]^=c[n]^c[n+8]}function h(f,l){if(!(f>0&&f<=32))throw new Error("Incorrect output length, should be in [1, 32]");const n=l?l.length:0;if(l&&!(n>0&&n<=32))throw new Error("Incorrect key length, should be in [1, 32]");const t={h:new Uint32Array(p),b:new Uint8Array(64),c:0,t:0,outlen:f};return t.h[0]^=16842752^n<<8^f,n>0&&(w(t,l),t.c=64),t}function w(f,l){for(let n=0;n<l.length;n++)f.c===64&&(f.t+=f.c,i(f,!1),f.c=0),f.b[f.c++]=l[n]}function k(f){for(f.t+=f.c;f.c<64;)f.b[f.c++]=0;i(f,!0);const l=new Uint8Array(f.outlen);for(let n=0;n<f.outlen;n++)l[n]=f.h[n>>2]>>8*(n&3)&255;return l}function E(f,l,n){n=n||32,f=s.normalizeInput(f);const t=h(n,l);return w(t,f),k(t)}function A(f,l,n){const t=E(f,l,n);return s.toHex(t)}return N={blake2s:E,blake2sHex:A,blake2sInit:h,blake2sUpdate:w,blake2sFinal:k},N}var v,V;function te(){if(V)return v;V=1;const s=Z(),e=ee();return v={blake2b:s.blake2b,blake2bHex:s.blake2bHex,blake2bInit:s.blake2bInit,blake2bUpdate:s.blake2bUpdate,blake2bFinal:s.blake2bFinal,blake2s:e.blake2s,blake2sHex:e.blake2sHex,blake2sInit:e.blake2sInit,blake2sUpdate:e.blake2sUpdate,blake2sFinal:e.blake2sFinal},v}var K=te();const ne=L({bits:24,rounds:23,rightRotations:8,leftRotations:3});function re(s){const e=K.blake2bHex(s,null,12);return[parseInt(e.slice(0,6),16),parseInt(e.slice(6,12),16),parseInt(e.slice(12,18),16),parseInt(e.slice(18,24),16)]}function oe(s,e){if(!s||s.length===0)return"";const a=s[0];return s.slice(1).map((p,b)=>{const c=a*16777216+(b&16777215),r=ne.encrypt(c,e),i=(p^r)>>>0;try{return String.fromCodePoint(i)}catch{return""}}).join("")}const ie=L();function se(s){const e=K.blake2bHex(s,null,8);return[parseInt(e.slice(0,4),16),parseInt(e.slice(4,8),16),parseInt(e.slice(8,12),16),parseInt(e.slice(12,16),16)]}function ce(s,e){return s.map(a=>{try{return String.fromCodePoint(ie.decrypt(a,e))}catch{return""}}).join("")}const _="",x={3:"",6:"",8:""},X={1:"SPECK48_96CTR",2:"SPECK32_64ECB (insecure)"};Object.fromEntries(Object.entries(X).map(([s,e])=>[e,+s]));function le(s){if(!s.includes(_))return null;const e=Object.keys(x).find(b=>s.includes(x[b]));if(!e)return null;const a=s.indexOf(x[e]),d=s.slice(a+x[e].length),p=I[e].unifier+I[e][0];if(d.startsWith(p)){const c=Array.from(d.slice(p.length,p.length+3)).map(w=>Object.keys(I[e]).find(k=>I[e][k]===w)).join(""),r=X[parseInt(c,e)],i=d.slice(p.length+3),h=x[e].length+p.length+3;return{base:e,cipher:r,payload:i,sigIdx:a,sigLen:h}}return{base:e,cipher:"PLAIN",payload:d,sigIdx:a,sigLen:x[e].length}}function ae(s,e,a){const d=new Set(Object.values(I[e]));let p=a;for(;p<s.length&&d.has(s[p]);)p++;return p}let R,j;const T=new Set;function ue(){if(R)return;R=document.createElement("div"),R.id="in0-host",j=R.attachShadow({mode:"open"});const s=document.createElement("style");s.textContent=`
|
||
.in0-wrap {
|
||
position: fixed;
|
||
pointer-events: auto;
|
||
z-index: 2147483647;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
font-family: system-ui, -apple-system, sans-serif;
|
||
transition: opacity 0.1s ease;
|
||
}
|
||
.in0-btn {
|
||
background: #18191c;
|
||
color: #fff;
|
||
border: 1px solid #3a3b40;
|
||
border-radius: 4px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
padding: 4px 10px;
|
||
cursor: pointer;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
|
||
position: relative;
|
||
white-space: nowrap;
|
||
}
|
||
.in0-btn:hover {
|
||
border-color: #00b4d8;
|
||
box-shadow: 0 0 8px rgba(0,180,216,0.4);
|
||
}
|
||
.in0-badge {
|
||
position: absolute;
|
||
top: -6px;
|
||
right: -6px;
|
||
width: 15px;
|
||
height: 15px;
|
||
border-radius: 50%;
|
||
background: #00b4d8;
|
||
color: #fff;
|
||
font-size: 10px;
|
||
font-weight: 700;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
|
||
}
|
||
.in0-arrow {
|
||
width: 0;
|
||
height: 0;
|
||
border-left: 5px solid transparent;
|
||
border-right: 5px solid transparent;
|
||
border-top: 6px solid #18191c;
|
||
margin-top: -1px;
|
||
}
|
||
`,j.appendChild(s),(document.body||document.documentElement).appendChild(R)}function fe(s,e,a,d){for(const h of T)if(h.node===s&&h.start===a)return;ue();const p=document.createElement("div");p.className="in0-wrap";const b=document.createElement("button");b.className="in0-btn",b.textContent=e.cipher==="PLAIN"?"Decode":"Decrypt";const c=document.createElement("span");c.className="in0-badge",c.textContent="Ø",b.appendChild(c);const r=document.createElement("div");r.className="in0-arrow",p.appendChild(b),p.appendChild(r),j.appendChild(p);const i={wrap:p,node:s,start:a,end:d};T.add(i),b.onclick=()=>de(i,e),W(i)}function W(s){const{wrap:e,node:a,start:d,end:p}=s;if(!a.isConnected){e.remove(),T.delete(s);return}const b=a.parentElement;if(!b||b.checkVisibility&&!b.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})){e.style.display="none";return}const c=document.createRange();try{c.setStart(a,d),c.setEnd(a,Math.min(p,a.nodeValue.length))}catch{e.remove(),T.delete(s);return}let r=c.getBoundingClientRect();if(!r.width&&!r.height&&(r=b.getBoundingClientRect()),!r.width&&!r.height){e.style.display="none";return}if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth){e.style.display="none";return}let i=b;for(;i&&i!==document.body&&i!==document.documentElement;){const k=window.getComputedStyle(i);if(k.overflow!=="visible"||k.overflowX!=="visible"||k.overflowY!=="visible"){const E=i.getBoundingClientRect();if(r.bottom<E.top||r.top>E.bottom||r.right<E.left||r.left>E.right){e.style.display="none";return}}i=i.parentElement}e.style.display="flex";const h=r.left+(r.width||0)/2,w=r.top;e.style.left=`${h-e.offsetWidth/2}px`,e.style.top=`${w-e.offsetHeight-2}px`}function de(s,e){const{wrap:a,node:d,start:p,end:b}=s,c=d.nodeValue.slice(p+e.sigLen,b);let r="";if(e.cipher==="PLAIN")try{r=I.decodeToString(c,e.base)}catch(i){console.error(i)}else{const i=prompt(`inØsight: enter password (${e.cipher}):`);if(!i)return;try{const h=I.decodeToNumberArray(c,e.base);e.cipher==="SPECK48_96CTR"?r=oe(h,re(i)):e.cipher==="SPECK32_64ECB (insecure)"&&(r=ce(h,se(i)))}catch(h){console.error(h)}if(!r){alert("Decryption failed.");return}}if(r){const i=document.createRange();i.setStart(d,p),i.setEnd(d,b),i.deleteContents();const h=document.createElement("span");h.className="inzerosight-decoded",h.style.color="#00b4d8",h.style.fontWeight="600",h.textContent=` ${r} `,i.insertNode(h),a.remove(),T.delete(s)}}function F(s){if(!s||s.nodeType!==Node.TEXT_NODE)return;const e=s.nodeValue;if(!e||!e.includes(_))return;let a=0;for(;a<e.length;){const d=e.slice(a),p=le(d);if(!p)break;const b=a+p.sigIdx,c=ae(e,p.base,b+p.sigLen);fe(s,p,b,c),a=c+1}}function $(s){if(!s)return;const e={SCRIPT:1,STYLE:1,TEXTAREA:1,INPUT:1,NOSCRIPT:1,"IN0-HOST":1},a=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,{acceptNode:p=>{var b;return e[(b=p.parentElement)==null?void 0:b.tagName]?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}});let d;for(;d=a.nextNode();)F(d)}$(document.body);let O;function P(){O||T.size===0||(O=requestAnimationFrame(()=>{O=null,T.forEach(W)}))}new MutationObserver(s=>{var e;for(const a of[...T])(!a.node.isConnected||!((e=a.node.nodeValue)!=null&&e.includes(_)))&&(a.wrap.remove(),T.delete(a));for(const a of s)if(a.type==="characterData")F(a.target);else for(const d of a.addedNodes)d.nodeType===Node.TEXT_NODE?F(d):d.nodeType===Node.ELEMENT_NODE&&d.id!=="in0-host"&&$(d);P()}).observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0}),window.addEventListener("scroll",P,{capture:!0,passive:!0}),window.addEventListener("resize",P,{passive:!0})})();
|