-
Notifications
You must be signed in to change notification settings - Fork 5
/
vpnbookpass
70 lines (57 loc) · 1.63 KB
/
vpnbookpass
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
VPNBOOKPAGE="https://www.vpnbook.com/"
WORKDIR="/tmp/vpnbook/"
HTMLFILE="vpnhtml.html"
PASSIMG="password.png"
AUTHPATH="~/openvpn/vpnbook/vpnbook.auth"
echo "GET VPNBOOK PASSWORD v 0.4"
if [[ "$1" == "-h" ]];then
echo "Use "`basename $0`" [parameters]"
echo "Parameters:"
echo "-h - this help"
echo "-s - show password image after recognize"
echo "After using this script you must install"
echo "Tesseract and FIM"
echo "Please check and set correct variable value"
echo "AUTPATH after use this script"
echo "(L) Hex_laden, 2019"
exit
fi
rm "$WORKDIR$HTMLFILE" 2>/dev/null
rm "$WORKDIR$PASSIMG" 2>/dev/null
mkdir -p "$WORKDIR"
echo -n "Get vpnbook page..."
wget -P "$WORKDIR" --default-page="$HTMLFILE" --header="Content-type: text/html" "$VPNBOOKPAGE" 2>/tmp/vpnpass.err.log
if [[ ! -f "$WORKDIR$HTMLFILE" ]];then
echo
echo "Page not downloaded!"
exit
else
echo "OK"
fi
echo -n "Get password image..."
PASSLNK=`xidel -s --extract "//img/@src" "$WORKDIR$HTMLFILE"|grep "password.php"|head -n1|sed 's% %+%'`
wget "$VPNBOOKPAGE$PASSLNK" -O "$WORKDIR$PASSIMG" 2>>/tmp/vpnpass.err.log
if [[ ! -f "$WORKDIR$PASSIMG" ]];then
echo
echo "Image not downloaded!"
exit
else
echo "OK"
fi
if [[ "$1" == "-s" ]];then
fim "$WORKDIR$PASSIMG"
fi
echo -n "Recognize image..."
VP_PASSWORD=`tesseract "$WORKDIR$PASSIMG" stdout`
echo "OK"
echo "Password: $VP_PASSWORD"
if [ -z "$VP_PASSWORD" ]; then
echo "Password is empty. Exitting!"
exit
fi
echo -n "Update autorisation file $AUTHPATH..."
echo "vpnbook" >"$AUTHPATH"
echo -n "$VP_PASSWORD">>"$AUTHPATH"
echo
echo "Complete!"