Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.06 KB | None | 0 0
  1. #!/bin/bash
  2. username='kennedn'
  3. password='NoPasswordForIgor'
  4. cluster='GB+Great+Britain'
  5. cookie='buffCookie.txt'
  6. workingDir='/media/server/VPN/'
  7. output="${workingDir}GB.ovpn"
  8. logFile="${workingDir}curl.log"
  9. csrf=
  10. sessionID=
  11.  
  12. #cd into correct folder
  13. cd ${workingDir}
  14.  
  15.  
  16. #Just want the password
  17. if [ "$1" = "-p" ] || [ "$1" = "--password" ]; then
  18.         echo "Buffered Password: ${password}"
  19.         exit 0
  20. fi
  21.  
  22. CSRFCMD="curl -s -X GET -c ${cookie} -b ${cookie} https://buffered.com/login -H 'referer: https://buffered.com/login'"
  23. AUTHCMD="curl -s -c ${cookie} -b ${cookie} https://buffered.com/login -H 'cookie: csrftoken=<<CSRF>>' -H 'referer: https://buffered.com/login' --data 'csrfmiddlewaretoken=<<CSRF>>&username=<<USER>>&password=<<PASS>>'"
  24. DOWNCMD="curl -s 'https://buffered.com/getconfig' -H 'cookie: csrftoken=<<CSRF>>; sessionid=<<SESSION>>' -H 'referer: https://buffered.com/getconfig' --data 'csrfmiddlewaretoken=<<CSRF>>&clustername=<<CLUSTER>>'"
  25.  
  26. #cleanup from last run
  27. if [ -f "$cookie" ]; then
  28.         rm "$cookie"
  29. fi
  30. #Execute Get request
  31. eval $CSRFCMD > /dev/null
  32.  
  33. #strip CSRF from cookie and set variables in AUTHCMD string
  34. csrf="$(grep -oh csrftoken.*$ ${cookie} | sed 's/csrftoken\s//g')"
  35. AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<CSRF>>/${csrf}/g")
  36. AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<USER>>/${username}/g")
  37. AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<PASS>>/${password}/g")
  38.  
  39. #Execute Auth request
  40. eval $AUTHCMD > /dev/null
  41.  
  42. #strip CSRF/SessionID from cookie and set variables in DOWNCMD string
  43. sessionID="$(grep -oh sessionid.*$ ${cookie} | sed 's/sessionid\s//g')"
  44. csrf="$(grep -oh csrftoken.*$ ${cookie} | sed 's/csrftoken\s//g')"
  45. DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<SESSION>>/${sessionID}/g")
  46. DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<CSRF>>/${csrf}/g")
  47. DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<CLUSTER>>/${cluster}/g")
  48.  
  49. #Execute Download request
  50. eval $DOWNCMD > ${output}
  51.  
  52. #log result
  53.  
  54. echo "OVPN Grabber exited with return code ${?} on $(date '+%D at %T')" >> ${logFile}
  55.  
  56. #cleanup
  57. if [ -f "$cookie" ]; then
  58.         rm "$cookie"
  59. fi
  60.  
  61. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement