-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwordwallHack.js
More file actions
237 lines (206 loc) · 7.66 KB
/
wordwallHack.js
File metadata and controls
237 lines (206 loc) · 7.66 KB
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
const axios = require('axios');
const readline = require('readline');
// Create an interface for reading input from the user
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Function to prompt the user for input
function prompt(query) {
return new Promise(resolve => rl.question(query, resolve));
}
function parseLeaderboardData(leaderboardData) {
if (typeof leaderboardData === 'string') {
try {
leaderboardData = leaderboardData.replace(/'/g, '"');
leaderboardData = JSON.parse(leaderboardData);
} catch (error) {
console.error('Failed to parse leaderboard data:', error);
return [];
}
}
if (!Array.isArray(leaderboardData) || leaderboardData.length === 0) {
console.error('Invalid leaderboard data');
return [];
}
return leaderboardData.map(entry => ({
entryId: entry.EntryId,
name: entry.Name,
score: entry.Score,
time: entry.Time
}));
}
function parseLeaderboardOptions(str) {
if (!str) {
console.error("Leaderboard options data is undefined or null.");
return null;
}
let jsonString = str.replace(/'/g, '"');
jsonString = jsonString.replace(/True/g, 'true')
.replace(/False/g, 'false')
.replace(/None/g, 'null');
if (jsonString.trim().charAt(0) !== '{') {
jsonString = `{${jsonString}}`;
}
try {
const data = JSON.parse(jsonString);
return data;
} catch (error) {
console.error("Error parsing JSON:", error);
return null;
}
}
async function leaderboard(url, score, time, leaderboardFunc, templateId, name = null, params = null) {
let leaderboardURL = `https://wordwall.net/leaderboardajax/${leaderboardFunc}`;
let mode = 1;
let activityId = url.split('/')[4];
let paramsStr;
let paramsJson;
if (params == null) {
paramsStr = `score=${score}&time=${time}&name=${encodeURIComponent(name)}&mode=${mode}&activityId=${activityId}&templateId=${templateId}`;
paramsJson = {
score: score,
time: time,
name: encodeURIComponent(name),
mode: mode,
activityId: activityId,
templateId: templateId
};
} else {
paramsStr = params;
paramsJson = params;
}
try {
let response;
const headers = {
'Content-Type': leaderboardFunc === 'addentry' ? 'application/x-www-form-urlencoded; charset=UTF-8' : 'application/json; charset=UTF-8',
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'en-US,en;q=0.9',
'Cache-Control': 'no-cache',
'Origin': 'https://wordwall.net',
'Referer': url,
'User-Agent': 'Mozilla/5.0',
'X-Requested-With': 'XMLHttpRequest',
'X-Wordwall-Version': '1.0.9055.15470'
};
if (leaderboardFunc !== 'addentry') {
response = await axios.get(leaderboardURL, { headers, params: paramsJson });
} else {
response = await axios.post(leaderboardURL, paramsStr, { headers });
}
if (leaderboardFunc === 'getentries') {
const data = parseLeaderboardData(response.data);
if (data.length > 0) {
data.forEach(entry => {
console.log(`Name: ${entry.name} ||| Score: ${entry.score} ||| Time: ${entry.time / 1000}`);
});
} else {
console.log('No leaderboard entries found.');
}
} else if (leaderboardFunc === 'getentryrank') {
console.log(`You would be in place ${response.data}`);
} else if (leaderboardFunc === 'getoption') {
return response.data;
}
} catch (error) {
console.error('Error with leaderboard request:', error.message);
} finally {
rl.close(); // Ensure readline is closed properly
}
}
(async () => {
console.log('Welcome to the Wordwall Hack. Please choose a function;');
let func = await prompt('Add Entry (1), Get Leaderboard (2), Get Entry Position on Leaderboard (3), Flood Leaderboard(4): ');
let url = await prompt('Wordwall game URL: ');
let templateId;
let authorUserId;
try {
const response = await axios.get(url);
let data = String(response.data);
let search = "var s=window.ServerModel={};";
let start = data.indexOf(search);
if (start === -1) {
console.error("Search string not found in the response.");
return;
}
let end = data.indexOf("</script>", start);
if (end === -1) {
console.error("End of script block not found.");
return;
}
end--;
data = data.slice(start, end);
let nsearch = "s.templateId=Number(";
let nstart = data.indexOf(nsearch);
if (nstart === -1) {
console.error("Template ID search string not found.");
return;
}
let nend = data.indexOf(")", nstart);
if (nend === -1) {
console.error("Closing parenthesis not found for templateId.");
return;
}
templateId = Number(data.slice(nstart + nsearch.length, nend));
console.log(`Template ID: ${templateId}`);
search = "s.authorUserId=Number(";
start = data.indexOf(search);
if (start === -1) {
console.error("Author User ID search string not found.");
return;
}
end = data.indexOf(")", start);
if (end === -1) {
console.error("Closing parenthesis not found for authorUserId.");
return;
}
authorUserId = Number(data.slice(start + search.length, end));
console.log('Author User ID:', authorUserId);
} catch (error) {
console.error('Axios Get Error:', error.message);
console.log('Axios Get URL: ' + url);
}
let score;
let time;
let name;
if (func != 2 && func != 4) {
score = await prompt('Score: ');
time = await prompt("Time (EX: 12.345): ");
time = parseFloat(time).toFixed(3);
time = time.split('.')[0] + time.split('.')[1].padEnd(3, '0');
time = time.replace('.', '');
}
if (func == 1) {
name = await prompt('Name: ');
leaderboard(url, score, time, 'addentry', templateId, name);
} else if (func == 2) {
leaderboard(url, null, null, 'getentries', templateId);
} else if (func == 3) {
leaderboard(url, score, time, 'getentryrank', templateId);
} else if (func == 4) {
time = "00001";
score = 69420;
let activityId = url.split('/')[4];
name = await prompt('Name to flood leaderboard with: ');
const paramsJson = {
activityId: activityId,
templateId: templateId,
authorUserId: authorUserId
};
let leaderboardStats = await leaderboard(url, score, time, 'getoption', templateId, null, paramsJson);
if (leaderboardStats) {
leaderboardStats = parseLeaderboardOptions(leaderboardStats);
if (leaderboardStats && leaderboardStats.EntryCount) {
for (let i = 0; i < leaderboardStats.EntryCount; i++) {
leaderboard(url, score, time, 'addentry', templateId, `${name}${i}`);
}
console.log('Leaderboard Flooded!')
} else {
console.log('No entries to flood or invalid leaderboard data.');
}
} else {
console.log('Could not retrieve leaderboard options.');
}
}
})();