A powerful Python CLI tool for discovering and analyzing Linux servers with SSH capability. NetScan allows you to scan networks, collect system information, and generate comprehensive reports with enterprise-grade features.
- π Network Discovery: Scan IP ranges for SSH-enabled hosts with optimized timeouts
- π Multiple Credentials: Support for testing multiple username/password combinations
- π System Information: Collect OS, CPU, memory, and disk usage data
- β‘ Comprehensive Scanning: Complete workflow in one command (
scan full) - πΎ Data Persistence: SQLite database for storing scan results and authentication details
- π Rich Reports: Beautiful CLI output with filtering and export options
- π§ Configuration Management: Persistent settings and secure credential storage
- π― Optimized Performance: Fast connection testing with configurable timeouts
- π¦ Additional Port Discovery: Probe configurable TCP ports alongside SSH for richer host context
git clone https://github.com/yourusername/netscan.git
cd netscan
pip install -e .- Python 3.8+
- nmap (optional, for faster network discovery)
Install nmap on your system:
# Ubuntu/Debian
sudo apt-get install nmap
# CentOS/RHEL
sudo yum install nmap
# macOS
brew install nmapNetScan includes a beautiful menu-based interface powered by Textual. Launch it by running:
python -m netscanOr explicitly:
python -m netscan menuThe menu interface provides:
- Scan Tab: Interactive forms for network scanning with real-time progress
- Reports Tab: Generate and view reports with filtering options
- Database Tab: Database management utilities
- Settings Tab: Configuration management
All features are accessible through the menu, or you can use the command-line interface directly.
python -m netscan scan network --range 192.168.1.0/24 --timeout 2 --threads 25 --retries 0This probes each IP/port; it never logs in or touches stored credentials.
-
Store secrets once and reuse them:
python -m netscan config set-credential username ubuntu python -m netscan config set-credential password
-
Or create a credentials file with
username:passwordpairs:cat > credentials.txt <<'EOF' admin:admin admin:password root:root root:password ubuntu:ubuntu EOF
python -m netscan scan auth --from-db \
--multiple-usernames admin,root,user \
--multiple-passwords admin,password,123456 \
--try-multiple-credentialsAdd --credentials-file credentials.txt if you prefer the file created above.
python -m netscan scan info --from-db \
--credentials-file credentials.txt \
--try-multiple-credentials --store-dbpython -m netscan report hosts --format table
python -m netscan report summary
python -m netscan report export --format json --output results.jsonCombine steps 1β4 with a single command:
python -m netscan scan full --range 192.168.1.0/24 --credentials-file credentials.txt-
Dot-notation mirrors the config structure and keeps legacy aliases working:
python -m netscan config set scanning.default_timeout 2 python -m netscan config set scanning.max_retries 1
-
Credential helpers remain available:
python -m netscan config set-credential ssh_key_path /home/user/.ssh/id_rsa python -m netscan config list-credentials python -m netscan config show
-
Additional port scanning is easily configured:
python -m netscan config set --set-additional-ports 80,443,3389 python -m netscan config set scanning.additional_ports 5900
# Filter hosts by OS substring and show the newest first
python -m netscan report hosts --filter "os=ubuntu" --sort last_scan
# Export hosts as CSV and include scan history in JSON
python -m netscan report export --format csv --output hosts.csv
python -m netscan report export --include-history --output hosts.jsonscan fullβ Complete workflow (Discovery β Authentication β Info Collection) βscan networkβ Discover SSH-enabled hosts and populate the inventoryscan authβ Test SSH authentication (single or multiple credentials)scan infoβ Collect detailed system informationreportβ Generate and export reportsconfigβ Manage configuration settings and stored credentialsdatabaseβ Maintenance utilities (backup, vacuum, restore)
| Command | Description |
|---|---|
python -m netscan scan network |
Discover SSH endpoints, auto-updating the host inventory. |
python -m netscan scan auth |
Test authentication (password/key/agent or credential lists) against known hosts. |
python -m netscan scan info |
Collect OS/CPU/memory/disk details; partial successes still update the DB. |
python -m netscan report hosts |
Render hosts in table/json/csv/text with filter, sort, limit controls. |
python -m netscan report summary |
Show aggregated host stats, OS distribution, recent activity. |
python -m netscan report export |
Export hosts (and optionally history) to json/csv/xml/txt/sql. |
python -m netscan config ... |
Manage configuration and credentials (supports aliases and dot keys). |
python -m netscan database ... |
Maintenance utilities (backup, vacuum, restore). |
--range / -r: IP range to scan (CIDR or single IP, required forscan network).--username / -u: SSH username (optional for network discovery; required for single-credential auth/info).--multiple-usernames: Comma-separated usernames to iterate through.--password / -p: SSH password; omit value to prompt securely and fall back to stored secrets if available.--multiple-passwords: Comma-separated passwords matching--multiple-usernames.--credentials-file: Path to username:password pairs (one per line).--key-file / -k: Path to SSH private key.--port / -P: SSH port (default 22).--threads / -t: Concurrent workers (1β100, defaults to configscanning.default_threads).--timeout / -T: Socket/SSH timeout in seconds (1β300).--retries / -R: Number of retries for unreachable hosts during network scans (0β10, default from config).--try-multiple-credentials: Enable the multi-credential authentication/collection workflow.--no-nmap: Skip the nmap pre-scan and force socket-only discovery.--store-db: Persist info-collection results (complete and partial datasets) to the database.
--filter:key=valuefilter (status,os,ip,hostname,portfor hosts; similar patterns elsewhere).--format / --Format: Switch output between table/json/csv/text.--output: Write report/export to file.--sort: Sort column (e.g.,last_scan,ip_address).--limit: Cap the number of rows displayed.
NetScan uses SQLite to store scan results with the following structure:
- hosts: Host information, system details, and authentication data
- scan_history: Historical scan records
- config: Application configuration
See DEVELOPMENT_PLAN.md for detailed architecture and development information.
NetScan's automated test suite lives under tests/. Run the entire suite with:
python -m pytestIf you prefer using the bundled virtual environment, ./venv/bin/pytest works as well.
Legacy helper scripts such as quick_validation.py and validate_system.py have been removedβrely on the pytest suite for validation.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Store credentials securely (consider using SSH keys)
- Use strong authentication methods
- Implement proper access controls
- Regular security audits
MIT License - see LICENSE file for details.
For issues and feature requests, please use the GitHub issue tracker.