Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fuchs-fabian/fritznetdevices

A Python script to retrieve user-friendly all connected devices from a Fritz!Box with additional (neccessary) information
https://github.com/fuchs-fabian/fritznetdevices

avm avm-fritz fritz-box fritzbox network scanning script simple

Last synced: about 1 month ago
JSON representation

A Python script to retrieve user-friendly all connected devices from a Fritz!Box with additional (neccessary) information

Awesome Lists containing this project

README

        

# `fritznetdevices` - A Python script to retrieve user-friendly all connected devices from a [Fritz!Box](https://en.avm.de/products/fritzbox/) with additional (neccessary) information



MIT



Repository fritznetdevices

## Description

A Python script designed to seamlessly retrieve all connected devices from a Fritz!Box network.

It provides detailed information in a user-friendly format and exports the data to various file types for easy access and analysis.

With enhanced features such as device categorization and reachability checks, this script is perfect to get a comprehensive overview of your network.

> **_Summary_**:
>
> - It is really useful if you want to migrate your devices to a new router or if you want to keep track of your network devices.
> - It provides information that is not available in the Fritz!Box user interface.
>
> It saves you a lot of time and effort by automating the process of retrieving and organizing the data.
>
> You have no need to work with tools like [Wireshark](https://www.wireshark.org/), [nmap](https://nmap.org/), [arp-scan](https://man.archlinux.org/man/arp-scan.1.en), etc. to get the information you need.

It can take a while to retrieve all the information, especially if you have a lot of devices in your network. So a few minutes of patience is required.

The following file types are generated by the script:

- `csv`
- `json`
- `xlsx` (Excel)

## Installation

Simply run the following command in your terminal to clone the repository and install the required packages:

```shell
git clone https://github.com/fuchs-fabian/fritznetdevices.git && pip install fritzconnection requests openpyxl pandas
```

`fritzconnection` is a Python library to communicate with the Fritz!Box. It is used to retrieve the necessary information.
For more information about the library, visit the [official repository](https://github.com/kbr/fritzconnection).

## Configuration

To use the script, you need to adjust the `config.ini` file to your Fritz!Box credentials.

```ini
[fritzbox]
address = 192.168.178.1
username = myuser
password = mypassword

[network]
cidr = 192.168.178.0/24

[features]
manufacturer_and_category = true
web_interface = true
hostname_and_ip_addresses = true
determine_unused_ip_addresses = true
ping_all_devices = false
```

Adjust minimal the following values:

- `username` with your Fritz!Box username
- `password` with your Fritz!Box password

> **_Note_**: It could be a good idea to create a new user for this script. This user should have only the necessary permissions.

The other values can be adjusted as needed but are not required.

There is also a `device_categories.json` file. You can adjust this file to your needs. With this file it is possible to determine if a device is an IoT device, a network device, a server, etc.

### Features

| Feature | Description | Time Intensity |
|---------------------------------|----------------------------------------------------------------------------------|----------------|
| `manufacturer_and_category` | Determines the manufacturer and category of the device based on the MAC address. | Low |
| `web_interface` | Determines if the device has a web interface. | Medium |
| `hostname_and_ip_addresses` | Determines the hostname and IP addresses of the device. | Medium |
| `determine_unused_ip_addresses` | Determines unused IP addresses in the network. | High |
| `ping_all_devices` | Determines if all devices are reachable. | High |

## Usage

First you need to go to the directory where the script is located.

Then you can run the script with the following command:

```shell
python fritznetdevices.py
```

Let the magic happen! 🎩✨

You can take a look at the `exports` folder. There you will find the generated files.

> **_Note_**: No sensitive data will be sent to the developer or any other third party. The script is designed to run locally on your machine. The only data that will be sent to a third party are the first three octets of the MAC address to determine the manufacturer.
>
> If you want to disable this feature, you can set the `manufacturer_and_category` feature to `false`.

To retrieve this manufacturer information, the script uses the [macvendors.com](https://macvendors.com/) API.

No costs will be incurred for using these services. Till **1000** requests per day are free. You don't have to register for this service.

> **_Note_**: Caching is used to reduce the number of requests to the services. The cache is stored in the `cache` folder.

The following information is listed for each device if all features are enabled (in the `devices` directory):

- **_IP Address_** (`ip`): The device’s IP address.
- **_Name_** (`name`): The device’s given name or identifier.
- **_MAC Address_** (`mac`): Unique hardware address of the device.
- **_Status_** (`status`): Indicates if the device is currently _active_ or _inactive_.
- **_Connection Type_** (`connection_type`): Type of connection, e.g., _LAN_ or _WLAN_.
- **_Address Source_** (`address_source`): Source from which the IP address is assigned, e.g., _DHCP_.
- **_Manufacturer_** (`manufacturer`): The device’s manufacturer, inferred from its MAC address.
- **_Category_** (`category`): Category or type of device, if available.
- **_Web Interface_** (`web_interface`): Indicates if the device has a web interface for direct access.
- **_Primary Hostname_** (`primary_hostname`): The primary hostname associated with the device's IP.
- **_All Hostnames by IPv4 Address_** (`all_hostnames_by_ipv4_address`): List of all hostnames tied to the device’s IPv4 address.
- **_Is Reachable Over Ping_** (`is_reachable_over_ping`): Specifies if the device responds to a network ping (reachable or not).

There are also a few other files generated that are useful for more detailed analysis.

All the exported files are stored in the `exports` folder.

## Bugs, Suggestions and Feedback

> If you have any bugs, suggestions or feedback, feel free to create an issue or create a pull request with your changes.

## Support Me

If you like `fritznetdevices`, you think this tool is useful and saves you a lot of work and nerves and lets you sleep better, please give it a star and consider donating.



Donate with PayPal