ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Privacy

Phishing URL Detection

Detect spoofing, suspicious TLDs, punycode homograph attacks, and redirect chains.

2 snippets Intermediate phishing-url-checker
phishingpunycodehomographsuspicious TLDURL analysis

What you'll learn

  • Punycode / homograph detection
  • Suspicious TLD and pattern check

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. Try the interactive related tool to see the concept in action.
Code Snippets

Copy-paste code snippets

2 ready-to-use snippets for phishing url detection. Click copy and paste into your project.

Punycode / homograph detection
                function detectHomograph(url) {
  try {
    const u = new URL(url);
    const domain = u.hostname;

    // Check for punycode (IDN)
    if (domain.includes('xn--')) {
      // Decode and compare
      const decoded = domain; // use punycode library
      return {
        suspicious: true,
        reason: 'IDN/punycode domain — possible homograph attack',
        original: domain,
      };
    }

    // Check for lookalike characters
    const lookalikes = /[0O1lI|]/;
    if (lookalikes.test(domain)) {
      return {
        suspicious: true,
        reason: 'Contains lookalike characters (0/O, 1/l, I/|)',
      };
    }

    return { suspicious: false };
  } catch (e) {
    return { suspicious: true, reason: 'Invalid URL' };
  }
}
              
Suspicious TLD and pattern check
                const SUSPICIOUS_TLDS = [
  '.zip', '.mov', '.xyz', '.top', '.tk', '.ml',
  '.ga', '.cf', '.gq', '.cn', '.ru'
];

function checkUrl(url) {
  const flags = [];
  const u = new URL(url);

  // Suspicious TLD
  if (SUSPICIOUS_TLDS.some(tld => u.hostname.endsWith(tld)))
    flags.push('Suspicious TLD');

  // Excessive subdomains
  if (u.hostname.split('.').length > 5)
    flags.push('Excessive subdomain depth');

  // IP address as hostname
  if (/^\d+\.\d+\.\d+\.\d+$/.test(u.hostname))
    flags.push('Raw IP address as hostname');

  // @ symbol in URL (user:pass@host)
  if (u.href.includes('@') && !u.href.includes('@'))
    flags.push('Credentials in URL');

  // URL shortener
  const shorteners = ['bit.ly', 'tinyurl.com', 't.co', 'goo.gl'];
  if (shorteners.some(s => u.hostname === s))
    flags.push('URL shortener — destination unknown');

  return flags;
}
              
100% Free · No signup · No cost

Generate something unguessable right now

148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site