Skip to content
Mr45401Public

About

Lightweight Python CLI tool for educational IPv4 validation, basic ICMP reachability checks, and JSON reporting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

NetScope (v0.1)

NetScope is a lightweight, beginner-friendly Python command-line tool for basic network reachability checks. It is built for educational use to help students and beginners understand how IPv4 validation, ICMP echo requests (ping), and structured JSON reporting work in Python using only the standard library.


Purpose and Objectives

When learning networking and cybersecurity fundamentals, one of the first practical tasks is checking whether a host on a local lab network responds to connectivity probes. NetScope v0.1 focuses on doing this single task clearly and safely:

  • Validate user-supplied IPv4 addresses before executing any network command.
  • Perform a single, non-intrusive ICMP echo check across Windows, Linux, and macOS.
  • Explain what the response means—and why a lack of response does not automatically mean a system is offline.
  • Save results in a structured JSON format for lab notes or further analysis.

Features (v0.1)

  1. IPv4 Validation: Verifies that the target input is a properly formatted IPv4 address using Python's built-in ipaddress module.
  2. Basic Connectivity Check: Sends a single ICMP echo request (ping) with a configurable timeout.
  3. Clear Terminal Output: Displays the target IP, reachability status (REACHABLE or UNREACHABLE), operating system, timestamp, and diagnostic details.
  4. Graceful Error Handling: Handles empty inputs, malformed IP addresses, timeouts, and user cancellations (Ctrl+C) without crashing.
  5. JSON Report Export: Automatically exports each check to a timestamped .json file inside the reports/ directory (or a custom file path).
  6. Simple CLI: Supports both direct command-line arguments (python main.py 127.0.0.1) and interactive prompts (python main.py).

Screenshots

(Placeholders — replace with actual terminal screenshots from your lab environment)

  • Reachable Host Check (127.0.0.1): [Screenshot placeholder: docs/screenshots/reachable_check.png]
  • Invalid IPv4 Input Handling: [Screenshot placeholder: docs/screenshots/invalid_input.png]

Requirements

  • Python: 3.10 or newer
  • Operating System: Windows, Linux (including Kali Linux), or macOS
  • Dependencies: None (uses only the Python standard library)
  • System Utility: Standard OS ping command available in system PATH

Installation

  1. Clone the repository:

    git clone https://github.com/Mr45401/netscope.git
    cd netscope
  2. Verify your Python version (must be 3.10+):

    python --version

    (On Linux/Kali, you may need to use python3 instead of python.)


Usage Examples

1. Check a host directly from the command line

python main.py 127.0.0.1

Example terminal output:

Checking reachability for 127.0.0.1 (timeout: 2s)...

--- NetScope Connectivity Result ---
Target IP      : 127.0.0.1
Status         : REACHABLE
Check Method   : icmp_ping (Windows)
Timestamp (UTC): 2026-11-08T11:05:00Z
Details        : Host responded to ICMP echo request (ping).
------------------------------------
JSON report saved to: reports\report_127_0_0_1_20261108_110500.json

2. Run interactively (prompts for an IPv4 address)

python main.py

3. Specify a custom timeout and custom report path

python main.py 192.168.1.1 --timeout 3 --output reports/router_check.json

4. Check a host without saving a JSON file

python main.py 127.0.0.1 --no-report

5. View help options

python main.py --help

Example JSON Output

When a check completes, NetScope writes a JSON report like this:

{
    "tool": "NetScope",
    "version": "0.1.0",
    "generated_at": "2026-11-08T11:05:00Z",
    "result": {
        "target_ip": "127.0.0.1",
        "reachable": true,
        "status": "reachable",
        "method": "icmp_ping",
        "operating_system": "Windows",
        "timestamp": "2026-11-08T11:05:00Z",
        "details": "Host responded to ICMP echo request (ping)."
    }
}

Project Structure

NetScope/
├── README.md               # Project documentation
├── LICENSE                 # MIT License
├── .gitignore              # Ignored Python cache and generated report files
├── requirements.txt        # Documents standard-library-only requirement
├── main.py                 # Command-line interface entry point
├── netscope/
│   ├── __init__.py         # Package version definition
│   ├── validator.py        # IPv4 validation functions
│   ├── scanner.py          # Cross-platform ICMP connectivity check
│   └── reporter.py         # JSON report formatting and file export
├── reports/
│   └── .gitkeep            # Directory where JSON reports are saved
└── tests/
    ├── __init__.py
    ├── test_validator.py   # Tests for IPv4 validation and CLI input errors
    └── test_reporter.py    # Tests for JSON payload creation and saving

Running Tests

NetScope uses Python's built-in unittest framework. Run the full test suite from the project root directory:

python -m unittest discover -s tests -v

Current Limitations

  1. ICMP Does Not Guarantee Host Status:
    • If a host shows UNREACHABLE, it does not prove the machine is powered off. Many servers, firewalls, and Windows workstations block incoming ICMP echo requests by default even when they are online and running network services.
    • Conversely, in some network environments, a firewall or proxy device may respond on behalf of an address.
  2. Single IPv4 Target Only:
    • Version 0.1 checks one IPv4 address at a time. It does not yet accept domain names (DNS), IPv6 addresses, or CIDR subnet ranges (such as 192.168.1.0/24).
  3. Relies on System ping Utility:
    • NetScope invokes the operating system's native ping command rather than constructing raw ICMP sockets (which require administrator/root privileges).

Future Roadmap

Planned improvements as I continue learning Python and networking:

  • v0.2: Support checking a list of IPv4 addresses read from a text file.
  • v0.3: Add basic TCP port connectivity checks (using Python's socket module) for when ICMP is blocked.
  • v0.4: Add optional hostname / DNS resolution.

Responsible Use and Legal Disclaimer

NetScope is created strictly for educational purposes and authorized lab practice.

  • Only test hosts, virtual machines, and networks that you own or have explicit permission to test.
  • Do not use network discovery tools against external systems without authorization.
  • The author assumes no liability for misuse of this software.

License

This project is licensed under the MIT License.

About

Lightweight Python CLI tool for educational IPv4 validation, basic ICMP reachability checks, and JSON reporting.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages