Tout ce qui concerne internet
Répondre

"nom" des appareils distants

#1Messageil y a 4 ans

bonjour à tou.te.s

peut_on retrouver le "nom" des appareils connectés
au réseau local (freebox pour ne pas le citer ) ?

avec nmap -T5 -sP --system-dns 192.168.1.0/24 | grep report | grep -v gateway
on affiche

		Nmap scan report for 192.168.1.19
		Nmap scan report for 192.168.1.34
		Nmap scan report for lenovo (192.168.1.49)
lenovo c'est le "nom" du pc local
mais ceux distants ?

avec arp -a | grep -v _gateway
on affiche

		? (192.168.1.19) at e4:9e:12:5c:02:1e [ether] on wlp1s0
		? (192.168.1.34) at 28:e3:47:b9:07:04 [ether] on wlp1s0
aucun "nom"

y'a un truc qui donnerait cela ?
avec l'IP ou l'adresse mac ( ou autres ? ) ou pas

merci d'avance

"nom" des appareils distants

#2Messageil y a 4 ans

Bonjour.
J'ai essayé avec nmap en pointant ma box et j'ai ceci:

$ nmap -v -sn 192.168.1.1/24
Starting Nmap 7.70 ( https://nmap.org ) at 2019-08-27 07:33 CEST
Initiating Ping Scan at 07:33
Scanning 256 hosts [2 ports/host]
Completed Ping Scan at 07:33, 2.40s elapsed (256 total hosts)
Initiating Parallel DNS resolution of 256 hosts. at 07:33
Completed Parallel DNS resolution of 256 hosts. at 07:33, 0.00s elapsed
Nmap scan report for 192.168.1.0 [host down]
Nmap scan report for lan.home (192.168.1.1)
Host is up (0.00087s latency).
Nmap scan report for 192.168.1.2 [host down]
Nmap scan report for 192.168.1.3 [host down]
.......
.......
Nmap scan report for dcodeurtvdorange.home (192.168.1.10)
Host is up (0.0056s latency).
Nmap scan report for 192.168.1.11 [host down]
Nmap scan report for 192.168.1.12 [host down]
........
........
Nmap scan report for android.home (192.168.1.51)
Host is up (0.055s latency).
Nmap scan report for 192.168.1.52 [host down]
Nmap scan report for manjaro.home (192.168.1.53)
Host is up (0.00012s latency).
......
......
J'ai donc une ip interne et la dénomination des appareils connectés .

"nom" des appareils distants

#3Messageil y a 4 ans

merci pour ton intervention

ah ben alors ? pourquoi pas chez moi ?
sudo ./nmap -v -sn 192.168.1.1/24

Starting Nmap 7.80 ( https://nmap.org ) at 2019-08-27 07:58 CEST
Initiating ARP Ping Scan at 07:58
Scanning 255 hosts [1 port/host]
Completed ARP Ping Scan at 07:58, 1.75s elapsed (255 total hosts)
Initiating Parallel DNS resolution of 255 hosts. at 07:58
Completed Parallel DNS resolution of 255 hosts. at 07:58, 0.01s elapsed
Nmap scan report for 192.168.1.0 [host down]
...
Nmap scan report for 192.168.1.19
Host is up (0.019s latency).
MAC Address: E4:9E:12:5C:02:1E (Freebox SAS)
...
Nmap scan report for 192.168.1.34
Host is up (0.039s latency).
MAC Address: CA:7C:3F:35:3F:0F (Unknown)
...
Nmap scan report for 192.168.1.254
Host is up (0.084s latency).
MAC Address: F4:CA:E5:5B:D0:B2 (Freebox SAS)
Nmap scan report for 192.168.1.255 [host down]
Initiating Parallel DNS resolution of 1 host. at 07:58
Completed Parallel DNS resolution of 1 host. at 07:58, 0.00s elapsed
Nmap scan report for 192.168.1.49
Host is up.
Read data files from: /run/media/bul/ext/Exec/nmap/exec/bin/../share/nmap
Nmap done: 256 IP addresses (4 hosts up) scanned in 1.89 seconds
           Raw packets sent: 507 (14.196KB) | Rcvd: 3 (84B)
du à la version ( 7.80 pour moi ) ? à la compilation depuis les sources ?
à ma config ? à une bétise de ma part ?
@+

"nom" des appareils distants

#4Messageil y a 4 ans

:bjr:

Déterrage (mais j'avais envie de faire mumuse avec ma box)

Seule solution c'est d'écrire une application freebox :?
J'ai donc trouvé un bibliothèque python qui permet de créer son application (c'était le plus difficile!)...

installer la bibliothèque :

git clone https://github.com/stilllman/aiofreepybox.git
besoin aussi d'installer le paquet python-aiohttp

Aller dans le répertoire et créer son programme (ici fichier free-distant):

cd aiofreepybox
touch free-distant
chmod +x free-distant
Il ne reste plus qu'a écrire du code dans ce fichier (free-distant):

#!/usr/bin/env python
import asyncio
from aiofreepybox import Freepybox
from urllib import request
import json

async def demo():

    with request.urlopen('http://mafreebox.freebox.fr/api_version') as f_url:
        req = f_url.read()
    datas = json.loads(req)

    fbx = Freepybox(api_version="v5")
    #print("\nfreeboxapp:", fbx.app_desc)

     # lire datas à l'adresse http://mafreebox.freebox.fr/api_version
    # Connect to the freebox
    # Be ready to authorize the application on the Freebox if you use this script for the first time
    await fbx.open(host=datas['api_domain'], port=datas['https_port'])

    fbx_lan_hosts = await fbx.lan.get_hosts_list()
    hosts = [h['names'] for h in fbx_lan_hosts if h['active']]
    liste = [[c['name'] for c in h] for h in hosts]
    for h in liste:
        print("Connecté: ", set(h))

    await fbx.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(demo())
loop.close()
Ici, les datas des connectés sont un peu brute, mais il est facile de faire plus propre... Ici il n'y a que le nom mais nous avons beaucoup plus comme l'heure de connection, le type de matériel, vendor_name, les adresses ip et mac ...
avec un seul connecté, j'ai le nom de ma machine et mon alias ; et si j'allume mon player j'en ai un de plus :

Connecté:  {'PATRICK-PC', 'tower: minidlna', 'tower'}
Connecté:  {'Freebox Player', 'Freebox-Player'}
Chaque box a son propre nom de domaine (au format XXXXXXXX.fbxos.fr), donc il faut le trouver à l'adresse : http://mafreebox.freebox.fr/api_version. Ici le programme fait une auto-détection.

Chaque application freebox a besoin d'une autorisation pour ce connecter la première fois à la box. Donc au premier lancement, la box serveur va demander l'autorisation sur l'écran led.
Ensuite tout roule ... :pompom:


---
Toute la documentation sur l'api car on peut faire beaucoup plus...

"nom" des appareils distants

#5Messageil y a 4 ans

ah ben : merci beaucoup
un déterrage ? vaut mieux "tard" que jamais
si en plus il ne me reste qu'à faire du copier coller !!!
dommage pour ceux qui n'ont pas de freebox
je regarde tout ça de très près
@+
Répondre