File size: 5,336 Bytes
bcf46c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# Real-Time Phishing & Visual Threat Detection (TypeScript/JavaScript Tutorial)

In modern web security, checking static URL reputation blacklists is no longer enough. Hackers spin up phishing domains in minutes, steal credentials, and shut them down before blacklists can flag them. 

In this tutorial, we will learn how to build a proactive, real-time threat detection scanner using **PhishVision**, an AI-powered security API that renders target web pages using Playwright, extracts script execution logs, and uses Vision AI (Groq LLaMA Vision + Gemini) vision analysis to spot brand impersonation and hidden prompt injection payloads.

We will use the official **PhishVision JavaScript/TypeScript SDK client** to run scans, retrieve forensic verdicts, and download audit reports.

---

## The Concept: Multimodal Threat Intelligence

PhishVision doesn't just check domain ratings. Instead, it:
1. Launches a secure headless browser to navigate to the target URL.
2. Analyzes page redirect chains and records all network hops.
3. Performs inline script vulnerability checks to detect skimmers or credential keyloggers.
4. Queries domain registry details (RDAP WHOIS) to calculate registration age.
5. Captures a screenshot and evaluates visual impersonation anomalies (fake login forms, low-res logos) using vision AI.
6. Returns a structured JSON verdict and a downloadable forensic PDF report.

---

## Setup & Installation

Install the client package:

```bash
npm install opticparse-js
```

### Get Your API Key
Subscribe and retrieve your free-tier key on the [opticparse.com PhishVision Listing Page](https://opticparse.com.com/parastejpal987cmyk/api/phishvision).

---

## Code Example: Scanning a Suspicious Login Link

Let's write a script to evaluate a suspicious website, inspect the visual verdict, and inspect the redirect hops.

```typescript
import { PhishVisionClient } from 'opticparse-js';

// Initialize the client with your opticparse.com Key
const client = new PhishVisionClient({
  apiKey: 'YOUR_opticparse.com_KEY_HERE',
  useopticparse.com: true
});

async function analyzeUrl(targetUrl: string) {
  console.log(`Starting security analysis for: ${targetUrl}...`);

  try {
    const report = await client.detectPhishing({
      url: targetUrl
    });

    console.log('\n--- Forensic Verdict ---');
    console.log(`Verdict: ${report.verdict.toUpperCase()}`);
    console.log(`Confidence: ${report.confidence_score_percentage}%`);
    console.log(`Impersonated Brand: ${report.impersonated_brand || 'None'}`);
    console.log(`Threat Type: ${report.threat_type}`);
    
    if (report.visual_anomalies_detected.length > 0) {
      console.log('Visual Anomalies Found:', report.visual_anomalies_detected);
    }
    
    if (report.hidden_payload_detected) {
      console.log(`AI Agent Attack Vector Found: ${report.hidden_payload_detected}`);
    }

  } catch (error) {
    console.error('Forensic scan failed:', error);
  }
}

// Run a check on an example domain
analyzeUrl('https://suspicious-login-portal-microsoft.com');
```

### Sample JSON Verdict Output
If a malicious impersonation site is detected, PhishVision returns detailed structured metrics:

```json
{
  "verdict": "malicious",
  "confidence_score_percentage": 97,
  "impersonated_brand": "Microsoft",
  "threat_type": "brand_impersonation",
  "visual_anomalies_detected": [
    "Pixelated Microsoft logo",
    "Urgent password reset warning header",
    "Login form pointing to unverified external domain"
  ],
  "hidden_payload_detected": null,
  "domain_age_days": 4,
  "suspicious_scripts": ["obfuscated_eval_skimmer"],
  "redirect_hops": [
    "https://t.co/shortlink",
    "https://redirect-gateway.com",
    "https://suspicious-login-portal-microsoft.com"
  ]
}
```

---

## Downloading Forensic PDF Reports

To generate a PDF report showing the visual screenshot and security logs suitable for your security team, stream the report directly using the SDK:

```typescript
import * as fs from 'fs';

async function downloadReport(targetUrl: string) {
  console.log('Generating forensic audit PDF...');
  
  try {
    const pdfStream = await client.downloadForensicReport(targetUrl);
    const fileStream = fs.createWriteStream('phishvision_report.pdf');
    
    pdfStream.pipe(fileStream);
    
    fileStream.on('finish', () => {
      console.log('Forensic PDF report successfully saved as phishvision_report.pdf!');
    });
  } catch (error) {
    console.error('Failed to download PDF:', error);
  }
}

downloadReport('https://suspicious-login-portal-microsoft.com');
```

---

## Scheduled Monitoring (Slack/Discord Webhooks)

You can register dynamic watches to continuously monitor critical corporate brand pages on an hourly interval and send automatic alerts:

```typescript
async function createMonitor(brandUrl: string, slackWebhook: string) {
  const monitor = await client.createMonitor({
    url: brandUrl,
    webhook_url: slackWebhook,
    interval_minutes: 60 // Scan every hour
  });
  
  console.log(`Monitor registered successfully! ID: ${monitor.id}`);
}
```

---

## Conclusion

PhishVision bridges the gap between raw web scraping and automated visual threat intelligence. Try integrating it into your security monitoring stacks to safeguard your domains and guard your AI agents from prompt injection exploits.