-
Notifications
You must be signed in to change notification settings - Fork 2
/
password_extractor
executable file
·69 lines (61 loc) · 1.88 KB
/
password_extractor
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
#!/bin/sh
mkdir -p ./tmp
# Begin functions
# Print out the help
__usage(){
echo "usage: password_extractor [-o output_file | [-h]]"
}
__extract_pwd(){
local file="$@"
local pwd=$(cat ${output_file} \
| grep -Eo '"WordText":.*?[^\\]",' \
| awk -F':' '{print $2}' \
| awk -F',' '{print $1}' \
| awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }' \
| tr -d \")
echo ${pwd##*|}
}
# End functions
debug_flag=0
vpnbook_folder=$HOME/.vpnbook
vpnbook_base_url=https://www.vpnbook.com
vpnbook_url=${vpnbook_base_url}/freevpn
tesseract_service_url=https://api.ocr.space/parse/image
timestamp=$(date +%s)
output_file=/tmp/vpnbok_pwd_${timestamp}.json
log_file=/tmp/vpnbok_pwd_${timestamp}.log
# Start Script
while [ "$1" != "" ]; do
case $1 in
-o | --output ) shift
output_file=$1
;;
-d | --debug ) shift
debug_flag=1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
# Retrieve the Password URL from the official webpage
pwd_url=$(curl -s ${vpnbook_url} | grep -m2 "Password:" | tail -n1 | cut -d \" -f2)
echo "Retrieving Password at the following URL: ${vpnbook_base_url}/${pwd_url}"
curl -X POST --header "apikey: 5a64d478-9c89-43d8-88e3-c65de9999580" \
-F "url=${vpnbook_base_url}/${pwd_url}" \
-F 'language=eng' \
-F 'isOverlayRequired=true' \
-F 'FileType=.Auto' \
-F 'IsCreateSearchablePDF=false' \
-F 'isSearchablePdfHideTextLayer=true' \
-F 'scale=true' \
-F 'detectOrientation=false' \
-F 'isTable=false' \
${tesseract_service_url} -o ${output_file}
pwd=$(__extract_pwd ${output_file})
echo ${pwd} > ${output_file}
echo 'Retrieved password:---'${pwd}'---'
exit 0;