domainlooker
Version:
🕵️ Mission-critical domain intelligence gathering tool with spy-themed interface. Comprehensive WHOIS, DNS, SSL, network analysis, subdomain discovery, and API-ready JSON exports.
59 lines • 2.12 kB
JavaScript
import whois from 'whois';
export class WhoisService {
async lookup(domain) {
return new Promise((resolve, reject) => {
whois.lookup(domain, (err, data) => {
if (err) {
reject(err);
return;
}
const parsed = this.parseWhoisData(data);
resolve(parsed);
});
});
}
parseWhoisData(data) {
const lines = data.split('\n');
const result = {};
for (const line of lines) {
const trimmed = line.trim();
if (trimmed.match(/registrar:/i)) {
result.registrar = this.extractValue(trimmed);
}
else if (trimmed.match(/creation date|registered on|registration date:/i)) {
result.registrationDate = this.extractValue(trimmed);
}
else if (trimmed.match(/expir|expiry date|expires on:/i)) {
result.expirationDate = this.extractValue(trimmed);
}
else if (trimmed.match(/name server|nserver:/i)) {
if (!result.nameServers)
result.nameServers = [];
const ns = this.extractValue(trimmed);
if (ns && !result.nameServers.includes(ns)) {
result.nameServers.push(ns);
}
}
else if (trimmed.match(/registrant country:/i)) {
result.registrantCountry = this.extractValue(trimmed);
}
else if (trimmed.match(/status:/i)) {
if (!result.status)
result.status = [];
const status = this.extractValue(trimmed);
if (status && !result.status.includes(status)) {
result.status.push(status);
}
}
}
return result;
}
extractValue(line) {
const parts = line.split(':');
if (parts.length > 1) {
return parts.slice(1).join(':').trim();
}
return undefined;
}
}
//# sourceMappingURL=whois.js.map