@fanboynz/network-scanner 1.0.38 → 1.0.40
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/README.md +10 -0
- package/nwss.js +80 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -66,6 +66,8 @@ A Puppeteer-based tool for scanning websites to find third-party (or optionally
|
|
|
66
66
|
| `--eval-on-doc` | Globally enable evaluateOnNewDocument() for Fetch/XHR interception |
|
|
67
67
|
| `--help`, `-h` | Show this help menu |
|
|
68
68
|
| `--version` | Show script version |
|
|
69
|
+
| `--max-concurrent <number>` | Maximum concurrent site processing (1-50, overrides config/default) |
|
|
70
|
+
| `--cleanup-interval <number>` | Browser restart interval in URLs processed (1-1000, overrides config/default) |
|
|
69
71
|
|
|
70
72
|
### Validation Options
|
|
71
73
|
|
|
@@ -251,6 +253,8 @@ These options go at the root level of your config.json:
|
|
|
251
253
|
| `ignore_similar` | Boolean | `true` | Ignore domains similar to already found domains |
|
|
252
254
|
| `ignore_similar_threshold` | Integer | `80` | Similarity threshold percentage for ignore_similar |
|
|
253
255
|
| `ignore_similar_ignored_domains` | Boolean | `true` | Ignore domains similar to ignoreDomains list |
|
|
256
|
+
| `max_concurrent_sites` | Integer | `6` | Maximum concurrent site processing (1-50) |
|
|
257
|
+
| `resource_cleanup_interval` | Integer | `180` | Browser restart interval in URLs processed (1-1000) |
|
|
254
258
|
|
|
255
259
|
---
|
|
256
260
|
|
|
@@ -289,6 +293,12 @@ node nwss.js --clean-rules existing_rules.txt
|
|
|
289
293
|
node nwss.js --debug --color -o stealth_rules.txt
|
|
290
294
|
```
|
|
291
295
|
|
|
296
|
+
### Performance Tuning
|
|
297
|
+
```bash
|
|
298
|
+
# High-performance scanning with custom concurrency
|
|
299
|
+
node nwss.js --max-concurrent 12 --cleanup-interval 300 -o rules.txt
|
|
300
|
+
```
|
|
301
|
+
|
|
292
302
|
### Stealth Configuration Examples
|
|
293
303
|
|
|
294
304
|
#### E-commerce Site Scanning
|
package/nwss.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// === Network scanner script (nwss.js) v1.0.
|
|
1
|
+
// === Network scanner script (nwss.js) v1.0.40 ===
|
|
2
2
|
|
|
3
3
|
// puppeteer for browser automation, fs for file system operations, psl for domain parsing.
|
|
4
4
|
// const pLimit = require('p-limit'); // Will be dynamically imported
|
|
@@ -33,9 +33,7 @@ const { navigateWithRedirectHandling, handleRedirectTimeout } = require('./lib/r
|
|
|
33
33
|
const { monitorBrowserHealth, isBrowserHealthy } = require('./lib/browserhealth');
|
|
34
34
|
|
|
35
35
|
// --- Script Configuration & Constants ---
|
|
36
|
-
const VERSION = '1.0.
|
|
37
|
-
const MAX_CONCURRENT_SITES = 12;
|
|
38
|
-
const RESOURCE_CLEANUP_INTERVAL = 180; // Close browser and restart every N sites to free resources
|
|
36
|
+
const VERSION = '1.0.40'; // Script version
|
|
39
37
|
|
|
40
38
|
// get startTime
|
|
41
39
|
const startTime = Date.now();
|
|
@@ -105,6 +103,18 @@ if (cleanRulesIndex !== -1 && args[cleanRulesIndex + 1] && !args[cleanRulesIndex
|
|
|
105
103
|
cleanRules = true; // Override the boolean if file specified
|
|
106
104
|
}
|
|
107
105
|
|
|
106
|
+
let maxConcurrentSites = null;
|
|
107
|
+
const maxConcurrentIndex = args.findIndex(arg => arg === '--max-concurrent');
|
|
108
|
+
if (maxConcurrentIndex !== -1 && args[maxConcurrentIndex + 1]) {
|
|
109
|
+
maxConcurrentSites = parseInt(args[maxConcurrentIndex + 1]);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let cleanupInterval = null;
|
|
113
|
+
const cleanupIntervalIndex = args.findIndex(arg => arg === '--cleanup-interval');
|
|
114
|
+
if (cleanupIntervalIndex !== -1 && args[cleanupIntervalIndex + 1]) {
|
|
115
|
+
cleanupInterval = parseInt(args[cleanupIntervalIndex + 1]);
|
|
116
|
+
}
|
|
117
|
+
|
|
108
118
|
const enableColors = args.includes('--color') || args.includes('--colour');
|
|
109
119
|
let adblockRulesMode = args.includes('--adblock-rules');
|
|
110
120
|
|
|
@@ -327,6 +337,8 @@ General Options:
|
|
|
327
337
|
--eval-on-doc Globally enable evaluateOnNewDocument() for Fetch/XHR interception
|
|
328
338
|
--help, -h Show this help menu
|
|
329
339
|
--version Show script version
|
|
340
|
+
--max-concurrent <number> Maximum concurrent site processing (1-50, overrides config/default)
|
|
341
|
+
--cleanup-interval <number> Browser restart interval in URLs processed (1-1000, overrides config/default)
|
|
330
342
|
--remove-tempfiles Remove Chrome/Puppeteer temporary files before exit
|
|
331
343
|
|
|
332
344
|
Validation Options:
|
|
@@ -342,7 +354,8 @@ Global config.json options:
|
|
|
342
354
|
ignore_similar: true/false Ignore domains similar to already found domains (default: true)
|
|
343
355
|
ignore_similar_threshold: 80 Similarity threshold percentage for ignore_similar (default: 80)
|
|
344
356
|
ignore_similar_ignored_domains: true/false Ignore domains similar to ignoreDomains list (default: true)
|
|
345
|
-
|
|
357
|
+
max_concurrent_sites: 6 Maximum concurrent site processing (1-50, default: 6)
|
|
358
|
+
resource_cleanup_interval: 180 Browser restart interval in URLs processed (1-1000, default: 180)
|
|
346
359
|
|
|
347
360
|
Per-site config.json options:
|
|
348
361
|
url: "site" or ["site1", "site2"] Single URL or list of URLs
|
|
@@ -456,7 +469,68 @@ try {
|
|
|
456
469
|
process.exit(1);
|
|
457
470
|
}
|
|
458
471
|
// Extract config values while ignoring 'comments' field at global and site levels
|
|
459
|
-
const {
|
|
472
|
+
const {
|
|
473
|
+
sites = [],
|
|
474
|
+
ignoreDomains = [],
|
|
475
|
+
blocked: globalBlocked = [],
|
|
476
|
+
whois_delay = 3000,
|
|
477
|
+
whois_server_mode = 'random',
|
|
478
|
+
ignore_similar = true,
|
|
479
|
+
ignore_similar_threshold = 80,
|
|
480
|
+
ignore_similar_ignored_domains = true,
|
|
481
|
+
max_concurrent_sites = 6,
|
|
482
|
+
resource_cleanup_interval = 180,
|
|
483
|
+
comments: globalComments,
|
|
484
|
+
...otherGlobalConfig
|
|
485
|
+
} = config;
|
|
486
|
+
|
|
487
|
+
// Apply global configuration overrides with validation
|
|
488
|
+
// Priority: Command line args > config.json > defaults
|
|
489
|
+
const MAX_CONCURRENT_SITES = (() => {
|
|
490
|
+
// Check command line argument first
|
|
491
|
+
if (maxConcurrentSites !== null) {
|
|
492
|
+
if (maxConcurrentSites > 0 && maxConcurrentSites <= 50) {
|
|
493
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Using command line max_concurrent_sites: ${maxConcurrentSites}`));
|
|
494
|
+
return maxConcurrentSites;
|
|
495
|
+
} else {
|
|
496
|
+
console.warn(`⚠ Invalid --max-concurrent value: ${maxConcurrentSites}. Must be 1-50. Using config/default value.`);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// Check config.json value
|
|
501
|
+
if (typeof max_concurrent_sites === 'number' && max_concurrent_sites > 0 && max_concurrent_sites <= 50) {
|
|
502
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Using config max_concurrent_sites: ${max_concurrent_sites}`));
|
|
503
|
+
return max_concurrent_sites;
|
|
504
|
+
} else if (max_concurrent_sites !== 6) {
|
|
505
|
+
console.warn(`⚠ Invalid config max_concurrent_sites value: ${max_concurrent_sites}. Using default: 6`);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Use default
|
|
509
|
+
return 6;
|
|
510
|
+
})();
|
|
511
|
+
|
|
512
|
+
const RESOURCE_CLEANUP_INTERVAL = (() => {
|
|
513
|
+
// Check command line argument first
|
|
514
|
+
if (cleanupInterval !== null) {
|
|
515
|
+
if (cleanupInterval > 0 && cleanupInterval <= 1000) {
|
|
516
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Using command line resource_cleanup_interval: ${cleanupInterval}`));
|
|
517
|
+
return cleanupInterval;
|
|
518
|
+
} else {
|
|
519
|
+
console.warn(`⚠ Invalid --cleanup-interval value: ${cleanupInterval}. Must be 1-1000. Using config/default value.`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// Check config.json value
|
|
524
|
+
if (typeof resource_cleanup_interval === 'number' && resource_cleanup_interval > 0 && resource_cleanup_interval <= 1000) {
|
|
525
|
+
if (forceDebug) console.log(formatLogMessage('debug', `Using config resource_cleanup_interval: ${resource_cleanup_interval}`));
|
|
526
|
+
return resource_cleanup_interval;
|
|
527
|
+
} else if (resource_cleanup_interval !== 180) {
|
|
528
|
+
console.warn(`⚠ Invalid config resource_cleanup_interval value: ${resource_cleanup_interval}. Using default: 180`);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// Use default
|
|
532
|
+
return 180;
|
|
533
|
+
})();
|
|
460
534
|
|
|
461
535
|
// Handle --clean-rules after config is loaded (so we have access to sites)
|
|
462
536
|
if (cleanRules || cleanRulesFile) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fanboynz/network-scanner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40",
|
|
4
4
|
"description": "A Puppeteer-based network scanner for analyzing web traffic, generating adblock filter rules, and identifying third-party requests. Features include fingerprint spoofing, Cloudflare bypass, content analysis with curl/grep, and multiple output formats.",
|
|
5
5
|
"main": "nwss.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"p-limit": "^4.0.0",
|
|
14
|
-
"psl": "^1.
|
|
15
|
-
"puppeteer": "^
|
|
14
|
+
"psl": "^1.15.0",
|
|
15
|
+
"puppeteer": "^23.10.0"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"puppeteer",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"author": "FanboyNZ",
|
|
30
30
|
"license": "GPL-3.0",
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|
|
36
36
|
"url": "git+https://github.com/ryanbr/network-scanner"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
|
-
|
|
39
|
+
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url": "https://github.com/ryanbr/network-scanner/issues"
|