-
Notifications
You must be signed in to change notification settings - Fork 61
/
choicebot.sh
294 lines (218 loc) · 10.7 KB
/
choicebot.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#!/bin/bash
# ChoiceBot v1.1
# Coded by: @thelinuxchoice (Don't change!)
# Github: www.github.com/thelinuxchoice/choicebot
# Instagram: @thelinuxchoice
trap 'printf "\n";stop;exit 1' 2
############################################################
###################### Bot Config ##########################
## Your Credentials here
default_username=""
default_password=""
## Comments
arr[0]="Your profile is amazing!"
arr[1]="Its look good"
arr[2]="Your feed is great!"
arr[3]="Yours pictures are so good!"
arr[4]=":)"
arr[5]="i liked that"
arr[6]="yes!"
############################################################
rand=$[$RANDOM % ${#arr[@]}]
IFS=$'\n'
commt=$(echo ${arr[$rand]})
counter1=0
counter2=0
turn=2
startline_bot=1
endline_bot=1
startline_follow=1
endline_follow=1
csrftoken=$(curl https://www.instagram.com/accounts/login/ajax -L -i -s | grep "csrftoken" | cut -d "=" -f2 | cut -d ";" -f1)
banner() {
printf "\e[1;92m ____ _ _ ____ _ \e[0m\n"
printf "\e[1;92m / ___| |__ ___ (_) ___ ___| __ ) ___ | |_ \e[0m\n"
printf "\e[1;92m | | | '_ \ / _ \| |/ __/ _ \ _ \ / _ \| __| \e[0m\n"
printf "\e[1;92m | |___| | | | (_) | | (_| __/ |_) | (_) | |_ \e[0m\n"
printf "\e[1;92m \____|_| |_|\___/|_|\___\___|____/ \___/ \__| \e[0mv1.1\n"
printf "\n"
printf "\e[1;77m\e[45m Instagram bot by @thelinuxchoice \e[0m\n"
printf "\n"
}
dependencies() {
command -v curl > /dev/null 2>&1 || { echo >&2 "I require curl but it's not installed. Run apt-get install curl"; exit 1; }
}
check_hashtag() {
touch hashtags.txt
total_hashtag=$(wc -l hashtags.txt | cut -d " " -f1)
if [ $total_hashtag == "0" ]; then
printf "\e[1;93m[!] Please, put your hashtags on file: \e[0m\e[1;77m hashtags.txt\e[0m\e[1;93m (1 per line, without #)\e[0m\n"
exit 1
fi
}
stop() {
touch likes comments follows unfollows followedtotal.txt
cat follows >> followedtotal.txt
cat unfollows >> unfollowedtotal.txt
session_likes=$(wc -l likes | cut -d " " -f1)
session_comments=$(wc -l comments | cut -d " " -f1)
session_follows=$(wc -l follows | cut -d " " -f1)
session_unfollows=$(wc -l unfollows | cut -d " " -f1)
total_likes=$(wc -l liked.txt | cut -d " " -f1)
total_comments=$(wc -l commented.txt | cut -d " " -f1)
total_follows=$(wc -l followedtotal.txt | cut -d " " -f1)
total_unfollows=$(wc -l unfollowedtotal.txt | cut -d " " -f1)
rm -rf likes comments follows unfollows
printf "\e[1;31m[*] Bot stopped.\e[0m\n"
printf "\n"
printf "\e[1;92m[*] Statistics for this session:\e[0m\n"
printf "\e[1;93m[*] Likes: \e[0m\e[1;77m%s\e[0m\n" $session_likes
printf "\e[1;93m[*] Comments: \e[0m\e[1;77m%s\e[0m\n" $session_comments
printf "\e[1;93m[*] Follows: \e[0m\e[1;77m%s\e[0m\n" $session_follows
printf "\e[1;93m[*] Unfollows: \e[0m\e[1;77m%s\e[0m\n" $session_unfollows
printf "\n"
printf "\e[1;92m[*] Statistics total:\e[0m\n"
printf "\e[1;93m[*] Likes: \e[0m\e[1;77m%s\e[0m\n" $total_likes
printf "\e[1;93m[*] Comments: \e[0m\e[1;77m%s\e[0m\n" $total_comments
printf "\e[1;93m[*] Follows: \e[0m\e[1;77m%s\e[0m\n" $total_follows
printf "\e[1;93m[*] Unfollows: \e[0m\e[1;77m%s\e[0m\n" $total_unfollows
res2=$(date +%s)
secs=$(($res1-$res2))
printf '\e[1;93m[*] Work time:\e[0m\e[1;77m %dd:%dh:%dm:%ds\e[0m\n' $(($secs/86400)) $(($secs%86400/3600)) $(($secs%3600/60)) \
$(($secs%60))
exit 1
}
login_user() {
if [[ "$default_username" == "" ]]; then
read -p $'\e[1;92m[*] Username: \e[0m' username
else
username="${username:-${default_username}}"
fi
if [[ "$default_password" == "" ]]; then
read -s -p $'\e[1;92m[*] Password: \e[0m' password
else
password="${password:-${default_password}}"
fi
printf "\e[\n1;77m[*] Trying to login as\e[0m\e[1;77m %s\e[0m\n" $username
check_login=$(curl -c cookies.txt 'https://www.instagram.com/accounts/login/ajax/' -H 'Cookie: csrftoken='$csrftoken'' -H 'X-Instagram-AJAX: 1' -H 'Referer: https://www.instagram.com/' -H 'X-CSRFToken:'$csrftoken'' -H 'X-Requested-With: XMLHttpRequest' --data 'username='$username'&password='$password'&intent' -L --compressed -s | grep -o '"authenticated": true')
if [[ "$check_login" == *'"authenticated": true'* ]]; then
printf "\e[1;92m[*] Login Successful!\e[0m\n"
else
printf "\e[1;93m[!] Check your login data or IP! Dont use Tor, VPN, Proxy. It's requires your usual IP.\n\e[0m"
exit 1
fi
}
createlist() {
touch liked.txt commented.txt followed.txt
rm -rf hashtags_id.txt owner_id.txt
IFS=$'\n'
for hashtag in $(cat hashtags.txt);do
printf "\e[1;77m[*] Creating media list for hashtag %s\e[0m\n" $hashtag
{( trap '' SIGINT && curl -s https://www.instagram.com/explore/tags/$hashtag/?__a=1 | grep -o '"node":{"comments_disabled":false,"id":"..................[0-9]' | cut -d ":" -f4 | tr -d '\"' | head -n 10 >> hashtags_id.txt )} & wait $!;
printf "\e[1;77m[*] Creating follower list for hashtag %s\e[0m\n" $hashtag
{( trap '' SIGINT && curl -s https://www.instagram.com/explore/tags/hacking/?__a=1 | grep -o '"owner":{"id":".........[0-9]"' | cut -d ":" -f3 | tr -d '\"' | head -n 10 >> owner_id.txt )} & wait $!;
done
}
bot() {
likes=0
comments=0
follows=0
while [ $counter1 -lt $turn ]; do
for media_id in $(sed -n ''$startline_bot','$endline_bot'p' hashtags_id.txt); do
let count_media++
my_media=$(curl -s https://www.instagram.com/$username/ -L | grep -o '"GraphImage","id":"..................[0-9]"' | cut -d ":" -f2 | tr -d '\"' | grep -o "$media_id")
if [[ "$my_media" == "" ]]; then
check_media=$(grep -o "$media_id" liked.txt)
if [[ "$check_media" == "" ]]; then
printf "\e[1;77m[*] Trying to like media id %s\e[0m\n" $media_id
#like
{( trap '' SIGINT && like=$(curl -b cookies.txt -H 'Cookie: csrftoken=$csrftoken' -H 'X-Instagram-AJAX: 1' -H 'Referer: https://www.instagram.com/' -H 'X-CSRFToken:$csrftoken' -H 'X-Requested-With: XMLHttpRequest' "https://www.instagram.com/web/likes/$media_id/like" -s -L --request POST | grep -o '"status": "ok"'); if [[ "$like" == *'"status": "ok"'* ]]; then printf "\e[1;92m[*] Media liked\e[0m\n"; printf "%s\n" $media_id >> liked.txt; let likes++ ; echo $likes >> likes ; sleep 60; else printf "\e[1;93m[!] Media not liked\e[0m\n"; sleep 300; fi )} & wait $!;
fi # check_media
fi # my media
#comment
if [[ "$my_media" == "" ]]; then
check_comment=$(grep -o "$media_id" commented.txt)
if [[ "$check_comment" == "" ]]; then
printf "\e[1;77m[*] Trying to comment media id %s\e[0m\n" $media_id
{( trap '' SIGINT && comment=$(curl --data 'comment_text='$commt'' -b cookies.txt -H 'Cookie: csrftoken='$csrftoken'' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Connection: keep-alive' -H 'Content-Lenght: 0' -H 'X-Instagram-AJAX: 1' -H 'Host: www.instagram.com' -H 'Referer: https://www.instagram.com/' -H 'X-CSRFToken:'$csrftoken'' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://www.instagram.com' -H 'User-Agent: "Instagram 10.26.0 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)"' -H 'Content-Type: application/x-www-form-urlencoded' --user-agent 'User-Agent: "Instagram 10.26.0 Android (18/4.3; 320dpi; 720x1280; Xiaomi; HM 1SW; armani; qcom; en_US)"' -s -L "https://www.instagram.com/web/comments/$media_id/add/" -w "\n%{http_code}\n" | grep -a "200"); if [[ "$comment" == "200" ]]; then printf "\e[1;92m[*] Media commented\e[0m\n"; let comments++ ; printf "%s\n" $media_id >> commented.txt; echo $comments >> comments ; sleep 60 ; else printf "\e[1;93m[!] Media not commented\e[0m\n"; sleep 300; fi; )} & wait $!;
fi
fi
let counter1++
let startline_bot++
let endline_bot++
done
done
}
function owner_follow() {
while [ $counter2 -lt $turn ]; do
let count_owner++
for owner_id in $(sed -n ''$startline_follow','$endline_follow'p' owner_id.txt); do
my_id=$(curl -s "https://www.instagram.com/$username/" -L | grep -o 'profilePage_.*"' | cut -d "," -f1 | cut -d "_" -f2 | tr -d '\"')
check_id=$(grep -o "$my_id" owner_id.txt )
if [[ "$check_id" == "" ]]; then
check_follow=$(grep -o "$owner_id" followed.txt)
if [[ "$check_follow" == "" ]]; then
count_followers=$(curl -s -L "https://i.instagram.com/api/v1/users/$owner_id/info/" | grep -o 'follower_count":.*,' | cut -d "," -f1 | cut -d ":" -f2 | tr -d " ")
if [[ "$count_followers" -gt "1500" ]]; then
printf "\e[1;93m[!] Selebgram or fake account, not following %s\e[0m\n" $owner_id
sleep 10
let counter2++
else
#follow
printf "\e[1;77m[*] Trying to follow user id %s\e[0m\n" $owner_id
{( trap '' SIGINT && follow=$(curl -b cookies.txt -H 'Cookie: csrftoken='$csrftoken'' -H 'X-Instagram-AJAX: 1' -H 'Referer: https://www.instagram.com/' -H 'X-CSRFToken:'$csrftoken'' -H 'X-Requested-With: XMLHttpRequest' "https://www.instagram.com/web/friendships/$owner_id/follow/" -s -L --request POST | grep -o '"status": "ok"'); if [[ "$follow" == *'"status": "ok"'* ]]; then printf "\e[1;92m[*] User followed\e[0m\n"; printf "%s\n" $owner_id >> followed.txt; let follows++ ; echo $follows >> follows ; sleep 60 ; else printf "\e[1;93m[!] User not followed\e[0m\n" ; sleep 300 ; fi )} & wait $!;
fi
fi #check_id
fi #check follow
let counter2++
let startline_follow++
let endline_follow++
done
done
}
unfollow() {
touch unfollows
unfollows=0
total_unfollow=$(wc -l followed.txt | cut -d " " -f1)
if [[ $total_unfollow -gt 0 ]]; then
for ownerid in $(cat followed.txt);do
printf "\e[1;77m[*] Trying to unfollow user id %s\e[0m\n" $ownerid
{( trap '' SIGINT && unfollow=$(curl -b cookies.txt -H 'Cookie: csrftoken='$csrftoken'' -H 'X-Instagram-AJAX: 1' -H 'Referer: https://www.instagram.com/' -H 'X-CSRFToken:'$csrftoken'' -H 'X-Requested-With: XMLHttpRequest' "https://www.instagram.com/web/friendships/$ownerid/unfollow/" -s -L --request POST | grep -o '"status": "ok"'); if [[ "$unfollow" == *'"status": "ok"'* ]]; then printf "\e[1;92m[*] User unfollowed\e[0m\n" ; awk '!/'$ownerid'/' followed.txt > temp && mv temp followed.txt ; let unfollows++ ; echo $unfollows >> unfollows ; sleep 30 ; else printf "\e[1;93m[!] User not unfollowed\e[0m\n" ; sleep 300 ; fi )} & wait $!;
done
fi # total_follow
remain=$(wc -l followed.txt | cut -d " " -f1)
session_unfollows=$(wc -l unfollows | cut -d " " -f1)
printf "\e[1;92m[*] Total unfollows:\e[0m\e[1;77m %s\e[0m\n" $session_unfollows
if [[ $total_follow -gt 0 ]]; then
printf "\e[1;92m[*] Remaining:\e[0m\e[1;77m %s\e[0m\n" $remain
fi
}
res1=$(date +%s)
start_date=$(date +%H:%M:%S)
function control() {
count_media=0
count_owner=0
total_media=$(wc -l hashtags_id.txt | cut -d " " -f1)
total_owner=$(wc -l owner_id.txt | cut -d " " -f1)
while [ $count_media -lt $total_media ] && [ "$count_owner" -lt "$total_owner" ]; do
bot
owner_follow
let turn+=1
done
unfollow
createlist
let count_media=0
let count_owner=0
let startline_bot=1
let endline_bot=1
let startline_follow=1
let endline_follow=1
control
}
banner
dependencies
check_hashtag
login_user
printf "\e[1;93m[*] Bot started at:\e[0m\e[1;77m %s\e[0m\n" $start_date
createlist
control