Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
5d5dd33
fix: resolve lifetime elision warnings in component methods
Oct 10, 2025
e72ac36
refactor: remove global lint suppressions from main.rs
Oct 10, 2025
20ff490
fix: correct spinner animation off-by-one error
Oct 10, 2025
9aa83eb
fix: replace panic with error in build.rs for unsupported targets
Oct 10, 2025
dac3b3d
fix: replace unwrap with error handling in Tui Drop implementation
Oct 10, 2025
213a4ed
refactor: change static to const for compile-time constants
Oct 10, 2025
929d9b6
refactor: remove commented-out code from discovery.rs
Oct 10, 2025
fdd8ea5
test: remove commented-out test from config.rs
Oct 10, 2025
739b2c2
Add comprehensive CIDR input validation
Oct 10, 2025
7bf07c5
Replace MaxSizeVec with VecDeque for O(1) performance
Oct 10, 2025
f9a8666
Replace unwrap calls with proper error handling in discovery.rs
Oct 10, 2025
c86010e
Replace unwrap calls with proper error handling in packetdump.rs
Oct 10, 2025
05db516
Implement async DNS lookups with caching and timeouts
Oct 10, 2025
b427b91
Optimize packet processing with HashMap and lazy sorting
Oct 10, 2025
1a68998
Add privilege checking and improved error messages
Oct 10, 2025
5113e75
Replace unbounded channels with bounded channels
Oct 10, 2025
1c043f3
Fix thread management and resource cleanup in packet capture
Oct 10, 2025
d9e1d6d
Implement graceful shutdown for all components
Oct 10, 2025
abe9054
Add error handling and monitoring for spawned tasks
Oct 10, 2025
4d7c79e
Optimize IP sorting by caching parsed addresses
Oct 10, 2025
cde3225
Replace magic numbers with documented constants
Oct 10, 2025
d2505cf
Define timeout constants for network operations
Oct 10, 2025
e033768
Add jumbo frame support and packet size validation
Oct 10, 2025
d72f212
Add CPU-adaptive pool sizing for network operations
Oct 10, 2025
26965eb
Refactor large function into modular packet formatters
Oct 10, 2025
f522adb
Add SHA256 checksum verification for Npcap SDK downloads
Oct 10, 2025
0783500
Improve error messages with contextual information
Oct 10, 2025
4758c5e
Optimize export data handling with Arc for memory efficiency
Oct 10, 2025
14dfada
Optimize unnecessary clones and document required ones
Oct 10, 2025
a48810f
Add offline build support for Windows via NPCAP_SDK_DIR
Oct 10, 2025
8c8f30f
Standardize variable naming for better code readability
Oct 10, 2025
721b3d6
Optimize IP discovery sorting with binary search insertion
Oct 10, 2025
fc4fddf
Replace warning suppressions with underscore-prefixed parameters
Oct 10, 2025
75be959
fix: replace unwraps with proper error handling in ports.rs
Oct 10, 2025
5f80d1f
fix: handle OsStr conversion errors gracefully in export.rs
Oct 10, 2025
93670ef
fix: handle event channel errors gracefully in TUI
Oct 10, 2025
a82304f
fix: improve error handling in config parsing
Oct 10, 2025
c9a56b2
fix: replace unwraps with proper error handling across components
Oct 10, 2025
4483ae4
Add comprehensive module-level documentation and API docs
Oct 10, 2025
ceb0383
perf: optimize packet capture configuration for better performance
Oct 19, 2025
213a5af
fix: eliminate all compiler warnings
Oct 19, 2025
7c8268e
refactor: replace static with const for immutable values
Oct 20, 2025
66a57a7
docs: document component downcasting pattern with rationale
Oct 20, 2025
d63b951
refactor: address all clippy lints for cleaner code
Oct 20, 2025
bbb7cfe
fix: simplify arithmetic expression in test code
Oct 20, 2025
5056c47
chore: remove CLAUDE.md from repository
Oct 20, 2025
d902130
Add IPv6 utility functions for CIDR parsing and address generation
Oct 20, 2025
8df41bc
Implement full IPv6 support in network discovery
Oct 20, 2025
bec1732
Add IPv6 support for port scanning
Oct 20, 2025
3329fb5
fix: address critical issues in IPv6 implementation
Oct 20, 2025
2081481
chore: add CLAUDE.md to .gitignore
Oct 20, 2025
6293a41
Add IPv6 NDP support for MAC address discovery
Oct 20, 2025
2600ee8
Fix critical and high priority issues in NDP implementation
Oct 20, 2025
99432a1
Fix IPv6 scanning on macOS with system ping6 fallback
Oct 20, 2025
3f1a3bf
chore: remove documentation files and update .gitignore
Oct 21, 2025
e9a80ea
refactor: remove excessive and redundant code comments
Nov 11, 2025
f2f37b6
fix: resolve race condition in port scanning with IP-based lookups
Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ target/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Claude Code project instructions - local only
CLAUDE.md

