oculon 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -13
- package/dist/cli/main.js +316 -1
- package/dist/core/der.d.ts +2 -0
- package/dist/core/der.js +17 -0
- package/dist/core/http.d.ts +19 -1
- package/dist/core/http.js +24 -0
- package/dist/core/qr.d.ts +23 -0
- package/dist/core/qr.js +577 -0
- package/dist/core/quota.js +5 -0
- package/dist/core/raster.d.ts +6 -0
- package/dist/core/raster.js +298 -0
- package/dist/core/safeurl.d.ts +5 -0
- package/dist/core/safeurl.js +26 -0
- package/dist/core/verdict.js +1 -1
- package/dist/core/zip.d.ts +9 -0
- package/dist/core/zip.js +46 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.js +99 -0
- package/dist/mcp.js +131 -5
- package/dist/modules/address.d.ts +6 -2
- package/dist/modules/address.js +32 -5
- package/dist/modules/apk.d.ts +37 -0
- package/dist/modules/apk.js +191 -0
- package/dist/modules/approvals.d.ts +40 -0
- package/dist/modules/approvals.js +155 -0
- package/dist/modules/archive.d.ts +21 -0
- package/dist/modules/archive.js +94 -0
- package/dist/modules/checks.js +33 -0
- package/dist/modules/contract.d.ts +56 -0
- package/dist/modules/contract.js +167 -0
- package/dist/modules/deployer.d.ts +42 -0
- package/dist/modules/deployer.js +90 -0
- package/dist/modules/doc.d.ts +24 -2
- package/dist/modules/doc.js +133 -7
- package/dist/modules/eml.d.ts +46 -0
- package/dist/modules/eml.js +175 -0
- package/dist/modules/hashcheck.d.ts +19 -3
- package/dist/modules/hashcheck.js +28 -4
- package/dist/modules/image.d.ts +32 -0
- package/dist/modules/image.js +276 -0
- package/dist/modules/invite.d.ts +27 -0
- package/dist/modules/invite.js +69 -0
- package/dist/modules/job.d.ts +33 -0
- package/dist/modules/job.js +64 -0
- package/dist/modules/meerkat.d.ts +1 -1
- package/dist/modules/meerkat.js +35 -2
- package/dist/modules/monitor.js +14 -0
- package/dist/modules/poisoning.d.ts +43 -0
- package/dist/modules/poisoning.js +114 -0
- package/dist/modules/qrcheck.d.ts +24 -0
- package/dist/modules/qrcheck.js +136 -0
- package/dist/modules/repo.d.ts +61 -0
- package/dist/modules/repo.js +162 -0
- package/dist/modules/report.d.ts +32 -0
- package/dist/modules/report.js +108 -0
- package/dist/modules/signature.d.ts +35 -0
- package/dist/modules/signature.js +283 -0
- package/dist/modules/site.d.ts +62 -0
- package/dist/modules/site.js +191 -0
- package/dist/modules/stocktoken.d.ts +48 -0
- package/dist/modules/stocktoken.js +99 -0
- package/dist/modules/trace.d.ts +37 -0
- package/dist/modules/trace.js +150 -0
- package/dist/modules/txexplain.d.ts +40 -0
- package/dist/modules/txexplain.js +135 -0
- package/dist/modules/urlcheck.js +15 -1
- package/dist/modules/where.d.ts +63 -0
- package/dist/modules/where.js +165 -0
- package/dist/report-pdf.js +3 -0
- package/dist/sources/cfurlscan.d.ts +24 -0
- package/dist/sources/cfurlscan.js +46 -0
- package/dist/sources/chainabuse.d.ts +17 -0
- package/dist/sources/chainabuse.js +19 -0
- package/dist/sources/evm.d.ts +135 -0
- package/dist/sources/evm.js +260 -0
- package/dist/sources/phishlists.d.ts +20 -0
- package/dist/sources/phishlists.js +90 -0
- package/dist/telegram.d.ts +17 -0
- package/dist/telegram.js +151 -4
- package/dist/web/docs.html +1 -1
- package/dist/web/index.html +147 -11
- package/dist/web/landing.html +1 -1
- package/dist/web/legal.html +3 -1
- package/dist/web/mcp.html +1 -1
- package/dist/web/openapi.js +13 -0
- package/dist/web/pages.js +2 -2
- package/dist/web/public.js +14 -1
- package/dist/web/server.d.ts +13 -0
- package/dist/web/server.js +77 -12
- package/dist/web/token.html +24 -4
- package/dist/web/token.json +12 -1
- package/package.json +2 -2
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image decoding to a grayscale raster, without dependencies: PNG (all color types, bit depths 1-16,
|
|
3
|
+
* no interlacing) and baseline JPEG (Huffman, any sampling; only the luminance channel is reconstructed,
|
|
4
|
+
* which is all a QR reader needs). Progressive JPEG and interlaced PNG are rejected with a plain message.
|
|
5
|
+
*/
|
|
6
|
+
import { inflateSync } from 'node:zlib';
|
|
7
|
+
const MAX_PIXELS = 25_000_000;
|
|
8
|
+
export function decodeGray(b) {
|
|
9
|
+
if (b.subarray(0, 8).equals(Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])))
|
|
10
|
+
return png(b);
|
|
11
|
+
if (b[0] === 0xff && b[1] === 0xd8)
|
|
12
|
+
return jpeg(b);
|
|
13
|
+
throw new Error('not a PNG or JPEG image');
|
|
14
|
+
}
|
|
15
|
+
/* ---------- PNG ---------- */
|
|
16
|
+
function png(b) {
|
|
17
|
+
let i = 8, w = 0, h = 0, depth = 8, ct = 0, interlace = 0;
|
|
18
|
+
let palette = null, trns = null;
|
|
19
|
+
const idat = [];
|
|
20
|
+
while (i + 12 <= b.length) {
|
|
21
|
+
const len = b.readUInt32BE(i), t = b.toString('latin1', i + 4, i + 8), d = b.subarray(i + 8, i + 8 + len);
|
|
22
|
+
if (t === 'IHDR') {
|
|
23
|
+
w = d.readUInt32BE(0);
|
|
24
|
+
h = d.readUInt32BE(4);
|
|
25
|
+
depth = d[8];
|
|
26
|
+
ct = d[9];
|
|
27
|
+
interlace = d[12];
|
|
28
|
+
}
|
|
29
|
+
else if (t === 'PLTE')
|
|
30
|
+
palette = d;
|
|
31
|
+
else if (t === 'tRNS')
|
|
32
|
+
trns = d;
|
|
33
|
+
else if (t === 'IDAT')
|
|
34
|
+
idat.push(d);
|
|
35
|
+
else if (t === 'IEND')
|
|
36
|
+
break;
|
|
37
|
+
i += 12 + len;
|
|
38
|
+
}
|
|
39
|
+
if (!w || !h || w * h > MAX_PIXELS)
|
|
40
|
+
throw new Error('the image is empty or too large');
|
|
41
|
+
if (interlace)
|
|
42
|
+
throw new Error('interlaced PNG is not supported; save it again without interlacing or take a screenshot');
|
|
43
|
+
const ch = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 }[ct];
|
|
44
|
+
if (!ch)
|
|
45
|
+
throw new Error('unsupported PNG color type');
|
|
46
|
+
const raw = inflateSync(Buffer.concat(idat));
|
|
47
|
+
const bpp = Math.max(1, (ch * depth) >> 3);
|
|
48
|
+
const stride = Math.ceil((w * ch * depth) / 8);
|
|
49
|
+
const cur = Buffer.alloc(stride), prev = Buffer.alloc(stride);
|
|
50
|
+
const out = new Uint8Array(w * h);
|
|
51
|
+
let p = 0;
|
|
52
|
+
for (let y = 0; y < h; y++) {
|
|
53
|
+
const f = raw[p++];
|
|
54
|
+
raw.copy(cur, 0, p, p + stride);
|
|
55
|
+
p += stride;
|
|
56
|
+
for (let x = 0; x < stride; x++) {
|
|
57
|
+
const a = x >= bpp ? cur[x - bpp] : 0, up = prev[x], c = x >= bpp ? prev[x - bpp] : 0;
|
|
58
|
+
let v = cur[x];
|
|
59
|
+
if (f === 1)
|
|
60
|
+
v += a;
|
|
61
|
+
else if (f === 2)
|
|
62
|
+
v += up;
|
|
63
|
+
else if (f === 3)
|
|
64
|
+
v += (a + up) >> 1;
|
|
65
|
+
else if (f === 4) {
|
|
66
|
+
const pa = Math.abs(up - c), pb = Math.abs(a - c), pc = Math.abs(a + up - 2 * c);
|
|
67
|
+
v += pa <= pb && pa <= pc ? a : pb <= pc ? up : c;
|
|
68
|
+
}
|
|
69
|
+
cur[x] = v & 255;
|
|
70
|
+
}
|
|
71
|
+
const sample = (k) => {
|
|
72
|
+
if (depth === 8)
|
|
73
|
+
return cur[k];
|
|
74
|
+
if (depth === 16)
|
|
75
|
+
return cur[k * 2];
|
|
76
|
+
const per = 8 / depth, byte = cur[Math.floor(k / per)], shift = 8 - depth * ((k % per) + 1);
|
|
77
|
+
return (byte >> shift) & ((1 << depth) - 1);
|
|
78
|
+
};
|
|
79
|
+
const scale = depth < 8 && ct !== 3 ? 255 / ((1 << depth) - 1) : 1;
|
|
80
|
+
for (let x = 0; x < w; x++) {
|
|
81
|
+
let g, alpha = 255;
|
|
82
|
+
if (ct === 0)
|
|
83
|
+
g = sample(x) * scale;
|
|
84
|
+
else if (ct === 2) {
|
|
85
|
+
const r = sample(x * 3), gg = sample(x * 3 + 1), bl = sample(x * 3 + 2);
|
|
86
|
+
g = 0.299 * r + 0.587 * gg + 0.114 * bl;
|
|
87
|
+
}
|
|
88
|
+
else if (ct === 3) {
|
|
89
|
+
const k = sample(x) * 3;
|
|
90
|
+
g = palette ? 0.299 * palette[k] + 0.587 * palette[k + 1] + 0.114 * palette[k + 2] : 0;
|
|
91
|
+
if (trns && sample(x) < trns.length)
|
|
92
|
+
alpha = trns[sample(x)];
|
|
93
|
+
}
|
|
94
|
+
else if (ct === 4) {
|
|
95
|
+
g = sample(x * 2);
|
|
96
|
+
alpha = sample(x * 2 + 1);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const r = sample(x * 4), gg = sample(x * 4 + 1), bl = sample(x * 4 + 2);
|
|
100
|
+
g = 0.299 * r + 0.587 * gg + 0.114 * bl;
|
|
101
|
+
alpha = sample(x * 4 + 3);
|
|
102
|
+
}
|
|
103
|
+
// Transparent parts sit on white, as a viewer shows them.
|
|
104
|
+
out[y * w + x] = Math.round((g * alpha + 255 * (255 - alpha)) / 255);
|
|
105
|
+
}
|
|
106
|
+
cur.copy(prev);
|
|
107
|
+
}
|
|
108
|
+
return { width: w, height: h, data: out };
|
|
109
|
+
}
|
|
110
|
+
/* ---------- baseline JPEG ---------- */
|
|
111
|
+
const ZZ = [0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63];
|
|
112
|
+
const COS = Array.from({ length: 8 }, (_, x) => Array.from({ length: 8 }, (_, u) => (u === 0 ? Math.SQRT1_2 : 1) * Math.cos(((2 * x + 1) * u * Math.PI) / 16)));
|
|
113
|
+
function buildHuff(counts, syms) {
|
|
114
|
+
const lookup = Array.from({ length: 17 }, () => new Map());
|
|
115
|
+
let code = 0, k = 0;
|
|
116
|
+
for (let len = 1; len <= 16; len++) {
|
|
117
|
+
for (let i = 0; i < counts[len - 1]; i++)
|
|
118
|
+
lookup[len].set(code++, syms[k++]);
|
|
119
|
+
code <<= 1;
|
|
120
|
+
}
|
|
121
|
+
return { lookup };
|
|
122
|
+
}
|
|
123
|
+
function idct(block, out, ow, ox, oy, oh) {
|
|
124
|
+
const tmp = new Float32Array(64);
|
|
125
|
+
for (let y = 0; y < 8; y++)
|
|
126
|
+
for (let u = 0; u < 8; u++) {
|
|
127
|
+
let s = 0;
|
|
128
|
+
for (let v = 0; v < 8; v++)
|
|
129
|
+
s += COS[y][v] * block[v * 8 + u];
|
|
130
|
+
tmp[y * 8 + u] = s;
|
|
131
|
+
}
|
|
132
|
+
for (let y = 0; y < 8; y++)
|
|
133
|
+
for (let x = 0; x < 8; x++) {
|
|
134
|
+
let s = 0;
|
|
135
|
+
for (let u = 0; u < 8; u++)
|
|
136
|
+
s += COS[x][u] * tmp[y * 8 + u];
|
|
137
|
+
const px = ox + x, py = oy + y;
|
|
138
|
+
if (px < ow && py < oh)
|
|
139
|
+
out[py * ow + px] = Math.max(0, Math.min(255, Math.round(s / 4 + 128)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function jpeg(b) {
|
|
143
|
+
const qt = [];
|
|
144
|
+
const dcT = [], acT = [];
|
|
145
|
+
let w = 0, h = 0, restart = 0;
|
|
146
|
+
let comps = [];
|
|
147
|
+
let i = 2;
|
|
148
|
+
while (i < b.length) {
|
|
149
|
+
if (b[i] !== 0xff) {
|
|
150
|
+
i++;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const m = b[i + 1];
|
|
154
|
+
if (m === 0xd8 || m === 0x01 || (m >= 0xd0 && m <= 0xd7) || m === 0xff) {
|
|
155
|
+
i += m === 0xff ? 1 : 2;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (m === 0xd9)
|
|
159
|
+
break;
|
|
160
|
+
const len = b.readUInt16BE(i + 2), seg = b.subarray(i + 4, i + 2 + len);
|
|
161
|
+
if (m === 0xdb) {
|
|
162
|
+
let p = 0;
|
|
163
|
+
while (p < seg.length) {
|
|
164
|
+
const pq = seg[p] >> 4, tq = seg[p] & 15;
|
|
165
|
+
p++;
|
|
166
|
+
const t = new Int32Array(64);
|
|
167
|
+
for (let k = 0; k < 64; k++) {
|
|
168
|
+
t[ZZ[k]] = pq ? seg.readUInt16BE(p + k * 2) : seg[p + k];
|
|
169
|
+
}
|
|
170
|
+
p += pq ? 128 : 64;
|
|
171
|
+
qt[tq] = t;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else if (m === 0xc4) {
|
|
175
|
+
let p = 0;
|
|
176
|
+
while (p < seg.length) {
|
|
177
|
+
const tc = seg[p] >> 4, th = seg[p] & 15;
|
|
178
|
+
const counts = [...seg.subarray(p + 1, p + 17)];
|
|
179
|
+
const n = counts.reduce((s, x) => s + x, 0);
|
|
180
|
+
const t = buildHuff(counts, [...seg.subarray(p + 17, p + 17 + n)]);
|
|
181
|
+
if (tc === 0)
|
|
182
|
+
dcT[th] = t;
|
|
183
|
+
else
|
|
184
|
+
acT[th] = t;
|
|
185
|
+
p += 17 + n;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (m === 0xc0 || m === 0xc1) {
|
|
189
|
+
h = seg.readUInt16BE(1);
|
|
190
|
+
w = seg.readUInt16BE(3);
|
|
191
|
+
const n = seg[5];
|
|
192
|
+
comps = Array.from({ length: n }, (_, k) => ({ id: seg[6 + k * 3], h: seg[7 + k * 3] >> 4, v: seg[7 + k * 3] & 15, tq: seg[8 + k * 3], td: 0, ta: 0, pred: 0 }));
|
|
193
|
+
}
|
|
194
|
+
else if (m === 0xc2 || m === 0xc3 || (m >= 0xc5 && m <= 0xcf && m !== 0xc8 && m !== 0xcc)) {
|
|
195
|
+
throw new Error('progressive or lossless JPEG is not supported; take a screenshot (PNG) of the QR code instead');
|
|
196
|
+
}
|
|
197
|
+
else if (m === 0xdd)
|
|
198
|
+
restart = seg.readUInt16BE(0);
|
|
199
|
+
else if (m === 0xda) {
|
|
200
|
+
if (!w || !h || w * h > MAX_PIXELS)
|
|
201
|
+
throw new Error('the image is empty or too large');
|
|
202
|
+
const ns = seg[0];
|
|
203
|
+
const scan = Array.from({ length: ns }, (_, k) => { const c = comps.find((x) => x.id === seg[1 + k * 2]); c.td = seg[2 + k * 2] >> 4; c.ta = seg[2 + k * 2] & 15; return c; });
|
|
204
|
+
return scanData(b, i + 2 + len, w, h, comps, scan, qt, dcT, acT, restart);
|
|
205
|
+
}
|
|
206
|
+
i += 2 + len;
|
|
207
|
+
}
|
|
208
|
+
throw new Error('no image data in the JPEG');
|
|
209
|
+
}
|
|
210
|
+
function scanData(b, start, w, h, comps, scan, qt, dcT, acT, restart) {
|
|
211
|
+
const hmax = Math.max(...comps.map((c) => c.h)), vmax = Math.max(...comps.map((c) => c.v));
|
|
212
|
+
const y0 = comps[0];
|
|
213
|
+
// Luminance plane at its own resolution; scaled to full size at the end when subsampled.
|
|
214
|
+
const lw = Math.ceil((w * y0.h) / hmax), lh = Math.ceil((h * y0.v) / vmax);
|
|
215
|
+
const plane = new Uint8Array(lw * lh);
|
|
216
|
+
let pos = start, bitBuf = 0, bitCnt = 0;
|
|
217
|
+
const readBit = () => {
|
|
218
|
+
if (bitCnt === 0) {
|
|
219
|
+
let byte = b[pos++] ?? 0;
|
|
220
|
+
if (byte === 0xff) {
|
|
221
|
+
const nx = b[pos];
|
|
222
|
+
if (nx === 0)
|
|
223
|
+
pos++;
|
|
224
|
+
else if (nx !== undefined && nx >= 0xd0 && nx <= 0xd7) { /* marker: handled by restart */ }
|
|
225
|
+
}
|
|
226
|
+
bitBuf = byte;
|
|
227
|
+
bitCnt = 8;
|
|
228
|
+
if (byte === undefined)
|
|
229
|
+
byte = 0;
|
|
230
|
+
}
|
|
231
|
+
bitCnt--;
|
|
232
|
+
return (bitBuf >> bitCnt) & 1;
|
|
233
|
+
};
|
|
234
|
+
const receive = (n) => { let v = 0; for (let k = 0; k < n; k++)
|
|
235
|
+
v = (v << 1) | readBit(); return v; };
|
|
236
|
+
const extend = (v, n) => (n && v < 1 << (n - 1) ? v - (1 << n) + 1 : v);
|
|
237
|
+
const decode = (t) => { let code = 0; for (let len = 1; len <= 16; len++) {
|
|
238
|
+
code = (code << 1) | readBit();
|
|
239
|
+
const s = t.lookup[len].get(code);
|
|
240
|
+
if (s !== undefined)
|
|
241
|
+
return s;
|
|
242
|
+
} throw new Error('bad Huffman code in JPEG'); };
|
|
243
|
+
const block = new Float32Array(64);
|
|
244
|
+
const mcuX = Math.ceil(w / (8 * hmax)), mcuY = Math.ceil(h / (8 * vmax));
|
|
245
|
+
const single = scan.length === 1;
|
|
246
|
+
const blocksX = single ? Math.ceil(lw / 8) : mcuX, blocksY = single ? Math.ceil(lh / 8) : mcuY;
|
|
247
|
+
let mcus = 0;
|
|
248
|
+
const doBlock = (c, bx, by) => {
|
|
249
|
+
block.fill(0);
|
|
250
|
+
const s = decode(dcT[c.td]);
|
|
251
|
+
c.pred += s ? extend(receive(s), s) : 0;
|
|
252
|
+
const q = qt[c.tq];
|
|
253
|
+
block[0] = c.pred * q[0];
|
|
254
|
+
for (let k = 1; k < 64;) {
|
|
255
|
+
const rs = decode(acT[c.ta]), r = rs >> 4, sz = rs & 15;
|
|
256
|
+
if (!sz) {
|
|
257
|
+
if (r === 15) {
|
|
258
|
+
k += 16;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
k += r;
|
|
264
|
+
if (k > 63)
|
|
265
|
+
break;
|
|
266
|
+
block[ZZ[k]] = extend(receive(sz), sz) * q[ZZ[k]];
|
|
267
|
+
k++;
|
|
268
|
+
}
|
|
269
|
+
if (c === y0)
|
|
270
|
+
idct(block, plane, lw, bx * 8, by * 8, lh);
|
|
271
|
+
};
|
|
272
|
+
for (let my = 0; my < blocksY; my++)
|
|
273
|
+
for (let mx = 0; mx < blocksX; mx++) {
|
|
274
|
+
if (restart && mcus && mcus % restart === 0) {
|
|
275
|
+
bitCnt = 0;
|
|
276
|
+
while (pos < b.length && !(b[pos] === 0xff && b[pos + 1] >= 0xd0 && b[pos + 1] <= 0xd7))
|
|
277
|
+
pos++;
|
|
278
|
+
pos += 2;
|
|
279
|
+
for (const c of comps)
|
|
280
|
+
c.pred = 0;
|
|
281
|
+
}
|
|
282
|
+
if (single)
|
|
283
|
+
doBlock(scan[0], mx, my);
|
|
284
|
+
else
|
|
285
|
+
for (const c of scan)
|
|
286
|
+
for (let v = 0; v < c.v; v++)
|
|
287
|
+
for (let u = 0; u < c.h; u++)
|
|
288
|
+
doBlock(c, mx * c.h + u, my * c.v + v);
|
|
289
|
+
mcus++;
|
|
290
|
+
}
|
|
291
|
+
if (lw === w && lh === h)
|
|
292
|
+
return { width: w, height: h, data: plane };
|
|
293
|
+
const out = new Uint8Array(w * h);
|
|
294
|
+
for (let y = 0; y < h; y++)
|
|
295
|
+
for (let x = 0; x < w; x++)
|
|
296
|
+
out[y * w + x] = plane[Math.min(lh - 1, Math.floor((y * lh) / h)) * lw + Math.min(lw - 1, Math.floor((x * lw) / w))];
|
|
297
|
+
return { width: w, height: h, data: out };
|
|
298
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Links Oculon is asked to open itself (page checks, archiving) must point at the public internet:
|
|
3
|
+
* http or https, a real host name, no IP literals, no internal names, no odd ports.
|
|
4
|
+
*/
|
|
5
|
+
export function publicUrl(input) {
|
|
6
|
+
let s = input.trim();
|
|
7
|
+
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(s))
|
|
8
|
+
s = `https://${s}`;
|
|
9
|
+
let u;
|
|
10
|
+
try {
|
|
11
|
+
u = new URL(s);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new Error('not a valid link');
|
|
15
|
+
}
|
|
16
|
+
if (u.protocol !== 'https:' && u.protocol !== 'http:')
|
|
17
|
+
throw new Error('only http and https links are opened');
|
|
18
|
+
const h = u.hostname.toLowerCase();
|
|
19
|
+
if (!h.includes('.') || /^(\d+\.){3}\d+$|^\[|^0x|^localhost$|\.(local|internal|localhost|lan|home|corp|arpa)$/.test(h))
|
|
20
|
+
throw new Error('only links to public hosts are opened');
|
|
21
|
+
if (u.port && !['80', '443', '8080', '8443'].includes(u.port))
|
|
22
|
+
throw new Error('only standard web ports are opened');
|
|
23
|
+
u.username = '';
|
|
24
|
+
u.password = '';
|
|
25
|
+
return u;
|
|
26
|
+
}
|
package/dist/core/verdict.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* apps, PDF reports, "seen before" changes and brief mode, so every check gets them without its own code.
|
|
4
4
|
* Results differ per module; this reads the fields they share (verdict, risk, level, reasons, flags, warnings).
|
|
5
5
|
*/
|
|
6
|
-
const BAD = /\b(likely scam|scam|malicious|danger|dangerous|spoof|spoofed|high|critical|not valid|invalid|leaked|likely edited|edited|sanction|sanctioned|honeypot|cannot sell|vulnerable|exploited|unprotected|not protected|fake|fraud)\b/i;
|
|
6
|
+
const BAD = /\b(likely scam|scam|malicious|danger|dangerous|spoof|spoofed|high|critical|not valid|invalid|leaked|likely edited|edited|sanction|sanctioned|honeypot|poisoned|cannot sell|vulnerable|exploited|unprotected|not protected|fake|fraud)\b/i;
|
|
7
7
|
const WARN = /\b(suspicious|caution|medium|moderate|partly|warn|warning|signs of|unknown|unverified|elevated|risky|check)\b/i;
|
|
8
8
|
const OK = /\b(ok|safe|valid|protected|clean|low|no known|not found|none found|no signs|legit|genuine|active|operational|no recalls)\b/i;
|
|
9
9
|
export function toneOf(verdict, risk) {
|
package/dist/core/zip.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal ZIP reader (central directory, stored and deflated entries) for Office files, which are ZIP packages.
|
|
3
|
+
* Entries are read lazily; sizes are capped so a zip bomb cannot exhaust memory.
|
|
4
|
+
*/
|
|
5
|
+
import { inflateRawSync } from 'node:zlib';
|
|
6
|
+
const MAX_ENTRY = 40 * 1024 * 1024;
|
|
7
|
+
export function zipEntries(b) {
|
|
8
|
+
let eocd = -1;
|
|
9
|
+
for (let i = b.length - 22; i >= Math.max(0, b.length - 66_000); i--)
|
|
10
|
+
if (b.readUInt32LE(i) === 0x06054b50) {
|
|
11
|
+
eocd = i;
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
if (eocd < 0)
|
|
15
|
+
throw new Error('not a valid ZIP package');
|
|
16
|
+
const n = b.readUInt16LE(eocd + 10);
|
|
17
|
+
let p = b.readUInt32LE(eocd + 16);
|
|
18
|
+
const out = [];
|
|
19
|
+
for (let k = 0; k < n && p + 46 <= b.length; k++) {
|
|
20
|
+
if (b.readUInt32LE(p) !== 0x02014b50)
|
|
21
|
+
break;
|
|
22
|
+
const method = b.readUInt16LE(p + 10), csize = b.readUInt32LE(p + 20), size = b.readUInt32LE(p + 24);
|
|
23
|
+
const nl = b.readUInt16LE(p + 28), el = b.readUInt16LE(p + 30), cl = b.readUInt16LE(p + 32);
|
|
24
|
+
const offset = b.readUInt32LE(p + 42);
|
|
25
|
+
out.push({ name: b.toString('utf8', p + 46, p + 46 + nl), method, size, csize, offset });
|
|
26
|
+
p += 46 + nl + el + cl;
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
export function zipRead(b, e) {
|
|
31
|
+
if (e.size > MAX_ENTRY || e.offset + 30 > b.length)
|
|
32
|
+
return null;
|
|
33
|
+
const nl = b.readUInt16LE(e.offset + 26), el = b.readUInt16LE(e.offset + 28);
|
|
34
|
+
const start = e.offset + 30 + nl + el;
|
|
35
|
+
const data = b.subarray(start, start + e.csize);
|
|
36
|
+
try {
|
|
37
|
+
if (e.method === 0)
|
|
38
|
+
return data;
|
|
39
|
+
if (e.method === 8)
|
|
40
|
+
return inflateRawSync(data, { maxOutputLength: MAX_ENTRY });
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -288,6 +288,67 @@ export declare class Oculon {
|
|
|
288
288
|
addressCheck(address: string, opts?: {
|
|
289
289
|
network?: string;
|
|
290
290
|
}): Promise<ModuleResult<import("./modules/address.js").AddressReport>>;
|
|
291
|
+
/** Token and NFT approvals still active on a wallet, with risky spenders flagged (Ethereum, Arbitrum, Polygon). */
|
|
292
|
+
approvalsCheck(address: string, opts?: {
|
|
293
|
+
chain?: string;
|
|
294
|
+
}): Promise<ModuleResult<import("./modules/approvals.js").ApprovalsReport>>;
|
|
295
|
+
/** What the owner of a token contract can still do: mint, blacklist, taxes, upgrades, plus holders and liquidity. */
|
|
296
|
+
contractRisk(address: string, opts?: {
|
|
297
|
+
chain?: string;
|
|
298
|
+
}): Promise<ModuleResult<import("./modules/contract.js").ContractReport>>;
|
|
299
|
+
/** What a wallet signature request really allows: permits, Permit2, Seaport orders, approvals, calldata. */
|
|
300
|
+
signatureCheck(request: string, opts?: {
|
|
301
|
+
chain?: string;
|
|
302
|
+
to?: string;
|
|
303
|
+
}): Promise<ModuleResult<import("./modules/signature.js").SignatureReport>>;
|
|
304
|
+
/** Lookalike addresses, zero-value transfers and fake tokens planted in a wallet's history. */
|
|
305
|
+
poisoningCheck(address: string, opts?: {
|
|
306
|
+
chain?: string;
|
|
307
|
+
}): Promise<ModuleResult<import("./modules/poisoning.js").PoisoningReport>>;
|
|
308
|
+
/** Follow funds out of an address for a few hops, until exchanges, mixers, bridges or sanctioned addresses. */
|
|
309
|
+
traceFunds(address: string, opts?: {
|
|
310
|
+
chain?: string;
|
|
311
|
+
hops?: number;
|
|
312
|
+
width?: number;
|
|
313
|
+
}): Promise<ModuleResult<import("./modules/trace.js").TraceReport>>;
|
|
314
|
+
/** Was this image made by AI, edited, or taken with a camera? C2PA credentials, IPTC, generator settings, EXIF. */
|
|
315
|
+
imageCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/image.js").ImageReport>>;
|
|
316
|
+
/** Read the QR code in an image and check where it leads: link, crypto or bank payment, Wi-Fi. */
|
|
317
|
+
qrCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/qrcheck.js").QrReport>>;
|
|
318
|
+
/** Is this GitHub repo safe to run? Install hooks, remote code, wallet and browser theft, obfuscation, fake stars. */
|
|
319
|
+
repoCheck(repo: string): Promise<ModuleResult<import("./modules/repo.js").RepoReport>>;
|
|
320
|
+
/** One report for a domain: link check, email protection, exposure, lookalikes and the company. */
|
|
321
|
+
domainReport(domain: string): Promise<ModuleResult<import("./modules/report.js").FullReport>>;
|
|
322
|
+
/** One report for a wallet or token: address, approvals, poisoning, fund trace, or contract risk and sell test. */
|
|
323
|
+
walletReport(address: string, opts?: {
|
|
324
|
+
chain?: string;
|
|
325
|
+
}): Promise<ModuleResult<import("./modules/report.js").FullReport>>;
|
|
326
|
+
/** Open a page and look for wallet drainer code and phishing (forms, brand copies, Telegram exfiltration). */
|
|
327
|
+
siteCheck(url: string, opts?: {
|
|
328
|
+
browser?: boolean;
|
|
329
|
+
}): Promise<ModuleResult<import("./modules/site.js").SiteReport>>;
|
|
330
|
+
/** What happened in a transaction: function, token transfers, approvals, tokens taken with an earlier approval. */
|
|
331
|
+
explainTx(hash: string, opts?: {
|
|
332
|
+
chain?: string;
|
|
333
|
+
}): Promise<ModuleResult<import("./modules/txexplain.js").TxReport>>;
|
|
334
|
+
/** Who created a token and how many of their other tokens are dead (Ethereum, Arbitrum, Polygon). */
|
|
335
|
+
creatorCheck(token: string, opts?: {
|
|
336
|
+
chain?: string;
|
|
337
|
+
}): Promise<ModuleResult<import("./modules/deployer.js").DeployerReport>>;
|
|
338
|
+
/** A whole .eml email: headers, message and links, and every attachment through the matching check. */
|
|
339
|
+
emlCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/eml.js").EmlReport>>;
|
|
340
|
+
/** Is this Android app safe to install? Permissions, accessibility and SMS abuse, signer, known malware. */
|
|
341
|
+
apkCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/apk.js").ApkReport>>;
|
|
342
|
+
/** Is this job offer a scam? Fees, paid tasks, crypto pay, chat-only contact, test-task repos. */
|
|
343
|
+
jobCheck(message: string): Promise<ModuleResult<import("./modules/job.js").JobReport>>;
|
|
344
|
+
/** Where and when a photo was taken (EXIF GPS and time), the place, and the weather and daylight at that hour. */
|
|
345
|
+
whereCheck(file: Buffer, name?: string): Promise<ModuleResult<import("./modules/where.js").WhereReport>>;
|
|
346
|
+
/** Save a page as evidence in the Wayback Machine and record its hash, status and final address. */
|
|
347
|
+
archivePage(url: string): Promise<ModuleResult<import("./modules/archive.js").ArchiveReport>>;
|
|
348
|
+
/** What is behind a Telegram or Discord invite: members, age, verified badge, scam labels, impersonation. */
|
|
349
|
+
inviteCheck(link: string): Promise<ModuleResult<import("./modules/invite.js").InviteReport>>;
|
|
350
|
+
/** Robinhood Stock Tokens: official contract, live price, corporate actions; or whether an address is a fake one. */
|
|
351
|
+
stockToken(query?: string): Promise<ModuleResult<import("./modules/stocktoken.js").StockTokenReport>>;
|
|
291
352
|
/** Satellites: launches of the last 30 days, or one object's orbit, owner and status (CelesTrak). */
|
|
292
353
|
satellites(query?: string): Promise<ModuleResult<import("./modules/satellites.js").SatResult>>;
|
|
293
354
|
/** Airport status: METAR and TAF, FAA delays and ground stops (US), emergency squawks nearby. */
|
package/dist/index.js
CHANGED
|
@@ -79,6 +79,25 @@ import { lookalikes } from './modules/lookalike.js';
|
|
|
79
79
|
import { honeypotCheck } from './modules/honeypot.js';
|
|
80
80
|
import { addressCheck } from './modules/address.js';
|
|
81
81
|
import { satellites } from './modules/satellites.js';
|
|
82
|
+
import { approvalsCheck } from './modules/approvals.js';
|
|
83
|
+
import { contractRisk } from './modules/contract.js';
|
|
84
|
+
import { signatureCheck } from './modules/signature.js';
|
|
85
|
+
import { poisoningCheck } from './modules/poisoning.js';
|
|
86
|
+
import { traceFunds } from './modules/trace.js';
|
|
87
|
+
import { imageCheck } from './modules/image.js';
|
|
88
|
+
import { qrCheck } from './modules/qrcheck.js';
|
|
89
|
+
import { repoCheck } from './modules/repo.js';
|
|
90
|
+
import { domainReport, walletReport } from './modules/report.js';
|
|
91
|
+
import { siteCheck } from './modules/site.js';
|
|
92
|
+
import { explainTx } from './modules/txexplain.js';
|
|
93
|
+
import { deployerCheck } from './modules/deployer.js';
|
|
94
|
+
import { emlCheck } from './modules/eml.js';
|
|
95
|
+
import { apkCheck } from './modules/apk.js';
|
|
96
|
+
import { jobCheck } from './modules/job.js';
|
|
97
|
+
import { whereCheck } from './modules/where.js';
|
|
98
|
+
import { archivePage } from './modules/archive.js';
|
|
99
|
+
import { inviteCheck } from './modules/invite.js';
|
|
100
|
+
import { stockToken } from './modules/stocktoken.js';
|
|
82
101
|
export class Oculon {
|
|
83
102
|
ctx;
|
|
84
103
|
constructor(opts = {}) {
|
|
@@ -445,6 +464,86 @@ export class Oculon {
|
|
|
445
464
|
addressCheck(address, opts = {}) {
|
|
446
465
|
return addressCheck(this.ctx, address, opts);
|
|
447
466
|
}
|
|
467
|
+
/** Token and NFT approvals still active on a wallet, with risky spenders flagged (Ethereum, Arbitrum, Polygon). */
|
|
468
|
+
approvalsCheck(address, opts = {}) {
|
|
469
|
+
return approvalsCheck(this.ctx, address, opts);
|
|
470
|
+
}
|
|
471
|
+
/** What the owner of a token contract can still do: mint, blacklist, taxes, upgrades, plus holders and liquidity. */
|
|
472
|
+
contractRisk(address, opts = {}) {
|
|
473
|
+
return contractRisk(this.ctx, address, opts);
|
|
474
|
+
}
|
|
475
|
+
/** What a wallet signature request really allows: permits, Permit2, Seaport orders, approvals, calldata. */
|
|
476
|
+
signatureCheck(request, opts = {}) {
|
|
477
|
+
return signatureCheck(this.ctx, request, opts);
|
|
478
|
+
}
|
|
479
|
+
/** Lookalike addresses, zero-value transfers and fake tokens planted in a wallet's history. */
|
|
480
|
+
poisoningCheck(address, opts = {}) {
|
|
481
|
+
return poisoningCheck(this.ctx, address, opts);
|
|
482
|
+
}
|
|
483
|
+
/** Follow funds out of an address for a few hops, until exchanges, mixers, bridges or sanctioned addresses. */
|
|
484
|
+
traceFunds(address, opts = {}) {
|
|
485
|
+
return traceFunds(this.ctx, address, opts);
|
|
486
|
+
}
|
|
487
|
+
/** Was this image made by AI, edited, or taken with a camera? C2PA credentials, IPTC, generator settings, EXIF. */
|
|
488
|
+
imageCheck(file, name) {
|
|
489
|
+
return imageCheck(this.ctx, file, name);
|
|
490
|
+
}
|
|
491
|
+
/** Read the QR code in an image and check where it leads: link, crypto or bank payment, Wi-Fi. */
|
|
492
|
+
qrCheck(file, name) {
|
|
493
|
+
return qrCheck(this.ctx, file, name);
|
|
494
|
+
}
|
|
495
|
+
/** Is this GitHub repo safe to run? Install hooks, remote code, wallet and browser theft, obfuscation, fake stars. */
|
|
496
|
+
repoCheck(repo) {
|
|
497
|
+
return repoCheck(this.ctx, repo);
|
|
498
|
+
}
|
|
499
|
+
/** One report for a domain: link check, email protection, exposure, lookalikes and the company. */
|
|
500
|
+
domainReport(domain) {
|
|
501
|
+
return domainReport(this.ctx, domain);
|
|
502
|
+
}
|
|
503
|
+
/** One report for a wallet or token: address, approvals, poisoning, fund trace, or contract risk and sell test. */
|
|
504
|
+
walletReport(address, opts = {}) {
|
|
505
|
+
return walletReport(this.ctx, address, opts);
|
|
506
|
+
}
|
|
507
|
+
/** Open a page and look for wallet drainer code and phishing (forms, brand copies, Telegram exfiltration). */
|
|
508
|
+
siteCheck(url, opts = {}) {
|
|
509
|
+
return siteCheck(this.ctx, url, opts);
|
|
510
|
+
}
|
|
511
|
+
/** What happened in a transaction: function, token transfers, approvals, tokens taken with an earlier approval. */
|
|
512
|
+
explainTx(hash, opts = {}) {
|
|
513
|
+
return explainTx(this.ctx, hash, opts);
|
|
514
|
+
}
|
|
515
|
+
/** Who created a token and how many of their other tokens are dead (Ethereum, Arbitrum, Polygon). */
|
|
516
|
+
creatorCheck(token, opts = {}) {
|
|
517
|
+
return deployerCheck(this.ctx, token, opts);
|
|
518
|
+
}
|
|
519
|
+
/** A whole .eml email: headers, message and links, and every attachment through the matching check. */
|
|
520
|
+
emlCheck(file, name) {
|
|
521
|
+
return emlCheck(this.ctx, file, name);
|
|
522
|
+
}
|
|
523
|
+
/** Is this Android app safe to install? Permissions, accessibility and SMS abuse, signer, known malware. */
|
|
524
|
+
apkCheck(file, name) {
|
|
525
|
+
return apkCheck(this.ctx, file, name);
|
|
526
|
+
}
|
|
527
|
+
/** Is this job offer a scam? Fees, paid tasks, crypto pay, chat-only contact, test-task repos. */
|
|
528
|
+
jobCheck(message) {
|
|
529
|
+
return jobCheck(this.ctx, message);
|
|
530
|
+
}
|
|
531
|
+
/** Where and when a photo was taken (EXIF GPS and time), the place, and the weather and daylight at that hour. */
|
|
532
|
+
whereCheck(file, name) {
|
|
533
|
+
return whereCheck(this.ctx, file, name);
|
|
534
|
+
}
|
|
535
|
+
/** Save a page as evidence in the Wayback Machine and record its hash, status and final address. */
|
|
536
|
+
archivePage(url) {
|
|
537
|
+
return archivePage(this.ctx, url);
|
|
538
|
+
}
|
|
539
|
+
/** What is behind a Telegram or Discord invite: members, age, verified badge, scam labels, impersonation. */
|
|
540
|
+
inviteCheck(link) {
|
|
541
|
+
return inviteCheck(this.ctx, link);
|
|
542
|
+
}
|
|
543
|
+
/** Robinhood Stock Tokens: official contract, live price, corporate actions; or whether an address is a fake one. */
|
|
544
|
+
stockToken(query = '') {
|
|
545
|
+
return stockToken(this.ctx, query);
|
|
546
|
+
}
|
|
448
547
|
/** Satellites: launches of the last 30 days, or one object's orbit, owner and status (CelesTrak). */
|
|
449
548
|
satellites(query = '') {
|
|
450
549
|
return satellites(this.ctx, query);
|