private void changeNameBox_TextChanged(object sender, EventArgs e) { GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnNameChanged"); variantPacket.AppendString("`w" + changeNameBox.Text + "``"); variantPacket.NetID = messageHandler.worldMap.netID; PacketSending.SendData(variantPacket.GetBytes(), proxyPeer); //variantPacket.NetID = }
private void ghostmodskin_CheckedChanged(object sender, EventArgs e) { if (ghostmodskin.Checked) { skinColor[0] = 110; // A - transparency skinColor[1] = 255; skinColor[2] = 255; skinColor[3] = 255; GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnChangeSkin"); variantPacket.AppendUInt(BitConverter.ToUInt32(skinColor, 0)); variantPacket.NetID = messageHandler.worldMap.netID; //variantPacket.delay = 100; PacketSending.SendData(variantPacket.GetBytes(), proxyPeer); } else { skinColor[0] = 255; GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnChangeSkin"); variantPacket.AppendUInt(BitConverter.ToUInt32(skinColor, 0)); variantPacket.NetID = messageHandler.worldMap.netID; //variantPacket.delay = 100; PacketSending.SendData(variantPacket.GetBytes(), proxyPeer); } }
void doRGBHack() { bool k1 = false; bool k2 = false; bool k3 = false; bool kAll = false; while (rgbSkinHack.Checked) { Thread.Sleep(32); skinColor[0] = 255; if (kAll == false) { if (skinColor[1] < 255) { skinColor[1]++; } else { k1 = true; } if (k1 == true) { if (skinColor[2] < 255) { skinColor[2]++; } else { k2 = true; } } if (k2 == true) { if (skinColor[3] < 255) { skinColor[3]++; } else { k3 = true; } } if (k3 == true) { kAll = true; } } else { if (skinColor[3] > 0) { skinColor[3]--; } else { k1 = false; } if (k1 == false) { if (skinColor[2] > 0) { skinColor[2]--; } else { k2 = false; } } if (k2 == false) { if (skinColor[1] > 0) { skinColor[1]--; } else { k3 = false; } } if (k3 == false) { kAll = false; } } //else Array.Copy(BitConverter.GetBytes(0), 0, skinColor, 1, 3); GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnChangeSkin"); variantPacket.AppendUInt(BitConverter.ToUInt32(skinColor, 0)); variantPacket.NetID = messageHandler.worldMap.netID; //variantPacket.delay = 100; PacketSending.SendData(variantPacket.GetBytes(), proxyPeer); } }
/* **ONSENDTOSERVER INDEXES/VALUE LOCATIONS** * port = 1 * token = 2 * userId = 3 * IPWithExtraData = 4 * lmode = 5 (Used for determining how client should behave when leaving, and could also influence the connection after. */ private int OperateVariant(VariantList.VarList vList) { switch (vList.FunctionName) { case "OnSuperMainStartAcceptLogonHrdxs47254722215a": { if (MainForm.skipCache) { MainForm.LogText += ("[" + DateTime.UtcNow + "] (CLIENT): Skipping potential caching (will make world list disappear)..."); GamePacketProton gp = new GamePacketProton(); // variant list gp.AppendString("OnRequestWorldSelectMenu"); packetSender.SendData(gp.GetBytes(), MainForm.proxyPeer); } return(-1); } case "OnZoomCamera": { MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): Camera zoom parameters (" + vList.functionArgs.Length + "): v1: " + ((float)vList.functionArgs[1] / 1000).ToString() + " v2: " + vList.functionArgs[2].ToString()); return(-1); } case "onShowCaptcha": ((string)vList.functionArgs[1]).Replace("PROCESS_LOGON_PACKET_TEXT_42", ""); // make captcha completable try { string[] lines = ((string)vList.functionArgs[1]).Split('\n'); foreach (string line in lines) { if (line.Contains("+")) { string line2 = line.Replace(" ", ""); int a1, a2; string[] splitByPipe = line2.Split('|'); string[] splitByPlus = splitByPipe[1].Split('+'); a1 = int.Parse(splitByPlus[0]); a2 = int.Parse(splitByPlus[1]); int result = a1 + a2; string resultingPacket = "action|dialog_return\ndialog_name|captcha_submit\ncaptcha_answer|" + result.ToString() + "\n"; packetSender.SendPacket(2, resultingPacket, MainForm.realPeer); } } return(-1); } catch { return(-1); // Give this to user. } case "OnDialogRequest": MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): OnDialogRequest called, logging its params here:\n" + (string)vList.functionArgs[1] + "\n"); if (!((string)vList.functionArgs[1]).ToLower().Contains("captcha")) { return(-1); // Send Client Dialog } ((string)vList.functionArgs[1]).Replace("PROCESS_LOGON_PACKET_TEXT_42", ""); // make captcha completable try { string[] lines = ((string)vList.functionArgs[1]).Split('\n'); foreach (string line in lines) { if (line.Contains("+")) { string line2 = line.Replace(" ", ""); int a1, a2; string[] splitByPipe = line2.Split('|'); string[] splitByPlus = splitByPipe[1].Split('+'); a1 = int.Parse(splitByPlus[0]); a2 = int.Parse(splitByPlus[1]); int result = a1 + a2; string resultingPacket = "action|dialog_return\ndialog_name|captcha_submit\ncaptcha_answer|" + result.ToString() + "\n"; packetSender.SendPacket(2, resultingPacket, MainForm.realPeer); } } return(-1); } catch { return(-1); // Give this to user. } case "OnSendToServer": { string ip = (string)vList.functionArgs[4]; if (ip.Contains("|")) { ip = ip.Substring(0, ip.IndexOf("|")); } int port = (int)vList.functionArgs[1]; int userID = (int)vList.functionArgs[3]; int token = (int)vList.functionArgs[2]; int lmode = (int)vList.functionArgs[5]; MainForm.lmode = lmode; if (MainForm.token <= 0) { ip = MainForm.Growtopia_Master_IP; port = MainForm.Growtopia_Master_Port; MainForm.token = token; } MainForm.userID = userID; MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): OnSendToServer (func call used for server switching/sub-servers) " + "IP: " + ip + " PORT: " + port + " UserId: " + userID + " Session-Token: " + token + "\n"); GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnConsoleMessage"); variantPacket.AppendString("`6(PROXY)`o Switching subserver...``"); packetSender.SendData(variantPacket.GetBytes(), MainForm.proxyPeer); GamePacketProton variantPacket2 = new GamePacketProton(); variantPacket2.AppendString("OnSendToServer"); variantPacket2.AppendInt(2); variantPacket2.AppendInt(token); variantPacket2.AppendInt(userID); variantPacket2.AppendString("127.0.0.1|" + MainForm.doorid); variantPacket2.AppendInt(lmode); // MainForm.doorid = ""; fix cant enter door with link to other door in other subserver/world packetSender.SendData(variantPacket2.GetBytes(), MainForm.proxyPeer); MainForm.Growtopia_IP = ip; // proper sub server switching MainForm.Growtopia_Port = port; return(-1); } case "OnSpawn": { worldMap.playerCount++; string onspawnStr = (string)vList.functionArgs[1]; //MessageBox.Show(onspawnStr); string[] tk = onspawnStr.Split('|'); Player p = new Player(); string[] lines = onspawnStr.Split('\n'); bool localplayer = false; foreach (string line in lines) { string[] lineToken = line.Split('|'); if (lineToken.Length != 2) { continue; } switch (lineToken[0]) { case "netID": p.netID = Convert.ToInt32(lineToken[1]); break; case "userID": p.userID = Convert.ToInt32(lineToken[1]); break; case "name": p.name = lineToken[1]; break; case "country": p.country = lineToken[1]; break; case "invis": p.invis = Convert.ToInt32(lineToken[1]); break; case "mstate": p.mstate = Convert.ToInt32(lineToken[1]); break; case "smstate": p.mstate = Convert.ToInt32(lineToken[1]); break; case "type": if (lineToken[1] == "local") { localplayer = true; } break; } } //MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): " + onspawnStr); worldMap.players.Add(p); if (p.name.Length > 2) { worldMap.AddPlayerControlToBox(p); } /*if (p.name.Contains(MainForm.tankIDName)) * { * * }*///crappy code if (p.mstate > 0 || p.smstate > 0 || p.invis > 0) { if (MainForm.cheat_autoworldban_mod) { banEveryoneInWorld(); } MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): A moderator or developer seems to have joined your world!\n"); } if (localplayer) { string lestring = (string)vList.functionArgs[1]; string[] avatardata = lestring.Split('\n'); string modified_avatardata = string.Empty; foreach (string av in avatardata) { if (av.Length <= 0) { continue; } string key = av.Substring(0, av.IndexOf('|')); string value = av.Substring(av.IndexOf('|') + 1); switch (key) { case "mstate": // unlimited punch/place range edit smstate, but is dangerous/detectable and can autoban! value = "1"; break; } modified_avatardata += key + "|" + value + "\n"; } //lestring = lestring.Replace("mstate|0", "mstate|1"); if (MainForm.unlimitedZoom) { GamePacketProton gp = new GamePacketProton(); gp.AppendString("OnSpawn"); gp.AppendString(modified_avatardata); gp.delay = (int)vList.delay; gp.NetID = vList.netID; packetSender.SendData(gp.GetBytes(), MainForm.proxyPeer); } MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): World player objects loaded! Your NetID: " + p.netID + " -- Your UserID: " + p.userID + "\n"); worldMap.netID = p.netID; worldMap.userID = p.userID; return(-2); } else { return(p.netID); } } case "OnRemove": { int netID = -1; string onremovestr = (string)vList.functionArgs[1]; string[] lineToken = onremovestr.Split('|'); if (lineToken[0] != "netID") { break; } int.TryParse(lineToken[1], out netID); for (int i = 0; i < worldMap.players.Count; i++) { if (worldMap.players[i].netID == netID) { worldMap.players.RemoveAt(i); break; } } worldMap.RemovePlayerControl(netID); return(netID); } default: return(-1); } return(0); }
public string HandlePacketFromServer(ENetPacket packet) { if (MainForm.proxyPeer == null) { return(""); } if (MainForm.proxyPeer.State != ENetPeerState.Connected) { return(""); } if (MainForm.realPeer == null) { return(""); } if (MainForm.realPeer.State != ENetPeerState.Connected) { return(""); } byte[] data = packet.GetPayloadFinal(); //else //{ //return "_none_"; //} NetTypes.NetMessages msgType = (NetTypes.NetMessages)data[0]; // more performance. switch (msgType) { case NetTypes.NetMessages.SERVER_HELLO: MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): Initial logon accepted." + "\n"); break; case NetTypes.NetMessages.GAME_MESSAGE: string str = GetProperGenericText(data); MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): A game_msg packet was sent: " + str + "\n"); if (str.Contains("Server requesting that you re-logon...")) { MainForm.token = 0; MainForm.doorid = ""; GamePacketProton gp = new GamePacketProton(); gp.AppendString("OnConsoleMessage"); gp.AppendString("`6(PROXY) `4Handling server relogon request automatically..."); packetSender.SendData(gp.GetBytes(), MainForm.proxyPeer); SwitchServers(MainForm.Growtopia_Master_IP, MainForm.Growtopia_Master_Port); return("Server forces logon request, switching server automatically so user does not have to cancel to login menu and reconnect."); } break; case NetTypes.NetMessages.GAME_PACKET: byte[] tankPacket = VariantList.get_struct_data(data); if (tankPacket == null) { break; } byte tankPacketType = tankPacket[0]; NetTypes.PacketTypes packetType = (NetTypes.PacketTypes)tankPacketType; if (MainForm.logallpackettypes) { GamePacketProton gp = new GamePacketProton(); gp.AppendString("OnConsoleMessage"); gp.AppendString("`6(PROXY) `wPacket TYPE: " + tankPacketType.ToString()); packetSender.SendData(gp.GetBytes(), MainForm.proxyPeer); } switch (packetType) { case NetTypes.PacketTypes.INVENTORY_STATE: { worldMap.player.SerializePlayerInventory(VariantList.get_extended_data(tankPacket)); /*foreach (InventoryItem item in worldMap.player.inventory.items) * { * ItemDatabase.ItemDefinition itemDef = ItemDatabase.GetItemDef(item.itemID); * MessageBox.Show("ITEM NAME: " + itemDef.itemName + " AMOUNT: " + item.amount); * }*/ break; } case NetTypes.PacketTypes.PLAYER_LOGIC_UPDATE: { TankPacket p = TankPacket.UnpackFromPacket(data); foreach (Player pl in worldMap.players) { if (pl.netID == p.NetID) { pl.X = (int)p.X; pl.Y = (int)p.Y; break; } } break; } case NetTypes.PacketTypes.TILE_CHANGE_REQ: { TankPacket p = TankPacket.UnpackFromPacket(data); // world tile map in proxy, by playingo :) if (worldMap == null) { MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): (ERROR) World map was null." + "\n"); break; } byte tileX = (byte)p.PunchX; byte tileY = (byte)p.PunchY; ushort item = (ushort)p.MainValue; if (tileX >= worldMap.width) { break; } else if (tileY >= worldMap.height) { break; } ItemDatabase.ItemDefinition itemDef = ItemDatabase.GetItemDef(item); if (ItemDatabase.isBackground(item)) { worldMap.tiles[tileX + (tileY * worldMap.width)].bg = item; } else { worldMap.tiles[tileX + (tileY * worldMap.width)].fg = item; } break; } case NetTypes.PacketTypes.CALL_FUNCTION: VariantList.VarList VarListFetched = VariantList.GetCall(VariantList.get_extended_data(tankPacket)); VarListFetched.netID = BitConverter.ToInt32(tankPacket, 4); // add netid VarListFetched.delay = BitConverter.ToUInt32(tankPacket, 20); // add keep track of delay modifier int netID = OperateVariant(VarListFetched); string argText = string.Empty; for (int i = 0; i < VarListFetched.functionArgs.Count(); i++) { argText += " [" + i.ToString() + "]: " + (string)VarListFetched.functionArgs[i].ToString(); } MainForm.LogText += ("[" + DateTime.UtcNow + "] (SERVER): A function call was requested, see log infos below:\nFunction Name: " + VarListFetched.FunctionName + " parameters: " + argText + " \n"); if (VarListFetched.FunctionName == "OnSendToServer") { return("Server switching forced, not continuing as Proxy Client has to deal with this."); } if (VarListFetched.FunctionName == "onShowCaptcha") { return("Received captcha solving request, instantly bypassed it so it doesnt show up on client side."); } if (VarListFetched.FunctionName == "OnDialogRequest" && ((string)VarListFetched.functionArgs[1]).ToLower().Contains("captcha")) { return("Received captcha solving request, instantly bypassed it so it doesnt show up on client side."); } if (VarListFetched.FunctionName == "OnSetPos" && MainForm.ignoreonsetpos && netID == worldMap.netID) { return("Ignored position set by server, may corrupt doors but is used so it wont set back. (CAN BE BUGGY WITH SLOW CONNECTIONS)"); } if (VarListFetched.FunctionName == "OnSpawn" && netID == -2) { if (MainForm.unlimitedZoom) { return("Modified OnSpawn for unlimited zoom (mstate|1)"); // only doing unlimited zoom and not unlimited punch/place to be sure that no bans occur due to this. If you wish to use unlimited punching/placing as well, change the smstate in OperateVariant function instead. } } break; case NetTypes.PacketTypes.SET_CHARACTER_STATE: { /*TankPacket p = TankPacket.UnpackFromPacket(data); * * return "Log of potentially wanted received GAME_PACKET Data:" + * "\nnetID: " + p.NetID + * "\nsecondnetid: " + p.SecondaryNetID + * "\ncharacterstate (prob 8): " + p.CharacterState + * "\nwaterspeed / offs 16: " + p.Padding + * "\nmainval: " + p.MainValue + * "\nX|Y: " + p.X + "|" + p.Y + * "\nXSpeed: " + p.XSpeed + * "\nYSpeed: " + p.YSpeed + * "\nSecondaryPadding: " + p.SecondaryPadding + * "\nPunchX|PunchY: " + p.PunchX + "|" + p.PunchY;*/ break; } case NetTypes.PacketTypes.PING_REQ: SpoofedPingReply(); break; case NetTypes.PacketTypes.LOAD_MAP: if (MainForm.LogText.Length >= 32678) { MainForm.LogText = string.Empty; } worldMap = worldMap.LoadMap(tankPacket); worldMap.player.didCharacterStateLoad = false; worldMap.player.didClothingLoad = false; if (MainForm.pForm.IsHandleCreated) { Action action = () => { MainForm.pForm.Text = "All players in " + worldMap.currentWorld; foreach (Button btn in MainForm.pForm.playerBox.Controls) { btn.Dispose(); } MainForm.pForm.playerBox.Controls.Clear(); }; MainForm.pForm.Invoke(action); } MainForm.realPeer.Timeout(1000, 7000, 11000); break; case NetTypes.PacketTypes.MODIFY_ITEM_OBJ: { TankPacket p = TankPacket.UnpackFromPacket(data); if (p.NetID == -1) { if (worldMap == null) { MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): (ERROR) World map was null." + "\n"); break; } worldMap.dropped_ITEMUID++; DroppedObject dItem = new DroppedObject(); dItem.id = p.MainValue; dItem.itemCount = data[16]; dItem.x = p.X; dItem.y = p.Y; dItem.uid = worldMap.dropped_ITEMUID; worldMap.droppedItems.Add(dItem); if (MainForm.cheat_magplant) { TankPacket p2 = new TankPacket(); p2.PacketType = (int)NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ; p2.NetID = p.NetID; p2.X = (int)p.X; p2.Y = (int)p.Y; p2.MainValue = dItem.uid; packetSender.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p2.PackForSendingRaw(), MainForm.realPeer); //return "Blocked dropped packet due to magplant hack (auto collect/pickup range) tried to collect it instead, infos of dropped item => uid was " + worldMap.dropped_ITEMUID.ToString() + " id: " + p.MainValue.ToString(); } } } break; default: break; } break; case NetTypes.NetMessages.TRACK: case NetTypes.NetMessages.LOG_REQ: case NetTypes.NetMessages.ERROR: return("Blocked track/logreq/error message type by server."); default: //return "(SERVER): An unknown event occured. Message Type: " + msgType.ToString() + "\n"; break; } packetSender.SendData(data, MainForm.proxyPeer, ENetPacketFlags.Reliable); if (msgType == NetTypes.NetMessages.GAME_PACKET && data[4] > 39) // customizable on which packets you wanna log, for speed im just gonna do this! { TankPacket p = TankPacket.UnpackFromPacket(data); uint extDataSize = BitConverter.ToUInt32(data, 56); byte[] actualData = data.Skip(4).Take(56).ToArray(); byte[] extData = data.Skip(60).ToArray(); string extDataStr = ""; string extDataStrShort = ""; string extDataString = Encoding.UTF8.GetString(extData); for (int i = 0; i < extDataSize; i++) { //ushort pos = BitConverter.ToUInt16(extData, i); extDataStr += extData[i].ToString() + "|"; } return("Log of potentially wanted received GAME_PACKET Data:" + "\npackettype: " + actualData[0].ToString() + "\npadding byte 1|2|3: " + actualData[1].ToString() + "|" + actualData[2].ToString() + "|" + actualData[3].ToString() + "\nnetID: " + p.NetID + "\nsecondnetid: " + p.SecondaryNetID + "\ncharacterstate (prob 8): " + p.CharacterState + "\nwaterspeed / offs 16: " + p.Padding + "\nmainval: " + p.MainValue + "\nX|Y: " + p.X + "|" + p.Y + "\nXSpeed: " + p.XSpeed + "\nYSpeed: " + p.YSpeed + "\nSecondaryPadding: " + p.SecondaryPadding + "\nPunchX|PunchY: " + p.PunchX + "|" + p.PunchY + "\nExtended Packet Data Length: " + extDataSize.ToString() + "\nExtended Packet Data:\n" + extDataStr + "\n"); return(string.Empty); } else { return(string.Empty); } }
/* **ONSENDTOSERVER INDEXES/VALUE LOCATIONS** * port = 1 * token = 2 * userId = 3 * IPWithExtraData = 4 * lmode = 5 (Used for determining how client should behave when leaving, and could also influence the connection after. */ private int OperateVariant(VariantList.VarList vList, object botPeer) { switch (vList.FunctionName) { case "OnConsoleMessage": { string m = (string)vList.functionArgs[1]; if ((m.Contains("lagged out,") || m.Contains("experiencing high load")) && !m.Contains("<") && !m.Contains("[")) { GamePacketProton variantPacket2 = new GamePacketProton(); variantPacket2.AppendString("OnReconnect"); packetSender.SendData(variantPacket2.GetBytes(), Proxyhelper.proxyPeer); } break; } case "OnRequestWorldSelectMenu": { if (Proxyhelper.globalUserData.autoEnterWorld != "") { packetSender.SendPacket(3, "action|join_request\nname|" + Proxyhelper.globalUserData.autoEnterWorld, Proxyhelper.realPeer); } break; } case "OnSuperMainStartAcceptLogonHrdxs47254722215a": { if (Proxyhelper.skipCache && botPeer == null) { GamePacketProton gp = new GamePacketProton(); // variant list gp.AppendString("OnRequestWorldSelectMenu"); packetSender.SendData(gp.GetBytes(), Proxyhelper.proxyPeer); } if (botPeer != null) { Console.WriteLine("BOT PEER IS ENTERING THE GAME..."); packetSender.SendPacket(3, "action|enter_game\n", (ENetPeer)botPeer); } return(-1); } case "OnZoomCamera": { return(-1); } case "onShowCaptcha": ((string)vList.functionArgs[1]).Replace("PROCESS_LOGON_PACKET_TEXT_42", ""); // make captcha completable try { string[] lines = ((string)vList.functionArgs[1]).Split('\n'); foreach (string line in lines) { if (line.Contains("+")) { string line2 = line.Replace(" ", ""); int a1, a2; string[] splitByPipe = line2.Split('|'); string[] splitByPlus = splitByPipe[1].Split('+'); a1 = int.Parse(splitByPlus[0]); a2 = int.Parse(splitByPlus[1]); int result = a1 + a2; string resultingPacket = "action|dialog_return\ndialog_name|captcha_submit\ncaptcha_answer|" + result.ToString() + "\n"; packetSender.SendPacket(2, resultingPacket, Proxyhelper.realPeer); } } return(-1); } catch { return(-1); // Give this to user. } case "OnDialogRequest": if (!((string)vList.functionArgs[1]).ToLower().Contains("captcha")) { return(-1); // Send Client Dialog } ((string)vList.functionArgs[1]).Replace("PROCESS_LOGON_PACKET_TEXT_42", ""); // make captcha completable try { string[] lines = ((string)vList.functionArgs[1]).Split('\n'); foreach (string line in lines) { if (line.Contains("+")) { string line2 = line.Replace(" ", ""); int a1, a2; string[] splitByPipe = line2.Split('|'); string[] splitByPlus = splitByPipe[1].Split('+'); a1 = int.Parse(splitByPlus[0]); a2 = int.Parse(splitByPlus[1]); int result = a1 + a2; string resultingPacket = "action|dialog_return\ndialog_name|captcha_submit\ncaptcha_answer|" + result.ToString() + "\n"; packetSender.SendPacket(2, resultingPacket, Proxyhelper.realPeer); } } return(-1); } catch { return(-1); // Give this to user. } case "OnSendToServer": { // TODO FIX THIS AND MIRROR ALL PACKETS AND SOME BUG FIXES. string ip = (string)vList.functionArgs[4]; string doorid = ""; if (ip.Contains("|")) { doorid = ip.Substring(ip.IndexOf("|") + 1); ip = ip.Substring(0, ip.IndexOf("|")); } int port = (int)vList.functionArgs[1]; int userID = (int)vList.functionArgs[3]; int token = (int)vList.functionArgs[2]; GamePacketProton variantPacket = new GamePacketProton(); variantPacket.AppendString("OnConsoleMessage"); variantPacket.AppendString("`6(PROXY)`o Switching subserver...``"); packetSender.SendData(variantPacket.GetBytes(), Proxyhelper.proxyPeer); Proxyhelper.globalUserData.Growtopia_IP = token < 0 ? Proxyhelper.globalUserData.Growtopia_Master_IP : ip; Proxyhelper.globalUserData.Growtopia_Port = token < 0 ? Proxyhelper.globalUserData.Growtopia_Master_Port : port; Proxyhelper.globalUserData.isSwitchingServer = true; Proxyhelper.globalUserData.token = token; Proxyhelper.globalUserData.lmode = 1; Proxyhelper.globalUserData.userID = userID; Proxyhelper.globalUserData.doorid = doorid; packetSender.SendPacket(3, "action|quit", Proxyhelper.realPeer); Proxyhelper.realPeer.Disconnect(0); return(-1); } case "OnSpawn": { worldMap.playerCount++; string onspawnStr = (string)vList.functionArgs[1]; //MessageBox.Show(onspawnStr); string[] tk = onspawnStr.Split('|'); Player p = new Player(); string[] lines = onspawnStr.Split('\n'); bool localplayer = false; foreach (string line in lines) { string[] lineToken = line.Split('|'); if (lineToken.Length != 2) { continue; } switch (lineToken[0]) { case "netID": p.netID = Convert.ToInt32(lineToken[1]); break; case "userID": p.userID = Convert.ToInt32(lineToken[1]); break; case "name": p.name = lineToken[1]; break; case "country": p.country = lineToken[1]; break; case "invis": p.invis = Convert.ToInt32(lineToken[1]); break; case "mstate": p.mstate = Convert.ToInt32(lineToken[1]); break; case "smstate": p.mstate = Convert.ToInt32(lineToken[1]); break; case "posXY": if (lineToken.Length == 3) // exactly 3 not more not less { p.X = Convert.ToInt32(lineToken[1]); p.Y = Convert.ToInt32(lineToken[2]); } break; case "type": if (lineToken[1] == "local") { localplayer = true; } break; } } //MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): " + onspawnStr); worldMap.players.Add(p); /*if (p.name.Contains(MainForm.tankIDName)) * { * * }*///crappy code if (p.mstate > 0 || p.smstate > 0 || p.invis > 0) { if (Proxyhelper.globalUserData.cheat_autoworldban_mod) { banEveryoneInWorld(); } } if (localplayer) { string lestring = (string)vList.functionArgs[1]; string[] avatardata = lestring.Split('\n'); string modified_avatardata = string.Empty; foreach (string av in avatardata) { if (av.Length <= 0) { continue; } string key = av.Substring(0, av.IndexOf('|')); string value = av.Substring(av.IndexOf('|') + 1); switch (key) { case "mstate": // unlimited punch/place range edit smstate value = "1"; break; } modified_avatardata += key + "|" + value + "\n"; } //lestring = lestring.Replace("mstate|0", "mstate|1"); if (Proxyhelper.globalUserData.unlimitedZoom) { GamePacketProton gp = new GamePacketProton(); gp.AppendString("OnSpawn"); gp.AppendString(modified_avatardata); gp.delay = (int)vList.delay; gp.NetID = vList.netID; packetSender.SendData(gp.GetBytes(), Proxyhelper.proxyPeer); } worldMap.netID = p.netID; worldMap.userID = p.userID; return(-2); } else { return(p.netID); } } case "OnRemove": { int netID = -1; string onremovestr = (string)vList.functionArgs[1]; string[] lineToken = onremovestr.Split('|'); if (lineToken[0] != "netID") { break; } int.TryParse(lineToken[1], out netID); for (int i = 0; i < worldMap.players.Count; i++) { if (worldMap.players[i].netID == netID) { worldMap.players.RemoveAt(i); break; } } return(netID); } default: return(-1); } return(0); }
public string HandlePacketFromServer(ref ENetPeer peer, ENetPacket packet) { if (Proxyhelper.proxyPeer.IsNull) { return("HandlePacketFromServer() -> Proxy peer is null!"); } if (Proxyhelper.proxyPeer.State != ENetPeerState.Connected) { return($"HandlePacketFromServer() -> proxyPeer is not connected: state = {Proxyhelper.proxyPeer.State}"); } if (peer.IsNull) { return("HandlePacketFromServer() -> peer.IsNull is true!"); } if (peer.State != ENetPeerState.Connected) { return("HandlePacketFromServer() -> peer.State was not ENetPeerState.Connected!"); } byte[] data = packet.Data.ToArray(); NetTypes.NetMessages msgType = (NetTypes.NetMessages)data[0]; // more performance. switch (msgType) { case NetTypes.NetMessages.SERVER_HELLO: { Proxyhelper.UserData ud; if (peer.TryGetUserData(out ud)) { packetSender.SendPacket(2, Proxyhelper.CreateLogonPacket(ud.tankIDName, ud.tankIDPass, ud.userID, ud.token, ud.doorid), peer); } break; } case NetTypes.NetMessages.GAME_MESSAGE: string str = GetProperGenericText(data); Proxyhelper.LogText += ("[" + DateTime.UtcNow + "] (SERVER): A game_msg packet was sent: " + str + "\n"); if (str.Contains("Server requesting that you re-logon")) { Proxyhelper.globalUserData.token = -1; Proxyhelper.globalUserData.Growtopia_IP = Proxyhelper.globalUserData.Growtopia_Master_IP; Proxyhelper.globalUserData.Growtopia_Port = Proxyhelper.globalUserData.Growtopia_Master_Port; Proxyhelper.globalUserData.isSwitchingServer = true; Proxyhelper.realPeer.Disconnect(0); } break; case NetTypes.NetMessages.GAME_PACKET: byte[] tankPacket = VariantList.get_struct_data(data); if (tankPacket == null) { break; } byte tankPacketType = tankPacket[0]; NetTypes.PacketTypes packetType = (NetTypes.PacketTypes)tankPacketType; if (Proxyhelper.logallpackettypes) { GamePacketProton gp = new GamePacketProton(); gp.AppendString("OnConsoleMessage"); gp.AppendString("`6(PROXY) `wPacket TYPE: " + tankPacketType.ToString()); packetSender.SendData(gp.GetBytes(), Proxyhelper.proxyPeer); if (tankPacketType > 18) { File.WriteAllBytes("newpacket.dat", tankPacket); } } switch (packetType) { case NetTypes.PacketTypes.PLAYER_LOGIC_UPDATE: { TankPacket p = TankPacket.UnpackFromPacket(data); foreach (Player pl in worldMap.players) { if (pl.netID == p.NetID) { pl.X = (int)p.X; pl.Y = (int)p.Y; break; } } break; } case NetTypes.PacketTypes.INVENTORY_STATE: { if (!Proxyhelper.globalUserData.dontSerializeInventory) { worldMap.player.SerializePlayerInventory(VariantList.get_extended_data(tankPacket)); } break; } case NetTypes.PacketTypes.TILE_CHANGE_REQ: { TankPacket p = TankPacket.UnpackFromPacket(data); if (worldMap == null) { Proxyhelper.LogText += ("[" + DateTime.UtcNow + "] (PROXY): (ERROR) World map was null." + "\n"); break; } byte tileX = (byte)p.PunchX; byte tileY = (byte)p.PunchY; ushort item = (ushort)p.MainValue; if (tileX >= worldMap.width) { break; } else if (tileY >= worldMap.height) { break; } ItemDatabase.ItemDefinition itemDef = ItemDatabase.GetItemDef(item); if (ItemDatabase.isBackground(item)) { worldMap.tiles[tileX + (tileY * worldMap.width)].bg = item; } else { worldMap.tiles[tileX + (tileY * worldMap.width)].fg = item; } break; } case NetTypes.PacketTypes.CALL_FUNCTION: VariantList.VarList VarListFetched = VariantList.GetCall(VariantList.get_extended_data(tankPacket)); VarListFetched.netID = BitConverter.ToInt32(tankPacket, 4); // add netid VarListFetched.delay = BitConverter.ToUInt32(tankPacket, 20); // add keep track of delay modifier bool isABot = false; Proxyhelper.UserData ud = null; int netID = OperateVariant(VarListFetched, isABot ? (object)peer : null); // box enetpeer obj to generic obj string argText = string.Empty; for (int i = 0; i < VarListFetched.functionArgs.Count(); i++) { argText += " [" + i.ToString() + "]: " + (string)VarListFetched.functionArgs[i].ToString(); } Proxyhelper.LogText += ("[" + DateTime.UtcNow + "] (SERVER): A function call was requested, see log infos below:\nFunction Name: " + VarListFetched.FunctionName + " parameters: " + argText + " \n"); if (VarListFetched.FunctionName == "OnSendToServer") { return("Server switching forced, not continuing as Proxy Client has to deal with this."); } if (VarListFetched.FunctionName == "onShowCaptcha") { return("Received captcha solving request, instantly bypassed it so it doesnt show up on client side."); } if (VarListFetched.FunctionName == "OnDialogRequest" && ((string)VarListFetched.functionArgs[1]).ToLower().Contains("captcha")) { return("Received captcha solving request, instantly bypassed it so it doesnt show up on client side."); } if (VarListFetched.FunctionName == "OnDialogRequest" && ((string)VarListFetched.functionArgs[1]).ToLower().Contains("gazette")) { return("Received gazette, skipping it..."); } if (VarListFetched.FunctionName == "OnSetPos" && Proxyhelper.globalUserData.ignoreonsetpos && netID == worldMap.netID) { return("Ignored position set by server, may corrupt doors but is used so it wont set back. (CAN BE BUGGY WITH SLOW CONNECTIONS)"); } if (VarListFetched.FunctionName == "OnSpawn" && netID == -2) { if (Proxyhelper.globalUserData.unlimitedZoom) { return("Modified OnSpawn for unlimited zoom (mstate|1)"); // only doing unlimited zoom and not unlimited punch/place to be sure that no bans occur due to this. If you wish to use unlimited punching/placing as well, change the smstate in OperateVariant function instead. } } break; case NetTypes.PacketTypes.SET_CHARACTER_STATE: { /*TankPacket p = TankPacket.UnpackFromPacket(data); * * return "Log of potentially wanted received GAME_PACKET Data:" + * "\nnetID: " + p.NetID + * "\nsecondnetid: " + p.SecondaryNetID + * "\ncharacterstate (prob 8): " + p.CharacterState + * "\nwaterspeed / offs 16: " + p.Padding + * "\nmainval: " + p.MainValue + * "\nX|Y: " + p.X + "|" + p.Y + * "\nXSpeed: " + p.XSpeed + * "\nYSpeed: " + p.YSpeed + * "\nSecondaryPadding: " + p.SecondaryPadding + * "\nPunchX|PunchY: " + p.PunchX + "|" + p.PunchY;*/ break; } case NetTypes.PacketTypes.PING_REQ: SpoofedPingReply(TankPacket.UnpackFromPacket(data)); break; case NetTypes.PacketTypes.LOAD_MAP: if (Proxyhelper.LogText.Length >= 32678) { Proxyhelper.LogText = string.Empty; } worldMap = worldMap.LoadMap(tankPacket); worldMap.player.didCharacterStateLoad = false; worldMap.player.didClothingLoad = false; Proxyhelper.realPeer.Timeout(1000, 2800, 3400); break; case NetTypes.PacketTypes.MODIFY_ITEM_OBJ: { TankPacket p = TankPacket.UnpackFromPacket(data); if (p.NetID == -1) { if (worldMap == null) { break; } worldMap.dropped_ITEMUID++; DroppedObject dItem = new DroppedObject(); dItem.id = p.MainValue; dItem.itemCount = data[16]; dItem.x = p.X; dItem.y = p.Y; dItem.uid = worldMap.dropped_ITEMUID; worldMap.droppedItems.Add(dItem); if (Proxyhelper.globalUserData.cheat_magplant) { TankPacket p2 = new TankPacket(); p2.PacketType = (int)NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ; p2.NetID = p.NetID; p2.X = (int)p.X; p2.Y = (int)p.Y; p2.MainValue = dItem.uid; packetSender.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p2.PackForSendingRaw(), Proxyhelper.realPeer); //return "Blocked dropped packet due to magplant hack (auto collect/pickup range) tried to collect it instead, infos of dropped item => uid was " + worldMap.dropped_ITEMUID.ToString() + " id: " + p.MainValue.ToString(); } } } break; default: break; } break; case NetTypes.NetMessages.TRACK: { return("Track message:\n" + GetProperGenericText(data)); break; } case NetTypes.NetMessages.LOG_REQ: case NetTypes.NetMessages.ERROR: return("Blocked LOG_REQUEST/ERROR message from server"); default: //return "(SERVER): An unknown event occured. Message Type: " + msgType.ToString() + "\n"; break; } packetSender.SendData(data, Proxyhelper.proxyPeer); if (msgType == NetTypes.NetMessages.GAME_PACKET && data[4] > 39) // customizable on which packets you wanna log, for speed im just gonna do this! { TankPacket p = TankPacket.UnpackFromPacket(data); uint extDataSize = BitConverter.ToUInt32(data, 56); byte[] actualData = data.Skip(4).Take(56).ToArray(); byte[] extData = data.Skip(60).ToArray(); string extDataStr = ""; string extDataStrShort = ""; string extDataString = Encoding.UTF8.GetString(extData); for (int i = 0; i < extDataSize; i++) { //ushort pos = BitConverter.ToUInt16(extData, i); extDataStr += extData[i].ToString() + "|"; } return("Log of potentially wanted received GAME_PACKET Data:" + "\npackettype: " + actualData[0].ToString() + "\npadding byte 1|2|3: " + actualData[1].ToString() + "|" + actualData[2].ToString() + "|" + actualData[3].ToString() + "\nnetID: " + p.NetID + "\nsecondnetid: " + p.SecondaryNetID + "\ncharacterstate (prob 8): " + p.CharacterState + "\nwaterspeed / offs 16: " + p.Padding + "\nmainval: " + p.MainValue + "\nX|Y: " + p.X + "|" + p.Y + "\nXSpeed: " + p.XSpeed + "\nYSpeed: " + p.YSpeed + "\nSecondaryPadding: " + p.SecondaryPadding + "\nPunchX|PunchY: " + p.PunchX + "|" + p.PunchY + "\nExtended Packet Data Length: " + extDataSize.ToString() + "\nExtended Packet Data:\n" + extDataStr + "\n"); return(string.Empty); } else { return(string.Empty); } }