oculon 0.1.3 → 0.1.5

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.
Files changed (43) hide show
  1. package/README.md +21 -3
  2. package/dist/cli/main.js +196 -1
  3. package/dist/core/http.js +4 -0
  4. package/dist/core/quota.js +20 -0
  5. package/dist/index.d.ts +20 -0
  6. package/dist/index.js +43 -0
  7. package/dist/mcp.d.ts +7 -0
  8. package/dist/mcp.js +97 -3
  9. package/dist/modules/breach.d.ts +53 -0
  10. package/dist/modules/breach.js +98 -0
  11. package/dist/modules/company.d.ts +53 -0
  12. package/dist/modules/company.js +149 -0
  13. package/dist/modules/contradictions.js +6 -4
  14. package/dist/modules/hashcheck.d.ts +29 -0
  15. package/dist/modules/hashcheck.js +82 -0
  16. package/dist/modules/ipintel.d.ts +52 -0
  17. package/dist/modules/ipintel.js +149 -0
  18. package/dist/modules/lynx.js +15 -9
  19. package/dist/modules/owl.js +4 -1
  20. package/dist/modules/phone.d.ts +32 -0
  21. package/dist/modules/phone.js +148 -0
  22. package/dist/modules/ransomware.d.ts +56 -0
  23. package/dist/modules/ransomware.js +85 -0
  24. package/dist/modules/satellites.d.ts +45 -0
  25. package/dist/modules/satellites.js +113 -0
  26. package/dist/sources/threatintel.d.ts +151 -0
  27. package/dist/sources/threatintel.js +256 -0
  28. package/dist/telegram.js +55 -5
  29. package/dist/web/ask.html +1 -1
  30. package/dist/web/assets/og-app.png +0 -0
  31. package/dist/web/assets/og-docs.png +0 -0
  32. package/dist/web/assets/og-mcp.png +0 -0
  33. package/dist/web/assets/og.png +0 -0
  34. package/dist/web/docs.html +1 -1
  35. package/dist/web/index.html +109 -11
  36. package/dist/web/insights.js +2 -0
  37. package/dist/web/landing.html +1 -1
  38. package/dist/web/legal.html +1 -1
  39. package/dist/web/mcp.html +1 -1
  40. package/dist/web/openapi.js +7 -0
  41. package/dist/web/public.js +9 -1
  42. package/dist/web/server.js +63 -4
  43. package/package.json +2 -2
