#!/usr/bin/env python import csv, threading, requests host = '<<SZ hostname="">>' adminname = '<<ADMIN username="">>' adminpassword = '<<ADMIN password="">>' zoneid = '<<ZONE id="">>' wlanid = '<<WLAN id="">>' newwifikey = '<<NEW wpa2="" key="">>' def loginRuckus(): import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) session = requests.session() urlsession = 'https://%s:8443/wsg/api/public/v8_0/session' % (host) response = session.post(urlsession, json={"username":adminname, "password":adminpassword }, verify=False) print(response.text) return session def change_enc_key(session): url = 'https://%s:8443/wsg/api/public/v8_0/rkszones/%s/wlans/%s/encryption' % (host, zoneid, wlanid) response = session.patch(url, json={"method":"WPA2","passphrase":newwifikey}, verify=False) print(response.text) print(response) return def main(): change_enc_key(loginRuckus()) return if __name__ == '__main__': main() </NEW></WLAN></ZONE></ADMIN></ADMIN></SZ>
# Queries vSZ controllers using powershell$UrlBase = "https://vsz:8443/wsg/api/public";$apiVer = "v8_0"$Body = [pscustomobject]@{ username = 'admin'password = 'admin'timeZoneUtcOffset = "+08:00"}$json = $Body | ConvertTo-Json$session = Invoke-WebRequest -Uri $UrlBase/$apiVer/session -Method Post -Body $json -ContentType 'application/json' -SessionVariable websession# Translate Cookie header into useable string$stringCookie = [string]$session.Headers["Set-Cookie"]$cookie = $stringCookie.substring(0,($stringCookie.length - 21))# Add cookie to header$headers = @{}$headers.Add("Cookie",$cookie)Invoke-RestMethod -Uri $UrlBase/$apiVer/session -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websessionInvoke-RestMethod -Uri $UrlBase/apiInfo -Method GET -Headers $headers -ContentType 'application/json' -WebSession $websession