Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityTestMu AI Review: How AI is Solving the Quality Engineering Problem(23.09.2026 um 13:18 Uhr)
Windows Tipps & SecurityAmazon haut den kabellosen Dyson V8 Stabstaubsauger zum Tiefstpreis raus(24.09.2026 um 09:32 Uhr)
Windows Tipps & SecurityUpdates beheben etliche Schwachstellen in Foxit PDF Reader(24.09.2026 um 09:44 Uhr)
Windows Tipps & Security„Vom Experience Center zum monumentalen Signage-Projekt“(24.09.2026 um 10:30 Uhr)
Windows Tipps & SecurityTestMu AI Review: How AI is Solving the Quality Engineering Problem(23.09.2026 um 13:18 Uhr)
Windows Tipps & SecurityAmazon haut den kabellosen Dyson V8 Stabstaubsauger zum Tiefstpreis raus(24.09.2026 um 09:32 Uhr)
Windows Tipps & SecurityUpdates beheben etliche Schwachstellen in Foxit PDF Reader(24.09.2026 um 09:44 Uhr)
Windows Tipps & Security„Vom Experience Center zum monumentalen Signage-Projekt“(24.09.2026 um 10:30 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Tutorial: How to Detect VPNs and Tor Users in Node.js Express

If you run any kind of public API, SaaS, or forum, you already know the pain: Bot traffic. You ban a user for spamming, and 5 seconds later they are back with a new account because they toggled their VPN. You block an IP, and they switch…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

If you run any kind of public API, SaaS, or forum, you already know the pain: Bot traffic.



You ban a user for spamming, and 5 seconds later they are back with a new account because they toggled their VPN. You block an IP, and they switch to a Tor exit node.



In this tutorial, I'm going to show you how to detect Non-Residential IPs (VPNs, Proxies, and Hosting Centers) in your Node.js application so you can block them—or at least challenge them with a CAPTCHA—before they touch your database.






The Goal



We want a middleware function in Express that looks like this:







javascript
app.use((req, res, next) => {
if (isHighRisk(req.ip)) {
return res.status(403).send("VPNs are not allowed.");
}
next();
});

Here is how to build it.

Method 1: The "Hard" Way (Self-Hosted Lists)
If you want to do this entirely for free and offline, you need to download and maintain lists of known "Bad IPs."

Step 1: Get the Data
You will need to find a text file of Tor Exit nodes and IP ranges for major cloud providers (AWS, DigitalOcean, Linode).

Tor Exit Nodes: The Tor project publishes a list of exit addresses.

Cloud Ranges: AWS and Google publish their IP ranges in massive JSON files.

Step 2: The Code
You'll need to parse these lists into memory and check every incoming request.

JavaScript

const fs = require('fs');
const ipRangeCheck = require('ip-range-check'); // You'll need this npm package

// 1. Load the massive lists into memory (Careful with RAM!)
const torNodes = fs.readFileSync('tor-exit-nodes.txt', 'utf8').split('\n');
const awsRanges = JSON.parse(fs.readFileSync('aws-ip-ranges.json', 'utf8')).prefixes.map(p => p.ip_prefix);

function isHighRisk(userIp) {
// Check if IP is in the Tor list
if (torNodes.includes(userIp)) return true;

// Check if IP is in a Cloud Range (CPU intensive)
if (ipRangeCheck(userIp, awsRanges)) return true;

return false;
}

The Problem with Method 1
Stale Data: VPN providers rotate IPs daily. If you don't update your lists every hour, you will miss attacks.

Memory Hog: Loading millions of IPs into Node.js memory can crash your server (I learned this the hard way and OOM-killed my $5 droplet).

False Positives: It's hard to distinguish between a "Good" data center IP and a "Bad" VPN.

Method 2: The "Easy" Way (Live API Lookup)
After struggling with maintaining my own lists, I built a dedicated API called CandyCornDB to handle the heavy lifting. It specifically targets Infrastructure (ASN/ISP data) rather than just "bad behavior," so it catches fresh VPNs instantly.

Here is how to implement it in 3 lines of code.

Step 1: Get a Free API Key
You can grab a free key here (no credit card required).

Step 2: The Middleware
We will query the API, which returns a trustScore (0-100).

0-50: Residential / Safe

75+: High Risk (VPN / Tor / Hosting)

JavaScript

const axios = require('axios');

async function checkRiskScore(req, res, next) {
const userIp = req.ip;

try {
const response = await axios.get('[https://candycorndb.com/api/public/ip-score](https://candycorndb.com/api/public/ip-score)', {
params: { ip: userIp }
});

const { score, isTor, isVPN } = response.data;

// BLOCK if it's a confirmed Tor node or very high risk
if (isTor || score > 85) {
return res.status(403).json({ error: 'Anonymizers not allowed.' });
}

// CHALLENGE if it's suspicious (e.g., DigitalOcean droplet)
if (score >= 50) {
// Logic to show a CAPTCHA goes here...
console.log(`Suspicious traffic from ${userIp}`);
}

next();
} catch (err) {
// Fail open: If API is down, let the user in so you don't block real people
next();
}
}

// Apply to your sensitive routes
app.post('/api/signup', checkRiskScore, (req, res) => {
res.send("Account created!");
});

Why this is better
Just-in-Time Scanning: If the API hasn't seen the IP before, it scans open ports and ISP data in <500ms. You never get "Unknown."

No Maintenance: You don't need to download daily CSV dumps.

Saves RAM: Your Node server handles the logic, not the database storage.

Summary

Blocking bad IPs is an arms race. If you are building a small hobby project, Method 1 is a fun learning exercise. But if you are protecting a production app, offloading the risk detection to a dedicated API (Method 2) is usually cheaper than the time you'll spend unbanning spam accounts.

Let me know if you have questions about IP filtering logic! I've spent way too much time staring at ASN lists lately. 😅


CTI Threat Relationship Graph2 Knoten / 1 Relationen
CVE / Incident Software MITRE ATT&CK CWE Weakness IoC
SOC Incident Playbook: Vulnerability Remediation & Verification
title: Detect Exploitation - Tutorial: How to Detect VPNs and Tor Users in Node.js Express
id: 2013c0b4-3b20-45cf-a2cc-169e25d05daf
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Tutorial: How to Detect VPNs a" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Tutorial: How to Detect VPNs and Tor Use.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Tutorial: How to Detect VPNs and Tor Users in Node.js Express

Thematisch verwandte Begriffe: Tutorial, Detect, VPNs, Users · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97056 | SigNoz versions from v0.98.0 up to (but not including) v0.143.0, when co…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick