Metadata-Version: 2.1
Name: rtsp-network-scanner
Version: 1.0.0
Summary: A comprehensive tool for scanning and debugging RTSP streams in networks
Home-page: https://github.com/sssanjaya/rtsp-scanner
Author: RTSP Scanner Team
Author-email: contact@sanjayhona.com.np
License: UNKNOWN
Project-URL: Bug Reports, https://github.com/sssanjaya/rtsp-scanner/issues
Project-URL: Source, https://github.com/sssanjaya/rtsp-scanner
Project-URL: Documentation, https://github.com/sssanjaya/rtsp-scanner#readme
Keywords: rtsp scanner network camera security debug stream video surveillance ipcam monitoring
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Intended Audience :: Information Technology
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: Topic :: Multimedia :: Video
Classifier: Topic :: Security
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Environment :: Console
Classifier: Natural Language :: English
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest (>=7.0.0) ; extra == 'dev'
Requires-Dist: black (>=22.0.0) ; extra == 'dev'
Requires-Dist: flake8 (>=4.0.0) ; extra == 'dev'
Requires-Dist: twine (>=4.0.0) ; extra == 'dev'

# RTSP Scanner

A comprehensive Python tool for scanning, debugging, and testing RTSP (Real Time Streaming Protocol) streams in networks. This tool helps network administrators and security professionals discover RTSP cameras, test connectivity, and identify available channels.

## Features

- **Network Port Scanning**: Scan entire networks or IP ranges for open RTSP ports
- **RTSP URL Testing**: Validate and test RTSP URLs for connectivity and accessibility
- **Channel Discovery**: Automatically discover available RTSP channels on cameras
- **Credential Testing**: Test common default credentials on RTSP streams
- **Multi-threaded**: Fast concurrent scanning with configurable workers
- **Debug Logging**: Detailed logging for troubleshooting
- **Export Results**: Export scan results to JSON or CSV formats
- **No Dependencies**: Uses only Python standard library

## Installation

### From Source

```bash
# Clone the repository
git clone https://github.com/yourusername/rtsp-scanner.git
cd rtsp-scanner

# Install the package
pip install -e .
```

### Using pip (once published)

```bash
pip install rtsp-scanner
```

### Build Distribution Package

```bash
# Build wheel and source distribution
python setup.py sdist bdist_wheel

# Install from built package
pip install dist/rtsp-scanner-1.0.0-py3-none-any.whl
```

## Usage

### Command Line Interface

The tool provides several commands for different scanning operations:

#### 1. Scan Network for RTSP Ports

Scan an entire network range for open RTSP ports:

```bash
rtsp-scanner scan-network 192.168.1.0/24
```

With custom ports:

```bash
rtsp-scanner scan-network 192.168.1.0/24 --ports 554 8554 7447
```

#### 2. Scan Single Host

Scan ports on a specific host:

```bash
rtsp-scanner scan-ports 192.168.1.100
```

#### 3. Scan IP Range

Scan a range of IP addresses:

```bash
rtsp-scanner scan-range 192.168.1.1 192.168.1.50
```

#### 4. Test RTSP URL

Test a specific RTSP URL for connectivity:

```bash
rtsp-scanner test-url rtsp://192.168.1.100:554/stream
```

With authentication:

```bash
rtsp-scanner test-url rtsp://192.168.1.100:554/stream --username admin --password admin
```

#### 5. Validate RTSP URL

Validate URL format and parse components:

```bash
rtsp-scanner validate-url rtsp://192.168.1.100:554/Streaming/Channels/101
```

#### 6. Scan for Channels

Discover available RTSP channels on a camera:

```bash
rtsp-scanner scan-channels 192.168.1.100
```

With authentication:

```bash
rtsp-scanner scan-channels 192.168.1.100 --username admin --password admin
```

With credential testing (tries common default credentials):

```bash
rtsp-scanner scan-channels 192.168.1.100 --with-creds
```

#### 7. Quick Channel Scan

Quick scan with only the most common paths:

```bash
rtsp-scanner quick-scan 192.168.1.100
```

#### 8. Scan Numbered Channels

Scan numbered channel patterns (channel1, channel2, etc.):

```bash
rtsp-scanner scan-numbered 192.168.1.100
```

With custom range:

```bash
rtsp-scanner scan-numbered 192.168.1.100 --range 1-32
```

#### 9. Test Common Credentials

Test common default credentials on a URL:

```bash
rtsp-scanner test-credentials rtsp://192.168.1.100:554/
```

### Global Options

Available for all commands:

- `--debug`: Enable debug logging for detailed output
- `--log-file FILE`: Log output to a file
- `--output FILE`: Export results to JSON or CSV file
- `--timeout SECONDS`: Connection timeout (default: 2.0)
- `--workers NUM`: Max concurrent workers (default: 50)

Examples:

```bash
# Enable debug mode with file logging
rtsp-scanner scan-network 192.168.1.0/24 --debug --log-file scan.log

# Export results to JSON
rtsp-scanner scan-channels 192.168.1.100 --output results.json

# Adjust timeout and workers
rtsp-scanner scan-network 192.168.1.0/24 --timeout 5 --workers 100
```

## Python API

You can also use RTSP Scanner as a Python library:

### Port Scanner

