|
发表于 2021-1-11 14:10:00
|
显示全部楼层
提供一段python代码,临时用用还是挺好的。
===================== 下面的是代码 ======================
- import os
- import re
- import requests # pip install requests
-
- # base values
- gocloud_host = 'gao.ke'
- gocloud_username = 'admin'
- gocloud_password = 'admin'
-
- # login & retun sysauth
- url = 'http://{}/cgi-bin/webui/admin#/user/login'.format(gocloud_host)
- v = requests.get(url).text
- timestamp = re.findall('gocloud.sysauth.timestamp = "(.*)";', v)[0]
- csrftoken = re.findall('gocloud.sysauth.csrftoken = "(.*)";', v)[0]
-
- data = {
- 'userName': gocloud_username,
- 'password': gocloud_password, # 明文
- 'timestamp': timestamp,
- 'csrftoken': csrftoken,
- 'newwebui': 'yes',
- 'username': gocloud_username,
- 'type': 'account'
- }
-
- url = 'http://{}/cgi-bin/webui/admin'.format(gocloud_host)
- r = requests.post(url, headers={'Accept': 'application/json'}, data=data)
- j = r.json()
-
- if j[ "status"] == "success":
- sysauth = r.cookies['sysauth']
- else:
- print(d)
- os._exit(1)
-
- # sta 显示所有的接入用户
- url = 'http://{}{}'.format(gocloud_host, '/cgi-bin/webui/admin/wifi/sta?')
- r = requests.get(url, cookies={'sysauth': sysauth})
- sta = r.json()
-
- print('key mac ip地址 所属ssid 频段 RSSI0 RSSI1 Rate(Tx/Rx) 设备名')
- for i in sta['tblsection']['list']:
- key = i['key']
- mac = i[f'cbid.table.{key}.mac']['value']
- ip = i[f'cbid.table.{key}.ip']['value']
- host= i[f'cbid.table.{key}.host']['value']
- ssid= i[f'cbid.table.{key}.ssid']['value']
- rssi0=i[f'cbid.table.{key}.rssi0']['value']
- rssi1=i[f'cbid.table.{key}.rssi1']['value']
- rate= i[f'cbid.table.{key}.rate']['value']
- device=i[f'cbid.table.{key}.device']['value']
-
- print(f'{key:3s} {mac} {ip:15s} {ssid:10s} {device:4s} {rssi0} {rssi1} {rate:13s} {host}')
复制代码
|
|