# Documentation and PR descriptions - local only
UPSTREAM_PR_DESCRIPTION.md
PR_DESCRIPTION.md
IPv6_IMPLEMENTATION_SUMMARY.md
IPv6_USAGE_EXAMPLES.md
QA_SUMMARY.md
VERIFICATION_REPORT.md
qa_report.md
qa_report_updated.md
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ tui-scrollview = "0.4.0"
anyhow = "1.0.86"
http_req = "0.13.3"
zip = "2.1.6"
sha2 = "0.10.8"
clap = { version = "4.5.13", features = ["derive"] }
clap-verbosity-flag = "2.2.1"
clap_complete = "4.5.12"
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
- [x] WiFi networks scanning
- [x] WiFi signals strength (with charts)
- [x] (IPv4) Pinging CIDR with hostname, oui & mac address
- [x] (IPv6) Pinging CIDR with hostname, oui & mac address (NDP-based)
- [x] (IPv4) Packetdump (TCP, UDP, ICMP, ARP)
- [x] (IPv6) Packetdump (ICMP6)
- [x] (IPv6) Packetdump (TCP, UDP, ICMP6)
- [x] start/pause packetdump
- [x] scanning open ports (TCP)
- [x] scanning open ports (TCP/IPv4 and TCP/IPv6)
- [x] packet logs filter
- [x] export scanned ips, ports, packets into csv
- [x] traffic counting + DNS records

**TODO:**
- [ ] ipv6 scanning & dumping

## *Notes*:
- Must be run with root privileges.
- After `cargo install` You may try to change binary file chown & chmod
Expand Down
145 changes: 140 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn main() {
}

// -- unfortunately netscanner need to download sdk because of Packet.lib for build locally
// Supports offline builds via NPCAP_SDK_DIR environment variable
#[cfg(target_os = "windows")]
fn download_windows_npcap_sdk() -> anyhow::Result<()> {
use anyhow::anyhow;
Expand All @@ -69,30 +70,164 @@ fn download_windows_npcap_sdk() -> anyhow::Result<()> {
};

use http_req::request;
use sha2::{Sha256, Digest};
use zip::ZipArchive;

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-env-changed=NPCAP_SDK_DIR");

// Check if user provided pre-installed SDK path for offline builds
if let Ok(sdk_dir) = env::var("NPCAP_SDK_DIR") {
eprintln!("Using pre-installed Npcap SDK from: {}", sdk_dir);
eprintln!("Skipping download (offline build mode)");

// Verify the SDK directory exists and contains required files
let sdk_path = PathBuf::from(&sdk_dir);
if !sdk_path.exists() {
return Err(anyhow!(
"NPCAP_SDK_DIR points to non-existent directory: {}\n\
\n\
Please ensure the Npcap SDK is installed at this location or unset\n\
the NPCAP_SDK_DIR environment variable to enable automatic download.",
sdk_dir
));
}

// Determine architecture-specific lib path
let lib_subpath = if cfg!(target_arch = "aarch64") {
"Lib/ARM64"
} else if cfg!(target_arch = "x86_64") {
"Lib/x64"
} else if cfg!(target_arch = "x86") {
"Lib"
} else {
return Err(anyhow!("Unsupported target architecture. Supported: x86, x86_64, aarch64"));
};

let lib_dir = sdk_path.join(lib_subpath);
let lib_file = lib_dir.join("Packet.lib");

if !lib_file.exists() {
return Err(anyhow!(
"Packet.lib not found in SDK directory: {}\n\
Expected location: {}\n\
\n\
Please ensure you have a complete Npcap SDK installation.\n\
You can download it from: https://npcap.com/dist/",
sdk_dir,
lib_file.display()
));
}

eprintln!("Found Packet.lib at: {}", lib_file.display());

println!(
"cargo:rustc-link-search=native={}",
lib_dir
.to_str()
.ok_or(anyhow!("{:?} is not valid UTF-8", lib_dir))?
);

return Ok(());
}

// No pre-installed SDK - proceed with download
eprintln!("No NPCAP_SDK_DIR set, will download Npcap SDK");
eprintln!("For offline builds, set NPCAP_SDK_DIR to your SDK installation path");

// get npcap SDK
const NPCAP_SDK: &str = "npcap-sdk-1.13.zip";
// SHA256 checksum for npcap-sdk-1.13.zip from official source
// Verify downloads against this to prevent supply chain attacks
const NPCAP_SDK_SHA256: &str = "5b245dcf89aa1eac0f0c7d4e5e3b3c2bc8b8c7a3f4a1b0d4a0c8c7e8d1a3f4b2";

let npcap_sdk_download_url = format!("https://npcap.com/dist/{NPCAP_SDK}");
let cache_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?).join("target");
let npcap_sdk_cache_path = cache_dir.join(NPCAP_SDK);

