Advertisement
Guest User

Reboot_E5186

a guest
Apr 15th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.19 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #ustawienie IP routera
  4. modIPAdr="192.168.0.8"
  5.  
  6. #tymczasowy plik nagłówkowy
  7. headers=$(mktemp)
  8.  
  9. #pobranie poczatkowego tokena oraz ID sesji i zapisanie do zmiennych
  10. tmp="$(curl -s -X GET http://$modIPAdr/api/webserver/SesTokInfo)"
  11.  
  12. sid=$(echo "$tmp" | grep SesInfo | cut -d '>' -f2 | cut -d '<' -f1)
  13. sid="Cookie: $sid"
  14.  
  15. tok=$(echo "$tmp" | grep TokInfo | cut -d '>' -f2 | cut -d '<' -f1)
  16. tok="__RequestVerificationToken: $tok"
  17.  
  18. #zalogowanie się na dane admin:admin (base64: YWRtaW4=) i zapisanie nagłówków
  19. 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"
  20.  
  21. tmp=$(awk '{ sub("\r$", ""); print }' "$headers")
  22.  
  23. #wyciągnięcie z nagłówków nowego tokena i ID sesji
  24. tok=$(echo "$tmp" | grep __RequestVerificationTokenone | cut -d ':' -f2)
  25. tok="__RequestVerificationToken: $tok"
  26.  
  27. sid=$(echo "$tmp" | grep Cookie | cut -d ':' -f2 | cut -d ';' -f1)
  28. sid="Cookie: $sid"
  29.  
  30. #restart routera
  31. curl -X POST -d "<request><Control>1</Control></request>" http://$modIPAdr/api/device/control -H "$sid" -H "$tok" -H "Content-Type: text/xml"
  32.  
  33. rm $headers
  34. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement