daily pastebin goal
17%
SHARE
TWEET

vpnbook-get-password

tolikpunkoff Nov 8th, 2016 (edited) 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. VPNBOOKPAGE="http://www.vpnbook.com/#pptpvpn"
  3. WORKDIR="/tmp/"
  4. HTMLFILE="vpnhtml.txt"
  5. PASSANCOR="Password:"
  6. VPNBOOKPASS=""
  7. FILEPASS=""
  8. PEERSDIR="/etc/ppp/peers/"
  9. PEERSFILES[0]="vpnbook-e214"
  10. PEERSFILES[1]="vpnbook-e217"
  11. PEERSFILES[2]="vpnbook-de233"
  12. PEERSFILES[3]="vpnbook-us1"
  13. PEERSFILES[4]="vpnbook-us2"
  14. PEERSFILES[5]="vpnbook-ca1"
  15.  
  16.  
  17. passwork()
  18. {
  19.     echo -n "Checking $1..."
  20.     if [ -e $1 ]; then #file exist
  21.         COUNT=`cat $1|grep "password" -c`
  22.     if [ $COUNT -eq 1 ]; then # strochek s parolem 1
  23.         #vitaskivaem password i udalyaem kavichki
  24.         FILEPASS=`cat $1|grep "password"|awk ' {print $2} '|sed 's/\"//g'`
  25.         echo -n "password "$FILEPASS
  26.        
  27.         if [ "$FILEPASS" = "$VPNBOOKPASS" ]; then #proverka parolya
  28.         echo " not replaced."
  29.         else
  30.         #backup file
  31.         cp $1 $1".bak"
  32.         echo "...file backuped..."
  33.         sed -i 's/'$FILEPASS'/'$VPNBOOKPASS'/g' $1 #replace password
  34.         echo "...replaced!"
  35.         fi
  36.        
  37.     else #>1 ili 0
  38.         echo  " Peer file format error"
  39.     fi
  40.     else
  41.    
  42.     echo  " $1 not found"
  43.     fi
  44. }
  45.  
  46. echo "GET VPNBOOK PASSWORD v 0.2"
  47.  
  48. rm $WORKDIR$HTMLFILE
  49. echo "Get vpnbook page..."
  50. wget -P $WORKDIR --default-page=$HTMLFILE --header="Content-type: text/plain" $VPNBOOKPAGE
  51.  
  52. #testiruem nalichie failov
  53. if [ ! -f $WORKDIR$HTMLFILE ]; then
  54.     echo "ERROR: Page not saved"
  55.     exit 1
  56. fi
  57.  
  58. #poluchaem parol
  59. VPNBOOKPASS=`cat $WORKDIR$HTMLFILE|grep "$PASSANCOR"|head -n1|sed -e :a -e 's/<[^>]*>//g;/</N;//ba'|sed 's/.$//'|awk ' {print $2} '`
  60. echo "vpnbook.com password: "$VPNBOOKPASS
  61.  
  62. #proveryaem i zamenyaem paroli esli nado
  63. CTR="${#PEERSFILES[*]}"; I="0"
  64. until [ "$CTR" -eq "$I" ]; do
  65.     passwork $PEERSDIR${PEERSFILES[I]}
  66.     let "I+=1"
  67. done
RAW Paste Data
Top