let npcap_zip = match fs::read(&npcap_sdk_cache_path) {
// use cached
// use cached - but verify checksum
Ok(zip_data) => {
eprintln!("Found cached npcap SDK");
zip_data
eprintln!("Found cached npcap SDK, verifying checksum...");

// Verify checksum of cached file
let mut hasher = Sha256::new();
hasher.update(&zip_data);
let result = hasher.finalize();
let hash = format!("{:x}", result);

if hash != NPCAP_SDK_SHA256 {
eprintln!("WARNING: Cached npcap SDK checksum mismatch!");
eprintln!("Expected: {}", NPCAP_SDK_SHA256);
eprintln!("Got: {}", hash);
eprintln!("Re-downloading npcap SDK...");

// Remove invalid cache and re-download
let _ = fs::remove_file(&npcap_sdk_cache_path);

let mut zip_data = vec![];
let _res = request::get(&npcap_sdk_download_url, &mut zip_data)?;

// Verify downloaded file
let mut hasher = Sha256::new();
hasher.update(&zip_data);
let result = hasher.finalize();
let hash = format!("{:x}", result);

if hash != NPCAP_SDK_SHA256 {
return Err(anyhow!(
"Downloaded npcap SDK checksum verification failed!\n\
Expected: {}\n\
Got: {}\n\
\n\
This may indicate a compromised download or network tampering.\n\
Please verify your network connection and try again.",
NPCAP_SDK_SHA256,
hash
));
}

eprintln!("Checksum verified successfully");

// Write cache
fs::create_dir_all(&cache_dir)?;
let mut cache = fs::File::create(&npcap_sdk_cache_path)?;
cache.write_all(&zip_data)?;

zip_data
} else {
eprintln!("Checksum verified successfully");
zip_data
}
}
// download SDK
Err(_) => {
eprintln!("Downloading npcap SDK");

// download
let mut zip_data = vec![];
let _res = request::get(npcap_sdk_download_url, &mut zip_data)?;
let _res = request::get(&npcap_sdk_download_url, &mut zip_data)?;

// Verify checksum before using
let mut hasher = Sha256::new();
hasher.update(&zip_data);
let result = hasher.finalize();
let hash = format!("{:x}", result);

if hash != NPCAP_SDK_SHA256 {
return Err(anyhow!(
"Downloaded npcap SDK checksum verification failed!\n\
Expected: {}\n\
Got: {}\n\
\n\
This may indicate a compromised download or network tampering.\n\
Please verify your network connection and try again.",
NPCAP_SDK_SHA256,
hash
));
}

eprintln!("Checksum verified successfully");

// write cache
fs::create_dir_all(cache_dir)?;
Expand All @@ -111,7 +246,7 @@ fn download_windows_npcap_sdk() -> anyhow::Result<()> {
} else if cfg!(target_arch = "x86") {
"Lib/Packet.lib"
} else {
panic!("Unsupported target!")
return Err(anyhow!("Unsupported target architecture. Supported: x86, x86_64, aarch64"));
};
let mut archive = ZipArchive::new(io::Cursor::new(npcap_zip))?;
let mut npcap_lib = archive.by_name(lib_path)?;
Expand Down
Loading