oculon 0.1.6 → 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 +93 -17
- package/dist/cli/main.js +397 -0
- package/dist/core/calls.d.ts +63 -0
- package/dist/core/calls.js +120 -0
- package/dist/core/der.d.ts +2 -0
- package/dist/core/der.js +17 -0
- package/dist/core/http.d.ts +30 -1
- package/dist/core/http.js +133 -29
- package/dist/core/pdf.d.ts +51 -0
- package/dist/core/pdf.js +211 -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.d.ts +30 -0
- package/dist/core/verdict.js +164 -0
- package/dist/core/zip.d.ts +9 -0
- package/dist/core/zip.js +46 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.js +128 -0
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.js +256 -6
- 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.d.ts +59 -0
- package/dist/modules/checks.js +167 -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 +83 -0
- package/dist/modules/doc.js +841 -0
- 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/utility.d.ts +27 -1
- package/dist/modules/utility.js +108 -11
- package/dist/modules/where.d.ts +63 -0
- package/dist/modules/where.js +165 -0
- package/dist/report-pdf.d.ts +7 -0
- package/dist/report-pdf.js +84 -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/card.d.ts +28 -0
- package/dist/web/card.js +75 -0
- package/dist/web/docs.html +1 -1
- package/dist/web/index.html +213 -5
- 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 +15 -0
- package/dist/web/pages.d.ts +24 -0
- package/dist/web/pages.js +139 -0
- package/dist/web/public.js +16 -1
- package/dist/web/server.d.ts +13 -0
- package/dist/web/server.js +152 -13
- package/dist/web/token.html +25 -4
- package/dist/web/token.json +12 -1
- package/dist/web/utility.html +40 -14
- package/package.json +2 -2
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { codeAt, EVM_CHAINS, evmChain, formatUnits, isAddr, labelOf, sourcify, tokenMeta, UNLIMITED, wordAddr, wordInt } from '../sources/evm.js';
|
|
2
|
+
import { decodeSelectors } from '../sources/signatures.js';
|
|
3
|
+
const big = (v) => { try {
|
|
4
|
+
return v === undefined || v === null || v === '' ? null : BigInt(String(v));
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return null;
|
|
8
|
+
} };
|
|
9
|
+
const isUnl = (v) => v !== null && v >= UNLIMITED;
|
|
10
|
+
const when = (s) => { const n = Number(s); return !n ? null : n > 1e12 ? new Date(n).toISOString().slice(0, 10) : new Date(n * 1000).toISOString().slice(0, 10); };
|
|
11
|
+
const farFuture = (s) => { const n = Number(s); return !n || n > Date.now() / 1000 + 365 * 86_400 * 5; };
|
|
12
|
+
async function party(x, address, role) {
|
|
13
|
+
const a = String(address).toLowerCase();
|
|
14
|
+
if (!isAddr(a) || x.parties.some((p) => p.address === a && p.role === role))
|
|
15
|
+
return;
|
|
16
|
+
const name = labelOf(a);
|
|
17
|
+
let type = name ? 'known' : null;
|
|
18
|
+
if (!name && x.chain) {
|
|
19
|
+
const code = await codeAt(x.ctx, x.chain, a);
|
|
20
|
+
if (code === '0x' || (code && /^0xef0100/i.test(code)))
|
|
21
|
+
type = 'wallet';
|
|
22
|
+
else if (code)
|
|
23
|
+
type = (await sourcify(x.ctx, x.chain, a)).data ? 'verified contract' : 'unverified contract';
|
|
24
|
+
}
|
|
25
|
+
x.parties.push({ address: a, role, name, type });
|
|
26
|
+
if (/spender|operator|receiver of your assets/.test(role)) {
|
|
27
|
+
if (type === 'wallet')
|
|
28
|
+
x.reasons.push([`the ${role} is a plain wallet, not an app contract: this is how drainers collect approvals`, 45]);
|
|
29
|
+
if (type === 'unverified contract')
|
|
30
|
+
x.reasons.push([`the ${role} is a contract with unpublished code`, 25]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function tokenLabel(x, token) {
|
|
34
|
+
if (!x.chain || !isAddr(token))
|
|
35
|
+
return { sym: String(token).slice(0, 12), dec: null };
|
|
36
|
+
const m = await tokenMeta(x.ctx, x.chain, token);
|
|
37
|
+
return { sym: m.symbol ?? token.slice(0, 10), dec: m.decimals };
|
|
38
|
+
}
|
|
39
|
+
async function typed(x, d) {
|
|
40
|
+
const pt = String(d.primaryType ?? '');
|
|
41
|
+
const m = (d.message ?? {});
|
|
42
|
+
const dom = (d.domain ?? {});
|
|
43
|
+
const vc = String(dom.verifyingContract ?? '').toLowerCase();
|
|
44
|
+
if (dom.chainId && !x.chain) {
|
|
45
|
+
const id = Number(dom.chainId);
|
|
46
|
+
const k = Object.values(EVM_CHAINS).find((c) => c.id === id);
|
|
47
|
+
if (k)
|
|
48
|
+
x.chain = k;
|
|
49
|
+
}
|
|
50
|
+
if (pt === 'Permit' && m.spender) {
|
|
51
|
+
const t = await tokenLabel(x, vc);
|
|
52
|
+
const allowed = m.allowed !== undefined ? Boolean(m.allowed) : null;
|
|
53
|
+
const v = allowed === null ? big(m.value) : allowed ? 1n << 255n : 0n;
|
|
54
|
+
const amt = isUnl(v) ? `all your ${t.sym}` : `${formatUnits(v ?? 0n, t.dec)} ${t.sym}`;
|
|
55
|
+
x.allows.push(`${m.spender} can take ${amt} from your wallet${m.deadline || m.expiry ? `, until ${when(m.deadline ?? m.expiry) ?? 'forever'}` : ''}, with no further transaction from you`);
|
|
56
|
+
if (isUnl(v))
|
|
57
|
+
x.reasons.push(['unlimited permit: the spender can take every token of this kind, now and later', 35]);
|
|
58
|
+
if (farFuture(m.deadline ?? m.expiry))
|
|
59
|
+
x.reasons.push(['the permit never expires (or not for years)', 10]);
|
|
60
|
+
x.reasons.push(['permits move no tokens when signed, so wallets often show them as harmless; they are the most common drain signature', 15]);
|
|
61
|
+
await party(x, m.spender, 'spender');
|
|
62
|
+
return `Token permit (${t.sym})`;
|
|
63
|
+
}
|
|
64
|
+
if ((pt === 'PermitSingle' || pt === 'PermitBatch') && m.spender) {
|
|
65
|
+
const det = (Array.isArray(m.details) ? m.details : [m.details]).filter(Boolean);
|
|
66
|
+
for (const dd of det) {
|
|
67
|
+
const t = await tokenLabel(x, String(dd.token));
|
|
68
|
+
const v = big(dd.amount);
|
|
69
|
+
x.allows.push(`${m.spender} can take ${isUnl(v) ? `all your ${t.sym}` : `${formatUnits(v ?? 0n, t.dec)} ${t.sym}`} through Permit2, until ${when(dd.expiration) ?? 'forever'}`);
|
|
70
|
+
if (isUnl(v))
|
|
71
|
+
x.reasons.push([`unlimited Permit2 allowance for ${t.sym}`, 30]);
|
|
72
|
+
}
|
|
73
|
+
if (det.length > 1)
|
|
74
|
+
x.reasons.push([`${det.length} tokens in one signature: drainers bundle every token they found in the wallet`, 25]);
|
|
75
|
+
await party(x, m.spender, 'spender');
|
|
76
|
+
return `Permit2 allowance (${det.length} token${det.length > 1 ? 's' : ''})`;
|
|
77
|
+
}
|
|
78
|
+
if (/^Permit(Batch)?(Witness)?TransferFrom$/.test(pt) && m.spender) {
|
|
79
|
+
const perm = (Array.isArray(m.permitted) ? m.permitted : [m.permitted]).filter(Boolean);
|
|
80
|
+
for (const p of perm) {
|
|
81
|
+
const t = await tokenLabel(x, String(p.token));
|
|
82
|
+
x.allows.push(`${m.spender} can transfer ${formatUnits(big(p.amount) ?? 0n, t.dec)} ${t.sym} out of your wallet once, before ${when(m.deadline) ?? 'the deadline'}`);
|
|
83
|
+
}
|
|
84
|
+
if (perm.length > 2)
|
|
85
|
+
x.reasons.push([`${perm.length} tokens moved in one signature`, 25]);
|
|
86
|
+
await party(x, m.spender, 'spender');
|
|
87
|
+
return 'Permit2 signature transfer';
|
|
88
|
+
}
|
|
89
|
+
if (pt === 'OrderComponents' || (m.offer && m.consideration)) {
|
|
90
|
+
const offer = (m.offer ?? []), cons = (m.consideration ?? []);
|
|
91
|
+
const offerer = String(m.offerer ?? '').toLowerCase();
|
|
92
|
+
const toYou = cons.filter((c) => String(c.recipient ?? '').toLowerCase() === offerer);
|
|
93
|
+
const desc = (i) => `${[0].includes(Number(i.itemType)) ? 'native coin' : [1].includes(Number(i.itemType)) ? 'tokens' : 'NFT'} ${i.token ? String(i.token).slice(0, 10) : ''}${i.identifierOrCriteria && Number(i.itemType) >= 2 ? ` #${String(i.identifierOrCriteria).slice(0, 12)}` : ''} x${i.startAmount ?? i.endAmount ?? '?'}`;
|
|
94
|
+
for (const o of offer)
|
|
95
|
+
x.allows.push(`you give: ${desc(o)}`);
|
|
96
|
+
for (const c of cons)
|
|
97
|
+
x.allows.push(`${String(c.recipient ?? '').toLowerCase() === offerer ? 'you get' : `${String(c.recipient).slice(0, 10)}... gets`}: ${desc(c)}`);
|
|
98
|
+
const youGet = toYou.reduce((s, c) => s + (big(c.startAmount) ?? 0n), 0n);
|
|
99
|
+
if (offer.length && (!toYou.length || youGet === 0n))
|
|
100
|
+
x.reasons.push(['you give assets and get nothing back: this listing hands them over for free', 70]);
|
|
101
|
+
if (offer.length >= 3)
|
|
102
|
+
x.reasons.push([`${offer.length} items offered in one order`, 15]);
|
|
103
|
+
for (const c of cons.filter((c) => String(c.recipient ?? '').toLowerCase() !== offerer).slice(0, 3))
|
|
104
|
+
await party(x, String(c.recipient), 'receiver of your assets');
|
|
105
|
+
return 'Marketplace order (Seaport)';
|
|
106
|
+
}
|
|
107
|
+
// Any other typed message: list the addresses and amounts it names.
|
|
108
|
+
const addrs = JSON.stringify(m).match(/0x[0-9a-fA-F]{40}/g) ?? [];
|
|
109
|
+
for (const a of [...new Set(addrs)].slice(0, 4))
|
|
110
|
+
await party(x, a, 'named in the message');
|
|
111
|
+
x.allows.push(`a "${pt || 'typed'}" message for ${dom.name ?? 'an app'}${vc ? ` (contract ${vc})` : ''}`);
|
|
112
|
+
if (/order|permit|approv|transfer|withdraw|delegat/i.test(pt))
|
|
113
|
+
x.reasons.push([`"${pt}" messages can move or allow assets; only sign it on the app's real site`, 20]);
|
|
114
|
+
return `Typed message (${pt || 'unknown'})`;
|
|
115
|
+
}
|
|
116
|
+
const SELECTORS = {
|
|
117
|
+
'0x095ea7b3': 'approve', '0x39509351': 'increaseAllowance', '0xa22cb465': 'setApprovalForAll', '0xa9059cbb': 'transfer', '0x23b872dd': 'transferFrom',
|
|
118
|
+
'0x42842e0e': 'safeTransferFrom', '0xb88d4fde': 'safeTransferFrom', '0xf242432a': 'safeTransferFrom (1155)', '0x2eb2c2d6': 'safeBatchTransferFrom', '0x87517c45': 'Permit2 approve',
|
|
119
|
+
'0xac9650d8': 'multicall', '0x5ae401dc': 'multicall', '0xd505accf': 'permit',
|
|
120
|
+
};
|
|
121
|
+
async function calldata(x, data, to, value, depth = 0) {
|
|
122
|
+
const sel = data.slice(0, 10).toLowerCase();
|
|
123
|
+
const args = data.slice(10);
|
|
124
|
+
const name = SELECTORS[sel];
|
|
125
|
+
const t = to ? await tokenLabel(x, to) : { sym: 'the token', dec: null };
|
|
126
|
+
if (sel === '0x095ea7b3' || sel === '0x39509351') {
|
|
127
|
+
const spender = wordAddr(args, 0), v = wordInt(args, 1);
|
|
128
|
+
if (v === 0n) {
|
|
129
|
+
x.allows.push(`removes the approval of ${spender} for ${t.sym}`);
|
|
130
|
+
return 'Revoke approval';
|
|
131
|
+
}
|
|
132
|
+
x.allows.push(`${spender} can take ${isUnl(v) ? `all your ${t.sym}, now and later` : `${formatUnits(v, t.dec)} ${t.sym}`}`);
|
|
133
|
+
if (isUnl(v))
|
|
134
|
+
x.reasons.push(['unlimited approval', 20]);
|
|
135
|
+
await party(x, spender, 'spender');
|
|
136
|
+
return `${name} (${t.sym})`;
|
|
137
|
+
}
|
|
138
|
+
if (sel === '0xa22cb465') {
|
|
139
|
+
const op = wordAddr(args, 0), on = wordInt(args, 1) !== 0n;
|
|
140
|
+
if (!on) {
|
|
141
|
+
x.allows.push(`removes ${op} as operator`);
|
|
142
|
+
return 'Revoke NFT approval';
|
|
143
|
+
}
|
|
144
|
+
x.allows.push(`${op} can move every NFT you hold in collection ${to ?? ''}, now and later`);
|
|
145
|
+
x.reasons.push(['approval for all NFTs in a collection: the most common NFT drain', 35]);
|
|
146
|
+
await party(x, op, 'operator');
|
|
147
|
+
return 'Approve all NFTs';
|
|
148
|
+
}
|
|
149
|
+
if (sel === '0xa9059cbb') {
|
|
150
|
+
const rcp = wordAddr(args, 0), v = wordInt(args, 1);
|
|
151
|
+
x.allows.push(`sends ${formatUnits(v, t.dec)} ${t.sym} to ${rcp}`);
|
|
152
|
+
await party(x, rcp, 'recipient');
|
|
153
|
+
return `Token transfer (${t.sym})`;
|
|
154
|
+
}
|
|
155
|
+
if (['0x23b872dd', '0x42842e0e', '0xb88d4fde', '0xf242432a'].includes(sel)) {
|
|
156
|
+
const from = wordAddr(args, 0), rcp = wordAddr(args, 1);
|
|
157
|
+
x.allows.push(`moves ${sel === '0x23b872dd' ? `${formatUnits(wordInt(args, 2), t.dec)} ${t.sym}` : `item #${wordInt(args, 2).toString().slice(0, 16)}`} from ${from} to ${rcp}`);
|
|
158
|
+
await party(x, rcp, 'recipient');
|
|
159
|
+
return name;
|
|
160
|
+
}
|
|
161
|
+
if (sel === '0x2eb2c2d6') {
|
|
162
|
+
x.allows.push(`moves a batch of items to ${wordAddr(args, 1)}`);
|
|
163
|
+
x.reasons.push(['batch transfer of many items', 20]);
|
|
164
|
+
await party(x, wordAddr(args, 1), 'recipient');
|
|
165
|
+
return name;
|
|
166
|
+
}
|
|
167
|
+
if (sel === '0x87517c45') {
|
|
168
|
+
const tok = wordAddr(args, 0), spender = wordAddr(args, 1), v = wordInt(args, 2);
|
|
169
|
+
const tl = await tokenLabel(x, tok);
|
|
170
|
+
x.allows.push(`${spender} can take ${isUnl(v) ? `all your ${tl.sym}` : `${formatUnits(v, tl.dec)} ${tl.sym}`} through Permit2 until ${when(wordInt(args, 3).toString()) ?? 'forever'}`);
|
|
171
|
+
await party(x, spender, 'spender');
|
|
172
|
+
return 'Permit2 approve';
|
|
173
|
+
}
|
|
174
|
+
if ((sel === '0xac9650d8' || sel === '0x5ae401dc') && depth === 0) {
|
|
175
|
+
const base = sel === '0x5ae401dc' ? 1 : 0;
|
|
176
|
+
const off = Number(wordInt(args, base)) / 32;
|
|
177
|
+
const n = Number(wordInt(args, off));
|
|
178
|
+
const inner = [];
|
|
179
|
+
for (let i = 0; i < Math.min(n, 12); i++) {
|
|
180
|
+
const o = off + 1 + Number(wordInt(args, off + 1 + i)) / 32;
|
|
181
|
+
const len = Number(wordInt(args, o));
|
|
182
|
+
const hex = args.slice((o + 1) * 64, (o + 1) * 64 + len * 2);
|
|
183
|
+
if (hex.length >= 8)
|
|
184
|
+
inner.push(await calldata(x, `0x${hex}`, to, 0n, 1));
|
|
185
|
+
}
|
|
186
|
+
return `Bundle of ${n} calls: ${inner.join(', ')}`;
|
|
187
|
+
}
|
|
188
|
+
// Unknown function: name it if a database knows it.
|
|
189
|
+
const d = await decodeSelectors(x.ctx, [sel]).catch(() => ({}));
|
|
190
|
+
const sig = d[sel] ?? null;
|
|
191
|
+
x.allows.push(`calls ${sig ?? `an unknown function ${sel}`} on ${to ?? 'a contract'}${value ? ` and sends ${formatUnits(value, 18)} ${x.chain?.native ?? 'ETH'}` : ''}`);
|
|
192
|
+
if (!sig)
|
|
193
|
+
x.reasons.push(['the function is not in any public signature database: nobody can say what it does', 20]);
|
|
194
|
+
if (value && sig && /^(claim|claimreward|claimrewards|claimairdrop|securityupdate|connect|verify|airdrop|mint)\b/i.test(sig) && !sig.includes(','))
|
|
195
|
+
x.reasons.push([`"${sig.split('(')[0]}" with a payment attached: a classic fake airdrop or "security update" drainer`, 40]);
|
|
196
|
+
if (to)
|
|
197
|
+
await party(x, to, 'contract called');
|
|
198
|
+
return sig ? `Call ${sig.split('(')[0]}` : 'Unknown call';
|
|
199
|
+
}
|
|
200
|
+
export async function signatureCheck(ctx, input, opts = {}) {
|
|
201
|
+
const raw = input.trim();
|
|
202
|
+
if (!raw)
|
|
203
|
+
throw new Error('paste the signature request: typed data JSON, transaction data (0x...), or the message');
|
|
204
|
+
if (raw.length > 100_000)
|
|
205
|
+
throw new Error('the request is too long (max 100,000 characters)');
|
|
206
|
+
const x = { ctx, chain: opts.chain ? evmChain(opts.chain) : null, parties: [], reasons: [], allows: [], prov: [] };
|
|
207
|
+
let kind = 'message', type = 'Plain message';
|
|
208
|
+
let parsed = null;
|
|
209
|
+
try {
|
|
210
|
+
parsed = JSON.parse(raw);
|
|
211
|
+
}
|
|
212
|
+
catch { }
|
|
213
|
+
if (parsed && Array.isArray(parsed.params))
|
|
214
|
+
parsed = parsed.params.find((p) => typeof p === 'object' || (typeof p === 'string' && p.trim().startsWith('{'))) ?? parsed;
|
|
215
|
+
if (typeof parsed === 'string') {
|
|
216
|
+
try {
|
|
217
|
+
parsed = JSON.parse(parsed);
|
|
218
|
+
}
|
|
219
|
+
catch { }
|
|
220
|
+
}
|
|
221
|
+
if (parsed && typeof parsed === 'object' && (parsed.primaryType || parsed.types)) {
|
|
222
|
+
kind = 'typed data';
|
|
223
|
+
type = await typed(x, parsed);
|
|
224
|
+
}
|
|
225
|
+
else if (parsed && typeof parsed === 'object' && typeof parsed.data === 'string') {
|
|
226
|
+
kind = 'transaction';
|
|
227
|
+
if (!x.chain && parsed.chainId) {
|
|
228
|
+
const id = Number(parsed.chainId);
|
|
229
|
+
x.chain = Object.values(EVM_CHAINS).find((c) => c.id === id) ?? null;
|
|
230
|
+
}
|
|
231
|
+
if (!x.chain)
|
|
232
|
+
x.chain = evmChain('eth');
|
|
233
|
+
const v = big(parsed.value) ?? 0n;
|
|
234
|
+
type = parsed.data.length >= 10 ? await calldata(x, parsed.data, parsed.to ? String(parsed.to).toLowerCase() : null, v) : 'Plain transfer';
|
|
235
|
+
if (parsed.data.length < 10 && parsed.to) {
|
|
236
|
+
x.allows.push(`sends ${formatUnits(v, 18)} ${x.chain.native} to ${parsed.to}`);
|
|
237
|
+
await party(x, parsed.to, 'recipient');
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (/^0x[0-9a-fA-F]{64}$/.test(raw)) {
|
|
241
|
+
kind = 'raw hash';
|
|
242
|
+
type = 'Raw hash (eth_sign)';
|
|
243
|
+
x.allows.push('nothing you can read: a raw hash can stand for any transaction, including one that empties the wallet');
|
|
244
|
+
x.reasons.push(['blind signature: a raw 32-byte hash hides what it authorizes. Legitimate apps do not ask for this', 75]);
|
|
245
|
+
}
|
|
246
|
+
else if (/^0x[0-9a-fA-F]{8,}$/.test(raw)) {
|
|
247
|
+
kind = 'transaction';
|
|
248
|
+
x.chain ??= evmChain('eth');
|
|
249
|
+
type = await calldata(x, raw, opts.to && isAddr(opts.to) ? opts.to.toLowerCase() : null, 0n);
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
let text = raw;
|
|
253
|
+
if (/^0x[0-9a-fA-F]+$/.test(raw)) {
|
|
254
|
+
try {
|
|
255
|
+
text = Buffer.from(raw.slice(2), 'hex').toString('utf8');
|
|
256
|
+
}
|
|
257
|
+
catch { }
|
|
258
|
+
}
|
|
259
|
+
x.allows.push(`signs the text: "${text.slice(0, 160)}${text.length > 160 ? '...' : ''}"`);
|
|
260
|
+
if (/seed|recovery phrase|private key|mnemonic/i.test(text))
|
|
261
|
+
x.reasons.push(['the message mentions your seed phrase or private key: no real app asks for that', 80]);
|
|
262
|
+
if (/sign.?in|login|log in|nonce|verify (your )?wallet|SIWE|wants you to sign in/i.test(text)) {
|
|
263
|
+
type = 'Sign-in message';
|
|
264
|
+
const dom = /^(\S+) wants you to sign in/m.exec(text)?.[1];
|
|
265
|
+
if (dom)
|
|
266
|
+
x.allows.push(`proves you own this wallet to ${dom}. Check that ${dom} is the site you are on`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const reasons = x.reasons.sort((a, b) => b[1] - a[1]);
|
|
270
|
+
const risk = Math.min(100, reasons.reduce((s, [, w]) => s + w, 0));
|
|
271
|
+
const verdict = risk >= 70 ? 'dangerous signature' : risk >= 40 ? 'risky signature' : risk >= 15 || kind === 'typed data' ? 'check before signing' : 'no known risk found';
|
|
272
|
+
const summary = x.allows[0] ?? type;
|
|
273
|
+
const advice = verdict === 'dangerous signature'
|
|
274
|
+
? ['Do not sign. Close the site.', 'If you already signed, revoke approvals right away (oculon approvals <wallet>) and move your funds to a new wallet.']
|
|
275
|
+
: verdict === 'risky signature'
|
|
276
|
+
? ['Only sign if you started this yourself on the real site of the app, and the spender is the app you expect.', 'Prefer a limited amount over unlimited.']
|
|
277
|
+
: ['Sign only on the site you meant to use. Typed messages and approvals can move assets later without another prompt.'];
|
|
278
|
+
return {
|
|
279
|
+
module: 'signature', input: raw.slice(0, 200), generatedAt: ctx.now().toISOString(),
|
|
280
|
+
result: { kind, type, verdict, risk, summary, allows: x.allows.slice(0, 20), reasons: reasons.map(([r]) => r), parties: x.parties, chain: x.chain?.label ?? null, advice },
|
|
281
|
+
signals: [], provenance: [{ source: 'oculon-signature', url: 'local', status: 'LIVE', fetchedAt: ctx.now().toISOString(), note: 'decoded locally; addresses and selectors looked up on chain' }, ...x.prov],
|
|
282
|
+
};
|
|
283
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site check: open a page the way a visitor would and look for what phishing pages and wallet drainers do.
|
|
3
|
+
* Drainers: wallet connection code next to signature requests that hand over assets (permits, Permit2,
|
|
4
|
+
* setApprovalForAll, unlimited approve, Seaport orders, eth_sign), a receiver address written into the
|
|
5
|
+
* script, token-balance APIs used to rank what to take first, and heavy obfuscation.
|
|
6
|
+
* Phishing: a login, card or seed-phrase form on a domain that is not the brand the page shows, forms that send
|
|
7
|
+
* to another domain, and Telegram bot tokens or Discord webhooks in the code (phishing kits send what people
|
|
8
|
+
* type there).
|
|
9
|
+
* Reputation: the link check (Safe Browsing, URLhaus, urlscan.io, domain age) of the final address after
|
|
10
|
+
* redirects, and lookalikes of well known apps and brands.
|
|
11
|
+
* Browser: when a Cloudflare URL Scanner token is set, the page is also opened in a real browser on Cloudflare's
|
|
12
|
+
* side, so scripts that load later, redirects done in JavaScript and the rendered page are read too, and
|
|
13
|
+
* Cloudflare's own verdict is added. Victims' reports on the domain come from Chainabuse.
|
|
14
|
+
* The page is fetched here with a normal browser User-Agent; scripts are read here, never run here.
|
|
15
|
+
*/
|
|
16
|
+
import type { Ctx } from '../core/context.js';
|
|
17
|
+
import type { ModuleResult } from '../core/types.js';
|
|
18
|
+
import { type AbuseReports } from '../sources/chainabuse.js';
|
|
19
|
+
export interface SiteReport {
|
|
20
|
+
url: string;
|
|
21
|
+
finalUrl: string;
|
|
22
|
+
domain: string;
|
|
23
|
+
title: string | null;
|
|
24
|
+
verdict: 'wallet drainer' | 'phishing page' | 'suspicious' | 'no known risk found';
|
|
25
|
+
risk: number;
|
|
26
|
+
drainer: string[];
|
|
27
|
+
phishing: string[];
|
|
28
|
+
reputation: {
|
|
29
|
+
verdict: string;
|
|
30
|
+
risk: number;
|
|
31
|
+
ageDays: number | null;
|
|
32
|
+
reasons: string[];
|
|
33
|
+
} | null;
|
|
34
|
+
forms: {
|
|
35
|
+
action: string;
|
|
36
|
+
password: boolean;
|
|
37
|
+
seed: boolean;
|
|
38
|
+
card: boolean;
|
|
39
|
+
external: boolean;
|
|
40
|
+
}[];
|
|
41
|
+
scripts: {
|
|
42
|
+
read: number;
|
|
43
|
+
external: string[];
|
|
44
|
+
};
|
|
45
|
+
/** The page opened in a real browser (Cloudflare URL Scanner), when configured. */
|
|
46
|
+
browser: {
|
|
47
|
+
malicious: boolean;
|
|
48
|
+
categories: string[];
|
|
49
|
+
report: string;
|
|
50
|
+
finalUrl: string | null;
|
|
51
|
+
domains: number;
|
|
52
|
+
scripts: number;
|
|
53
|
+
} | null;
|
|
54
|
+
/** Scam reports on the domain filed by victims (Chainabuse). */
|
|
55
|
+
reports: AbuseReports | null;
|
|
56
|
+
exfil: string[];
|
|
57
|
+
reasons: string[];
|
|
58
|
+
advice: string[];
|
|
59
|
+
}
|
|
60
|
+
export declare function siteCheck(ctx: Ctx, input: string, opts?: {
|
|
61
|
+
browser?: boolean;
|
|
62
|
+
}): Promise<ModuleResult<SiteReport>>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { publicUrl } from '../core/safeurl.js';
|
|
2
|
+
import { signalId } from '../core/text.js';
|
|
3
|
+
import { apexOf, urlCheck } from './urlcheck.js';
|
|
4
|
+
import { browserScan } from '../sources/cfurlscan.js';
|
|
5
|
+
import { chainabuse } from '../sources/chainabuse.js';
|
|
6
|
+
/** Brands and apps people are phished for, with the domains that really belong to them. */
|
|
7
|
+
const BRANDS = {
|
|
8
|
+
uniswap: ['uniswap.org'], opensea: ['opensea.io'], pancakeswap: ['pancakeswap.finance'], metamask: ['metamask.io'], blur: ['blur.io'],
|
|
9
|
+
lido: ['lido.fi'], aave: ['aave.com'], curve: ['curve.fi', 'curve.finance'], jupiter: ['jup.ag'], raydium: ['raydium.io'], 'pump.fun': ['pump.fun'],
|
|
10
|
+
'magic eden': ['magiceden.io'], arbitrum: ['arbitrum.io', 'arbitrum.foundation'], layerzero: ['layerzero.network'], zksync: ['zksync.io'],
|
|
11
|
+
eigenlayer: ['eigenlayer.xyz'], etherscan: ['etherscan.io'], coinbase: ['coinbase.com'], binance: ['binance.com'], phantom: ['phantom.app', 'phantom.com'],
|
|
12
|
+
rabby: ['rabby.io'], ledger: ['ledger.com'], trezor: ['trezor.io'], 'revoke.cash': ['revoke.cash'], kraken: ['kraken.com'], bybit: ['bybit.com'], okx: ['okx.com'],
|
|
13
|
+
paypal: ['paypal.com'], apple: ['apple.com', 'icloud.com'], microsoft: ['microsoft.com', 'live.com', 'office.com', 'microsoftonline.com'], google: ['google.com'],
|
|
14
|
+
amazon: ['amazon.com'], netflix: ['netflix.com'], facebook: ['facebook.com'], instagram: ['instagram.com'], whatsapp: ['whatsapp.com'], telegram: ['telegram.org', 't.me'],
|
|
15
|
+
dhl: ['dhl.com'], fedex: ['fedex.com'], usps: ['usps.com'], steam: ['steampowered.com', 'steamcommunity.com'], discord: ['discord.com'], docusign: ['docusign.com', 'docusign.net'],
|
|
16
|
+
};
|
|
17
|
+
const DRAIN = [
|
|
18
|
+
[/\b(receiver|recipient|drainTo|walletReceiver|receiveAddress)\s*[:=]\s*["'`]0x[0-9a-fA-F]{40}["'`]/, 'a receiver address is written into the script: where taken assets go', 35],
|
|
19
|
+
[/0x000000000022d473030f116ddee9f6b43ac78ba3/i, 'asks for Uniswap Permit2 signatures, which can hand over many tokens at once', 10],
|
|
20
|
+
[/\bPermitBatch\b|\bPermitSingle\b|primaryType["']?\s*:\s*["']Permit["']/, 'builds permit signatures in the page', 10],
|
|
21
|
+
[/a22cb465|setApprovalForAll/, 'asks to approve all NFTs of a collection (setApprovalForAll)', 5],
|
|
22
|
+
[/0x095ea7b3[\s\S]{0,400}f{40,}|approve\([^)]{0,120}(MaxUint256|MAX_UINT|maxUint|0xf{20,}|115792089237316195423570985008687907853269984665640564039457584007913129639935)/i, 'asks for unlimited token approvals', 10],
|
|
23
|
+
[/0x00000000000000adc04c56bf30ac9d3c0aaf14dc|0x0000000000000068f116a894984e2db1123eb395|OrderComponents/i, 'builds Seaport marketplace orders (a common way to take NFTs for nothing)', 5],
|
|
24
|
+
[/["']eth_sign["']/, 'uses eth_sign, which signs a blind hash', 5],
|
|
25
|
+
[/getWalletTokenBalances|ankr_getAccountBalance|getTokenBalances|alchemy_getTokenBalances|api\.debank|covalenthq|\/balances_v2\//i, 'reads the visitor\'s token balances to pick what to take first', 15],
|
|
26
|
+
[/signAllTransactions/, 'asks Solana wallets to sign all transactions at once', 5],
|
|
27
|
+
[/wallet_switchEthereumChain[\s\S]{0,2000}wallet_switchEthereumChain/, 'switches the wallet through several chains in a row', 5],
|
|
28
|
+
[/\bdrainer\b|inferno.?drainer|angel.?drainer|pink.?drainer|ms.?drainer|venom.?drainer/i, 'names a known drainer kit', 40],
|
|
29
|
+
];
|
|
30
|
+
/** Markers a normal app does not have; generic wallet-library strings alone never make a drainer verdict. */
|
|
31
|
+
const STRONG = /receiver address is written|known drainer kit|token balances to pick/;
|
|
32
|
+
const CONNECTS = /window\.ethereum|ethereum\.request|walletconnect|web3modal|@reown|wagmi|rainbowkit|solana\.connect|window\.solana|phantom\.solana/i;
|
|
33
|
+
const edits = (a, b) => {
|
|
34
|
+
const d = Array.from({ length: a.length + 1 }, (_, i) => [i, ...new Array(b.length).fill(0)]);
|
|
35
|
+
for (let j = 1; j <= b.length; j++)
|
|
36
|
+
d[0][j] = j;
|
|
37
|
+
for (let i = 1; i <= a.length; i++)
|
|
38
|
+
for (let j = 1; j <= b.length; j++)
|
|
39
|
+
d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
40
|
+
return d[a.length][b.length];
|
|
41
|
+
};
|
|
42
|
+
const attr = (tag, name) => new RegExp(`\\b${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, 'i').exec(tag)?.slice(1).find((x) => x !== undefined) ?? null;
|
|
43
|
+
export async function siteCheck(ctx, input, opts = {}) {
|
|
44
|
+
const u = publicUrl(input);
|
|
45
|
+
const provenance = [];
|
|
46
|
+
// The browser scan runs on Cloudflare while the page and its scripts are read here.
|
|
47
|
+
const scanning = opts.browser === false ? Promise.resolve({ data: null, prov: null }) : browserScan(ctx, u.href).catch(() => ({ data: null, prov: null }));
|
|
48
|
+
const page = await ctx.http.getPage(u.href, { source: 'site', timeoutMs: 25_000 });
|
|
49
|
+
provenance.push(page.prov);
|
|
50
|
+
if (!page.data)
|
|
51
|
+
throw new Error(`the page did not open (${page.prov.note ?? page.prov.status})`);
|
|
52
|
+
const finalUrl = page.data.finalUrl;
|
|
53
|
+
const fu = publicUrl(finalUrl);
|
|
54
|
+
const domain = apexOf(fu.hostname);
|
|
55
|
+
const scan = await scanning;
|
|
56
|
+
if (scan.prov)
|
|
57
|
+
provenance.push(scan.prov);
|
|
58
|
+
// The rendered page (after scripts ran) shows forms and text that the raw HTML may only build later.
|
|
59
|
+
const html = page.data.body.toString('utf8') + (scan.data?.dom ? `\n${scan.data.dom}` : '');
|
|
60
|
+
const lower = html.toLowerCase();
|
|
61
|
+
const title = /<title[^>]*>([^<]{1,200})<\/title>/i.exec(html)?.[1]?.trim() ?? /property=["']og:site_name["'][^>]*content=["']([^"']{1,100})/i.exec(html)?.[1] ?? null;
|
|
62
|
+
const drainer = [], phishing = [], exfil = [];
|
|
63
|
+
// Scripts: inline ones and up to 12 external files, read as text.
|
|
64
|
+
const inline = [...html.matchAll(/<script\b[^>]*>([\s\S]*?)<\/script>/gi)].map((m) => m[1]).join('\n');
|
|
65
|
+
const srcs = [...new Set([...html.matchAll(/<script\b[^>]*\bsrc\s*=\s*["']([^"']+)["']/gi)].map((m) => { try {
|
|
66
|
+
return new URL(m[1], finalUrl).href;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
} }).filter((x) => Boolean(x && /^https?:/.test(x))))];
|
|
71
|
+
const external = srcs.filter((s) => apexOf(new URL(s).hostname) !== domain).map((s) => new URL(s).hostname);
|
|
72
|
+
let js = inline, read = 0;
|
|
73
|
+
// Scripts the browser loaded that the raw page did not name (loaded by other scripts).
|
|
74
|
+
for (const extra of (scan.data?.scripts ?? []).filter((x) => !srcs.includes(x)).slice(0, 8))
|
|
75
|
+
srcs.push(extra);
|
|
76
|
+
const pick = srcs.filter((s) => !/googletagmanager|google-analytics|gstatic|cloudflareinsights|recaptcha|hotjar|clarity\.ms|facebook\.net|cdn\.jsdelivr\.net\/npm\/(bootstrap|jquery)/i.test(s)).slice(0, 20);
|
|
77
|
+
for (let i = 0; i < pick.length; i += 4) {
|
|
78
|
+
const got = await Promise.all(pick.slice(i, i + 4).map((s) => ctx.http.getPage(s, { source: 'site-script', timeoutMs: 15_000, maxBytes: 1_500_000 })));
|
|
79
|
+
for (const g of got)
|
|
80
|
+
if (g.data && g.data.status < 400) {
|
|
81
|
+
js += '\n' + g.data.body.toString('utf8');
|
|
82
|
+
read++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Drainer patterns, which only matter when the page also connects wallets.
|
|
86
|
+
const connects = CONNECTS.test(js) || CONNECTS.test(html);
|
|
87
|
+
if (connects)
|
|
88
|
+
for (const [re, what, w] of DRAIN)
|
|
89
|
+
if (re.test(js))
|
|
90
|
+
drainer.push([what, w]);
|
|
91
|
+
const obf = (js.match(/_0x[0-9a-f]{4,6}/g) ?? []).length;
|
|
92
|
+
if (obf > 200)
|
|
93
|
+
(connects ? drainer : phishing).push([`the scripts are heavily obfuscated (${obf} _0x names)`, connects ? 15 : 10]);
|
|
94
|
+
if (connects && drainer.length && /\bclaim\b|airdrop|eligib|reward|mint now|free mint/i.test(html + title))
|
|
95
|
+
drainer.push(['wraps the signature requests in an airdrop or claim page', 10]);
|
|
96
|
+
// Where typed data goes.
|
|
97
|
+
for (const m of js.matchAll(/api\.telegram\.org\/bot(\d{6,12}):[\w-]{30,}/g))
|
|
98
|
+
exfil.push(`Telegram bot ${m[1]}`);
|
|
99
|
+
for (const m of js.matchAll(/discord(?:app)?\.com\/api\/webhooks\/(\d+)/g))
|
|
100
|
+
exfil.push(`Discord webhook ${m[1]}`);
|
|
101
|
+
if (exfil.length)
|
|
102
|
+
phishing.push([`sends data to ${[...new Set(exfil)].slice(0, 3).join(', ')} from the page: how phishing kits collect what people type`, 45]);
|
|
103
|
+
// Forms.
|
|
104
|
+
const forms = [];
|
|
105
|
+
for (const m of html.matchAll(/<form\b([^>]*)>([\s\S]*?)<\/form>/gi)) {
|
|
106
|
+
const tag = m[1], body = m[2];
|
|
107
|
+
const action = attr(tag, 'action') ?? '';
|
|
108
|
+
let target = domain;
|
|
109
|
+
try {
|
|
110
|
+
target = action ? apexOf(new URL(action, finalUrl).hostname) : domain;
|
|
111
|
+
}
|
|
112
|
+
catch { }
|
|
113
|
+
const password = /type\s*=\s*["']?password/i.test(body);
|
|
114
|
+
const seed = /seed|mnemonic|recovery phrase|secret phrase|private key|12 words|24 words|word\s*#?\s*1\b/i.test(body);
|
|
115
|
+
const card = /cc-number|card.?number|cvv|cvc|expir/i.test(body);
|
|
116
|
+
forms.push({ action: action.slice(0, 160), password, seed, card, external: target !== domain });
|
|
117
|
+
if (target !== domain && (password || card || seed))
|
|
118
|
+
phishing.push([`a ${seed ? 'seed phrase' : password ? 'login' : 'card'} form sends to another domain (${target})`, 35]);
|
|
119
|
+
}
|
|
120
|
+
const seedText = /enter (your )?(12|24)[- ]word|import (your )?(wallet|seed)|recovery phrase|secret recovery|validate (your )?wallet|sync (your )?wallet|rectify|wallet ?connect.{0,40}manually/i.test(lower);
|
|
121
|
+
if (seedText && (forms.some((f) => f.seed) || /<textarea/i.test(html)))
|
|
122
|
+
phishing.push(['asks visitors to type a wallet seed phrase or private key: no real app ever does', 70]);
|
|
123
|
+
// Brand on the page vs the domain it is on.
|
|
124
|
+
const pageText = `${title ?? ''} ${(/<h1[^>]*>([\s\S]{0,200}?)<\/h1>/i.exec(html)?.[1] ?? '').replace(/<[^>]+>/g, '')}`.toLowerCase();
|
|
125
|
+
const label = domain.split('.')[0];
|
|
126
|
+
for (const [brand, own] of Object.entries(BRANDS)) {
|
|
127
|
+
const owns = own.some((d) => domain === d || domain.endsWith(`.${d}`));
|
|
128
|
+
if (owns)
|
|
129
|
+
continue;
|
|
130
|
+
const key = brand.replace(/[^a-z]/g, '');
|
|
131
|
+
const near = key.length >= 5 && label !== key && edits(label.replace(/[^a-z]/g, ''), key) <= 2;
|
|
132
|
+
if (near)
|
|
133
|
+
phishing.push([`the domain ${domain} looks like ${own[0]} (${brand})`, 35]);
|
|
134
|
+
else if ((label === key || new RegExp(`\\b${brand.replace('.', '\\.')}\\b`, 'i').test(pageText)) && (forms.some((f) => f.password || f.seed || f.card) || (connects && drainer.length)))
|
|
135
|
+
phishing.push([`the page presents itself as ${brand} but is not on ${own[0]}`, 30]);
|
|
136
|
+
}
|
|
137
|
+
if (scan.data?.malicious)
|
|
138
|
+
phishing.push([`Cloudflare's browser scan marks it malicious${scan.data.categories.length ? ` (${scan.data.categories.join(', ')})` : ''}`, 60]);
|
|
139
|
+
let reports = null;
|
|
140
|
+
try {
|
|
141
|
+
const ca = await chainabuse(ctx, 'domain', domain);
|
|
142
|
+
if (ca.prov)
|
|
143
|
+
provenance.push(ca.prov);
|
|
144
|
+
reports = ca.data;
|
|
145
|
+
}
|
|
146
|
+
catch { }
|
|
147
|
+
if (reports?.count)
|
|
148
|
+
phishing.push([`${reports.count} scam report${reports.count > 1 ? 's' : ''} about ${domain} filed by victims on Chainabuse${reports.categories.length ? ` (${reports.categories.join(', ')})` : ''}`, reports.trusted || reports.count >= 3 ? 40 : 15]);
|
|
149
|
+
// Reputation of the final address.
|
|
150
|
+
let reputation = null;
|
|
151
|
+
try {
|
|
152
|
+
const r = await urlCheck(ctx, finalUrl);
|
|
153
|
+
provenance.push(...r.provenance.slice(0, 5));
|
|
154
|
+
reputation = { verdict: r.result.verdict, risk: r.result.risk, ageDays: r.result.domainInfo?.ageDays ?? null, reasons: r.result.reasons.slice(0, 6) };
|
|
155
|
+
}
|
|
156
|
+
catch { }
|
|
157
|
+
if (apexOf(u.hostname) !== domain)
|
|
158
|
+
phishing.push([`the link redirects to another domain (${apexOf(u.hostname)} -> ${domain})`, 10]);
|
|
159
|
+
// The official domain of a known brand or app is not phishing it, and its wallet code is the real app's.
|
|
160
|
+
const official = Object.entries(BRANDS).find(([, own]) => own.some((d) => domain === d || domain.endsWith(`.${d}`)))?.[0] ?? null;
|
|
161
|
+
const notes = [];
|
|
162
|
+
if (official) {
|
|
163
|
+
notes.push(`${domain} is the official domain of ${official}.`);
|
|
164
|
+
drainer.splice(0, drainer.length, ...drainer.filter(([r]) => STRONG.test(r)));
|
|
165
|
+
}
|
|
166
|
+
const sum = (xs) => xs.reduce((s, [, w]) => s + w, 0);
|
|
167
|
+
const strong = drainer.some(([r]) => STRONG.test(r));
|
|
168
|
+
const dRisk = strong ? sum(drainer) : Math.min(25, sum(drainer)), pRisk = sum(phishing);
|
|
169
|
+
const young = reputation?.ageDays !== null && reputation?.ageDays !== undefined && reputation.ageDays < 30;
|
|
170
|
+
const risk = Math.min(100, Math.max(dRisk, pRisk, reputation?.risk ?? 0) + (young && (dRisk || pRisk) ? 15 : 0));
|
|
171
|
+
const verdict = dRisk >= 50 || (dRisk >= 35 && young) ? 'wallet drainer' : pRisk >= 50 || reputation?.verdict === 'malicious' ? 'phishing page' : risk >= 30 ? 'suspicious' : 'no known risk found';
|
|
172
|
+
const reasons = [...(strong || pRisk ? drainer : []), ...phishing].sort((a, b) => b[1] - a[1]).map(([r]) => r);
|
|
173
|
+
if (!strong && !pRisk && drainer.length)
|
|
174
|
+
notes.push(`The page connects wallets and its code mentions ${drainer.map(([r]) => r.replace(/^(asks for|asks to|asks|builds|uses|reads|switches) /, '')).slice(0, 3).join('; ')}. Wallet libraries contain these for every app, so alone they are not a warning.`);
|
|
175
|
+
reasons.push(...notes);
|
|
176
|
+
if (reputation)
|
|
177
|
+
reasons.push(...reputation.reasons.slice(0, 3));
|
|
178
|
+
if (!connects && verdict === 'no known risk found')
|
|
179
|
+
reasons.push('the page does not connect to crypto wallets');
|
|
180
|
+
const advice = verdict === 'wallet drainer'
|
|
181
|
+
? ['Do not connect a wallet or sign anything on this site.', 'If you already signed, revoke approvals now (oculon approvals <wallet>) and move what is left to a new wallet.']
|
|
182
|
+
: verdict === 'phishing page' ? ['Do not type anything on this page. Go to the real site by typing its address yourself.', 'If you entered a password, change it now and turn on two-factor sign-in.']
|
|
183
|
+
: ['Nothing alarming in the page and its scripts. Still type addresses yourself instead of following links from messages.'];
|
|
184
|
+
const now = ctx.now().toISOString();
|
|
185
|
+
const signals = risk >= 70 ? [{ id: signalId('site', domain), module: 'site', title: `${domain}: ${verdict}`, score: risk, entity: `domain:${domain}`, evidence: reasons.slice(0, 4).map((t) => ({ source: 'oculon-site', text: t, url: finalUrl })), createdAt: now }] : [];
|
|
186
|
+
return {
|
|
187
|
+
module: 'site', input: u.href, generatedAt: now,
|
|
188
|
+
result: { url: u.href, finalUrl, domain, title, verdict, risk, drainer: drainer.map(([r]) => r), phishing: phishing.map(([r]) => r), reputation, forms: forms.slice(0, 10), scripts: { read, external: [...new Set(external)].slice(0, 15) }, browser: scan.data ? { malicious: scan.data.malicious, categories: scan.data.categories, report: scan.data.report, finalUrl: scan.data.finalUrl, domains: scan.data.domains.length, scripts: scan.data.scripts.length } : null, reports, exfil: [...new Set(exfil)], reasons, advice },
|
|
189
|
+
signals, provenance,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Robinhood Stock Tokens: the official list, live prices and corporate actions from Robinhood's read-only API
|
|
3
|
+
* (api.robinhood.com/rhj, keyless), plus the token's supply on Robinhood Chain.
|
|
4
|
+
* A symbol (TSLA): the official contract, ISIN, status, which sessions trade, the live bid and ask (adjusted
|
|
5
|
+
* by the corporate-action multiplier), daily range and volume, upcoming dividends and splits.
|
|
6
|
+
* An address: whether it is an official Robinhood Stock Token. A token that copies a stock's ticker or calls
|
|
7
|
+
* itself a Robinhood token but is not on the official list is flagged as fake.
|
|
8
|
+
* Nothing: the list size and the corporate actions coming up.
|
|
9
|
+
*/
|
|
10
|
+
import type { Ctx } from '../core/context.js';
|
|
11
|
+
import type { ModuleResult } from '../core/types.js';
|
|
12
|
+
export interface StockTokenReport {
|
|
13
|
+
query: string;
|
|
14
|
+
verdict: 'official Robinhood stock token' | 'fake stock token' | 'not a stock token' | 'trading halted' | 'stock tokens overview';
|
|
15
|
+
risk: number;
|
|
16
|
+
symbol: string | null;
|
|
17
|
+
name: string | null;
|
|
18
|
+
isin: string | null;
|
|
19
|
+
contract: string | null;
|
|
20
|
+
chain: string | null;
|
|
21
|
+
status: string | null;
|
|
22
|
+
multiplier: number | null;
|
|
23
|
+
pendingMultiplier: number | null;
|
|
24
|
+
price: {
|
|
25
|
+
bid: number | null;
|
|
26
|
+
ask: number | null;
|
|
27
|
+
tokenBid: number | null;
|
|
28
|
+
tokenAsk: number | null;
|
|
29
|
+
dailyHigh: number | null;
|
|
30
|
+
dailyLow: number | null;
|
|
31
|
+
volume: number | null;
|
|
32
|
+
halted: boolean;
|
|
33
|
+
at: string | null;
|
|
34
|
+
} | null;
|
|
35
|
+
sessions: Record<string, string>;
|
|
36
|
+
supply: number | null;
|
|
37
|
+
corporateActions: {
|
|
38
|
+
symbol: string;
|
|
39
|
+
type: string;
|
|
40
|
+
date: string | null;
|
|
41
|
+
status: string;
|
|
42
|
+
detail: string | null;
|
|
43
|
+
}[];
|
|
44
|
+
tokens: number;
|
|
45
|
+
reasons: string[];
|
|
46
|
+
advice: string[];
|
|
47
|
+
}
|
|
48
|
+
export declare function stockToken(ctx: Ctx, input?: string): Promise<ModuleResult<StockTokenReport>>;
|