Skip to content

ShanazarDev/ip_scan_cidr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

IP Scanner

A fast and efficient IP address scanner written in Python that can ping multiple IP addresses concurrently and generate detailed reports.

Features

  • Concurrent Scanning: Uses ThreadPoolExecutor for fast parallel ping operations
  • CIDR Support: Scan entire subnets using CIDR notation (e.g., 192.168.1.0/24)
  • Cross-Platform: Works on Windows, Linux, and macOS
  • Detailed Reports: Generates timestamped result files with availability statistics
  • Real-time Output: Shows live progress during scanning
  • Standalone Executable: Can be compiled to a single executable file

Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)

Setup

  1. Clone or download this repository
  2. Create a virtual environment (recommended):
    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:
    pip install pyinstaller

Usage

Running with Python

python main.py <ip_or_cidr>

Examples

# Scan a single IP address
python main.py 192.168.1.1

# Scan a subnet
python main.py 192.168.1.0/24д

# Scan a larger network
python main.py 10.0.0.0/16

Running the Compiled Executable

After compilation (see Build section):

./dist/ip_scanner <ip_or_cidr>

Output

The scanner provides:

  • Real-time status updates during scanning
  • Final summary with available and unavailable IPs
  • Availability percentage
  • Timestamped result file (result_YYYY-MM-DD HH:MM:SS.txt)

Example Output

[+] Ping 254 addresses from 192.168.1.0/24...

[+] Available: 192.168.1.1
[+] Available: 192.168.1.5
[-] Unavailable: 192.168.1.2
...

--- Results ---
✅ Available (15):
192.168.1.1
192.168.1.5
...

❌ Unavailable (239):
192.168.1.2
192.168.1.3
...

📊 Availability: 5.91%

Build

To create a standalone executable:

# Activate virtual environment
source venv/bin/activate

# Compile the script
pyinstaller --onefile --name ip_scanner main.py

The executable will be created in the dist/ directory.

Configuration

Performance Tuning

You can adjust the MAX_WORKERS constant in main.py to optimize performance:

  • Increase for faster scanning (more concurrent threads)
  • Decrease if you experience network issues or want to be more conservative

Ping Timeouts

The scanner uses different ping commands optimized for each operating system:

  • Windows: ping -n 1 -w 1000
  • Linux: ping -c 1 -W 1
  • macOS: ping -c 1 -W 1000

Technical Details

Dependencies

  • ipaddress: Standard library for IP network operations
  • subprocess: Standard library for executing ping commands
  • platform: Standard library for OS detection
  • concurrent.futures: Standard library for concurrent execution
  • datetime: Standard library for timestamping

Architecture

  • Main Thread: Orchestrates the scanning process
  • Worker Threads: Execute ping commands concurrently
  • Result Collection: Gathers and processes results in real-time
  • File I/O: Writes results to timestamped files

Error Handling

The scanner includes robust error handling for:

  • Invalid IP addresses or CIDR notation
  • Network timeouts and failures
  • File system errors
  • Invalid command line arguments

License

This project is open source and available under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Disclaimer

This tool is intended for legitimate network administration and security testing purposes only. Always ensure you have proper authorization before scanning any network that you don't own or manage.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages