netsweep 1.0.1 → 1.1.0

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.
Files changed (2) hide show
  1. package/dist/index.js +305 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5220,6 +5220,187 @@ function checkPort(host, port, timeout = 1000) {
5220
5220
  });
5221
5221
  }
5222
5222
 
5223
+ // src/scanners/wifi.ts
5224
+ async function getWifiInfo() {
5225
+ let output = await exec("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I");
5226
+ if (output) {
5227
+ return parseAirportOutput(output);
5228
+ }
5229
+ output = await exec("system_profiler SPAirPortDataType");
5230
+ if (output) {
5231
+ return parseSystemProfilerOutput(output);
5232
+ }
5233
+ return null;
5234
+ }
5235
+ function parseAirportOutput(output) {
5236
+ const getValue = (key) => {
5237
+ const match = output.match(new RegExp(`^\\s*${key}:\\s*(.+)$`, "m"));
5238
+ return match ? match[1].trim() : "";
5239
+ };
5240
+ const ssid = getValue("SSID");
5241
+ if (!ssid) {
5242
+ return null;
5243
+ }
5244
+ const channel = parseInt(getValue("channel"), 10) || 0;
5245
+ const signal = parseInt(getValue("agrCtlRSSI"), 10) || 0;
5246
+ const noise = parseInt(getValue("agrCtlNoise"), 10) || 0;
5247
+ const txRate = parseInt(getValue("lastTxRate"), 10) || 0;
5248
+ return {
5249
+ ssid,
5250
+ bssid: getValue("BSSID"),
5251
+ signal,
5252
+ noise,
5253
+ channel,
5254
+ band: getBandFromChannel(channel),
5255
+ txRate,
5256
+ security: getValue("link auth") || "Unknown"
5257
+ };
5258
+ }
5259
+ function parseSystemProfilerOutput(output) {
5260
+ const currentNetMatch = output.match(/Current Network Information:\s*\n\s*(.+?):\s*\n([\s\S]*?)(?=\n\s+Other Local Wi-Fi Networks:|$)/);
5261
+ if (!currentNetMatch) {
5262
+ return null;
5263
+ }
5264
+ const ssid = currentNetMatch[1].trim();
5265
+ const networkInfo = currentNetMatch[2];
5266
+ const getValue = (key) => {
5267
+ const match = networkInfo.match(new RegExp(`${key}:\\s*(.+)`, "i"));
5268
+ return match ? match[1].trim() : "";
5269
+ };
5270
+ const channelStr = getValue("Channel");
5271
+ const channelMatch = channelStr.match(/(\d+)\s*\((\d+)GHz/);
5272
+ const channel = channelMatch ? parseInt(channelMatch[1], 10) : 0;
5273
+ const bandGhz = channelMatch ? channelMatch[2] : "2.4";
5274
+ const signalNoiseStr = getValue("Signal / Noise");
5275
+ const signalMatch = signalNoiseStr.match(/(-?\d+)\s*dBm\s*\/\s*(-?\d+)\s*dBm/);
5276
+ const signal = signalMatch ? parseInt(signalMatch[1], 10) : 0;
5277
+ const noise = signalMatch ? parseInt(signalMatch[2], 10) : 0;
5278
+ const txRate = parseInt(getValue("Transmit Rate"), 10) || 0;
5279
+ return {
5280
+ ssid,
5281
+ bssid: "",
5282
+ signal,
5283
+ noise,
5284
+ channel,
5285
+ band: bandGhz === "5" ? "5 GHz" : bandGhz === "6" ? "6 GHz" : "2.4 GHz",
5286
+ txRate,
5287
+ security: getValue("Security") || "Unknown"
5288
+ };
5289
+ }
5290
+ function getBandFromChannel(channel) {
5291
+ if (channel >= 36 && channel <= 177) {
5292
+ return "5 GHz";
5293
+ } else if (channel > 177) {
5294
+ return "6 GHz";
5295
+ }
5296
+ return "2.4 GHz";
5297
+ }
5298
+ function getSignalQuality(signal) {
5299
+ if (signal >= -50)
5300
+ return "Excellent";
5301
+ if (signal >= -60)
5302
+ return "Good";
5303
+ if (signal >= -70)
5304
+ return "Fair";
5305
+ return "Weak";
5306
+ }
5307
+
5308
+ // src/scanners/isp.ts
5309
+ async function getIspInfo() {
5310
+ try {
5311
+ const response = await fetch("http://ip-api.com/json");
5312
+ if (!response.ok) {
5313
+ return null;
5314
+ }
5315
+ const data = await response.json();
5316
+ return {
5317
+ isp: data.isp || "Unknown",
5318
+ asn: data.as ? data.as.split(" ")[0] : "Unknown",
5319
+ country: data.country || "Unknown",
5320
+ city: data.city || "Unknown",
5321
+ lat: data.lat || 0,
5322
+ lon: data.lon || 0
5323
+ };
5324
+ } catch {
5325
+ return null;
5326
+ }
5327
+ }
5328
+ function formatCoordinates(lat, lon) {
5329
+ const latDir = lat >= 0 ? "N" : "S";
5330
+ const lonDir = lon >= 0 ? "E" : "W";
5331
+ return `${Math.abs(lat).toFixed(4)}° ${latDir}, ${Math.abs(lon).toFixed(4)}° ${lonDir}`;
5332
+ }
5333
+
5334
+ // src/scanners/traceroute.ts
5335
+ async function runTraceroute(target = "1.1.1.1") {
5336
+ const output = await exec(`traceroute -n -q 1 -m 15 ${target}`);
5337
+ if (!output) {
5338
+ return [];
5339
+ }
5340
+ const hops = [];
5341
+ const lines = output.split(`
5342
+ `);
5343
+ for (const line of lines) {
5344
+ const match = line.match(/^\s*(\d+)\s+([\d.]+|\*)\s+([\d.]+)\s*ms/);
5345
+ if (match) {
5346
+ const hop = parseInt(match[1], 10);
5347
+ const ip = match[2];
5348
+ const latency = parseFloat(match[3]);
5349
+ if (ip !== "*") {
5350
+ hops.push({
5351
+ hop,
5352
+ ip,
5353
+ latency
5354
+ });
5355
+ }
5356
+ }
5357
+ }
5358
+ return hops;
5359
+ }
5360
+ function getMaxLatency(hops) {
5361
+ if (hops.length === 0)
5362
+ return 0;
5363
+ return Math.max(...hops.map((h) => h.latency));
5364
+ }
5365
+
5366
+ // src/scanners/health.ts
5367
+ var ENDPOINTS = [
5368
+ { name: "Google", url: "https://www.google.com" },
5369
+ { name: "Cloudflare", url: "https://1.1.1.1" },
5370
+ { name: "GitHub", url: "https://github.com" },
5371
+ { name: "AWS", url: "https://aws.amazon.com" }
5372
+ ];
5373
+ async function checkEndpoint(name, url) {
5374
+ const start = Date.now();
5375
+ try {
5376
+ const controller = new AbortController;
5377
+ const timeoutId = setTimeout(() => controller.abort(), 5000);
5378
+ const response = await fetch(url, {
5379
+ method: "HEAD",
5380
+ signal: controller.signal
5381
+ });
5382
+ clearTimeout(timeoutId);
5383
+ const latency = Date.now() - start;
5384
+ return {
5385
+ name,
5386
+ url,
5387
+ status: response.ok ? "up" : "down",
5388
+ latency
5389
+ };
5390
+ } catch {
5391
+ return {
5392
+ name,
5393
+ url,
5394
+ status: "down",
5395
+ latency: Date.now() - start
5396
+ };
5397
+ }
5398
+ }
5399
+ async function checkInternetHealth() {
5400
+ const results = await Promise.all(ENDPOINTS.map(({ name, url }) => checkEndpoint(name, url)));
5401
+ return results;
5402
+ }
5403
+
5223
5404
  // node_modules/chalk/source/vendor/ansi-styles/index.js
5224
5405
  var ANSI_BACKGROUND_OFFSET = 10;
5225
5406
  var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
@@ -6516,11 +6697,14 @@ function formatLatency(ms) {
6516
6697
  function padRight(str, len) {
6517
6698
  return str.length >= len ? str.slice(0, len) : str + " ".repeat(len - str.length);
6518
6699
  }
6700
+ function padLeft(str, len) {
6701
+ return str.length >= len ? str.slice(0, len) : " ".repeat(len - str.length) + str;
6702
+ }
6519
6703
 
6520
6704
  // src/ui/output.ts
6521
6705
  var BOX_WIDTH = 62;
6522
6706
  function header() {
6523
- console.log(boxen(source_default.bold.cyan(" NETPROBE - Network Diagnostics "), {
6707
+ console.log(boxen(source_default.bold.cyan(" NETSWEEP - Network Diagnostics "), {
6524
6708
  padding: 0,
6525
6709
  margin: { top: 1, bottom: 0, left: 0, right: 0 },
6526
6710
  borderStyle: "round",
@@ -6617,6 +6801,53 @@ function truncate(str, len) {
6617
6801
  function stripAnsi2(str) {
6618
6802
  return str.replace(/\x1B\[[0-9;]*m/g, "");
6619
6803
  }
6804
+ function wifiSection(info) {
6805
+ const quality = getSignalQuality(info.signal);
6806
+ const qualityColor = quality === "Excellent" ? source_default.green : quality === "Good" ? source_default.yellow : source_default.red;
6807
+ section("WIFI", [
6808
+ `${source_default.gray("SSID:")} ${source_default.white(info.ssid)}`,
6809
+ `${source_default.gray("Signal:")} ${source_default.white(`${info.signal} dBm`)} (${qualityColor(quality)})`,
6810
+ `${source_default.gray("Noise:")} ${source_default.white(`${info.noise} dBm`)}`,
6811
+ `${source_default.gray("Channel:")} ${source_default.white(`${info.channel}`)} (${source_default.white(info.band)})`,
6812
+ `${source_default.gray("Tx Rate:")} ${source_default.white(`${info.txRate} Mbps`)}`
6813
+ ]);
6814
+ }
6815
+ function ispSection(info) {
6816
+ section("ISP & LOCATION", [
6817
+ `${source_default.gray("ISP:")} ${source_default.white(info.isp)}`,
6818
+ `${source_default.gray("ASN:")} ${source_default.white(info.asn)}`,
6819
+ `${source_default.gray("Location:")} ${source_default.white(`${info.city}, ${info.country}`)}`,
6820
+ `${source_default.gray("Coordinates:")} ${source_default.white(formatCoordinates(info.lat, info.lon))}`
6821
+ ]);
6822
+ }
6823
+ function tracerouteSection(hops, target) {
6824
+ if (hops.length === 0) {
6825
+ section(`TRACEROUTE (to ${target})`, [
6826
+ source_default.gray("No hops recorded")
6827
+ ]);
6828
+ return;
6829
+ }
6830
+ const maxLatency = getMaxLatency(hops);
6831
+ const maxBarWidth = 30;
6832
+ const lines = hops.map((hop) => {
6833
+ const hopNum = padLeft(String(hop.hop), 3);
6834
+ const ip = padRight(hop.ip, 16);
6835
+ const latency = padLeft(`${hop.latency.toFixed(1)}ms`, 8);
6836
+ const barWidth = Math.ceil(hop.latency / maxLatency * maxBarWidth);
6837
+ const bar = source_default.cyan("█".repeat(Math.max(1, barWidth)));
6838
+ return `${source_default.white(hopNum)} ${source_default.white(ip)}${source_default.white(latency)} ${bar}`;
6839
+ });
6840
+ section(`TRACEROUTE (to ${target})`, lines);
6841
+ }
6842
+ function healthSection(checks) {
6843
+ const lines = checks.map((check) => {
6844
+ const name = padRight(check.name, 14);
6845
+ const status = check.status === "up" ? source_default.green("✓") : source_default.red("✗");
6846
+ const latency = check.status === "up" ? `${check.latency}ms` : "timeout";
6847
+ return `${source_default.white(name)}${status} ${source_default.white(latency)}`;
6848
+ });
6849
+ section("INTERNET HEALTH", lines);
6850
+ }
6620
6851
  function outputJson(results) {
6621
6852
  console.log(JSON.stringify(results, null, 2));
6622
6853
  }
@@ -7483,6 +7714,44 @@ async function scan(options) {
7483
7714
  results.ports = await scanPorts(results.gateway);
7484
7715
  } catch {}
7485
7716
  }
7717
+ if (options.wifi) {
7718
+ if (!options.json) {
7719
+ updateSpinner("Getting WiFi info...");
7720
+ }
7721
+ try {
7722
+ const wifi = await getWifiInfo();
7723
+ if (wifi) {
7724
+ results.wifi = wifi;
7725
+ }
7726
+ } catch {}
7727
+ }
7728
+ if (options.isp) {
7729
+ if (!options.json) {
7730
+ updateSpinner("Getting ISP info...");
7731
+ }
7732
+ try {
7733
+ const isp = await getIspInfo();
7734
+ if (isp) {
7735
+ results.isp = isp;
7736
+ }
7737
+ } catch {}
7738
+ }
7739
+ if (options.trace) {
7740
+ if (!options.json) {
7741
+ updateSpinner("Running traceroute...");
7742
+ }
7743
+ try {
7744
+ results.traceroute = await runTraceroute();
7745
+ } catch {}
7746
+ }
7747
+ if (options.health) {
7748
+ if (!options.json) {
7749
+ updateSpinner("Checking internet health...");
7750
+ }
7751
+ try {
7752
+ results.health = await checkInternetHealth();
7753
+ } catch {}
7754
+ }
7486
7755
  stopSpinner();
7487
7756
  if (options.json) {
7488
7757
  outputJson(results);
@@ -7500,33 +7769,53 @@ async function scan(options) {
7500
7769
  if (results.ports !== undefined && results.gateway) {
7501
7770
  portsSection(results.ports, results.gateway);
7502
7771
  }
7772
+ if (results.wifi) {
7773
+ wifiSection(results.wifi);
7774
+ }
7775
+ if (results.isp) {
7776
+ ispSection(results.isp);
7777
+ }
7778
+ if (results.traceroute) {
7779
+ tracerouteSection(results.traceroute, "1.1.1.1");
7780
+ }
7781
+ if (results.health) {
7782
+ healthSection(results.health);
7783
+ }
7503
7784
  }
7504
7785
  }
7505
7786
 
7506
7787
  // src/index.ts
7507
7788
  var args = process.argv.slice(2);
7508
- if (args.includes("--help") || args.includes("-h")) {
7789
+ if (args.includes("--help")) {
7509
7790
  console.log(`
7510
- ${"\x1B[36m"}netprobe${"\x1B[0m"} - Network Swiss Army Knife
7791
+ ${"\x1B[36m"}netsweep${"\x1B[0m"} - Network Swiss Army Knife
7511
7792
 
7512
- ${"\x1B[1m"}Usage:${"\x1B[0m"} netprobe [options]
7793
+ ${"\x1B[1m"}Usage:${"\x1B[0m"} netsweep [options]
7513
7794
 
7514
7795
  ${"\x1B[1m"}Options:${"\x1B[0m"}
7515
7796
  --all, -a Run all scans (default)
7516
7797
  --devices, -d Only scan for devices
7517
7798
  --speed, -s Only run speed test
7518
7799
  --ports, -p Only scan gateway ports
7800
+ --wifi, -w Show WiFi info
7801
+ --isp, -i Show ISP & geolocation
7802
+ --trace, -r Run traceroute to 1.1.1.1
7803
+ --health Check internet health
7519
7804
  --target, -t <ip> Scan specific IP for ports
7520
7805
  --json Output as JSON
7521
- --help, -h Show help
7806
+ --help Show help
7522
7807
 
7523
7808
  ${"\x1B[1m"}Examples:${"\x1B[0m"}
7524
- netprobe Full network scan
7525
- netprobe -d List network devices only
7526
- netprobe -s Speed test only
7527
- netprobe -p Scan gateway ports
7528
- netprobe -p -t 192.168.0.7 Scan ports on specific host
7529
- netprobe --json Output results as JSON
7809
+ netsweep Full network scan
7810
+ netsweep -d List network devices only
7811
+ netsweep -s Speed test only
7812
+ netsweep -p Scan gateway ports
7813
+ netsweep -w Show WiFi signal info
7814
+ netsweep --isp Show ISP and location
7815
+ netsweep --trace Run traceroute
7816
+ netsweep --health Check major services
7817
+ netsweep -p -t 192.168.0.7 Scan ports on specific host
7818
+ netsweep --json Output results as JSON
7530
7819
  `);
7531
7820
  process.exit(0);
7532
7821
  }
@@ -7535,12 +7824,16 @@ var targetIndex = args.findIndex((a) => a === "-t" || a === "--target");
7535
7824
  if (targetIndex !== -1 && args[targetIndex + 1]) {
7536
7825
  target = args[targetIndex + 1];
7537
7826
  }
7538
- var hasSpecificFlags = args.includes("-d") || args.includes("--devices") || args.includes("-s") || args.includes("--speed") || args.includes("-p") || args.includes("--ports");
7827
+ var hasSpecificFlags = args.includes("-d") || args.includes("--devices") || args.includes("-s") || args.includes("--speed") || args.includes("-p") || args.includes("--ports") || args.includes("-w") || args.includes("--wifi") || args.includes("-i") || args.includes("--isp") || args.includes("-r") || args.includes("--trace") || args.includes("--health");
7539
7828
  var runAll = args.includes("-a") || args.includes("--all") || !hasSpecificFlags;
7540
7829
  await scan({
7541
7830
  devices: runAll || args.includes("-d") || args.includes("--devices"),
7542
7831
  speed: runAll || args.includes("-s") || args.includes("--speed"),
7543
7832
  ports: runAll || args.includes("-p") || args.includes("--ports"),
7833
+ wifi: runAll || args.includes("-w") || args.includes("--wifi"),
7834
+ isp: runAll || args.includes("-i") || args.includes("--isp"),
7835
+ trace: runAll || args.includes("-r") || args.includes("--trace"),
7836
+ health: runAll || args.includes("--health"),
7544
7837
  json: args.includes("--json"),
7545
7838
  target
7546
7839
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netsweep",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Network Swiss Army Knife - CLI tool for comprehensive network diagnostics",
5
5
  "type": "module",
6
6
  "bin": {