```python
from rtsp_scanner.core.port_scanner import PortScanner
from rtsp_scanner.utils.logger import setup_logger

# Setup logger
logger = setup_logger(debug=True)

# Create scanner
scanner = PortScanner(timeout=2.0, max_workers=50, logger=logger)

# Scan network
results = scanner.scan_network('192.168.1.0/24')

# Scan single host
results = scanner.scan_host('192.168.1.100')

# Scan IP range
results = scanner.scan_ip_range('192.168.1.1', '192.168.1.50')

print(results)
```

### RTSP Tester

```python
from rtsp_scanner.core.rtsp_tester import RTSPTester

# Create tester
tester = RTSPTester(timeout=5.0)

# Validate URL
is_valid, message = tester.validate_rtsp_url('rtsp://192.168.1.100:554/stream')
print(f"Valid: {is_valid}, Message: {message}")

# Parse URL
parsed = tester.parse_rtsp_url('rtsp://admin:admin@192.168.1.100:554/stream')
print(parsed)

# Test connection
result = tester.test_rtsp_connection('rtsp://192.168.1.100:554/stream')
print(result)

# Test with authentication
result = tester.test_rtsp_with_auth('rtsp://192.168.1.100:554/stream', 'admin', 'admin')
print(result)

# Test common credentials
results = tester.test_common_credentials('rtsp://192.168.1.100:554/')
print(results)
```

### Channel Scanner

```python
from rtsp_scanner.core.channel_scanner import ChannelScanner

# Create scanner
scanner = ChannelScanner(timeout=5.0, max_workers=20)

# Scan channels
channels = scanner.scan_channels('192.168.1.100', port=554)
print(channels)

# Scan with authentication
channels = scanner.scan_channels('192.168.1.100', username='admin', password='admin')

# Scan with credential testing
channels = scanner.scan_with_credentials('192.168.1.100')

# Quick scan
channels = scanner.quick_scan('192.168.1.100')

# Scan numbered channels
channels = scanner.scan_numbered_channels('192.168.1.100', channel_range=range(1, 17))
```

### Output Formatting

```python
from rtsp_scanner.utils.output import OutputFormatter

formatter = OutputFormatter()

# Format as table
table = formatter.format_table(results, headers=['host', 'port', 'status'])
print(table)

# Format as JSON
json_str = formatter.format_json(results, pretty=True)
print(json_str)

# Export to file
formatter.export_json(results, 'results.json')
formatter.export_csv(results, 'results.csv')

# Print summary
summary = formatter.format_summary(results, scan_type="Network Scan")
print(summary)
```

## Supported Camera Manufacturers

The scanner includes path patterns for many popular camera brands:

- Hikvision
- Dahua
- Axis
- Foscam
- Amcrest
- TP-Link
- Generic ONVIF cameras
- And many more...

## Common RTSP Ports

The scanner checks these ports by default:

- 554 (Standard RTSP)
- 8554
- 7447
- 5554
- 88
- 8000
- 8080
- 8888

## Security Considerations

This tool is designed for:

- **Authorized network security assessments**
- **Testing your own cameras and infrastructure**
- **Network administration and troubleshooting**
- **Educational purposes**

**Warning**: Only use this tool on networks and devices you own or have explicit permission to test. Unauthorized scanning may be illegal in your jurisdiction.

## Troubleshooting

### Connection Timeouts

If you're experiencing many timeouts:

```bash
rtsp-scanner scan-network 192.168.1.0/24 --timeout 5
```

### Slow Scanning

Increase the number of workers:

```bash
rtsp-scanner scan-network 192.168.1.0/24 --workers 100
```

### Debug Mode

Enable debug logging to see detailed information:

```bash
rtsp-scanner scan-channels 192.168.1.100 --debug
```

### Save Logs

Save debugging logs to a file:

```bash
rtsp-scanner scan-network 192.168.1.0/24 --debug --log-file scan.log
```

## Project Structure

```
rtsp-scanner/
├── rtsp_scanner/
│   ├── __init__.py
│   ├── cli.py                  # Command-line interface
│   ├── core/
│   │   ├── __init__.py
│   │   ├── port_scanner.py     # Network port scanning
│   │   ├── rtsp_tester.py      # RTSP URL testing
│   │   └── channel_scanner.py  # Channel discovery
│   └── utils/
│       ├── __init__.py
│       ├── logger.py           # Logging utilities
│       └── output.py           # Output formatting
├── setup.py
├── pyproject.toml
├── requirements.txt
├── MANIFEST.in
└── README.md
```

## Requirements

- Python 3.7 or higher
- No external dependencies (uses only standard library)

## Development

### Running Tests

```bash
# Install development dependencies
pip install pytest

# Run tests (when implemented)
pytest tests/
```

### Code Formatting

```bash
# Install formatters
pip install black flake8

# Format code
black rtsp_scanner/

# Check style
flake8 rtsp_scanner/
```

## License

MIT License - see LICENSE file for details

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Changelog

### Version 1.0.0 (2025-11-25)

- Initial release
- Network port scanning
- RTSP URL testing and validation
- Channel discovery
- Credential testing
- Export to JSON/CSV
- Comprehensive CLI interface

## Author

RTSP Scanner Team

## Support

For issues, questions, or contributions, please visit:
https://github.com/yourusername/rtsp-scanner/issues


