Skip to content

Instantly share code, notes, and snippets.

@itshaadi
Created April 13, 2020 22:50
Show Gist options
  • Save itshaadi/1087348f54a15dc6570d04024259d855 to your computer and use it in GitHub Desktop.
Save itshaadi/1087348f54a15dc6570d04024259d855 to your computer and use it in GitHub Desktop.
huawei e3372 (vendorlock version MCI/IRANCELL)
#!/bin/abs
# requires https://www.abs-lang.org/
gateway = "http://192.168.8.1"
token_uri = "/api/webserver/token"
reboot_uri = "/api/device/control"
f get(uri) {
cmd = `curl -s -X GET ${gateway}${uri}`
return cmd
}
f post(uri, headers, data) {
args = ""
for header in headers {
args += '-H "${header}" '
}
cmd = `curl -s -X POST ${gateway}${uri} ${args} -d "${data}"`
return cmd
}
f reboot() {
req_token = get(token_uri)
token = req_token.lines()[2][7:-8]
headers = [
"__RequestVerificationToken: ${token}",
"Content-Type: text/xml"
]
data = '<?xml version="1.0" encoding="UTF-8"?><request><Control>1</Control></request>'
req_reboot = post(reboot_uri, headers, data).index("OK")
if req_reboot == 50 {
return true
}
return false
}
f main() {
if reboot() == true {
echo("done.")
} else {
echo("failed to reboot.")
}
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment