This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/scripts/experiment/luciRpc.sh

91 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2018-09-18 14:36:45 +02:00
#!/bin/bash
function rpcLogin() {
local IP=$1
local PORT=$2
local USER="$3"
local PASS="$4"
local RES=""
local cmd="curl"
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/auth"
local opt="--silent --data"
local data="{ \"id\": 1, \"method\": \"login\", \"params\": [ \"$USER\", \"$PASS\" ] }"
res=$(${cmd} ${url} ${opt} "${data}")
echo ${res} | jq -Ma ".result"
}
function iwList()
{
local IP=$1
local PORT=$2
local IFACE=$3
local TOKEN="$4"
local cmd="curl"
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
local opt="--silent --cookie sysauth=${TOKEN} --data"
local data="{ \"method\": \"wifi.getiwinfo\", \"params\": [ \"${IFACE}\" ] }"
res=$(${cmd} ${url} ${opt} "${data}")
echo ${res} |jq
}
function netDeviceInfo()
{
local IP=$1
local PORT=$2
local TOKEN="$3"
local cmd="curl"
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
local opt="--silent --cookie sysauth=${TOKEN} --data"
local data="{ \"method\": \"net.deviceinfo\", \"params\": [ \"wlan0\" ]}"
res=$(${cmd} ${url} ${opt} "${data}")
echo ${res} |jq
}
function netDevices()
{
local IP=$1
local PORT=$2
local TOKEN="$3"
local cmd="curl"
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
local opt="--silent --cookie sysauth=${TOKEN} --data"
local data="{ \"method\": \"net.devices\", \"params\": [] }"
res=$(${cmd} ${url} ${opt} "${data}")
echo ${res} |jq
}
function arpTable()
{
local IP=$1
local PORT=$2
local TOKEN="$3"
local cmd="curl"
local url="http://${IP}:${PORT}/cgi-bin/luci/rpc/sys"
local opt="--silent --cookie sysauth=${TOKEN} --data"
local data="{ \"method\": \"net.arptable\", \"params\": [] }"
res=$(${cmd} ${url} ${opt} "${data}")
echo ${res} |jq
}
#FIXME USER PASS
authToken=$(rpcLogin 192.168.1.1 8080 root 'XXXXXX EDITE MOI')
#netDevices 192.168.1.1 8080 ${authToken}
#netDeviceInfo 192.168.1.1 8080 ${authToken}
#iwList 192.168.1.1 8080 wlan0 ${authToken}
#iwList 192.168.1.1 8080 wlan1 ${authToken}
adoles: