k3c.sh

  sre

5feb304847e627891.jpg_fo742.jpg

#!/bin/bash
k3c_ip="192.168.2.1"
admin_password="c2hnZW50YWk\%3D"
#密码转义问题
function get_stok(){
    stock=`curl "http://k3c_ip/cgi-bin/" -H "Origin: http://k3c_ip" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,zh-CN;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: */*' -H "Referer: http://k3c_ip/cgi-bin" -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '{"method":"set","module":{"security":{"login":{"username":"admin","password":"c2hnZW50YWk%3D"}}},"_deviceType":"pc"}' --compressed ;`
    echostock |jq '.module.security.login.stok' |sed 's/\"//g'
}

function get_sysinfo(){
    curl "http://k3c_ip/cgi-bin/stok=1/data" -H "Origin: http://k3c_ip" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,zh-CN;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: */*' -H "Referer: http://k3c_ip/cgi-bin" -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '{"method":"get","module":{"device_manage":{"device_num":null},"network":{"wan_status":null},"device":{"info":null}},"_deviceType":"pc"}' --compressed
}

function get_onlineDevice(){
    curl "http://k3c_ip/cgi-bin/stok=1/data" -H "Origin: http://k3c_ip" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,zh-CN;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: */*' -H "Referer: http://k3c_ip/cgi-bin" -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '{"method":"get","module":{"device_manage":{"client_list":null}},"_deviceType":"pc"}' --compressed
}

function get_sysStatus(){
    curl "http://k3c_ip/cgi-bin/stok=1/data" -H "Origin: http://k3c_ip" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,zh-CN;q=0.9' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: */*' -H "Referer: http://k3c_ip/cgi-bin" -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' -H 'DNT: 1' --data-binary '{"method":"get","module":{"device":{"info":null},"network":{"wan_status":null,"lan":null},"wireless":{"wifi_2g_status":null,"wifi_5g_status":null},"usb":{"device":null},"wisp":{"config":null}},"_deviceType":"pc"}' --compressed
}
stok=`get_stok`
json_sysinfo=`get_sysinfo stok`
sys_uptime=`echojson_sysinfo |jq '.module.device.info.uptime'` |sed 's/\"//g'
sys_cpu_used=`echo json_sysinfo |jq '.module.device.info.cpu_used'` |sed 's/\"//g'
sys_cpu_freq=`echojson_sysinfo |jq '.module.device.info.cpu_freq'` |sed 's/\"//g'
sys_wan_ip=`echo json_sysinfo |jq '.module.device.info.wan_ip'` |sed 's/\"//g'
sys_total_ram=`echojson_sysinfo |jq '.module.device.info.total_ram'` |sed 's/\"//g'
sys_model=`echo json_sysinfo |jq '.module.device.info.model'` |sed 's/\"//g'
sys_current_time=`echojson_sysinfo |jq '.module.device.info.current_time'` |sed 's/\"//g'
sys_used_ram=`echo json_sysinfo |jq '.module.device.info.used_ram'` |sed 's/\"//g'

sys_upload_speed=`echojson_sysinfo |jq '.module.network.wan_status.upload_speed'` |sed 's/\"//g'
sys_download_speed=`echo json_sysinfo |jq '.module.network.wan_status.download_speed'` |sed 's/\"//g'
sys_internet_status=`echojson_sysinfo |jq '.module.network.wan_status.internet_status'` |sed 's/\"//g'

sys_online_24G=`echo json_sysinfo |jq '.module.device_manage.device_num.online_24G'` |sed 's/\"//g'
sys_online_5G=`echojson_sysinfo |jq '.module.device_manage.device_num.online_5G'` |sed 's/\"//g'
sys_online_lan=`echo json_sysinfo |jq '.module.device_manage.device_num.online_lan'` |sed 's/\"//g'
sys_online_guest=`echojson_sysinfo |jq '.module.device_manage.device_num.online_guest'` |sed 's/\"//g'


json_onlineDevice=`get_onlineDevice stok`
json_sysStatus=`get_sysStatusstok`
sys_usb_name=`echo json_sysinfo |jq '.module.usb.device.device_list.name'` |sed 's/\"//g'
sys_usb_free_capacity=`echojson_sysinfo |jq '.module.usb.device.device_list.free_capacity'` |sed 's/\"//g'
sys_usb_total_capacity=`echo json_sysinfo |jq '.module.usb.device.device_list.total_capacity'` |sed 's/\"//g'

echojson_sysinfo |jq '.module'
echo json_onlineDevice |jq '.module'
echojson_sysStatus |jq '.module'

LEAVE A COMMENT

Captcha Code