zteScanner

package module
v0.0.0-...-db38332 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

README

zteScanner

A go library to get connected devices from a ZTE ZXHN F670L WiFi Router. This probably won't work for toher models.

This repo also contains a cli tool and a telegram bot based on this library.

Why

I wanted to get connected devices to my WiFi router as fast as I could. Tools like arp-scanner, nmap took sometime and was hit or miss.

This library basically scraps ZTE dashboard and extract the connected devices, along with their IP Address, hostname and MAC Address.

Usage

Cli

cli

zte-scanner -u <username> -p <password>

cli

Bot

bot

zte-scanner-bot -db <sqlite db path> -u <router username> -p <router password>

bot

library
    scanner := zteScanner.New("http://192.168.1.1", "username", "password")
    /*
    All methods   
                scanner.GetDevices()
                scanner.GetDevicesAlive() -> get devices and perform ping scan
                scanner.GetDevicesForce() -> logout others, login and scan
                scanner.GetDevicesAliveForce()

    */
    devs, err := scanner.GetDevices()

	if err != nil {
		log.Fatal(err)
	}

	for _, device := range devices {
		fmt.Println("Host name: ", device.Hostname)
		fmt.Println("MAC: ", device.MacAddress)
		fmt.Println("IP: ", device.IPAddress)
		fmt.Printf("========\n\n")
	}

Build

cli
make cli/build
bot
make bot/build

Features

  • gets clients in less than 0.5s
  • Optional Ping scan to check if devices are alive
  • hostname, ip and mac address

NOTE

Setting up telegram bot with admin access to your wifi router is a bad idea.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	MacAddress string
	IPAddress  string
	Hostname   string
}

func (Device) IsAlive

func (d Device) IsAlive() bool

Ping th e device for 1 second

type Devices

type Devices []Device

type DevicesInfo

type DevicesInfo struct {
	XMLName xml.Name `xml:"ajax_response_xml_root"`
	Text    string   `xml:",chardata"`
	WlanID  struct {
		Text     string `xml:",chardata"`
		Instance []struct {
			Text      string   `xml:",chardata"`
			ParaName  []string `xml:"ParaName"`
			ParaValue []string `xml:"ParaValue"`
		} `xml:"Instance"`
	} `xml:"OBJ_WLAN_AD_ID"`
	LanID struct {
		Text     string `xml:",chardata"`
		Instance []struct {
			Text      string   `xml:",chardata"`
			ParaName  []string `xml:"ParaName"`
			ParaValue []string `xml:"ParaValue"`
		} `xml:"Instance"`
	} `xml:"OBJ_WLANAP_ID"`
}

type Scanner

type Scanner struct {
	URL      string
	Username string
	Password string
}

func New

func New(baseURL, username, password string) Scanner

func (Scanner) GetDevices

func (s Scanner) GetDevices() (Devices, error)

func (Scanner) GetDevicesAlive

func (s Scanner) GetDevicesAlive() (Devices, error)

GetDevices with ping scan

func (Scanner) GetDevicesAliveForce

func (s Scanner) GetDevicesAliveForce() (Devices, error)

Force Login, GetDevices and Ping Scan them

func (Scanner) GetDevicesForce

func (s Scanner) GetDevicesForce() (Devices, error)

Force Login and GetDevices

Directories

Path Synopsis
cmd
bot
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL