This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
warp-up.sh
406 lines (332 loc) · 9.73 KB
/
warp-up.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
#!/usr/bin/env bash
##############################################################
# Title : Warp-Up #
# Description : Automatically generated referrer bonuses #
# for Cloudflare WARP. #
# #
# Author : Sascha Greuel <[email protected]> #
# Date : 2021-04-03 19:07 #
# License : MIT #
# Version : 2.1.0 #
# #
# Usage : bash warp-up.sh #
##############################################################
######################
# Check requirements #
######################
command_exists() {
command -v "$@" >/dev/null 2>&1
}
required_packages="curl"
for package in $required_packages; do
if ! command_exists "$package"; then
echo "The package $package is missing. Please install it, before continuing."
exit 1
fi
done
####################
# Script arguments #
####################
# shellcheck disable=SC1091
if [ -f ./warp-up.conf ]; then
. ./warp-up.conf
fi
while [ "$#" -gt 0 ]; do
case "$1" in
--id)
REFERRER=$2
;;
--iterations)
ITERATIONS=$2
;;
--interval)
INTERVAL=$2
;;
--log-file)
LOG_FILE=$2
;;
--disclaimer)
DISCLAIMER_AGREE="yes"
;;
--ci)
CI_BUILD="yes"
;;
*) ;;
esac
shift
done
#############
# Variables #
#############
SUCCESS=0
FAILURE=0
# Colors
CSI='\033['
CRED="${CSI}1;31m"
CGREEN="${CSI}1;32m"
CYELLOW="${CSI}1;33m"
CBLUE="${CSI}1;36m"
CEND="${CSI}0m"
if [ -z "$INTERVAL" ]; then
INTERVAL=20
fi
if [ -z "$LOG_FILE" ]; then
LOG_FILE=warp-up.log
fi
if [ ! -w "$LOG_FILE" ] && [ ! -w "$(dirname "${LOG_FILE}")" ]; then
echo -e "${CRED}Could not write log file $LOG_FILE. Make sure, that you have the required permissions or restart Warp-Up with sudo.${CEND}"
exit 1
fi
####################
# Helper functions #
####################
str_repeat() {
printf -v v "%-*s" "$1" ""
echo "${v// /$2}"
}
version() {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'
}
rnd() {
tr </dev/urandom -dc 'a-zA-Z0-9' | fold -w "$1" | head -n 1
}
function json_val() {
temp=$(echo "$1" | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w "$2")
echo "${temp##*|}"
}
json_encode() {
local arr=("$@")
local len=${#arr[@]}
if [[ ${len} -eq 0 ]]; then
echo >&2 "Error: Length of input array needs to be at least 2."
return 1
fi
if [[ $((len % 2)) -eq 1 ]]; then
echo >&2 "Error: Length of input array needs to be even (key/value pairs)."
return 1
fi
local data=""
local foo=0
for i in "${arr[@]}"; do
local char=","
if [ $((++foo % 2)) -eq 0 ]; then
char=":"
fi
local first="${i:0:1}"
local app="\"$i\""
if [[ "$first" == "^" ]]; then
app="${i:1}"
fi
data="$data$char$app"
done
data="${data:1}"
echo "{$data}"
}
##################
# Version checks #
##################
if [ -f "$0" ]; then
WARP_UP_VER=$(grep -oP 'Version\s+:\s+\K([\d\.]+)' "$0")
WARP_UP_LATEST_VER=$(curl -sL "https://dist.1-2.dev/warp-up?uc" | grep -oP 'Version\s+:\s+\K([\d\.]+)')
fi
##################
# Base functions #
##################
warpUp() {
sleep "$INTERVAL"
# CI should never make API calls
if [ -n "$CI_BUILD" ]; then
if [ "$((1 + RANDOM % (1 + 10 - 1)))" -lt 5 ]; then
SUCCESS=$((SUCCESS + 1))
else
FAILURE=$((FAILURE + 1))
fi
return
fi
TMP_DIR="/tmp"
if [ -n "$TMPDIR" ]; then
TMP_DIR="$TMPDIR"
fi
API_URL="https://api.cloudflareclient.com/v0a$((100 + RANDOM % (1 + 999 - 100)))/reg"
INSTALL_ID=$(rnd 22)
BODY="$(
json_encode \
key "$(rnd 43)=" \
install_id "$INSTALL_ID" \
fcm_token "$INSTALL_ID":APA91b"$(rnd 134)" \
referrer "$REFERRER" \
warp_enabled ^false \
tos "$(date '+%Y-%m-%dT%T.000%:z')" \
type Android \
locale "en_US"
)"
{
API_RESPONSE=$(
curl \
--compressed \
--cookie "$TMP_DIR/cfwarp.txt" \
--cookie-jar "$TMP_DIR/cfwarp.txt" \
--header "Content-Type: application/json" \
--header "Host: api.cloudflareclient.com" \
--header "Connection: Keep-Alive" \
--header "Accept-Encoding: gzip" \
--header "User-Agent: okhttp/3.12.1" \
--request POST \
--data "$BODY" \
--silent \
"$API_URL"
)
if [ "$(json_val "$API_RESPONSE" referrer)" = "$REFERRER" ]; then
SUCCESS=$((SUCCESS + 1))
echo "$(date): Success"
else
FAILURE=$((FAILURE + 1))
if [[ "$API_RESPONSE" == *"Access denied"* ]]; then
echo -ne "\ec"
echo ""
echo -e "${CRED}Unable to establish an API connection. Aborting.${CEND}"
echo ""
echo ""
exit 1
elif [[ "$API_RESPONSE" == "Internal Server Error" ]]; then
echo "$(date): Failure: Internal Server Error. If this problem persists, restart Warp-Up with an increased request interval."
else
echo "$(date): Failure."
fi
fi
} >>"$LOG_FILE" 2>&1
}
#######
# Run #
#######
if [ -z "$CI_BUILD" ] && [ -z "$DISCLAIMER_AGREE" ]; then
echo -ne "\ec"
echo " DISCLAIMER"
echo ""
echo " This software and information is designed for educational purposes only."
echo ""
echo " This information is provided 'as is' and in no event shall the"
echo " provider or 1-2.dev be liable for any damages, including, without"
echo " limitation, damages resulting from lost data or lost profits or"
echo " revenue, the costs of recovering such data, the costs of substitute"
echo " data, claims by third parties or for other similar costs, or any"
echo " special, incidental, or consequential damages arising out of use or"
echo " misuse of this data. The accuracy or reliability of the data is not"
echo " guaranteed or warranted in any way and the provider disclaim"
echo " liability of any kind whatsoever, including, without limitation,"
echo " liability for quality, performance, merchantability and fitness"
echo " for a particular purpose arising out of the use, or inability"
echo " to use the data. Information obtained via this software MUST"
echo " NEVER BE USED to take medical decisions."
echo ""
echo " All respective trademarks belong to Cloudflare, Inc."
echo " 1-2.dev is not affiliated with or endorsed by Cloudflare."
echo ""
while true; do
read -rep " Do you agree? (y/n): " yn </dev/tty
case "$yn" in
[Yy]*)
break
;;
[Nn]*)
echo ""
echo " You did not agree to the disclaimer, therefore you are not allowed to use this software."
echo ""
exit
;;
*)
echo -e " ${CYELLOW}Please answer yes or no.${CEND}"
echo ""
;;
esac
done
fi
echo -ne "\ec"
WELCOME_TXT="Welcome to Warp Up - $WARP_UP_VER"
WELCOME_LEN=${#WELCOME_TXT}
echo ""
echo " $(str_repeat "$WELCOME_LEN" "#")"
echo " $WELCOME_TXT"
echo " $(str_repeat "$WELCOME_LEN" "#")"
echo ""
if [ -z "$CI_BUILD" ] && [ -n "$WARP_UP_VER" ] && [ "$(version "$WARP_UP_VER")" -lt "$(version "$WARP_UP_LATEST_VER")" ]; then
echo -e " ${CYELLOW}A newer Warp Up version ($WARP_UP_LATEST_VER) is available!${CEND}"
echo ""
fi
if [ -z "$REFERRER" ] || [[ ! "$REFERRER" =~ ^\{?[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}\}?$ ]]; then
while true; do
read -rep " Warp ID : " REFERRER </dev/tty
if [[ "$REFERRER" =~ ^\{?[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}\}?$ ]]; then
if [[ -x "$0" ]]; then
exec bash "$0" --id "$REFERRER" --iterations "$ITERATIONS" --interval "$INTERVAL" --disclaimer "$DISCLAIMER_AGREE" && exit
else
break
fi
else
echo -ne " ${CYELLOW}Invalid Warp ID provided. Please try again.${CEND}"
echo ""
echo ""
fi
done
else
echo " Warp ID : $REFERRER"
fi
if [ -z "$ITERATIONS" ] || [[ ! "$ITERATIONS" =~ ^[0-9]+$ ]]; then
while true; do
read -rep " Iterations : " ITERATIONS </dev/tty
if [[ "$ITERATIONS" =~ ^[0-9]+$ ]]; then
if [[ -x "$0" ]]; then
exec bash "$0" --id "$REFERRER" --iterations "$ITERATIONS" --interval "$INTERVAL" --disclaimer "$DISCLAIMER_AGREE" && exit
else
break
fi
else
echo -ne " ${CYELLOW}Please input numbers only.${CEND}"
echo ""
echo ""
fi
done
else
echo " Iterations : $ITERATIONS"
fi
echo " Interval : $INTERVAL"
echo ""
echo " Log File : $LOG_FILE"
echo " CI Build : ${CI_BUILD:-"no"}"
echo ""
echo " ##################"
echo " Generation Process"
echo " ##################"
echo ""
# Begin new log entry
HASH=$(date '+%s%N' | sha1sum | head -c 40)
START=$(date)
cat <<FOE >> "$LOG_FILE"
<<<<<<<<${HASH}<<<<
Warp-Up Version : ${WARP_UP_VER}
Warp ID : ${REFERRER}
Iterations : ${ITERATIONS}
Interval : ${INTERVAL}
Process Start : ${START}
======
FOE
echo -ne ' Generating extra traffic [..]\r'
if [ "$ITERATIONS" -lt 1 ]; then
while true; do
warpUp
echo -ne " Generating extra traffic [${CGREEN}Successful: $SUCCESS${CEND} - ${CRED}Failures: $FAILURE${CEND}]\r"
done
else
for ((i = 1; i <= ITERATIONS; i++)); do
warpUp
echo -ne " Generating extra traffic [${CGREEN}Successful: $SUCCESS${CEND} - ${CRED}Failures: $FAILURE${CEND}]\r"
done
fi
cat <<FOE >> "$LOG_FILE"
<<<<
FOE
echo ""
echo ""
echo -e "${CGREEN} Done! ${CEND}${CBLUE}$SUCCESS GB${CEND}${CGREEN} extra traffic have been added to your WARP account.${CEND}"
echo ""
echo ""