hackertarget_aslookup
Look up ASN information for IP addresses or AS numbers to identify network ownership and routing data using HackerTarget's database.
Instructions
Look up ASN information for an IP or ASN via HackerTarget. Free tier: 50 queries/day.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | IP address or ASN to look up |
Implementation Reference
- src/hackertarget/index.ts:52-65 (handler)The implementation of the hackertargetAslookup function, which handles the tool's core logic by querying the HackerTarget API and processing the returned text.
export async function hackertargetAslookup(query: string): Promise<AslookupResult> { const text = await htFetch("aslookup", query); const lines = text.split("\n").filter(Boolean); const entries: AslookupResult["entries"] = []; for (const line of lines) { const parts = line.split(",").map((p) => p.trim().replace(/^"|"$/g, "")); if (parts.length >= 3) { entries.push({ asn: parts[0], ip: parts[1], owner: parts[2] }); } } return { query, raw: text, entries }; } - src/protocol/tools.ts:426-433 (registration)The registration of the 'hackertarget_aslookup' tool in the protocol layer, defining its schema, description, and execution logic.
const hackertargetAslookupTool: ToolDef = { name: "hackertarget_aslookup", description: "Look up ASN information for an IP or ASN via HackerTarget. Free tier: 50 queries/day.", schema: { query: z.string().describe("IP address or ASN to look up"), }, execute: async (args) => json(await hackertargetAslookup(args.query as string)), }; - src/hackertarget/index.ts:12-16 (schema)The type definition for the AslookupResult, which specifies the structure of the tool's output.
interface AslookupResult { query: string; raw: string; entries: { asn: string; ip: string; owner: string }[]; }