Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #ustawienie IP routera
- modIPAdr="192.168.0.8"
- #tymczasowy plik nagłówkowy
- headers=$(mktemp)
- #pobranie poczatkowego tokena oraz ID sesji i zapisanie do zmiennych
- tmp="$(curl -s -X GET http://$modIPAdr/api/webserver/SesTokInfo)"
- sid=$(echo "$tmp" | grep SesInfo | cut -d '>' -f2 | cut -d '<' -f1)
- sid="Cookie: $sid"
- tok=$(echo "$tmp" | grep TokInfo | cut -d '>' -f2 | cut -d '<' -f1)
- tok="__RequestVerificationToken: $tok"
- #zalogowanie się na dane admin:admin (base64: YWRtaW4=) i zapisanie nagłówków
- curl -D "$headers" -X POST -d "<request><Username>admin</Username><Password>YWRtaW4=</Password>" http://$modIPAdr/api/user/login -H "$sid" -H "$tok" -H "Content-Type: text/xml"
- tmp=$(awk '{ sub("\r$", ""); print }' "$headers")
- #wyciągnięcie z nagłówków nowego tokena i ID sesji
- tok=$(echo "$tmp" | grep __RequestVerificationTokenone | cut -d ':' -f2)
- tok="__RequestVerificationToken: $tok"
- sid=$(echo "$tmp" | grep Cookie | cut -d ':' -f2 | cut -d ';' -f1)
- sid="Cookie: $sid"
- #restart routera
- curl -X POST -d "<request><Control>1</Control></request>" http://$modIPAdr/api/device/control -H "$sid" -H "$tok" -H "Content-Type: text/xml"
- rm $headers
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement