From 441572170f852bad1a61425471ef0e4db6877ae7 Mon Sep 17 00:00:00 2001 From: Manabu Niseki Date: Sun, 5 Jan 2020 09:55:38 +0900 Subject: [PATCH] feat: add Spyse lookup --- src/lib/searcher/index.ts | 1 + src/lib/searcher/searchers.ts | 2 ++ src/lib/searcher/spyse.ts | 27 +++++++++++++++++++++++++++ test/searcher/spyse.spec.ts | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 src/lib/searcher/spyse.ts create mode 100644 test/searcher/spyse.spec.ts diff --git a/src/lib/searcher/index.ts b/src/lib/searcher/index.ts index 70d898aa..3dd10d90 100644 --- a/src/lib/searcher/index.ts +++ b/src/lib/searcher/index.ts @@ -44,6 +44,7 @@ export { SecurityTrails } from "./securitytrails"; export { Shodan } from "./shodan"; export { Sploitus } from "./sploitus"; export { SpyOnWeb } from "./spyonweb"; +export { Spyse } from "./spyse"; export { Talos } from "./talos"; export { ThreatConnect } from "./threatconnect"; export { ThreatCrowd } from "./threatcrowd"; diff --git a/src/lib/searcher/searchers.ts b/src/lib/searcher/searchers.ts index 5382cb4d..ac6e2960 100644 --- a/src/lib/searcher/searchers.ts +++ b/src/lib/searcher/searchers.ts @@ -45,6 +45,7 @@ import { Shodan, Sploitus, SpyOnWeb, + Spyse, Talos, ThreatConnect, ThreatCrowd, @@ -112,6 +113,7 @@ export const Searchers: Searcher[] = [ new Shodan(), new Sploitus(), new SpyOnWeb(), + new Spyse(), new Talos(), new ThreatConnect(), new ThreatCrowd(), diff --git a/src/lib/searcher/spyse.ts b/src/lib/searcher/spyse.ts new file mode 100644 index 00000000..f4cda9db --- /dev/null +++ b/src/lib/searcher/spyse.ts @@ -0,0 +1,27 @@ +import { buildURL } from "../url_builder"; +import { Searcher, SearchableType } from "../types"; +import { extractASNumber } from "../utility"; + +export class Spyse implements Searcher { + public baseURL: string; + public name: string; + public supportedTypes: SearchableType[] = ["ip", "domain", "asn"]; + + public constructor() { + this.baseURL = "https://spyse.com"; + this.name = "Spyse"; + } + + public searchByIP(query: string): string { + return buildURL(this.baseURL, `/target/ip/${query}`); + } + + public searchByDomain(query: string): string { + return buildURL(this.baseURL, `/target/domain/${query}`); + } + + public searchByASN(query: string): string { + const asn = extractASNumber(query); + return buildURL(this.baseURL, `/target/as/${asn}`); + } +} diff --git a/test/searcher/spyse.spec.ts b/test/searcher/spyse.spec.ts new file mode 100644 index 00000000..4b51836b --- /dev/null +++ b/test/searcher/spyse.spec.ts @@ -0,0 +1,35 @@ +import { expect } from "chai"; +import "mocha"; +import { Spyse } from "../../src/lib/searcher"; + +describe("Spyse", function() { + const subject = new Spyse(); + + it("should support IP, domain and ASN", function() { + expect(subject.supportedTypes).to.deep.equal(["ip", "domain", "asn"]); + }); + + describe("#searchByIP", function() { + it("should return URL", function() { + expect(subject.searchByIP("1.1.1.1")).to.equal( + "https://spyse.com/target/ip/1.1.1.1" + ); + }); + }); + + describe("#searchByDomain", function() { + it("should return URL", function() { + expect(subject.searchByDomain("example.com")).to.equal( + "https://spyse.com/target/domain/example.com" + ); + }); + }); + + describe("#searchByASN", function() { + it("should return URL", function() { + expect(subject.searchByASN("AS13335")).to.equal( + "https://spyse.com/target/as/13335" + ); + }); + }); +});