A Python Utility for RTSP Source Scanning

Blake Bradford Avatar

·

Have you ever needed to scan a network for RTSP (Real-Time Streaming Protocol) sources? Look no further than RTSPScanner, a powerful Python utility that can help you with this task. In this article, we will explore how to use RTSPScanner as a command-line tool or as a class in your Python projects.

Overview of RTSPScanner

RTSPScanner is a Python utility that allows you to scan a network for RTSP sources. It is designed to be flexible and easy to use, offering both command-line and class-based interfaces.

System Architecture

RTSPScanner is built using Python and relies on several dependencies, including Pillow, beard-portscan, and ffmpeg. These dependencies enable RTSPScanner to perform the necessary network scanning and stream verification tasks.

Key Features

  • Command-line utility: RTSPScanner can be used as a command-line tool, allowing you to easily scan a network for RTSP sources and perform various operations such as adding or removing cameras.

  • Class-based interface: RTSPScanner can also be used as a class in your Python projects, providing a programmatic way to integrate RTSP scanning capabilities into your own applications.

  • Flexible scanning options: With RTSPScanner, you can specify various parameters such as the target address or network, camera names, ports, paths, and credentials. This enables you to tailor the scanning process to your specific needs.

  • Integration with rtsp-simple-server: RTSPScanner seamlessly integrates with rtsp-simple-server, allowing you to add discovered RTSP cameras to your server with a few simple commands.

Usage Examples

To showcase the capabilities of RTSPScanner, let’s explore some usage examples.

Scanning a Subnet

Suppose you have a network with the IP address range 192.168.2.0/24, and you want to scan this subnet for RTSP sources. You can use the following command:

rtspscanner.py -m scan -c admin:admin -a 192.168.2.0/24

This command will scan the specified subnet and display the potential RTSP sources found, along with their corresponding camera details, credentials used, and paths.

Scanning a Single IP

If you want to scan a single IP address for RTSP sources, you can use the following command:

rtspscanner.py -m scan -c admin:admin -a 192.168.2.189

This command will scan the specified IP address and display the potential RTSP source found, along with its camera details, credentials used, and paths.

Adding Discovered Cameras to rtsp-simple-server

If you’re using rtsp-simple-server and want to add all the discovered RTSP cameras to it, you can use the following command:

rtspscanner.py -m add -A 192.168.2.240 -c admin:admin -a 192.168.2.0/24

This command will add all the discovered RTSP cameras to rtsp-simple-server, using the specified API address and the provided credentials.

Implementation as a Python Class

Besides its command-line utility, RTSPScanner can also be used as a class in your Python projects. Here’s an example of how you can use it:

“`python
from rtspscanner import RTSPScanner

scanner = RTSPScanner()
scanner.address = “192.168.2.0/24”
scanner.mode = “scan”
scanner.creds = “admin:admin,user:password”
scanner.paths = “/Streaming/Channels/101,/live,live2”

Run the scan

scanner.scan()

Print the list of cameras found as a dictionary

print(scanner.scanResults)
“`

This example demonstrates how to create an instance of the RTSPScanner class, set relevant parameters, and perform a scan. You can then access the results as a dictionary.

Conclusion

In this article, we explored RTSPScanner, a Python utility that simplifies the process of scanning a network for RTSP sources. We discussed its key features, usage examples, and how to integrate it into your Python projects. Whether you’re a security professional, a system administrator, or a Python developer, RTSPScanner can be a valuable tool for your RTSP source scanning needs.

If you’re interested in learning more about RTSPScanner or trying it out for yourself, visit the RTSPScanner GitHub repository. Happy scanning!

References

Licensing Information

RTSPScanner is distributed under the MIT License. Please refer to the LICENSE file in the RTSPScanner GitHub repository for more details.

Leave a Reply

Your email address will not be published. Required fields are marked *