@@ -0,0 +1,151 @@
1
+ import type { Ctx } from '../core/context.js';
2
+ import type { Provenance, Sourced } from '../core/types.js';
3
+ /** POST with a response cache keyed by URL and body (abuse.ch answers lookups only over POST). */
4
+ export declare function postCached<T>(ctx: Ctx, url: string, body: string, contentType: string, headers: Record<string, string>, source: string, ttlSec: number): Promise<Sourced<T>>;
5
+ /** IPv4 or IPv6 as a BigInt plus its bit length, for CIDR matching. */
6
+ export declare function ipToBig(ip: string): {
7
+ v: bigint;
8
+ bits: number;
9
+ } | null;
10
+ export declare function inCidr(ip: string, cidr: string): boolean;
11
+ /** Private, loopback, documentation, multicast and other addresses that are not on the public internet. */
12
+ export declare function isPublicIp(ip: string): boolean;
13
+ export interface IpApi {
14
+ country: string | null;
15
+ countryCode: string | null;
16
+ region: string | null;
17
+ city: string | null;
18
+ lat: number | null;
19
+ lon: number | null;
20
+ isp: string | null;
21
+ org: string | null;
22
+ as: string | null;
23
+ reverse: string | null;
24
+ mobile: boolean;
25
+ proxy: boolean;
26
+ hosting: boolean;
27
+ }
28
+ export declare function ipApi(ctx: Ctx, ip: string): Promise<Sourced<IpApi>>;
29
+ export interface GreyNoise {
30
+ observed: boolean;
31
+ noise: boolean;
32
+ riot: boolean;
33
+ classification: string | null;
34
+ name: string | null;
35
+ lastSeen: string | null;
36
+ link: string | null;
37
+ }
38
+ export declare function greyNoise(ctx: Ctx, ip: string): Promise<Sourced<GreyNoise>>;
39
+ export declare function torExits(ctx: Ctx): Promise<Sourced<Set<string>>>;
40
+ export interface DropLists {
41
+ cidrs: {
42
+ cidr: string;
43
+ id: string;
44
+ }[];
45
+ asns: {
46
+ asn: number;
47
+ name: string;
48
+ }[];
49
+ }
50
+ export declare function spamhausDrop(ctx: Ctx): Promise<{
51
+ data: DropLists | null;
52
+ prov: Provenance[];
53
+ }>;
54
+ export interface PeeringNet {
55
+ name: string;
56
+ type: string | null;
57
+ website: string | null;
58
+ policy: string | null;
59
+ }
60
+ export declare function peeringDb(ctx: Ctx, asn: number): Promise<Sourced<PeeringNet>>;
61
+ export interface InternetDb {
62
+ ports: number[];
63
+ vulns: string[];
64
+ hostnames: string[];
65
+ tags: string[];
66
+ }
67
+ export declare function internetDb(ctx: Ctx, ip: string): Promise<Sourced<InternetDb>>;
68
+ export interface AbuseIpDb {
69
+ score: number;
70
+ reports: number;
71
+ reporters: number;
72
+ lastReported: string | null;
73
+ usageType: string | null;
74
+ isp: string | null;
75
+ domain: string | null;
76
+ countryCode: string | null;
77
+ isTor: boolean;
78
+ whitelisted: boolean;
79
+ }
80
+ export declare function abuseIpDb(ctx: Ctx, ip: string): Promise<Sourced<AbuseIpDb>>;
81
+ export interface OtxPulses {
82
+ count: number;
83
+ pulses: {
84
+ name: string;
85
+ created: string | null;
86
+ tags: string[];
87
+ url: string;
88
+ }[];
89
+ whitelisted: boolean;
90
+ family: string[];
91
+ }
92
+ /** AlienVault OTX community threat reports ("pulses") that mention an IP, domain or file hash. */
93
+ export declare function otx(ctx: Ctx, type: 'IPv4' | 'IPv6' | 'file' | 'domain', value: string): Promise<Sourced<OtxPulses>>;
94
+ export interface IpInfoLite {
95
+ asn: string | null;
96
+ asName: string | null;
97
+ asDomain: string | null;
98
+ country: string | null;
99
+ countryCode: string | null;
100
+ }
101
+ export declare function ipInfo(ctx: Ctx, ip: string): Promise<Sourced<IpInfoLite>>;
102
+ export interface VtStats {
103
+ malicious: number;
104
+ suspicious: number;
105
+ harmless: number;
106
+ undetected: number;
107
+ engines: number;
108
+ reputation: number | null;
109
+ label: string | null;
110
+ name: string | null;
111
+ type: string | null;
112
+ size: number | null;
113
+ firstSeen: string | null;
114
+ owner: string | null;
115
+ link: string;
116
+ }
117
+ /** VirusTotal verdicts for an IP address or a file hash (free public API: 4 requests a minute, 500 a day, non-commercial). */
118
+ export declare function virusTotal(ctx: Ctx, kind: 'ip' | 'file', value: string): Promise<Sourced<VtStats>>;
119
+ export interface CirclHit {
120
+ known: boolean;
121
+ fileName: string | null;
122
+ size: number | null;
123
+ sources: string[];
124
+ knownMalicious: string | null;
125
+ trust: number | null;
126
+ }
127
+ /** CIRCL hashlookup: is this a known file (NIST NSRL and other software sets), or known malware? */
128
+ export declare function circlHash(ctx: Ctx, algo: 'md5' | 'sha1' | 'sha256', hash: string): Promise<Sourced<CirclHit>>;
129
+ export interface BazaarHit {
130
+ sha256: string;
131
+ fileName: string | null;
132
+ fileType: string | null;
133
+ signature: string | null;
134
+ firstSeen: string | null;
135
+ lastSeen: string | null;
136
+ tags: string[];
137
+ delivery: string | null;
138
+ link: string;
139
+ }
140
+ export declare function malwareBazaar(ctx: Ctx, hash: string): Promise<Sourced<BazaarHit>>;
141
+ export interface ThreatFoxHit {
142
+ ioc: string;
143
+ threat: string | null;
144
+ malware: string | null;
145
+ confidence: number | null;
146
+ firstSeen: string | null;
147
+ link: string;
148
+ }
149
+ /** ThreatFox indicators of compromise: an IP:port, domain or file hash used by a malware family. */
150
+ export declare function threatFox(ctx: Ctx, kind: 'hash' | 'ioc', value: string): Promise<Sourced<ThreatFoxHit[]>>;
151
+ export declare const unavailable: (source: string, url: string, note: string) => Provenance;
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Threat intelligence sources for IP addresses and file hashes.
3
+ * Keyless: ip-api.com (location, proxy and hosting flags), GreyNoise Community (internet scanners),
4
+ * the Tor Project exit list, Spamhaus DROP (hijacked and criminal networks), PeeringDB (network type),
5
+ * Shodan InternetDB (open ports), CIRCL hashlookup (known files).
6
+ * Free keys: AbuseIPDB (ABUSEIPDB_API_KEY), AlienVault OTX (OTX_API_KEY), IPinfo Lite (IPINFO_TOKEN),
7
+ * VirusTotal (VIRUSTOTAL_API_KEY, non-commercial use), MalwareBazaar and ThreatFox (ABUSECH_AUTH_KEY).
8
+ * A missing key only turns that one source off.
9
+ */
10
+ import { isIP } from 'node:net';
11
+ import { key, noKey } from '../core/keys.js';
12
+ const nowIso = () => new Date().toISOString();
13
+ /** POST with a response cache keyed by URL and body (abuse.ch answers lookups only over POST). */
14
+ export async function postCached(ctx, url, body, contentType, headers, source, ttlSec) {
15
+ const cacheKey = `post:${url}:${body}`;
16
+ const cached = ctx.store.cacheGet(cacheKey);
17
+ if (cached && Date.now() - cached.fetchedAt < ttlSec * 1000) {
18
+ try {
19
+ return { data: JSON.parse(cached.body), prov: { source, url, status: 'CACHED', fetchedAt: new Date(cached.fetchedAt).toISOString() } };
20
+ }
21
+ catch { }
22
+ }
23
+ const r = await ctx.http.postBytes(url, new TextEncoder().encode(body), { source, headers: { 'content-type': contentType, ...headers }, timeoutMs: 25_000 });
24
+ if (!r.data)
25
+ return { data: null, prov: r.prov };
26
+ try {
27
+ const text = r.data.toString('utf8');
28
+ const data = JSON.parse(text);
29
+ ctx.store.cachePut(cacheKey, text);
30
+ return { data, prov: r.prov };
31
+ }
32
+ catch {
33
+ return { data: null, prov: { ...r.prov, status: 'ERROR', note: 'invalid JSON' } };
34
+ }
35
+ }
36
+ /* ---------- address helpers ---------- */
37
+ /** IPv4 or IPv6 as a BigInt plus its bit length, for CIDR matching. */
38
+ export function ipToBig(ip) {
39
+ const fam = isIP(ip);
40
+ if (fam === 4) {
41
+ const p = ip.split('.').map(Number);
42
+ return { v: BigInt(((p[0] << 24) >>> 0) + (p[1] << 16) + (p[2] << 8) + p[3]), bits: 32 };
43
+ }
44
+ if (fam === 6) {
45
+ let s = ip.toLowerCase();
46
+ const v4 = /(\d+\.\d+\.\d+\.\d+)$/.exec(s);
47
+ if (v4) {
48
+ const b = ipToBig(v4[1]);
49
+ if (!b)
50
+ return null;
51
+ s = s.replace(v4[1], `${(b.v >> 16n).toString(16)}:${(b.v & 0xffffn).toString(16)}`);
52
+ }
53
+ const [head, tail] = s.split('::');
54
+ const h = head ? head.split(':') : [];
55
+ const t = tail !== undefined ? (tail ? tail.split(':') : []) : [];
56
+ const groups = tail !== undefined ? [...h, ...Array(8 - h.length - t.length).fill('0'), ...t] : h;
57
+ if (groups.length !== 8)
58
+ return null;
59
+ let v = 0n;
60
+ for (const g of groups)
61
+ v = (v << 16n) + BigInt(parseInt(g || '0', 16));
62
+ return { v, bits: 128 };
63
+ }
64
+ return null;
65
+ }
66
+ export function inCidr(ip, cidr) {
67
+ const [net, lenS] = cidr.split('/');
68
+ const a = ipToBig(ip);
69
+ const b = ipToBig(net);
70
+ if (!a || !b || a.bits !== b.bits)
71
+ return false;
72
+ const len = lenS === undefined ? a.bits : Number(lenS);
73
+ if (!Number.isInteger(len) || len < 0 || len > a.bits)
74
+ return false;
75
+ const shift = BigInt(a.bits - len);
76
+ return a.v >> shift === b.v >> shift;
77
+ }
78
+ const PRIVATE_RANGES = ['0.0.0.0/8', '10.0.0.0/8', '100.64.0.0/10', '127.0.0.0/8', '169.254.0.0/16', '172.16.0.0/12', '192.0.0.0/24', '192.0.2.0/24', '192.168.0.0/16', '198.18.0.0/15', '198.51.100.0/24', '203.0.113.0/24', '224.0.0.0/3', '::/127', '::ffff:0:0/96', '64:ff9b:1::/48', '100::/64', '2001:db8::/32', 'fc00::/7', 'fe80::/10', 'ff00::/8'];
79
+ /** Private, loopback, documentation, multicast and other addresses that are not on the public internet. */
80
+ export function isPublicIp(ip) {
81
+ if (!isIP(ip))
82
+ return false;
83
+ return !PRIVATE_RANGES.some((r) => inCidr(ip, r));
84
+ }
85
+ export async function ipApi(ctx, ip) {
86
+ // The free endpoint is HTTP only and allows 45 requests a minute, non-commercial use.
87
+ const r = await ctx.http.get(`http://ip-api.com/json/${encodeURIComponent(ip)}?fields=status,message,country,countryCode,regionName,city,lat,lon,isp,org,as,reverse,mobile,proxy,hosting`, { source: 'ip-api', ttlSec: 12 * 3600 });
88
+ const d = r.data;
89
+ if (!d || d.status !== 'success')
90
+ return { data: null, prov: d ? { ...r.prov, status: 'ERROR', note: String(d.message ?? 'lookup failed') } : r.prov };
91
+ const s = (k) => (typeof d[k] === 'string' && d[k] ? d[k] : null);
92
+ const n = (k) => (typeof d[k] === 'number' ? d[k] : null);
93
+ return { data: { country: s('country'), countryCode: s('countryCode'), region: s('regionName'), city: s('city'), lat: n('lat'), lon: n('lon'), isp: s('isp'), org: s('org'), as: s('as'), reverse: s('reverse'), mobile: d.mobile === true, proxy: d.proxy === true, hosting: d.hosting === true }, prov: r.prov };
94
+ }
95
+ export async function greyNoise(ctx, ip) {
96
+ const url = `https://api.greynoise.io/v3/community/${encodeURIComponent(ip)}`;
97
+ const r = await ctx.http.get(url, { source: 'greynoise', ttlSec: 12 * 3600, retries: 1 });
98
+ // GreyNoise answers 404 for an address it has never seen scanning: that is a result, not an outage.
99
+ if (!r.data && r.prov.note === 'HTTP 404')
100
+ return { data: { observed: false, noise: false, riot: false, classification: null, name: null, lastSeen: null, link: null }, prov: { ...r.prov, status: 'LIVE', note: 'not observed scanning the internet' } };
101
+ const d = r.data;
102
+ if (!d)
103
+ return { data: null, prov: r.prov };
104
+ return { data: { observed: d.noise === true || d.riot === true, noise: d.noise === true, riot: d.riot === true, classification: typeof d.classification === 'string' ? d.classification : null, name: typeof d.name === 'string' && d.name !== 'unknown' ? d.name : null, lastSeen: typeof d.last_seen === 'string' ? d.last_seen : null, link: typeof d.link === 'string' ? d.link : null }, prov: r.prov };
105
+ }
106
+ export async function torExits(ctx) {
107
+ const r = await ctx.http.get('https://check.torproject.org/torbulkexitlist', { source: 'tor-exits', as: 'text', ttlSec: 3600 });
108
+ return { data: r.data ? new Set(r.data.split(/\s+/).filter(Boolean)) : null, prov: r.prov };
109
+ }
110
+ const ndjson = (text) => (text ?? '').split('\n').map((l) => { try {
111
+ return JSON.parse(l);
112
+ }
113
+ catch {
114
+ return null;
115
+ } }).filter((x) => x !== null);
116
+ export async function spamhausDrop(ctx) {
117
+ const [v4, v6, asn] = await Promise.all(['drop_v4.json', 'drop_v6.json', 'asndrop.json'].map((f) => ctx.http.get(`https://www.spamhaus.org/drop/${f}`, { source: 'spamhaus-drop', as: 'text', ttlSec: 12 * 3600 })));
118
+ const prov = [v4.prov, v6.prov, asn.prov];
119
+ if (!v4.data && !v6.data && !asn.data)
120
+ return { data: null, prov };
121
+ const cidrs = [...ndjson(v4.data), ...ndjson(v6.data)].filter((x) => x.cidr).map((x) => ({ cidr: x.cidr, id: x.sblid ?? '' }));
122
+ const asns = ndjson(asn.data).filter((x) => typeof x.asn === 'number').map((x) => ({ asn: x.asn, name: x.asname ?? '' }));
123
+ return { data: { cidrs, asns }, prov };
124
+ }
125
+ export async function peeringDb(ctx, asn) {
126
+ const r = await ctx.http.get(`https://www.peeringdb.com/api/net?asn=${asn}`, { source: 'peeringdb', ttlSec: 7 * 86_400, retries: 1, keep: (d) => ({ data: (d.data ?? []).slice(0, 1) }) });
127
+ const n = r.data?.data?.[0];
128
+ return { data: n?.name ? { name: n.name, type: n.info_type || null, website: n.website || null, policy: n.policy_general || null } : null, prov: r.prov };
129
+ }
130
+ export async function internetDb(ctx, ip) {
131
+ const r = await ctx.http.get(`https://internetdb.shodan.io/${encodeURIComponent(ip)}`, { source: 'shodan-internetdb', ttlSec: 12 * 3600, retries: 1 });
132
+ // 404 here means "no open ports seen", which is a result.
133
+ if (!r.data && r.prov.note === 'HTTP 404')
134
+ return { data: { ports: [], vulns: [], hostnames: [], tags: [] }, prov: { ...r.prov, status: 'LIVE', note: 'no open ports seen' } };
135
+ const d = r.data;
136
+ return { data: d ? { ports: d.ports ?? [], vulns: d.vulns ?? [], hostnames: d.hostnames ?? [], tags: d.tags ?? [] } : null, prov: r.prov };
137
+ }
138
+ export async function abuseIpDb(ctx, ip) {
139
+ const k = key('ABUSEIPDB_API_KEY');
140
+ if (!k)
141
+ return noKey('abuseipdb', 'ABUSEIPDB_API_KEY');
142
+ const r = await ctx.http.get(`https://api.abuseipdb.com/api/v2/check?ipAddress=${encodeURIComponent(ip)}&maxAgeInDays=90`, { source: 'abuseipdb', ttlSec: 6 * 3600, retries: 1, headers: { Key: k } });
143
+ const d = r.data?.data;
144
+ if (!d)
145
+ return { data: null, prov: r.prov };
146
+ const s = (x) => (typeof x === 'string' && x ? x : null);
147
+ return { data: { score: Number(d.abuseConfidenceScore ?? 0), reports: Number(d.totalReports ?? 0), reporters: Number(d.numDistinctUsers ?? 0), lastReported: s(d.lastReportedAt), usageType: s(d.usageType), isp: s(d.isp), domain: s(d.domain), countryCode: s(d.countryCode), isTor: d.isTor === true, whitelisted: d.isWhitelisted === true }, prov: r.prov };
148
+ }
149
+ /** AlienVault OTX community threat reports ("pulses") that mention an IP, domain or file hash. */
150
+ export async function otx(ctx, type, value) {
151
+ const k = key('OTX_API_KEY');
152
+ if (!k)
153
+ return noKey('otx', 'OTX_API_KEY');
154
+ const r = await ctx.http.get(`https://otx.alienvault.com/api/v1/indicators/${type}/${encodeURIComponent(value)}/general`, {
155
+ source: 'otx',
156
+ ttlSec: 6 * 3600,
157
+ timeoutMs: 25_000,
158
+ retries: 1,
159
+ headers: { 'X-OTX-API-KEY': k },
160
+ keep: (d) => ({ pulse_info: { count: d.pulse_info?.count ?? 0, pulses: (d.pulse_info?.pulses ?? []).slice(0, 6).map((p) => ({ id: p.id, name: p.name, created: p.created, tags: (p.tags ?? []).slice(0, 6) })), related: d.pulse_info?.related }, validation: (d.validation ?? []).slice(0, 3) }),
161
+ });
162
+ if (!r.data)
163
+ return { data: null, prov: r.prov };
164
+ const pi = r.data.pulse_info ?? {};
165
+ const fam = [...(pi.related?.alienvault?.malware_families ?? []), ...(pi.related?.other?.malware_families ?? [])];
166
+ return {
167
+ data: {
168
+ count: pi.count ?? 0,
169
+ pulses: (pi.pulses ?? []).filter((p) => p.name).map((p) => ({ name: p.name, created: p.created ?? null, tags: p.tags ?? [], url: `https://otx.alienvault.com/pulse/${p.id ?? ''}` })),
170
+ whitelisted: (r.data.validation ?? []).some((v) => /whitelist|alexa|majestic|akamai|false_positive/i.test(`${v.source ?? ''} ${v.name ?? ''}`)),
171
+ family: [...new Set(fam.map((f) => String(f)))].slice(0, 6),
172
+ },
173
+ prov: r.prov,
174
+ };
175
+ }
176
+ export async function ipInfo(ctx, ip) {
177
+ const k = key('IPINFO_TOKEN');
178
+ if (!k)
179
+ return noKey('ipinfo', 'IPINFO_TOKEN');
180
+ const r = await ctx.http.get(`https://api.ipinfo.io/lite/${encodeURIComponent(ip)}?token=${encodeURIComponent(k)}`, { source: 'ipinfo', ttlSec: 24 * 3600, retries: 1 });
181
+ const d = r.data;
182
+ const s = (x) => (typeof x === 'string' && x ? x : null);
183
+ return { data: d ? { asn: s(d.asn), asName: s(d.as_name), asDomain: s(d.as_domain), country: s(d.country), countryCode: s(d.country_code) } : null, prov: r.prov };
184
+ }
185
+ /** VirusTotal verdicts for an IP address or a file hash (free public API: 4 requests a minute, 500 a day, non-commercial). */
186
+ export async function virusTotal(ctx, kind, value) {
187
+ const k = key('VIRUSTOTAL_API_KEY');
188
+ if (!k)
189
+ return noKey('virustotal', 'VIRUSTOTAL_API_KEY');
190
+ const path = kind === 'ip' ? `ip_addresses/${encodeURIComponent(value)}` : `files/${encodeURIComponent(value)}`;
191
+ const link = kind === 'ip' ? `https://www.virustotal.com/gui/ip-address/${encodeURIComponent(value)}` : `https://www.virustotal.com/gui/file/${encodeURIComponent(value)}`;
192
+ const r = await ctx.http.get(`https://www.virustotal.com/api/v3/${path}`, {
193
+ source: 'virustotal',
194
+ ttlSec: 12 * 3600,
195
+ retries: 1,
196
+ headers: { 'x-apikey': k },
197
+ keep: (d) => {
198
+ const a = d.data?.attributes ?? {};
199
+ return { data: { attributes: { last_analysis_stats: a.last_analysis_stats, reputation: a.reputation, as_owner: a.as_owner, meaningful_name: a.meaningful_name, type_description: a.type_description, size: a.size, first_submission_date: a.first_submission_date, popular_threat_classification: { suggested_threat_label: a.popular_threat_classification?.suggested_threat_label } } } };
200
+ },
201
+ });
202
+ if (!r.data && r.prov.note === 'HTTP 404')
203
+ return { data: null, prov: { ...r.prov, status: 'LIVE', note: 'not in VirusTotal' } };
204
+ const a = r.data?.data?.attributes;
205
+ if (!a)
206
+ return { data: null, prov: r.prov };
207
+ const st = a.last_analysis_stats ?? {};
208
+ const engines = Object.values(st).reduce((x, y) => x + (Number(y) || 0), 0);
209
+ return {
210
+ data: { malicious: st.malicious ?? 0, suspicious: st.suspicious ?? 0, harmless: st.harmless ?? 0, undetected: st.undetected ?? 0, engines, reputation: typeof a.reputation === 'number' ? a.reputation : null, label: a.popular_threat_classification?.suggested_threat_label ?? null, name: a.meaningful_name ?? null, type: a.type_description ?? null, size: a.size ?? null, firstSeen: a.first_submission_date ? new Date(a.first_submission_date * 1000).toISOString() : null, owner: a.as_owner ?? null, link },
211
+ prov: r.prov,
212
+ };
213
+ }
214
+ /** CIRCL hashlookup: is this a known file (NIST NSRL and other software sets), or known malware? */
215
+ export async function circlHash(ctx, algo, hash) {
216
+ const r = await ctx.http.get(`https://hashlookup.circl.lu/lookup/${algo}/${encodeURIComponent(hash)}`, { source: 'circl-hashlookup', ttlSec: 7 * 86_400, retries: 1 });
217
+ if (!r.data && r.prov.note === 'HTTP 404')
218
+ return { data: { known: false, fileName: null, size: null, sources: [], knownMalicious: null, trust: null }, prov: { ...r.prov, status: 'LIVE', note: 'hash not in the known-file sets' } };
219
+ const d = r.data;
220
+ if (!d)
221
+ return { data: null, prov: r.prov };
222
+ const src = [d.source, d['db']].filter((x) => typeof x === 'string');
223
+ const trust = Number(d['hashlookup:trust']);
224
+ return { data: { known: true, fileName: typeof d.FileName === 'string' ? d.FileName : null, size: d.FileSize != null ? Number(d.FileSize) || null : null, sources: [...new Set(src)], knownMalicious: typeof d.KnownMalicious === 'string' ? d.KnownMalicious : null, trust: Number.isFinite(trust) ? trust : null }, prov: r.prov };
225
+ }
226
+ export async function malwareBazaar(ctx, hash) {
227
+ const k = key('ABUSECH_AUTH_KEY');
228
+ if (!k)
229
+ return noKey('malwarebazaar', 'ABUSECH_AUTH_KEY');
230
+ const r = await postCached(ctx, 'https://mb-api.abuse.ch/api/v1/', new URLSearchParams({ query: 'get_info', hash }).toString(), 'application/x-www-form-urlencoded', { 'Auth-Key': k }, 'malwarebazaar', 12 * 3600);
231
+ if (!r.data)
232
+ return { data: null, prov: r.prov };
233
+ const x = r.data.query_status === 'ok' ? r.data.data?.[0] : undefined;
234
+ if (!x)
235
+ return { data: null, prov: { ...r.prov, note: r.data.query_status === 'hash_not_found' ? 'not a known malware sample' : r.data.query_status } };
236
+ const s = (v) => (typeof v === 'string' && v ? v : null);
237
+ const sha = s(x.sha256_hash) ?? hash;
238
+ return { data: { sha256: sha, fileName: s(x.file_name), fileType: s(x.file_type), signature: s(x.signature), firstSeen: s(x.first_seen), lastSeen: s(x.last_seen), tags: Array.isArray(x.tags) ? x.tags.slice(0, 8) : [], delivery: s(x.delivery_method), link: `https://bazaar.abuse.ch/sample/${encodeURIComponent(sha)}/` }, prov: r.prov };
239
+ }
240
+ /** ThreatFox indicators of compromise: an IP:port, domain or file hash used by a malware family. */
241
+ export async function threatFox(ctx, kind, value) {
242
+ const k = key('ABUSECH_AUTH_KEY');
243
+ if (!k)
244
+ return noKey('threatfox', 'ABUSECH_AUTH_KEY');
245
+ const body = kind === 'hash' ? { query: 'search_hash', hash: value } : { query: 'search_ioc', search_term: value, exact_match: false };
246
+ const r = await postCached(ctx, 'https://threatfox-api.abuse.ch/api/v1/', JSON.stringify(body), 'application/json', { 'Auth-Key': k }, 'threatfox', 6 * 3600);
247
+ if (!r.data)
248
+ return { data: null, prov: r.prov };
249
+ if (r.data.query_status !== 'ok' || !Array.isArray(r.data.data))
250
+ return { data: [], prov: { ...r.prov, note: r.data.query_status === 'no_result' ? 'no matching indicators' : r.data.query_status } };
251
+ return {
252
+ data: r.data.data.slice(0, 10).map((x) => ({ ioc: String(x.ioc ?? value), threat: typeof x.threat_type_desc === 'string' ? x.threat_type_desc : typeof x.threat_type === 'string' ? x.threat_type : null, malware: typeof x.malware_printable === 'string' ? x.malware_printable : null, confidence: x.confidence_level != null ? Number(x.confidence_level) : null, firstSeen: typeof x.first_seen === 'string' ? x.first_seen : null, link: `https://threatfox.abuse.ch/ioc/${encodeURIComponent(String(x.id ?? ''))}/` })),
253
+ prov: r.prov,
254
+ };
255
+ }
256
+ export const unavailable = (source, url, note) => ({ source, url, status: 'UNAVAILABLE', fetchedAt: nowIso(), note });
package/dist/telegram.js CHANGED
@@ -21,9 +21,9 @@ export function formatSignal(s) {
21
21
  return `<b>[${Math.round(s.score)}] ${esc(s.title)}</b> <code>${esc(s.module)}</code>${ev ? `\n${ev}` : ''}`;
22
22
  }
