Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Username = "Email here, must include quotes"
- const Password = "Password here, must include quotes"
- const PlayerName = "MC Username here, must include quotes"
- /*
- 2B2T NodeJS proxy server
- Developed by BadPuns
- Built upon rom1504's 'minecraft-protocol'
- Below is the code to set up a minecraft server on localhost:25566 that will forward traffic onto a destination server.
- This performs a MITM-like role, where one can log the packets being sent between the client and the server.
- I added my own functionality to the proxy to modify packets en-route to the destination (client or server),
- filter out all packets of a certain type, and several other packet-based tasks within Minecraft. This is a stripped down version of my
- original proxy, which includes a lot of teleportation, item storage exploits, and chat features. This program includes:
- - Packet manager (.filter)
- - Chat formatter (.say [message], use % for color/format numbers)
- - Client-sided creative mode (.forcecreative)
- - Gamestate manager (.state [arg] [arg (optional)]) https://wiki.vg/Protocol#Change_Game_State
- Before attempting to use this client, you must have NodeJS installed on your system. You can do so at https://nodejs.org/en/
- Once node is installed, you will need to install the dependancies for this proxy. Here are the packages you'll need to install:
- - Minecraft protocol
- - readline
- - util
- - keypress
- You can read more about each package on https://www.npmjs.com/
- Detailed installation instructions below:
- 1. Create a new folder on your desktop
- 2. Open command prompt and cd into that folder. If you don't know how to do this you shouldn't own a computer.
- 3. Once in the correct folder/directory, you'll need to install the packages for this project. Simply type the following into the prompt window
- - "npm install [package]" (without quotes)
- Perform this command for each of the required packages listed above, replacing "[package]" with the name of the required package.
- 4. Next you'll want to create a text file. Name it "proxy.js"
- 5. Copy all the code from this file into that file, and save it. Make sure it's actually saved as a .js file, and not "proxy.js.txt"
- 6. You're almost done. Next you're going to want to create the launcher for the proxy. Create a new text file, and simply name it "start.txt"
- 7. You're going to want to copy the following text and paste it into the file.
- node proxy.js --dump-all -x keep_alive -x update_time -x block_break_animation -x advancements -x animation -x spawn_entity_living -x playerlist_header -x scoreboard_display_objective -x scoreboard_objective -x entity_update_attributes -x sound_effect -x map_chunk -x teams -x entity_equipment -x scoreboard_score -x world_particles -x entity_velocity -x rel_entity_move -x entity_look -x entity_move_look -x entity_teleport -x player_info -x entity_metadata -x entity_status -x entity_head_rotation 2b2t.org 1.12.2
- pause press [enter]
- each entry with a -x in front of it shows a packet to exclude from the logger, because it's either spammy or useless. Modify this as you please.
- 8. Save the file with the text above as "start.bat", making sure it's not "start.bat.txt"
- 9. Run the .bat file, and it should open up a terminal. If you don't get an error, your proxy should be up and running.
- 10. To connect to the proxy, add "localhost:25566" to your server list. The connection will likely be slower than you're used to.
- 11. If you haven't input your login information into the variables above, you will get an error. Make sure it's entered correctly if you're getting
- an invalid login error.
- [FIXING THE CHUNK BAN]
- 1. Connect to the server.
- 2. As soon as possible, type ".filter add client map_chunk"
- This adds the map_chunk packet to the blacklist for packets sent to the client, meaning terrain cannot be loaded.
- To undo this, type ".filter clear"
- NOTE: If you have priority queue, this could be a lot harder for you, as you load into the game immediately. I added an ability to send chat packets
- from normally impossible areas (like within a chest inventory.) Simply go over to the console window, make sure it's selected, and spam the
- "c" key. This could let you send the chat packet before you actually load the terrain. Alternatively, if this does not work, you can
- change the "chatForced" value below to "/kill"
- 3. If you successfully manage to join the server, chunks won't be rendered correctly. It's an odd mess, and you can't move. Your best bet is to
- /kill. It sucks, but it's a lot better than being banned.
- */
- const mc = require('minecraft-protocol')
- const readline = require('readline')
- const util = require('util')
- var keypress = require('keypress');
- const now = new Date();
- var prefix = "."
- var chatForced = ".filter add client map_chunk"
- var AccountEntity;
- var teleID = 0
- var pearlIntercept = false
- var targetClient;
- var clientPosition;
- var targetPosition = {
- x: 0,
- y: 0,
- z: 0
- }
- var onlineServer = true
- var loggingPackets = true
- var offlineUser = "Pablo" //Only used for offline servers
- var clientPackets = [
- "spawn_entity_experience_orb",
- "spawn_entity_weather",
- "spawn_entity_living",
- "spawn_entity_painting",
- "named_entity_spawn",
- "animation",
- "statistics",
- "advancements",
- "block_break_animation",
- "tile_entity_data",
- "block_action",
- "block_change",
- "boss_bar",
- "difficulty",
- "tab_complete",
- "chat",
- "multi_block_change",
- "transaction",
- "close_window",
- "open_window",
- "window_items",
- "craft_progress_bar",
- "set_slot",
- "set_cooldown",
- "custom_payload",
- "named_sound_effect",
- "kick_disconnect",
- "entity_status",
- "explosion",
- "unload_chunk",
- "game_state_change",
- "keep_alive",
- "map_chunk",
- "world_event",
- "world_particles",
- "login",
- "map",
- "rel_entity_move",
- "entity_move_look",
- "entity_look",
- "entity",
- "vehicle_move",
- "open_sign_entity",
- "craft_recipe_response",
- "abilities",
- "combat_event",
- "player_info",
- "position",
- "bed",
- "unlock_recipes",
- "entity_destroy",
- "remove_entity_effect",
- "resource_pack_send",
- "respawn",
- "entity_head_rotation",
- "world_border",
- "camera",
- "held_item_slot",
- "scoreboard_display_objective",
- "entity_metadata",
- "attach_entity",
- "entity_velocity",
- "entity_equipment",
- "experience",
- "update_health",
- "scoreboard_objective",
- "set_passengers",
- "teams",
- "scoreboard_score",
- "spawn_position",
- "update_time",
- "title",
- "sound_effect",
- "playerlist_header",
- "collect",
- "entity_teleport",
- "entity_update_attributes",
- "entity_effect",
- "select_advancement_tab",
- "spawn_entity",
- "packet"
- ]
- var serverPackets = [
- "teleport_confirm",
- "tab_complete",
- "chat",
- "client_command",
- "settings",
- "transaction",
- "enchant_item",
- "window_click",
- "close_window",
- "custom_payload",
- "use_entity",
- "keep_alive",
- "position",
- "position_look",
- "look",
- "flying",
- "vehicle_move",
- "steer_boat",
- "craft_recipe_request",
- "abilities",
- "block_dig",
- "entity_action",
- "steer_vehicle",
- "crafting_book_data",
- "resource_pack_receive",
- "held_item_slot",
- "set_creative_slot",
- "update_sign",
- "arm_animation",
- "spectate",
- "block_place",
- "use_item",
- "advancement_tab",
- "packet"
- ]
- var clientFiltered = []
- var serverFiltered = []
- const states = mc.states
- function printHelpAndExit (exitCode) {
- console.log('usage: node proxy.js [<options>...] <target_srv> <version>')
- console.log('options:')
- console.log(' --dump name')
- console.log(' print to stdout messages with the specified name.')
- console.log(' --dump-all')
- console.log(' print to stdout all messages, except those specified with -x.')
- console.log(' -x name')
- console.log(' do not print messages with this name.')
- console.log(' name')
- console.log(' a packet name as defined in protocol.json')
- console.log('examples:')
- console.log(' node proxy.js --dump-all -x keep_alive -x update_time -x entity_velocity -x rel_entity_move -x entity_look -x entity_move_look -x entity_teleport -x entity_head_rotation -x position localhost 1.8')
- console.log(' print all messages except for some of the most prolific.')
- console.log(' node examples/proxy.js --dump open_window --dump close_window --dump set_slot --dump window_items --dump craft_progress_bar --dump transaction --dump close_window --dump window_click --dump set_creative_slot --dump enchant_item localhost 1.8')
- console.log(' print messages relating to inventory management.')
- process.exit(exitCode)
- }
- if (process.argv.length < 4) {
- console.log('Too few arguments!')
- printHelpAndExit(1)
- }
- process.argv.forEach(function (val) {
- if (val === '-h') {
- printHelpAndExit(0)
- }
- })
- const args = process.argv.slice(2)
- let host
- let port = 25565
- let version
- let printAllNames = false
- const printNameWhitelist = {}
- const printNameBlacklist = {};
- (function () {
- let i = 0
- for (i = 0; i < args.length; i++) {
- const option = args[i]
- if (!/^-/.test(option)) break
- if (option === '--dump-all') {
- printAllNames = true
- continue
- }
- i++
- const name = args[i]
- if (option === '--dump') {
- printNameWhitelist[name] = 'io'
- } else if (option === '-x') {
- printNameBlacklist[name] = 'io'
- } else {
- printHelpAndExit(1)
- }
- }
- if (!(i + 2 <= args.length && args.length <= i + 4)) printHelpAndExit(1)
- host = args[i++]
- version = args[i++]
- })()
- if (host.indexOf(':') !== -1) {
- port = host.substring(host.indexOf(':') + 1)
- host = host.substring(0, host.indexOf(':'))
- }
- //DEFAULT VIRTUAL SERVER
- motds = ["§cPacket logging and injection at it's finest", "§c\"No mom I swear I'm not hacking please don't tell the admins\"", "§cNo homo", "§cOh it crashed again", "§cSounds like lag to me", "§cDeveloped by BadPuns. Don't take credit fags."]
- motdToUse = Math.floor(Math.random() * (+motds.length - +0)) + +0
- const srv = mc.createServer({
- 'online-mode': false,
- motd: motds[motdToUse],
- port: 25566,
- keepAlive: false,
- version: version
- })
- srv.on('login', function (client) {
- keypress(process.stdin);
- process.stdin.on('keypress', function (ch, key) {
- if(key && key.name == 'p'){
- if(loggingPackets == true){
- loggingPackets = false
- console.log("\x1b[43m" + "Toggled packet logging to false. Press P to enable." + "\x1b[0m")
- } else {
- loggingPackets = true
- console.log("\x1b[43m" + "Toggled packet logging to true. Press P to disable." + "\x1b[0m")
- }
- }
- if(key && key.name == 'c'){
- targetClient.write('chat', {message: chatForced});
- }
- });
- process.stdin.setRawMode(true);
- process.stdin.resume();
- })
- srv.on('login', function (client) {
- const addr = client.socket.remoteAddress
- console.log('Incoming connection', '(' + addr + ')')
- let endedClient = false
- let endedTargetClient = false
- var loginMsg = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Connected to §c" + host + ":" + port + "\n§7Online server: §c" + onlineServer + "\n§7Account: §c" + PlayerName + "\n\n§7For a list of commands, type " + prefix + "help"]
- };
- setTimeout(function(){
- client.write("chat", { message: JSON.stringify(loginMsg), position: 0 });
- }, 1000);
- client.on('end', function () {
- endedClient = true
- console.log('Connection closed by client', '(' + addr + ')')
- if (!endedTargetClient) { targetClient.end('§cHey! This is a Christian minecraft server, we don\'t appreciate language!') }
- })
- client.on('error', function (err) {
- endedClient = true
- console.log('Connection error by client', '(' + addr + ')')
- console.log(err.stack)
- if (!endedTargetClient) { targetClient.end('§c*robot noises* Base coordinates successfully exported.') }
- })
- if(onlineServer == false){
- targetClient = mc.createClient({
- host: host,
- port: port,
- username: client.username,
- keepAlive: false,
- version: version
- })
- } else {
- targetClient = mc.createClient({
- host: host,
- port: port,
- username: Username,
- password: Password,
- keepAlive: false,
- version: version
- })
- }
- client.on('packet', function (data, meta) {
- var sendPacket = true
- if (targetClient.state === states.PLAY && meta.state === states.PLAY) {
- //if (targetClient.state && meta.state) {
- if (shouldDump(meta.name, 'o')) {
- if(loggingPackets == true){
- console.log('client->server:',
- client.state + ' ' + meta.name + ' :',
- JSON.stringify(data))
- }
- }
- if(data.message){
- var words = data.message.split(' ');
- //Catch all messages that start with "."
- if(data.message.toLowerCase().startsWith(prefix)){
- sendPacket = false
- }
- //Help Command
- if(data.message.toLowerCase().startsWith(prefix + "help")){
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Help command coming soon. I'm lazy."]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- }
- //Packet filter command. Usage: 0/filter 1[add/remove/clear/list] 2[from:client/server] 3[packetName]
- if(data.message.toLowerCase().startsWith(prefix + "filter")){
- if(words[1]){
- if(words[1].toLowerCase() == "list"){//SUBCOMMAND FINISHED
- var serverStr = serverFiltered.join("\n§c")
- var clientStr = clientFiltered.join("\n§c")
- if(!serverFiltered[0]){
- serverStr = "§cThere are no packets currently being filtered from the server."
- }
- if(!clientFiltered[0]){
- clientStr = "§cThere are no packets currently being filtered from the client."
- }
- var c = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Packets from the client currently filtered:\n§c" + clientStr]
- };
- client.write("chat", { message: JSON.stringify(c), position: 0 });
- sendPacket = false
- var s = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Packets from the server currently filtered:\n§c" + serverStr]
- };
- client.write("chat", { message: JSON.stringify(s), position: 0 });
- sendPacket = false
- }
- if(words[1].toLowerCase() == "clear"){//SUBCOMMAND FINISHED
- if(words[2]){
- if(words[2].toLowerCase() == "client"){
- clientFiltered = []
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7All filters on traffic coming from the §cclient §7have been removed."]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- }
- if(words[2].toLowerCase() == "server"){
- serverFiltered = []
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7All filters on traffic coming from the §cserver §7have been removed."]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- }
- } else {
- clientFiltered = []
- serverFiltered = []
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7All filters on traffic coming from both the §cclient and server §7have been removed."]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- }
- }
- if(words[1].toLowerCase() == "add"){
- if(words[2]){
- if(words[2].toLowerCase() == "server"){
- if(words[3]){
- function serverFinder(item){
- return words[3].toLowerCase() == item.toLowerCase()
- }
- var foundPacket = serverPackets.find(serverFinder)
- if(foundPacket != undefined){
- serverFiltered.push(words[3].toLowerCase())
- var yes = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Added packet §c'" + words[3] + "'§7 to the " + words[2] + " filter"]
- };
- client.write("chat", { message: JSON.stringify(yes), position: 0 });
- sendPacket = false
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Could not find packet '" + words[3] + "'"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- if(words[2].toLowerCase() == "client"){
- if(words[3]){
- function clientFinder(item){
- return words[3].toLowerCase() == item.toLowerCase()
- }
- var foundPacket = clientPackets.find(clientFinder)
- if(foundPacket != undefined){
- clientFiltered.push(words[3].toLowerCase())
- var yes = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Added packet §c'" + words[3] + "'§7 to the " + words[2] + " filter"]
- };
- client.write("chat", { message: JSON.stringify(yes), position: 0 });
- sendPacket = false
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Could not find packet '" + words[3] + "'"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- if(words[1].toLowerCase() == "remove"){
- if(words[2]){
- if(words[2].toLowerCase() == "server"){
- if(words[3]){
- function serverFinder(item){
- return words[3].toLowerCase() == item.toLowerCase()
- }
- var foundPacket = serverPackets.find(serverFinder)
- if(foundPacket != undefined){
- //FIX THIS RIGHT HERE
- var index = serverFiltered.indexOf(words[3]);
- if (index > -1) {
- serverFiltered.splice(index, 1);
- }
- //
- var yes = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Removed packet §c'" + words[3] + "'§7 from the " + words[2] + " filter"]
- };
- client.write("chat", { message: JSON.stringify(yes), position: 0 });
- sendPacket = false
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Could not find packet '" + words[3] + "'"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- if(words[2].toLowerCase() == "client"){
- if(words[3]){
- function clientFinder(item){
- return words[3].toLowerCase() == item.toLowerCase()
- }
- var foundPacket = clientPackets.find(clientFinder)
- if(foundPacket != undefined){
- //FIX THIS RIGHT HERE
- var index = clientFiltered.indexOf(words[3]);
- if (index > -1) {
- clientFiltered.splice(index, 1);
- }
- //
- var yes = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Removed packet §c'" + words[3] + "'§7 from the " + words[2] + " filter"]
- };
- client.write("chat", { message: JSON.stringify(yes), position: 0 });
- sendPacket = false
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Could not find packet '" + words[3] + "'"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- } else {
- var err = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + words[0] + " [add/remove/clear/list] [client/server] [packetName]"]
- };
- client.write("chat", { message: JSON.stringify(err), position: 0 });
- sendPacket = false
- }
- }
- //Say command
- if(data.message.toLowerCase().startsWith(prefix + "say")){
- if(words[1] == undefined){
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax.\n§7§lUsage: " + prefix + "say [message]"]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- } else {
- words.shift()
- msgStr = words.join(' ')
- var msg = msgStr.replace(/%/gi, '§')
- targetClient.write('chat', {message: msg});
- sendPacket = false
- }
- }
- //Client creative
- if(data.message.toLowerCase().startsWith(prefix + "forcecreative")){
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Player gamemode set to §ccreatve §7§l(Client sided only)"]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- client.write('game_state_change', {
- reason: 3,
- gameMode: 1
- })
- sendPacket = false
- }
- //Gamestate command
- if(data.message.toLowerCase().startsWith(prefix + "state")){
- if(words[1] == undefined){
- var help = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§cError: Invalid syntax\n§7Usage: " + prefix + "state [reason] [value (optional)]"]
- };
- client.write("chat", { message: JSON.stringify(help), position: 0 });
- sendPacket = false
- } else {
- if(words[2] == undefined){
- var msg = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Packet has been sent to client"]
- };
- client.write("chat", { message: JSON.stringify(msg), position: 0 });
- client.write('game_state_change', {
- reason: parseInt(words[1])
- })
- sendPacket = false
- } else {
- var msg = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Packet has been sent to client"]
- };
- client.write("chat", { message: JSON.stringify(msg), position: 0 });
- client.write('game_state_change', {
- reason: parseInt(words[1]),
- gameMode: parseInt(words[2])
- })
- sendPacket = false
- }
- }
- }
- }
- if(data.channel){
- if(data.channel == "MC|BSign"){ //Add toggleable option too
- var f = {
- translate: 'chat.type.admin',
- "with": ["§3§lProxy", "§7Book detected with data:\n§c" + data.data]
- };
- //client.write("chat", { message: JSON.stringify(f), position: 0 });
- console.log("\n\nBOOK DATA: " + typeof(data.data) + "\n" + data.data + "\n\n")
- }
- }
- var loop; //maybe?
- for(loop = 0; loop < serverFiltered.length; loop++){
- if(meta.name.toLowerCase() == serverFiltered[loop].toLowerCase()){
- sendPacket = false
- console.log("\x1b[33m" + "\x1b[36m" + 'FILTERED PACKET DETECTED: ' + serverFiltered[loop] + "\x1b[0m")
- }
- } //
- if(sendPacket == true){
- if (!endedTargetClient) { targetClient.write(meta.name, data) }
- }
- }
- })
- targetClient.on('packet', function (data, meta) {
- var sendPacket = true
- if (meta.state === states.PLAY && client.state === states.PLAY) {
- //if (meta.state && client.state) {
- if (shouldDump(meta.name, 'i')) {
- if(loggingPackets == true){
- console.log("\x1b[36m" + "\x1b[47m" + 'server->client:' + "\x1b[0m" + "\x1b[36m",
- "\x1b[4m" + targetClient.state + '.' + meta.name + "\x1b[0m" + "\x1b[36m" + ':' +
- JSON.stringify(data) + "\x1b[0m")
- }
- }
- var loop; //Maybe?
- for(loop = 0; loop < clientFiltered.length; loop++){
- if(meta.name.toLowerCase() == clientFiltered[loop].toLowerCase()){
- sendPacket = false
- console.log("\x1b[33m" + "\x1b[36m" + 'FILTERED PACKET DETECTED: ' + clientFiltered[loop] + "\x1b[0m")
- }
- } //
- if(sendPacket == true){ //maybe?
- if (!endedClient) {
- client.write(meta.name, data)
- if (meta.name === 'set_compression') {
- client.compressionThreshold = data.threshold
- } // Set compression
- }
- } //
- }
- })
- targetClient.on('login', function (packet) {
- AccountEntity = packet.entityId
- console.log("\x1b[43m" + "\n\n\nACCOUNT ENTITY ID: " + AccountEntity + "\n\n\n" + "\x1b[0m")
- })
- const bufferEqual = require('buffer-equal')
- targetClient.on('raw', function (buffer, meta) {
- if (client.state !== states.PLAY || meta.state !== states.PLAY) { return }
- const packetData = targetClient.deserializer.parsePacketBuffer(buffer).data.params
- const packetBuff = client.serializer.createPacketBuffer({ name: meta.name, params: packetData })
- if (!bufferEqual(buffer, packetBuff)) {
- console.log('server->client: Error in packet ' + meta.state + '.' + meta.name)
- console.log('received buffer', buffer.toString('hex'))
- console.log('produced buffer', packetBuff.toString('hex'))
- console.log('received length', buffer.length)
- console.log('produced length', packetBuff.length)
- }
- /* if (client.state === states.PLAY && brokenPackets.indexOf(packetId.value) !=== -1)
- {
- console.log(`client<-server: raw packet);
- console.log(packetData);
- if (!endedClient)
- client.writeRaw(buffer);
- } */
- })
- client.on('raw', function (buffer, meta) {
- if (meta.state !== states.PLAY || targetClient.state !== states.PLAY) { return }
- const packetData = client.deserializer.parsePacketBuffer(buffer).data.params
- const packetBuff = targetClient.serializer.createPacketBuffer({ name: meta.name, params: packetData })
- if (!bufferEqual(buffer, packetBuff)) {
- console.log('client->server: Error in packet ' + meta.state + '.' + meta.name)
- console.log('received buffer', buffer.toString('hex'))
- console.log('produced buffer', packetBuff.toString('hex'))
- console.log('received length', buffer.length)
- console.log('produced length', packetBuff.length)
- }
- })
- targetClient.on('end', function () {
- endedTargetClient = true
- console.log('Connection closed by server', '(' + addr + ')')
- if (!endedClient) { client.end('§cYou have been banned from 2B2T for illegal modifications.') }
- })
- targetClient.on('error', function (err) {
- endedTargetClient = true
- console.log('Connection error by server', '(' + addr + ') ', err)
- console.log(err.stack)
- if (!endedClient) { client.end('§cNice job dumbass, you fucked something up. Check the console.') }
- })
- })
- function shouldDump (name, direction) {
- if (matches(printNameBlacklist[name])) return false
- if (printAllNames) return true
- return matches(printNameWhitelist[name])
- function matches (result) {
- return result !== undefined && result !== null && result.indexOf(direction) !== -1
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement