如何用 40 行 Node 和 RDAP 查詢「交易平台」網域年齡
Check how old a "trading platform" domain is with 40 lines of Node and RDAP
Flipzo 提供一段適用於 Node 18 或更新版本的腳本,透過 RDAP 查詢網域註冊日期、年齡、到期日和註冊商,毋須 API key 或額外依賴。文章以 SEC 在 2026 年 11 月 19 日起訴 8 個實體為背景;投訴稱相關行為涉及 4 組虛假投資顧問與加密貨幣交易平台,逾 1,500 名美國投資者至少損失 $37 million。
The news
On November 19, 2026 the SEC filed a complaint in federal court in Colorado against eight entities it says ran four fake investment adviser and crypto trading platform pairs. Per the complaint, more than 1,500 US investors lost at least $37 million. Victims were recruited through WhatsApp groups, shown fake gains in the platform's app, and asked to pay a separate "fee" before any withdrawal. Each adviser and platform pair ran for a few months before a new pair replaced it. (SEC press release, complaint PDF)
That rotation is the part a small script can help with. A platform that has existed for a few months usually sits on a domain that is only a few months old. Domain age proves nothing by itself, plenty of honest projects are new, but if someone tells you a platform has a long track record and its domain was registered last spring, you've learned something.
RDAP in one paragraph
RDAP (Registration Data Access Protocol) is the JSON replacement for WHOIS. Each registry runs an RDAP server, and IANA publishes a bootstrap file, https://data.iana.org/rdap/dns.json, that maps top-level domains to those servers. A domain record has an events array with entries like registration and expiration, and an entities array that names the registrar. No API key is needed.
The script
Save as domain-age.mjs. It needs Node 18 or newer for the built-in fetch.
// Usage: node domain-age.mjs <domain> [<domain> ...]
// Looks up each domain's registration date over RDAP, the registries' own JSON service.
// No API key, no dependencies (Node 18+). IANA's bootstrap file says which RDAP server
// answers for each top-level domain.
const days = (iso) => Math.floor((Date.now() - new Date(iso).getTime()) / 86400000);
async function rdapBase(tld) {
const boot = await (await fetch('https://data.iana.org/rdap/dns.json')).json();
const hit = boot.services.find(([tlds]) => tlds.includes(tld));
return hit ? hit[1][0].replace(/\/?$/, '/') : null;
}
async function lookup(domain) {
const tld = domain.split('.').pop().toLowerCase();
const base = await rdapBase(tld);
if (!base) return { domain, error: `no RDAP server listed for .${tld}` };
const res = await fetch(`${base}domain/${encodeURIComponent(domain)}`, {
headers: { accept: 'application/rdap+json' },
});
if (!res.ok) return { domain, error: `RDAP answered ${res.status}` };
const data = await res.json();
const ev = (name) => data.events?.find((e) => e.eventAction === name)?.eventDate;
const registered = ev('registration');
const registrar = data.entities
?.find((e) => e.roles?.includes('registrar'))
?.vcardArray?.[1]?.find((f) => f[0] === 'fn')?.[3];
return {
domain,
registered: registered?.slice(0, 10) ?? 'not given',
ageDays: registered ? days(registered) : null,
expires: ev('expiration')?.slice(0, 10) ?? 'not given',
registrar: registrar ?? 'not given',
};
}
const domains = process.argv.slice(2);
if (!domains.length) {
console.log('usage: node domain-age.mjs <domain> [<domain> ...]');
process.exit(1);
}
for (const d of domains) {
try {
const r = await lookup(d);
if (r.error) { console.log(`${d}: ${r.error}`); continue; }
const flag = r.ageDays !== null && r.ageDays < 365 ? ' <- under a year old' : '';
console.log(`${r.domain}: registered ${r.registered} (${r.ageDays ?? '?'} days), expires ${r.expires}, registrar ${r.registrar}${flag}`);
} catch (err) {
console.log(`${d}: lookup failed (${err.message})`);
}
}
Running it
node domain-age.mjs github.com sec.gov wikipedia.org
Output when I ran it on November 23, 2026:
github.com: registered 2007-10-09 (6984 days), expires 2028-10-09, registrar MarkMonitor Inc.
sec.gov: registered 1997-10-02 (10644 days), expires 2027-08-13, registrar get.gov
wikipedia.org: registered 2001-01-13 (9445 days), expires 2027-01-13, registrar MarkMonitor Inc.
Anything under a year gets a flag at the end of the line.
Limits worth knowing
- Some country-code registries don't run RDAP yet, so the script prints "no RDAP server listed". Use that registry's WHOIS instead.
- A few registries hide the registration date. The script says "not given" rather than guessing.
- The script fetches the bootstrap file once per domain. If you check a long list, cache it.
- A domain can be old and still bad (it may have been bought second hand), and a new domain can be fine. Treat the age as one input next to the obvious one from this case: if a platform wants a fee before it will release your money, the money isn't coming.
The SEC's release also points people to Investor.gov to check whether a seller or adviser is registered, which covers the "we're SEC registered" claim the scammers leaned on.
This post was drafted with AI assistance. The script was run as shown above.
來源:DEV Community · dev.to