23
23
  /** Commands anyone may use when the bot is public. Everything else stays with the allowlisted chats. */
24
- export const PUBLIC_COMMANDS = new Set(['/start', '/help', '/scam', '/url', '/factcheck', '/recall', '/email', '/travel', '/airport', '/country', '/papers', '/audit', '/monitor', '/monitors', '/unmonitor', '/cve', '/vulns', '/hazards', '/blackout', '/cloud', '/space', '/air', '/radar', '/signals', '/alerts', '/ask']);
24
+ export const PUBLIC_COMMANDS = new Set(['/start', '/help', '/scam', '/url', '/factcheck', '/recall', '/email', '/travel', '/airport', '/country', '/papers', '/audit', '/monitor', '/monitors', '/unmonitor', '/cve', '/vulns', '/hazards', '/blackout', '/cloud', '/space', '/air', '/radar', '/signals', '/alerts', '/ask', '/ip', '/hash', '/ransomware', '/company', '/breaches', '/phone', '/satellite']);
25
25
  /** Commands that start many upstream calls or an LLM get a tighter budget. */
26
- const HEAVY = new Set(['/factcheck', '/papers', '/travel', '/country', '/ask', '/scam', '/audit', '/radar']);
26
+ const HEAVY = new Set(['/factcheck', '/papers', '/travel', '/country', '/ask', '/scam', '/audit', '/radar', '/ip', '/hash', '/company']);
27
27
  export const PUBLIC_HELP = [
28
28
  '<b>Oculon</b>: check anything, every answer sourced.',
29
29
  '',
@@ -39,7 +39,13 @@ export const PUBLIC_HELP = [
39
39
  '/country &lt;name&gt; — country brief',
40
40
  '/papers &lt;topic&gt; — research brief',
41
41
  '/audit &lt;npm:name@ver ...&gt; — dependency vulnerabilities',
42
- '/cve &lt;id&gt; · /vulns · /hazards · /blackout · /cloud · /space · /air &lt;place&gt; · /radar',
42
+ '/phone &lt;+number&gt; — who is calling? premium-rate and callback-scam warnings',
43
+ '/company &lt;name, LEI or EU VAT&gt; — is this supplier real?',
44
+ '/breaches [domain] — newest data breaches, or one domain',
45
+ '/ip &lt;address or domain&gt; — abuse reports, scanners, Tor, threat reports',
46
+ '/hash &lt;md5|sha1|sha256&gt; — is this file known malware?',
47
+ '/ransomware [country, sector or name] — ransomware leak-site claims',
48
+ '/cve &lt;id&gt; · /vulns · /hazards · /blackout · /cloud · /space · /air &lt;place&gt; · /satellite · /radar',
43
49
  '',
44
50
  '/monitor &lt;request&gt; — watch anything, e.g. /monitor internet outages in Iran',
45
51
  '/monitors — your monitors · /unmonitor &lt;id&gt; — remove one',
@@ -62,6 +68,7 @@ export const HELP = [
62
68
  '/monitor &lt;request&gt; — watch anything in plain words, e.g. /monitor internet outages in Iran',
63
69
  '/recall &lt;VIN, "2018 Honda Accord" or product&gt; — vehicle and product recalls',
64
70
  '/email &lt;domain&gt; — can someone spoof email from this domain?',
71
+ '/phone · /company · /breaches · /ip · /hash · /ransomware · /satellite — caller, supplier, breach and threat checks',
65
72
  '/airport &lt;JFK|EGLL&gt; — airport weather, delays and ground stops',
66
73
  '/country &lt;name&gt; — economy, leaders, currency, travel advice, headlines',
67
74
  '/papers &lt;topic&gt; — research brief: most cited and newest papers',
@@ -419,6 +426,49 @@ export class TelegramBot {
419
426
  const fixes = d.fixes.slice(0, 3).map((x, i) => `${i + 1}. ${esc(x)}`).join('\n');
420
427
  return { html: `<b>${esc(d.domain)}</b>: <b>${esc(d.verdict.toUpperCase())}</b> (score ${d.score}/100)\nSPF ${esc(d.spf.all ?? (d.spf.record ? 'present' : 'missing'))} · DMARC ${esc(d.dmarc.policy ? `p=${d.dmarc.policy}` : 'missing')} · DKIM ${d.dkim.selectorsFound.length ? 'found' : 'not found'}${fixes ? `\n\n${fixes}` : ''}` };
421
428
  }
429
+ case '/ip': {
430
+ if (!arg)
431
+ return needArg('185.220.101.1');
432
+ const d = (await o.ipCheck(arg.split(/\s+/)[0])).result;
433
+ const where = d.location ? [d.location.city, d.location.country].filter(Boolean).join(', ') : '';
434
+ return { html: `<b>${esc(d.ip)}</b>${d.resolvedFrom ? ` (${esc(d.resolvedFrom)})` : ''}: <b>${esc(d.verdict.toUpperCase())}</b> · risk ${d.risk}/100\n${esc([d.network.asn, d.network.name].filter(Boolean).join(' '))}${where ? ` · ${esc(where)}` : ''}\n${d.reasons.map((x) => `• ${esc(x)}`).join('\n') || 'No source reports abuse.'}` };
435
+ }
436
+ case '/hash': {
437
+ if (!arg)
438
+ return needArg('sha256 hash');
439
+ const d = (await o.hashCheck(arg.split(/\s+/)[0])).result;
440
+ return { html: `<b>${esc(d.verdict.toUpperCase())}</b>${d.family ? ` · ${esc(d.family)}` : ''}\n<code>${esc(d.hash)}</code>\n${d.reasons.map((x) => `• ${esc(x)}`).join('\n')}${d.virustotal ? `\n<a href="${esc(d.virustotal.link)}">VirusTotal</a>` : ''}` };
441
+ }
442
+ case '/ransomware': {
443
+ const d = (await o.ransomware(arg)).result;
444
+ const items = d.victims.slice(0, 8).map((v) => `• ${v.url ? `<a href="${esc(v.url)}">${esc(v.victim.slice(0, 60))}</a>` : esc(v.victim.slice(0, 60))} <i>${esc(v.group)}${v.country ? ` · ${esc(v.country)}` : ''} · ${esc((v.discovered ?? '').slice(0, 10))}</i>`).join('\n');
445
+ return { html: `<b>${d.query ? `Ransomware claims: ${esc(d.query)}` : 'Newest ransomware claims'}</b> (${d.total})\n${items || 'None found.'}\n<i>Claims by criminal groups; they can be wrong.</i>` };
446
+ }
447
+ case '/company': {
448
+ if (!arg)
449
+ return needArg('NL004495445B01');
450
+ const d = (await o.companyCheck(arg)).result;
451
+ const vat = d.vat ? `<b>VAT ${esc(d.vat.country + d.vat.number)}: ${d.vat.valid ? 'VALID' : 'NOT VALID'}</b>${d.vat.name ? `\n${esc(d.vat.name)}` : ''}\n` : '';
452
+ const recs = d.records.slice(0, 3).map((x) => `• <a href="${esc(x.url)}">${esc(x.name)}</a> <i>${esc(x.status ?? '')} · ${esc(x.country ?? '')}${x.parent ? ` · parent ${esc(x.parent.name)}` : ''}</i>`).join('\n');
453
+ return { html: `${vat}${recs}${d.warnings.length ? `\n${d.warnings.map((w) => `! ${esc(w)}`).join('\n')}` : ''}`.trim() || 'Nothing found.' };
454
+ }
455
+ case '/breaches': {
456
+ const d = (await o.breaches(arg)).result;
457
+ const items = d.breaches.slice(0, 8).map((b) => `• <b>${esc(b.title)}</b> <i>${esc(b.breachDate ?? '')} · ${b.accounts.toLocaleString('en-US')} accounts</i>`).join('\n');
458
+ return { html: `<b>${d.query ? `Breaches: ${esc(d.query)}` : 'Newest breaches'}</b>${d.query ? ` (${d.total})` : ''}\n${items || 'None found.'}\n<i>Source: Have I Been Pwned (CC BY 4.0)</i>` };
459
+ }
460
+ case '/phone': {
461
+ if (!arg)
462
+ return needArg('+1 876 555 0100');
463
+ const d = (await o.phoneCheck(arg)).result;
464
+ return { html: `<b>${esc(d.e164)}</b>: <b>${esc(d.risk.toUpperCase())} RISK</b>\n${esc([d.country, d.lineType, d.carrier].filter(Boolean).join(' · '))}${d.warnings.length ? `\n${d.warnings.map((w) => `! ${esc(w)}`).join('\n')}` : ''}\n${esc(d.advice[0] ?? '')}` };
465
+ }
466
+ case '/satellite': {
467
+ const d = (await o.satellites(arg)).result;
468
+ if (d.mode === 'recent')
469
+ return { html: `<b>Launched in the last 30 days</b> (${d.total} objects)\n${d.launches.slice(0, 10).map((l) => `• ${esc(l.id)} ${esc(l.names.join(', '))} (${l.objects})`).join('\n')}` };
470
+ return { html: d.objects.length ? d.objects.slice(0, 4).map((x) => `<b>${esc(x.name)}</b> NORAD ${x.norad}${x.status ? ` · ${esc(x.status)}` : ''}${x.orbit ? `\n${x.orbit.regime} ${x.orbit.perigeeKm}-${x.orbit.apogeeKm} km · ${x.orbit.periodMin} min · ${x.orbit.inclination}°` : ''}`).join('\n\n') : esc(d.note) };
471
+ }
422
472
  case '/airport': {
423
473
  if (!arg)
424
474
  return needArg('JFK');
@@ -861,12 +911,12 @@ export class TelegramBot {
861
911
  const me = await this.call('getMe', {});
862
912
  this.log(`bot @${me.username} running; ${this.opts.allowedChats.length} allowed chat(s)`);
863
913
  if (this.isPublic) {
864
- await this.call('setMyCommands', { commands: ['scam', 'url', 'factcheck', 'recall', 'email', 'travel', 'airport', 'country', 'papers', 'audit', 'monitor', 'monitors', 'unmonitor', 'cve', 'hazards', 'blackout', 'alerts', 'help'].map((c) => ({ command: c, description: `Oculon ${c}` })) }).catch(() => { });
914
+ await this.call('setMyCommands', { commands: ['scam', 'url', 'factcheck', 'recall', 'email', 'phone', 'company', 'breaches', 'ip', 'hash', 'ransomware', 'travel', 'airport', 'country', 'papers', 'audit', 'monitor', 'monitors', 'unmonitor', 'cve', 'hazards', 'blackout', 'alerts', 'help'].map((c) => ({ command: c, description: `Oculon ${c}` })) }).catch(() => { });
865
915
  }
866
916
  for (const chat of this.opts.allowedChats)
867
917
  await this.call('setMyCommands', {
868
918
  scope: { type: 'chat', chat_id: Number(chat) },
869
- commands: ['ask', 'scam', 'monitors', 'unmonitor', 'url', 'factcheck', 'travel', 'audit', 'monitor', 'recall', 'email', 'airport', 'country', 'papers', 'case', 'brief', 'report', 'narratives', 'health', 'impact', 'contradict', 'sanctions', 'watch', 'fence', 'markets', 'launches', 'rewind', 'deployer', 'scoops', 'rh', 'ships', 'radar', 'signals', 'dossier', 'hype', 'footprint', 'plane', 'mil', 'events', 'lights', 'image', 'wallet', 'token', 'space', 'air', 'score', 'cloud', 'bgp', 'vulns', 'cve', 'regs', 'defi', 'squawk', 'filings', 'fires', 'sentinel', 'radar_image', 'darkships', 'vessel', 'blackout', 'hazards', 'podcast', 'exposure', 'social', 'calendar', 'connect', 'live', 'feedback', 'alerts'].filter((c) => onchainEnabled() || !/^(deployer|rh|wallet|token|defi|protocol)$/.test(c)).map((c) => ({ command: c, description: `Oculon ${c}` })),
919
+ commands: ['ask', 'scam', 'monitors', 'unmonitor', 'url', 'factcheck', 'travel', 'audit', 'monitor', 'recall', 'email', 'phone', 'company', 'breaches', 'ip', 'hash', 'ransomware', 'satellite', 'airport', 'country', 'papers', 'case', 'brief', 'report', 'narratives', 'health', 'impact', 'contradict', 'sanctions', 'watch', 'fence', 'markets', 'launches', 'rewind', 'deployer', 'scoops', 'rh', 'ships', 'radar', 'signals', 'dossier', 'hype', 'footprint', 'plane', 'mil', 'events', 'lights', 'image', 'wallet', 'token', 'space', 'air', 'score', 'cloud', 'bgp', 'vulns', 'cve', 'regs', 'defi', 'squawk', 'filings', 'fires', 'sentinel', 'radar_image', 'darkships', 'vessel', 'blackout', 'hazards', 'podcast', 'exposure', 'social', 'calendar', 'connect', 'live', 'feedback', 'alerts'].filter((c) => onchainEnabled() || !/^(deployer|rh|wallet|token|defi|protocol)$/.test(c)).map((c) => ({ command: c, description: `Oculon ${c}` })),
870
920
  }).catch(() => { });
871
921
  if (this.opts.watchMinutes && this.opts.watchMinutes > 0) {
872
922
  this.scheduler = startScheduler(this.oculon, {
package/dist/web/ask.html CHANGED
@@ -8,7 +8,7 @@
8
8
  <link rel="apple-touch-icon" href="/assets/icon-192.png">
9
9
  <title>Oculon Analyst</title>
10
10
  <meta name="description" content="Ask a question; Oculon checks live public data, then answers with a brief: bottom line, confidence, cited findings, and a cross-examination by other models.">
11
- <meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon Analyst"><meta property="og:description" content="Ask anything. It checks live public data first, then answers with a cited brief you can cross-examine."><meta property="og:image" content="https://oculon.live/assets/og.png"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og.png">
11
+ <meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon Analyst"><meta property="og:description" content="Ask anything. It checks live public data first, then answers with a cited brief you can cross-examine."><meta property="og:image" content="https://oculon.live/assets/og.png?v=2"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og.png?v=2">
12
12
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13
13
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
14
14
  <style>
Binary file
Binary file
Binary file
Binary file
@@ -8,7 +8,7 @@
8
8
  <link rel="icon" type="image/png" href="/favicon.ico">
9
9
  <link rel="apple-touch-icon" href="/assets/icon-192.png">
10
10
  <title>Oculon Docs</title>
11
- <meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon docs"><meta property="og:description" content="Install, CLI, remote MCP, SDK and every module of the Oculon intelligence engine."><meta property="og:url" content="https://oculon.live/docs"><meta property="og:image" content="https://oculon.live/assets/og.png"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og.png">
11
+ <meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon docs"><meta property="og:description" content="Install, CLI, remote MCP, SDK and every module of the Oculon intelligence engine."><meta property="og:url" content="https://oculon.live/docs"><meta property="og:image" content="https://oculon.live/assets/og-docs.png?v=2"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og-docs.png?v=2">
12
12
  <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13
13
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
14
14
  <style>