AirOS
SNMP
snmpwalk -c lessinianet.snmp -v 1 10.210.12.249 IF-MIB::ifDescr IF-MIB::ifDescr.1 = STRING: lo IF-MIB::ifDescr.2 = STRING: eth0 IF-MIB::ifDescr.3 = STRING: eth1 IF-MIB::ifDescr.4 = STRING: wifi0 IF-MIB::ifDescr.5 = STRING: ath0 IF-MIB::ifDescr.6 = STRING: eth0.10 IF-MIB::ifDescr.7 = STRING: br0
snmpget -c lessinianet.snmp -v 1 10.210.12.249 IF-MIB::ifPhysAddress.4 IF-MIB::ifPhysAddress.4 = STRING: 4:18:d6:ec:98:ac
Cercando dalla prima query i “wifi*” e sostituendo l'indice corrispondente (nell'esempio 4) nella seconda query si ottiene il mac. Ovviamente da fare usande le librerie SNMP PHP
http API
<?php // airOS-getFile_HTTP() from Omniflux: // https://community.ubnt.com/t5/airMAX-AC/Login-to-web-interface-with-PHP/m-p/2291860#M29858 // an example of fetching status.cgi from an AF24 (and probably any other UBNT radio) // the output is a bunch of JSON with the current radio stats // airOS_getFile_HTTP ($username, $password, $file, $address, $schema) #$out = airOS_getFile_HTTP ("root", "xxx", "status.cgi", "10.210.48.2", "https"); // CPE mng #$out = airOS_getFile_HTTP ("galileo", "xxx", "status.cgi", "10.210.12.247", "http"); // settore $out = airOS_getFile_HTTP ("root", "xxx", "status.cgi", "109.104.240.187:8008", "http"); // CPE print $out; function airOS_getFile_HTTP ($username, $password, $file, $address, $schema) { $ch = curl_init(); // Setup CURL curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, null); curl_setopt ($ch, CURLOPT_HTTPHEADER, Array ('Expect: ')); // Login AirOS >= 8.5.0+ OR get cookie with session ID for AirOS < 8.5.0 curl_setopt ($ch, CURLOPT_URL, "$schema://$address/api/auth"); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, Array ('username' => $username, 'password' => $password)); curl_setopt ($ch, CURLOPT_HEADER, 1); $response = curl_exec ($ch); // uncomment to see raw response //print "resp: $response\n"; curl_setopt ($ch, CURLOPT_HEADER, 0); // AirOS >= 8.5.0 request and return file if (curl_getinfo ($ch, CURLINFO_HTTP_CODE) == 200) { // Get X-CSRF-ID value preg_match ('/X-CSRF-ID: .*/', substr ($response, 0, curl_getinfo ($ch, CURLINFO_HEADER_SIZE)), $XCSRFID); curl_setopt ($ch, CURLOPT_URL, "$schema://$address/$file"); curl_setopt ($ch, CURLOPT_POST, 0); $retfile = curl_exec ($ch); curl_setopt ($ch, CURLOPT_URL, "$schema://$address/logout.cgi"); curl_setopt ($ch, CURLOPT_HTTPHEADER, Array (trim ($XCSRFID[0]), 'X-AIROS-LUA: 1')); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, Array()); curl_exec ($ch); } // Login failed, try AirOS < 8.5.0 login, request, and return file else { curl_setopt ($ch, CURLOPT_URL, "$schema://$address/login.cgi"); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, Array ('username' => $username, 'password' => $password)); curl_exec ($ch); curl_setopt ($ch, CURLOPT_URL, "$schema://$address/$file"); curl_setopt ($ch, CURLOPT_POST, 0); $retfile = curl_exec ($ch); } curl_close ($ch); return $retfile; } ?>
{ "chain_names": [ { "number": 1, "name": "Chain 0" }, { "number": 2, "name": "Chain 1" } ], "host": { "hostname": "cpe-188192-gal-lab", "uptime": 667685, "time": "2018-01-26 08:29:59", "timestamp": 828344250, "fwversion": "v8.5.0-cs.36727.180118.1402", "devmodel": "Rocket Prism 5AC Gen2", "netrole": "bridge", "loadavg": 0.129883, "totalram": 129982464, "freeram": 89100288, "temperature": 50, "cpuload": 39.603962 }, "genuine": "/images/genuine.png", "services": { "dhcpc": false, "dhcpd": false, "dhcp6d_stateful": false, "pppoe": false, "airview": 2 }, "firewall": { "iptables": false, "ebtables": false, "ip6tables": false, "eb6tables": false }, "portfw": false, "wireless": { "essid": "lessinianet.net", "mode": "sta-ptmp", "compat_11n": 0, "hide_essid": 0, "apmac": "80:2A:A8:A4:2F:9D", "frequency": 5655, "center1_freq": 5655, "dfs": 1, "distance": 14850, "security": "WPA2", "noisef": -90, "txpower": 22, "aprepeater": false, "rstatus": 5, "chanbw": 20, "rx_chainmask": 3, "tx_chainmask": 3, "cac_state": 0, "rx_idx": 4, "rx_nss": 2, "tx_idx": 6, "tx_nss": 2, "count": 1, "polling": { "dcap": 57720, "ucap": 95680, "use": 2, "tx_use": 1, "rx_use": 1, "atpc_status": 0, "fixed_frame": false, "gps_sync": false }, "sta": [ { "mac": "80:2A:A8:A4:2F:9D", "lastip": "0.0.0.0", "signal": -66, "rssi": 30, "noisefloor": -90, "chainrssi": [ 28, 26, 0 ], "tx_idx": 6, "rx_idx": 4, "tx_nss": 2, "rx_nss": 2, "tx_latency": 0, "distance": 14850, "tx_packets": 0, "tx_lretries": 0, "tx_sretries": 0, "uptime": 157916, "tx_ratedata": [ 3, 0, 0, 176, 14327, 102196, 156745, 178340, 0, 0 ], "stats": { "rx_bytes": 83701813, "rx_packets": 588950, "rx_pps": 11, "tx_bytes": 98347739, "tx_packets": 292160, "tx_pps": 0 }, "remote": { "hostname": "santuario-SudOvest", "platform": "Rocket 5AC Prism", "version": "XC.qca955x.v8.5.11.39842.190109.1449", "uptime": 240246, "time": "2019-01-12 10:33:00", "cpuload": 7, "temperature": 51, "totalram": 129961984, "freeram": 81661952, "netrole": "bridge", "mode": "ap-ptmp", "compat_11n": 1, "signal": -64, "rssi": 32, "noisefloor": -87, "tx_power": 22, "distance": 14850, "rx_chainmask": 3, "chainrssi": [ 30, 28, 0 ], "tx_ratedata": [ 2, 5, 220, 3920, 294380, 0, 0, 0, 0, 0 ], "tx_bytes": 139113407571, "rx_bytes": 9806798900, "ethlist": [ { "ifname": "eth0", "enabled": true, "plugged": true, "duplex": true, "speed": 1000, "snr": [ 30, 30, 30, 30 ], "cable_len": 14 } ], "ipaddr": [ "10.210.48.248", "169.254.47.157" ], "gps": { "lat": "45.545359", "lon": "10.878980", "fix": 1, "sats": 8, "dim": 3, "dop": "1.30", "alt": "341.6" }, "oob": "false" }, "airmax": { "actual_priority": 2, "beam": 0, "desired_priority": 2, "downlink_capacity": 57720, "uplink_capacity": 95680, "atpc_status": 0, "rx": { "usage": 1, "cinr": 26, "evm": [ [ 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 27, 28, 28, 28, 28, 28, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25, 25, 25, 25, 28, 28, 28, 25, 25, 25, 25, 24, 24, 24, 24, 24, 27, 27, 27, 27, 24, 24, 22, 22, 26, 26, 26, 26, 25, 25, 25, 25, 25, 25 ], [ 30, 30, 30, 31, 31, 31, 31, 31, 31, 30, 31, 30, 30, 30, 30, 30, 28, 28, 28, 28, 28, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29, 31, 31, 31, 31, 29, 29, 29, 29, 29, 29 ] ] }, "tx": { "usage": 1, "cinr": 26, "evm": [ [ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 26, 26, 26, 27, 27, 27, 27, 25, 27, 25, 26, 26, 26, 26, 25, 24, 24, 24, 24, 24, 24, 24, 24, 28, 28, 28, 28, 28, 28, 28, 28, 25, 25, 25, 25, 25, 25, 25, 25, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 26, 25, 27, 27 ], [ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 32, 32, 32, 33, 33, 33, 33, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 ] ] } } } ] }, "interfaces": [ { "ifname": "eth0", "hwaddr": "78:8A:20:AD:E4:4C", "enabled": true, "mtu": 1500, "status": { "plugged": true, "tx_bytes": 126448927, "rx_bytes": 32773228, "tx_errors": 0, "rx_errors": 0, "ipaddr": "0.0.0.0", "speed": 1000, "duplex": true, "snr": [ 29, 28, 29, 29 ], "cable_len": 38 } }, { "ifname": "ath0", "hwaddr": "78:8A:20:AC:E4:4C", "enabled": true, "mtu": 1500, "status": { "plugged": false, "tx_bytes": 394212716, "rx_bytes": 361312482, "tx_errors": 0, "rx_errors": 0, "ipaddr": "0.0.0.0", "speed": 0, "duplex": false } }, { "ifname": "br0", "hwaddr": "78:8A:20:AC:E4:4C", "enabled": true, "mtu": 1500, "status": { "plugged": true, "tx_bytes": 312537683, "rx_bytes": 249947706, "tx_errors": 0, "rx_errors": 0, "ipaddr": "10.210.48.2", "speed": 0, "duplex": false } } ], "provmode": {}, "ntpclient": {}, "unms": { "status": 1, "timestamp": "2018-01-26T08:29:57+0100" } }
risposta CPE
{ "host": { "uptime": 5104088, "time": "2017-02-16 18:53:02", "fwversion": "v6.0", "fwprefix": "XW", "hostname": "cpe-240187", "devmodel": "PowerBeam M5 300", "netrole": "router", "totalram": 63623168, "freeram": 39596032, "cputotal": 510331084, "cpubusy": 3895687 }, "wireless": { "mode": "sta", "essid": "lessinianet.net", "hide_essid": 0, "apmac": "04:18:D6:EC:98:AC", "countrycode": 380, "channel": 40, "frequency": "5200 MHz", "dfs": "0", "opmode": "11NAHT20", "antenna": "300 - 22 dBi", "chains": "2X2", "signal": -70, "rssi": 26, "noisef": -96, "txpower": 22, "ack": 37, "distance": 1950, "ccq": 991, "txrate": "39", "rxrate": "117", "security": "WPA2", "qos": "No QoS", "rstatus": 5, "count": 1, "cac_nol": 0, "nol_chans": 0, "polling": { "enabled": 0, "quality": 0, "capacity": 0, "priority": 0, "noack": 0, "airsync_mode": 0, "airsync_connections": 0, "airsync_down_util" : 0, "airsync_up_util" : 0, "airselect" : 0, "airselect_interval" : 0 }, "stats": { "rx_nwids": 0, "rx_crypts": 0, "rx_frags": 0, "tx_retries": 0, "missed_beacons": 0, "err_other": 0 }, "wds": 0, "aprepeater": 0, "chwidth": 20, "chanbw": 20, "cwmmode": 0, "rx_chainmask": 3, "tx_chainmask": 3, "chainrssi" : [ 20, 25, 0 ], "chainrssimgmt" : [ 21, 25, 0 ], "chainrssiext" : [ 20, 25, 0 ] }, "airview": { "enabled": 0 }, "services": { "dhcpc": 0, "dhcpd": 1, "pppoe": 1 }, "firewall": { "iptables": 0, "ebtables" : 0, "ip6tables": 0, "eb6tables" : 0 }, "genuine": "/images/genuine.png", "interfaces" : [ { "ifname" : "lo", "hwaddr": "00:00:00:00:00:00", "enabled" : true, "status" : { "plugged": 1, "speed": 0, "duplex": 255 }, "services" : { "dhcpc": false, "dhcpd": false, "pppoe": false } }, { "ifname" : "eth0", "hwaddr": "80:2A:A8:6F:67:A9", "enabled" : true, "status" : { "plugged": 1, "speed": 100, "duplex": 1 }, "services" : { "dhcpc": false, "dhcpd": false, "pppoe": false } }, { "ifname" : "wifi0", "hwaddr": "80:2A:A8:6E:67:A9", "enabled" : true, "status" : { "plugged": 1, "speed": 0, "duplex": 255 }, "services" : { "dhcpc": false, "dhcpd": false, "pppoe": false } }, { "ifname" : "ath0", "hwaddr": "80:2A:A8:6E:67:A9", "enabled" : true, "status" : { "plugged": 1, "speed": 0, "duplex": 255 }, "services" : { "dhcpc": false, "dhcpd": false, "pppoe": true } }, { "ifname" : "br0", "hwaddr": "80:2A:A8:6F:67:A9", "enabled" : true, "status" : { "plugged": 1, "speed": 0, "duplex": 255 }, "services" : { "dhcpc": false, "dhcpd": true, "pppoe": false } }, { "ifname" : "ppp0", "hwaddr": "00:00:00:00:00:00", "enabled" : true, "status" : { "plugged": 1, "speed": 0, "duplex": 255 }, "services" : { "dhcpc": false, "dhcpd": false, "pppoe": false } } ] }