-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathfollow.js
292 lines (258 loc) · 10.5 KB
/
follow.js
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
const fs = require('fs');
const axios = require('axios-https-proxy-fix');
const {getUserAgent, getProxy, MakeRandomID, TwitchClinetID} = require('./utils');
var config = require('./config');
const readline = require("readline");
const outFilePathTokens = './results/tokens.txt';
let tokens = fs.readFileSync(outFilePathTokens).toString().replace(/\r/g, '').split("\n");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let currennt_porxy = {};
let current_useragent = '';
let KasdaResponse = {};
const GetUserID = async (uname) => {
json = {"operationName": "ChannelShell",
"variables": {
"login": uname
},
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "580ab410bcd0c1ad194224957ae2241e5d252b2c5173d8e0cce9d32d5bb14efe"
}
}
}
headers = {
headers : {'Client-ID': TwitchClinetID}
}
response = await axios.post('https://gql.twitch.tv/gql', json, headers);
if(response.data.data.userOrError != undefined && response.data.data.userOrError.id != undefined)
{
return response.data.data.userOrError.id;
} else {
return false;
}
}
const KasdaResolver = async () => {
try {
let response = await axios.post('https://api.capsolver.com/kasada/invoke', {
"clientKey": config.CapSolverKey,
"appId": 'B278567A-C94E-457E-B419-F1D6A5D1AA6D',
"task": {
"type": "AntiKasadaTask",
"pageURL": "https://gql.twitch.tv/", //Required
"proxy": currennt_porxy.proxy.href, //Required
"cd": true, //Optional
"onlyCD": false, //Optional
"userAgent": current_useragent //Optional
}
}, {headers: { 'content-type': 'text/json' }});
if(response.data.success)
{
current_useragent = response.data.solution['user-agent'];
KasdaResponse = {};
KasdaResponse.original = response.data.solution;
KasdaResponse.useragent = response.data.solution['user-agent'];
KasdaResponse.kpsdkcd = response.data.solution['x-kpsdk-cd'];
KasdaResponse.kpsdkct = response.data.solution['x-kpsdk-ct'];
}
return KasdaResponse;
} catch (e) {
// console.log(e);
}
return false;
};
const GetTwitchCookies = async () => {
try {
let options = currennt_porxy;
// delete currennt_porxy.proxy.href;
options.headers = {
'User-Agent': current_useragent,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate, br',
'DNT': 1,
'Connection': 'keep-alive',
'Upgrade-Insecure-Requests': 1,
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
};
let response = await axios.get('https://twitch.tv', options);
let cookies = [];
response.headers['set-cookie'].forEach(element => {
let p1 = element.split(';')[0];
let p2 = p1.split('=');
cookies[p2[0]] = p2[1];
});
return cookies;
} catch (e) {
console.log(e);
}
return false;
};
const PublicIntegrityGetToken = async (TwitchClinetID, XDeviceId, ClientRequestId, ClientSessionId, ClientVersion, kpsdkct, kpsdkcd, accesstoken) => {
try {
let options = currennt_porxy;
options.headers = {
'User-Agent': current_useragent,
Accept: 'application/json',
'Accept-Language': 'en-US',
'Accept-Encoding': 'identity',
Authorization: "OAuth " + accesstoken,
'Referer': 'https://www.twitch.tv/',
'Client-Id': TwitchClinetID,
'X-Device-Id': XDeviceId,
'Client-Request-Id': ClientRequestId,
'Client-Session-Id': ClientSessionId,
'Client-Version': ClientVersion,
'x-kpsdk-ct': kpsdkct,
'x-kpsdk-cd': kpsdkcd,
'Origin': 'https://www.twitch.tv',
'DNT': 1,
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'Content-Length': 0,
};
let response = await axios.post('https://gql.twitch.tv/integrity', {}, options);
if(response.data.token) {
cookies = '';
response.headers['set-cookie'].forEach(element => {
let p1 = element.split(';')[0];
cookies = cookies + p1 + '; ';
});
let result = [];
result['token'] = response.data.token;
result['cookies'] = cookies;
return result;
}
} catch (e) {
console.log(e);
}
return false;
};
const FollowRequest = async (FollowUserID, ClientID, XDeviceId, ClientVersion, ClientSessionId, accessToken, ClientIntegrity) => {
let query = `[{"operationName":"FollowButton_FollowUser","variables":{"input":{"disableNotifications":false,"targetID":"${FollowUserID}"}},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"800e7346bdf7e5278a3c1d3f21b2b56e2639928f86815677a7126b093b2fdd08"}}}]`;
try {
let options = currennt_porxy;
options.headers = {
'User-Agent': current_useragent,
Accept: 'application/json',
'Accept-Language': 'en-US',
'Accept-Encoding': 'identity',
Referer: 'https://www.twitch.tv/',
'Client-Id': ClientID,
'X-Device-Id': XDeviceId,
'Client-Version': ClientVersion,
'Client-Session': ClientSessionId,
Authorization: "OAuth " + accessToken,
'Client-Integrity': ClientIntegrity,
'Content-Type': 'text/plain;charset=UTF-8',
Origin: 'https://www.twitch.tv',
DNT: 1,
Connection: 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site'
};
let response = await axios.post('https://gql.twitch.tv/gql#origin=twilight', query, options);
return response.data;
} catch (e) {
console.log(e);
return {};
}
};
async function FollowChannel(UserID, access_token) {
currennt_porxy = getProxy(config.proxyType);
current_useragent = getUserAgent();
console.log('\x1b[33m--------------------------------------\x1b[37m');
console.log('\x1b[33mStart Follow ...\x1b[37m');
console.log('\x1b[33m--------------------------------------\x1b[37m');
console.log('\x1b[37m 1) Getting Twitch cookies!');
let cookies = await GetTwitchCookies();
if(cookies === false) {
console.log('\x1b[37m Unable to get twitch cookies!');
console.log('\x1b[33m--------------------------------------\x1b[37m');
return false;
}
console.log('\x1b[37m 2) Getting Kasada code ...');
let kasada = await KasdaResolver();
if(kasada == false)
{
console.log('\x1b[37m Unable to solve Kasada!');
console.log('\x1b[33m--------------------------------------\x1b[37m');
return false;
}
console.log('\x1b[37m 3) Getting public integrity token ...');
let ClientID = TwitchClinetID;
let ClientSessionId = MakeRandomID(16).toLowerCase();
let XDeviceId = cookies['unique_id'];
let ClientVersion = '3040e141-5964-4d72-b67d-e73c1cf355b5';
let ClientRequestID = MakeRandomID(32);
let PublicInter = await PublicIntegrityGetToken(ClientID, XDeviceId, ClientRequestID, ClientSessionId, ClientVersion, KasdaResponse.kpsdkct, KasdaResponse.kpsdkcd, access_token);
await FollowRequest(UserID, ClientID, XDeviceId, ClientVersion, ClientSessionId, access_token, PublicInter['token']);
console.log('\x1b[37m Done!');
return true;
}
async function StartFollow(uname) {
let UserID = await GetUserID(uname);
if(UserID == undefined || UserID == null || UserID == false)
{
console.log('\x1b[37mTwitch account is not valid!');
console.log('\x1b[33m--------------------------------------\x1b[37m');
return;
}
for (const token of tokens) {
if(tokens == undefined ||tokens == null || tokens == "")
{
console.log('\x1b[37mIt\'s done, Used all tokens!');
console.log('\x1b[33m--------------------------------------\x1b[37m');
return;
}
await FollowChannel(UserID, token);
}
console.log('\x1b[33m--------------------------------------\x1b[37m');
}
async function FollowAccount(uname)
{
await StartFollow(uname);
setTimeout(() => GettingUsername(), 2000);
}
GettingUsername = async () => {
rl.question("Twitch Username:\n", function(uname) {
FollowAccount(uname)
});
};
StartProgram = async () => {
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m| \x1b[33mMasterkinG32 Twitch Account Creator\x1b[31m |\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m| ----------- \x1b[33mFOLLOW BOT\x1b[31m ------------ |\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
console.log('\x1b[31m---------------------------------------\x1b[37m');
if(config.CapSolverKey == 'YOUR CapSolver API KEY') {
console.log('\x1b[35mYour captcha solver API token (READ DOCUMENT TO KNOW HOW TO GET IT):\x1b[37m');
it = rl[Symbol.asyncIterator]();
let cpsl = await it.next();
config.CapSolverKey = cpsl.value;
}
console.log('\x1b[35mProxy type in proxy.txt [http/https/socks5/socks5]:\x1b[37m');
it = rl[Symbol.asyncIterator]();
let proxy_type = await it.next();
let proxy_typev = proxy_type.value;
if(proxy_typev.toLowerCase() == 'http' || proxy_typev.toLowerCase() == 'https' || proxy_typev.toLowerCase() == 'socks' || proxy_typev.toLowerCase() == 'socks5')
{
config.proxyType = proxy_typev.toLowerCase();
}
console.log('\x1b[33m---------------------------------------\x1b[37m');
GettingUsername();
}
StartProgram();