UNPKG

link-shield

Version:

Link Shield is a lightweight cybersecurity-focused npm package that detects suspicious and malicious URLs using heuristics, fuzzy matching, and threat intelligence patterns.

140 lines (98 loc) โ€ข 3.93 kB
# ๐Ÿ“ฆ Link Shield > **Link Shield** is a lightweight **cybersecurity-focused npm package** that detects **suspicious and malicious URLs** using heuristics, fuzzy matching, and threat intelligence patterns. > It helps developers, security teams, and applications identify **phishing attempts**, **typosquatting domains**, **dangerous downloads**, **obfuscated IPs**, **suspicious TLDs**, and other link-based threats. --- ## ๐Ÿ›ก๏ธ Why Cybersecurity Teams Need This More than **90% of cyberattacks start with a malicious link** โ€” whether in phishing emails, social engineering messages, or compromised websites. Attackers commonly use: * **Typosquatting domains** (`paypa1.com`, `g00gle.net`) * **Free hosting/CDNs** (Firebase, Dropbox, GitHub raw) * **Obfuscation tricks** (punycode, encoded IPs, double extensions) * **Dangerous downloads** (`.exe`, `.apk`, `.scr`) **Link Shield** provides a simple way to **detect and score these threats automatically**. It can be integrated into: * ๐Ÿ“จ **Email security filters** (detect phishing links in inbound emails) * ๐ŸŒ **Web applications** (protect users from malicious redirects) * ๐Ÿ” **Threat intelligence pipelines** (scan large volumes of URLs) * ๐Ÿง‘โ€๐Ÿ’ป **DevSecOps tooling** (validate links in CI/CD or monitoring scripts) --- ## ๐Ÿš€ Features * โœ… Detects **phishing & typosquatting** with fuzzy matching * โœ… Identifies **malicious protocols** (`javascript:`, `data:`, `file:`) * โœ… Flags **suspicious TLDs** (`.xyz`, `.tk`, `.ru`) * โœ… Catches **obfuscation tricks** (punycode, Unicode homoglyphs, hex IPs) * โœ… Detects **dangerous downloads** (`.exe`, `.apk`, `.scr`) * โœ… Warns on **free hosting/CDN abuse** (Dropbox, Firebase, GitHub raw, IPFS) * โœ… Provides a **risk score (0โ€“100)** with reasons for transparency --- ## ๐Ÿ“ฆ Installation ```bash npm install link-shield ``` or using yarn: ```bash yarn add link-shield ``` --- ## โšก Usage ```js const { detectSuspiciousLink } = require("link-shield"); const result = detectSuspiciousLink("http://g00gle.com/login"); console.log(result); ``` ### Example Output ```json { "url": "http://g00gle.com/login", "suspicious": true, "riskScore": 60, "reasons": [ "Domain contains numbers (possible typosquatting)", "Lookalike domain detected: g00gle โ‰ˆ google", "Suspicious keyword in domain" ] } ``` --- ## โš™๏ธ API ### `detectSuspiciousLink(url, options)` * **`url`** *(string, required)* โ†’ The URL to analyze * **`options`** *(object, optional)* * `threshold` *(number, default: 20)* โ†’ Minimum score to mark as `suspicious` **Returns:** ```ts { url: string; suspicious: boolean; riskScore: number; // 0โ€“100 reasons: string[]; } ``` --- ## ๐Ÿ” Cybersecurity Use Cases * **Email Security** โ†’ Filter malicious links in phishing campaigns * **Web Security** โ†’ Block suspicious redirects or downloads before execution * **Threat Intelligence** โ†’ Enrich suspicious indicators (IOCs) with scoring * **SOC Tools** โ†’ Automate link triage in incident response * **CI/CD Security** โ†’ Validate external links in codebases or docs --- ## ๐Ÿงช Testing We use **Jest** for testing. Run tests with: ```bash npm test ``` Example test case (`test/detector.test.js`): ```js const { detectSuspiciousLink } = require("../src"); test("flags g00gle.com as suspicious", () => { const result = detectSuspiciousLink("http://g00gle.com/login"); expect(result.suspicious).toBe(true); expect(result.riskScore).toBeGreaterThan(20); }); ``` --- ## ๐Ÿ”ฎ Roadmap * [ ] CLI support (`npx link-shield <url>`) * [ ] Configurable rule sets (enable/disable rules) * [ ] Integration with **threat intelligence feeds** * [ ] Browser extension integration * [ ] Machine-learning powered URL classification