Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- username='kennedn'
- password='NoPasswordForIgor'
- cluster='GB+Great+Britain'
- cookie='buffCookie.txt'
- workingDir='/media/server/VPN/'
- output="${workingDir}GB.ovpn"
- logFile="${workingDir}curl.log"
- csrf=
- sessionID=
- #cd into correct folder
- cd ${workingDir}
- #Just want the password
- if [ "$1" = "-p" ] || [ "$1" = "--password" ]; then
- echo "Buffered Password: ${password}"
- exit 0
- fi
- CSRFCMD="curl -s -X GET -c ${cookie} -b ${cookie} https://buffered.com/login -H 'referer: https://buffered.com/login'"
- 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>>'"
- DOWNCMD="curl -s 'https://buffered.com/getconfig' -H 'cookie: csrftoken=<<CSRF>>; sessionid=<<SESSION>>' -H 'referer: https://buffered.com/getconfig' --data 'csrfmiddlewaretoken=<<CSRF>>&clustername=<<CLUSTER>>'"
- #cleanup from last run
- if [ -f "$cookie" ]; then
- rm "$cookie"
- fi
- #Execute Get request
- eval $CSRFCMD > /dev/null
- #strip CSRF from cookie and set variables in AUTHCMD string
- csrf="$(grep -oh csrftoken.*$ ${cookie} | sed 's/csrftoken\s//g')"
- AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<CSRF>>/${csrf}/g")
- AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<USER>>/${username}/g")
- AUTHCMD=$(echo $AUTHCMD | sed -e "s/<<PASS>>/${password}/g")
- #Execute Auth request
- eval $AUTHCMD > /dev/null
- #strip CSRF/SessionID from cookie and set variables in DOWNCMD string
- sessionID="$(grep -oh sessionid.*$ ${cookie} | sed 's/sessionid\s//g')"
- csrf="$(grep -oh csrftoken.*$ ${cookie} | sed 's/csrftoken\s//g')"
- DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<SESSION>>/${sessionID}/g")
- DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<CSRF>>/${csrf}/g")
- DOWNCMD=$(echo $DOWNCMD | sed -e "s/<<CLUSTER>>/${cluster}/g")
- #Execute Download request
- eval $DOWNCMD > ${output}
- #log result
- echo "OVPN Grabber exited with return code ${?} on $(date '+%D at %T')" >> ${logFile}
- #cleanup
- if [ -f "$cookie" ]; then
- rm "$cookie"
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement