honeyweb-core 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -156,6 +156,10 @@ function honeyWeb() {
156
156
  if (TRAP_PATHS.includes(req.path)) {
157
157
  if (await banIP(clientIP, "Trap Triggered")) {
158
158
  generateThreatReport(clientIP, userAgent, "Reconnaissance", `Accessed trap: ${req.path}`);
159
+
160
+ // detect browser of attacker and other info (hardware?) for logging
161
+
162
+
159
163
  }
160
164
  return res.status(403).send('<h1>403 Forbidden</h1>');
161
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "honeyweb-core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/index V1.js DELETED
@@ -1,85 +0,0 @@
1
- // honeyweb-core/index.js
2
- const fs = require('fs-extra');
3
- const path = require('path');
4
- const cheerio = require('cheerio');
5
-
6
- // File path for storing banned IPs automatically
7
- const DB_FILE = path.join(__dirname, 'blocked-ips.json');
8
-
9
- // Ensure the JSON file exists on startup
10
- if (!fs.existsSync(DB_FILE)) {
11
- fs.writeJsonSync(DB_FILE, []);
12
- }
13
-
14
- // Configuration: List of fake trap paths
15
- // These look like real admin pages to a bot
16
- const TRAP_PATHS = [
17
- '/admin-backup-v2',
18
- '/wp-login-hidden',
19
- '/db-dump-2024',
20
- '/auth/root-access',
21
- '/sys/config-safe'
22
- ];
23
-
24
- /**
25
- * HoneyWeb Middleware
26
- * Usage: app.use(honeyWeb());
27
- */
28
- function honeyWeb() {
29
- return async (req, res, next) => {
30
- const clientIP = req.ip || req.connection.remoteAddress;
31
-
32
- // 1. LOAD BANNED LIST
33
- let bannedIPs = [];
34
- try {
35
- bannedIPs = await fs.readJson(DB_FILE);
36
- } catch (err) {
37
- console.error("HoneyWeb: Error reading blocklist", err);
38
- }
39
-
40
- // 2. CHECK IF IP IS ALREADY BANNED
41
- if (bannedIPs.includes(clientIP)) {
42
- console.log(`[HoneyWeb] BLOCKED access from banned IP: ${clientIP}`);
43
- return res.status(403).send('<h1>403 Forbidden</h1><p>Your IP has been flagged for suspicious activity.</p>');
44
- }
45
-
46
- // 3. CHECK IF TRAP ACCESSED
47
- if (TRAP_PATHS.includes(req.path)) {
48
- console.log(`[HoneyWeb] 🚨 TRAP TRIGGERED by ${clientIP} on ${req.path}`);
49
-
50
- // Ban the IP immediately
51
- if (!bannedIPs.includes(clientIP)) {
52
- bannedIPs.push(clientIP);
53
- await fs.writeJson(DB_FILE, bannedIPs);
54
- }
55
-
56
- return res.status(403).send('<h1>403 Forbidden</h1><p>You have accessed a restricted area.</p>');
57
- }
58
-
59
- // 4. INJECT TRAPS INTO HTML RESPONSES
60
- const originalSend = res.send;
61
-
62
- res.send = function (body) {
63
- // Only inject if the content is HTML
64
- if (typeof body === 'string' && (body.includes('<html') || body.includes('<body'))) {
65
- const $ = cheerio.load(body);
66
-
67
- // Pick a random trap
68
- const trapUrl = TRAP_PATHS[Math.floor(Math.random() * TRAP_PATHS.length)];
69
-
70
- // Create invisible link (Hidden by CSS)
71
- const trapLink = `<a href="${trapUrl}" style="opacity:0; position:absolute; z-index:-999; left:-9999px;">Admin Panel</a>`;
72
-
73
- // Inject into body
74
- $('body').append(trapLink);
75
-
76
- body = $.html();
77
- }
78
- originalSend.call(this, body);
79
- };
80
-
81
- next();
82
- };
83
- }
84
-
85
- module.exports = honeyWeb;