Ejemplo n.º 1
1
        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();
            if (data.Length > 5)
            {
                if (data[5] == 3)
                {
                    return("_none_");
                }
            }
            //else
            //{
            //return "_none_";
            //}


            NetTypes.NetMessages msgType = GetMessageType(data);
            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 = "";

                    SwitchServers("213.179.209.168", 17234);

                    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;
                }

                NetTypes.PacketTypes packetType = GetPacketType(tankPacket);


                switch (packetType)
                {
                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)
                    {
                        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.
                    }

                    /*if (VarListFetched.FunctionName == "OnSetClothing" && VarListFetched.netID == worldMap.netID)
                     * {
                     *  if (!worldMap.player.didClothingLoad)
                     *  {
                     *      worldMap.player.didClothingLoad = true;
                     *      Task.Delay(400).ContinueWith(t => PacketSending.SendData(data, MainForm.proxyPeer));
                     *      return "applying onsetclothing delayed...";
                     *  }
                     * }*/
                    // unused since 1.5.5
                    break;

                case NetTypes.PacketTypes.SET_CHARACTER_STATE:
                    /*if (!worldMap.player.didCharacterStateLoad)
                     * {
                     *  worldMap.player.didCharacterStateLoad = true; // optimization
                     *  Task.Delay(400).ContinueWith(t => PacketSending.SendData(data, MainForm.proxyPeer));
                     * }*/
                    // unused since 1.5.5
                    break;

                case NetTypes.PacketTypes.PING_REQ:
                    SpoofedPingReply();
                    break;

                case NetTypes.PacketTypes.LOAD_MAP:
                    if (MainForm.LogText.Length >= 65536)
                    {
                        MainForm.LogText = string.Empty;
                    }

                    worldMap = worldMap.LoadMap(tankPacket);
                    worldMap.player.didCharacterStateLoad = false;
                    worldMap.player.didClothingLoad       = false;

                    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;

                            PacketSending.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;
            }

            PacketSending.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);
            }
        }
Ejemplo n.º 2
0
        public static TankPacket Unpack(byte[] data)
        {
            TankPacket dataStruct = new TankPacket();

            // should/must contain these...
            dataStruct.PacketType     = BitConverter.ToInt32(data, 0);
            dataStruct.NetID          = BitConverter.ToInt32(data, 4);
            dataStruct.SecondaryNetID = BitConverter.ToInt32(data, 8);
            dataStruct.ExtDataMask    = BitConverter.ToInt32(data, 12);
            dataStruct.Padding        = BitConverter.ToInt32(data, 16);
            dataStruct.MainValue      = BitConverter.ToInt32(data, 20);
            dataStruct.X                = BitConverter.ToSingle(data, 24);
            dataStruct.Y                = BitConverter.ToSingle(data, 28);
            dataStruct.XSpeed           = BitConverter.ToSingle(data, 32);
            dataStruct.YSpeed           = BitConverter.ToSingle(data, 36);
            dataStruct.SecondaryPadding = BitConverter.ToInt32(data, 40);
            dataStruct.PunchX           = BitConverter.ToInt32(data, 44);
            dataStruct.PunchY           = BitConverter.ToInt32(data, 48);

            // this is very i might be unsure...
            //int len = BitConverter.ToInt32(data, 52);
            // dataStruct.ExtData_Alt = new byte[len];
            //Array.Copy(data, 56, dataStruct.ExtData_Alt, 0, len);



            return(dataStruct);
        }
Ejemplo n.º 3
0
        private void button13_Click(object sender, EventArgs e)
        {
            TankPacket p = new TankPacket();

            p.PacketType = -1;


            PacketSending.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p.PackForSendingRaw(), realPeer);
        }
Ejemplo n.º 4
0
        public static TankPacket UnpackFromPacket(byte[] p)
        {
            TankPacket packet = new TankPacket();

            if (p.Length >= 48)
            {
                byte[] s = new byte[p.Length - 4];
                Array.Copy(p, 4, s, 0, s.Length);
                packet = Unpack(s);
            }
            return(packet);
        }
Ejemplo n.º 5
0
        void doTakeAll()
        {
            int startingfrom = 0;

            int.TryParse(textBox3.Text, out startingfrom);

            for (int i = 0; i < 10000; i++)
            {
                Thread.Sleep(12);
                TankPacket p2 = new TankPacket();
                p2.PacketType = (int)NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ;
                p2.MainValue  = i;
                PacketSending.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p2.PackForSendingRaw(), MainForm.realPeer);
            }
        }
Ejemplo n.º 6
0
        private void button4_Click_1(object sender, EventArgs e)
        {
            TankPacket p = new TankPacket();

            p.PacketType = 3;

            for (int i = 0; i < 100; i++)
            {
                p.PunchX      = i;
                p.PunchY      = i;
                p.ExtDataMask = 838338258;
                PacketSending.SendPacketRaw(4, p.PackForSendingRaw(), realPeer);
                p.PacketType = 0;
                PacketSending.SendPacketRaw(4, p.PackForSendingRaw(), realPeer);
            }
        }
Ejemplo n.º 7
0
        private void SpoofedPingReply()
        {
            if (worldMap == null)
            {
                return;
            }
            TankPacket p = new TankPacket();

            p.YSpeed  = 1000;
            p.XSpeed  = 250;
            p.X       = worldMap.player.X;
            p.Y       = worldMap.player.Y;
            p.NetID   = worldMap.player.netID;
            p.Padding = 64.0f;
            // rest is 0 by default to not get detected by ac.
            packetSender.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p.PackForSendingRaw(), MainForm.realPeer);
        }
Ejemplo n.º 8
0
        void doTheFastNukaz()
        {
            while (checkBox1.Checked)
            {
                Thread.Sleep(10);
                if (realPeer != null)
                {
                    if (realPeer.State != ENetPeerState.Connected)
                    {
                        return;
                    }

                    for (int c = 0; c < 3; c++)
                    {
                        Thread.Sleep(1000);
                        for (int i = 0; i < 40; i++)
                        {
                            int x, y;
                            x = messageHandler.worldMap.player.X / 32;
                            y = messageHandler.worldMap.player.Y / 32;



                            TankPacket tkPt = new TankPacket();
                            tkPt.PunchX       = x;
                            tkPt.PunchY       = y + i;
                            tkPt.MainValue    = 18;
                            tkPt.X            = messageHandler.worldMap.player.X;
                            tkPt.Y            = messageHandler.worldMap.player.Y;
                            tkPt.ExtDataMask &= ~0x04;
                            tkPt.ExtDataMask &= ~0x40;
                            tkPt.ExtDataMask &= ~0x10000;
                            tkPt.NetID        = -1;
                            PacketSending.SendPacketRaw(4, tkPt.PackForSendingRaw(), realPeer);
                            tkPt.NetID       = -1;
                            tkPt.PacketType  = 3;
                            tkPt.ExtDataMask = 0;
                            PacketSending.SendPacketRaw(4, tkPt.PackForSendingRaw(), realPeer);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void SpoofedPingReply(TankPacket tPacket)
        {
            if (worldMap == null)
            {
                return;
            }
            TankPacket p = new TankPacket();

            p.PacketType     = (int)NetTypes.PacketTypes.PING_REPLY;
            p.PunchX         = (int)1000.0f;
            p.PunchY         = (int)250.0f;
            p.X              = 64.0f;
            p.Y              = 64.0f;
            p.MainValue      = tPacket.MainValue;                                                    // GetTickCount()
            p.SecondaryNetID = (int)Proxyhelper.HashBytes(BitConverter.GetBytes(tPacket.MainValue)); // HashString of it

            // rest is 0 by default to not get detected by ac.
            packetSender.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p.PackForSendingRaw(), Proxyhelper.realPeer);
        }
Ejemplo n.º 10
0
        private void button1_Click_2(object sender, EventArgs e)
        {
            try
            {
                TankPacket p2 = new TankPacket();
                p2.PacketType = (int)NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ;
                if (messageHandler.worldMap == null)
                {
                    return;
                }
                custom_collect_x.Text = messageHandler.worldMap.player.X.ToString(); // crahp
                custom_collect_y.Text = messageHandler.worldMap.player.Y.ToString(); // crahp
                p2.X         = int.Parse(custom_collect_x.Text);
                p2.Y         = int.Parse(custom_collect_y.Text);
                p2.MainValue = int.Parse(custom_collect_uid.Text);

                PacketSending.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, p2.PackForSendingRaw(), MainForm.realPeer);
            }
            catch // ignore exception
            {
            }
        }
Ejemplo n.º 11
0
        private void button14_Click(object sender, EventArgs e)
        {
            TankPacket p = new TankPacket();

            p.PacketType = (int)NetTypes.PacketTypes.SET_CHARACTER_STATE;
            p.X          = 1000;
            p.Y          = 300;
            p.YSpeed     = 1000;
            p.NetID      = messageHandler.worldMap.netID;
            if (cheat_speed.Checked)
            {
                p.XSpeed = 100000;
            }
            else
            {
                p.XSpeed = 300;
            }
            p.MainValue = 1;
            byte[] data = p.PackForSendingRaw();
            Buffer.BlockCopy(BitConverter.GetBytes(8487168), 0, data, 1, 3);
            PacketSending.SendPacketRaw((int)NetTypes.NetMessages.GAME_PACKET, data, proxyPeer);
        }
Ejemplo n.º 12
0
        public string HandlePacketFromClient(ENetPacket packet) // Why string? Oh yeah, it's the best thing to also return a string response for anything you want!
        {
            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();

            switch ((NetTypes.NetMessages)data[0])
            {
            case NetTypes.NetMessages.GENERIC_TEXT:
                string str = GetProperGenericText(data);

                MainForm.LogText += ("[" + DateTime.UtcNow + "] (CLIENT): String package fetched:\n" + str + "\n");
                if (str.StartsWith("action|"))
                {
                    string actionExecuted = str.Substring(7, str.Length - 7);
                    string inputPH        = "input\n|text|";
                    if (actionExecuted.StartsWith("enter_game"))
                    {
                        if (MainForm.blockEnterGame)
                        {
                            return("Blocked enter_game packet!");
                        }
                        enteredGame = true;
                    }
                    else if (actionExecuted.StartsWith(inputPH))
                    {
                        string text = actionExecuted.Substring(inputPH.Length);

                        if (text.Length > 0)
                        {
                            if (text.StartsWith("/"))     // bAd hAcK - but also lazy, so i'll be doing this.
                            {
                                switch (text)
                                {
                                case "/banworld":
                                {
                                    banEveryoneInWorld();
                                    return("called /banworld, attempting to ban everyone who is in world (requires admin/owner)");
                                }
                                break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    // for (int i = 0; i < 1000; i++) packetSender.SendPacket(2, "action|refresh_item_data\n", MainForm.realPeer);
                    string[] lines = str.Split('\n');

                    string tankIDName = "";
                    foreach (string line in lines)
                    {
                        string[] lineToken = line.Split('|');
                        if (lineToken.Length != 2)
                        {
                            continue;
                        }
                        switch (lineToken[0])
                        {
                        case "tankIDName":
                            tankIDName = lineToken[1];
                            break;

                        case "tankIDPass":
                            MainForm.tankIDPass = lineToken[1];
                            break;

                        case "requestedName":
                            MainForm.requestedName = lineToken[1];
                            break;
                        }
                    }
                    MainForm.tankIDName = tankIDName;

                    bool hasAcc = false;

                    packetSender.SendPacket((int)NetTypes.NetMessages.GENERIC_TEXT, MainForm.CreateLogonPacket(), MainForm.realPeer);
                    return("Sent logon packet!");    // handling logon over proxy
                }
                break;

            case NetTypes.NetMessages.GAME_MESSAGE:
                string str2 = GetProperGenericText(data);
                MainForm.LogText += ("[" + DateTime.UtcNow + "] (CLIENT): String package fetched:\n" + str2 + "\n");
                if (str2.StartsWith("action|"))
                {
                    string actionExecuted = str2.Substring(7, str2.Length - 7);
                    if (actionExecuted == "quit")
                    {
                        MainForm.token          = 0;
                        MainForm.Growtopia_IP   = MainForm.Growtopia_Master_IP;
                        MainForm.Growtopia_Port = MainForm.Growtopia_Master_Port;

                        if (MainForm.realPeer != null && MainForm.proxyPeer != null)
                        {
                            if (MainForm.realPeer.State == ENetPeerState.Connected)
                            {
                                MainForm.realPeer.Disconnect(0);
                            }
                            if (MainForm.proxyPeer.State == ENetPeerState.Connected)
                            {
                                MainForm.proxyPeer.Disconnect(0);
                            }
                        }
                    }
                }
                break;

            case NetTypes.NetMessages.GAME_PACKET:
            {
                TankPacket p = TankPacket.UnpackFromPacket(data);
                switch ((NetTypes.PacketTypes)(byte) p.PacketType)
                {
                case NetTypes.PacketTypes.APP_INTEGRITY_FAIL:                                             /*rn definitely just blocking autoban packets,
                                                                                                           * usually a failure of an app integrity is never good
                                                                                                           * and usually used for security stuff*/
                    return("Possible autoban packet with id (25) from your GT Client has been blocked."); // remember, returning anything will interrupt sending this packet. To Edit packets, load/parse them and you may just resend them like normally after fetching their bytes.

                case NetTypes.PacketTypes.PLAYER_LOGIC_UPDATE:
                    if (p.PunchX > 0 || p.PunchY > 0)
                    {
                        MainForm.LogText += ("[" + DateTime.UtcNow + "] (PROXY): PunchX/PunchY detected, pX: " + p.PunchX.ToString() + " pY: " + p.PunchY.ToString() + "\n");
                    }
                    MainForm.isFacingSwapped = IsBitSet(p.CharacterState, 4);

                    worldMap.player.X = (int)p.X;
                    worldMap.player.Y = (int)p.Y;
                    break;

                case NetTypes.PacketTypes.TILE_CHANGE_REQ:
                    if (p.MainValue == 18 && MainForm.redDamageToBlock)
                    {
                        // playingo
                        p.SecondaryPadding = -1;
                        p.ExtDataMask     |= 1 << 27;
                        p.Padding          = 1;
                        packetSender.SendPacketRaw(4, p.PackForSendingRaw(), MainForm.realPeer);
                        return("");
                    }
                    break;

                case NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ:             // just incase, to keep better track of items incase something goes wrong
                    worldMap.dropped_ITEMUID = p.MainValue;
                    if (MainForm.blockCollecting)
                    {
                        return("");
                    }
                    break;

                default:
                    break;
                }
            }
            break;

            case NetTypes.NetMessages.TRACK:
                return("Packet with messagetype used for tracking was blocked!");

            case NetTypes.NetMessages.LOG_REQ:
                return("Log request packet from client was blocked!");

            default:
                break;
            }

            packetSender.SendData(data, MainForm.realPeer, ENetPacketFlags.Reliable);
            return(string.Empty);
        }
Ejemplo n.º 13
0
        void doTheNukaz()
        {
            while (checkBox3.Checked)
            {
                Thread.Sleep(10);
                if (realPeer != null)
                {
                    if (realPeer.State != ENetPeerState.Connected)
                    {
                        return;
                    }

                    int c = 3;
                    if (checkBox4.Checked)
                    {
                        c = 4;
                    }
                    for (int i = 0; i < c; i++)
                    {
                        int x, y;
                        x = messageHandler.worldMap.player.X / 32;
                        y = messageHandler.worldMap.player.Y / 32;

                        if (!checkBox5.Checked)
                        {
                            if (i == 0)
                            {
                                x = x + 1;
                            }
                            else if (i == 1)
                            {
                                x = x - 1;
                            }
                            else if (i == 2)
                            {
                                y = y - 1;
                            }
                            if (checkBox4.Checked)
                            {
                                if (i == 3)
                                {
                                    y = y + 1;
                                }
                            }
                        }
                        else
                        {
                            if (i == 1)
                            {
                                x -= 1;
                            }
                            if (i == 2)
                            {
                                x -= 2;
                            }
                        }

                        Thread.Sleep(166);
                        TankPacket tkPt = new TankPacket();
                        tkPt.PunchX       = x;
                        tkPt.PunchY       = y;
                        tkPt.MainValue    = 18;
                        tkPt.X            = messageHandler.worldMap.player.X;
                        tkPt.Y            = messageHandler.worldMap.player.Y;
                        tkPt.ExtDataMask &= ~0x04;
                        tkPt.ExtDataMask &= ~0x40;
                        tkPt.ExtDataMask &= ~0x10000;
                        tkPt.NetID        = -1;
                        PacketSending.SendPacketRaw(4, tkPt.PackForSendingRaw(), realPeer);
                        tkPt.NetID       = -1;
                        tkPt.PacketType  = 3;
                        tkPt.ExtDataMask = 0;
                        PacketSending.SendPacketRaw(4, tkPt.PackForSendingRaw(), realPeer);
                    }
                }
            }
        }
Ejemplo n.º 14
0
        public string HandlePacketFromClient(ref ENetPeer peer, ENetPacket packet) // Why string? Oh yeah, it's the best thing to also return a string response for anything you want!
        {
            if (peer.IsNull)
            {
                return("");
            }
            if (peer.State != ENetPeerState.Connected)
            {
                return("");
            }
            if (Proxyhelper.realPeer.IsNull)
            {
                return("");
            }
            if (Proxyhelper.realPeer.State != ENetPeerState.Connected)
            {
                return("");
            }

            bool respondToBotPeers = true;

            byte[] data = packet.Data.ToArray();

            string log = string.Empty;



            switch ((NetTypes.NetMessages)data[0])
            {
            case NetTypes.NetMessages.GENERIC_TEXT:
                string str = GetProperGenericText(data);

                if (str.StartsWith("action|"))
                {
                    string actionExecuted = str.Substring(7, str.Length - 7);
                    string inputPH        = "input\n|text|";
                    if (actionExecuted.StartsWith("enter_game"))
                    {
                        respondToBotPeers = true;
                        if (Proxyhelper.globalUserData.blockEnterGame)
                        {
                            return("Blocked enter_game packet!");
                        }
                        enteredGame = true;
                    }
                    else if (actionExecuted.StartsWith(inputPH))
                    {
                        string text = actionExecuted.Substring(inputPH.Length);

                        if (text.Length > 0)
                        {
                            if (text.StartsWith("/"))     // bAd hAcK - but also lazy, so i'll be doing this.
                            {
                                switch (text)
                                {
                                case "/banworld":
                                {
                                    banEveryoneInWorld();
                                    return("called /banworld, attempting to ban everyone who is in world (requires admin/owner)");
                                }
                                break;

                                default:
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    // for (int i = 0; i < 1000; i++) packetSender.SendPacket(2, "action|refresh_item_data\n", MainForm.realPeer);
                    respondToBotPeers = false;
                    string[] lines = str.Split('\n');

                    string tankIDName = "";
                    foreach (string line in lines)
                    {
                        string[] lineToken = line.Split('|');
                        if (lineToken.Length != 2)
                        {
                            continue;
                        }
                        switch (lineToken[0])
                        {
                        case "tankIDName":
                            tankIDName = lineToken[1];
                            break;

                        case "tankIDPass":
                            Proxyhelper.globalUserData.tankIDPass = lineToken[1];
                            break;

                        case "requestedName":
                            Proxyhelper.globalUserData.requestedName = lineToken[1];
                            break;

                        case "token":
                            Proxyhelper.globalUserData.token = int.Parse(lineToken[1]);
                            break;

                        case "user":
                            Proxyhelper.globalUserData.userID = int.Parse(lineToken[1]);
                            break;

                        case "lmode":
                            Proxyhelper.globalUserData.lmode = int.Parse(lineToken[1]);
                            break;
                        }
                    }
                    Proxyhelper.globalUserData.tankIDName = tankIDName;

                    bool hasAcc = false;

                    packetSender.SendPacket((int)NetTypes.NetMessages.GENERIC_TEXT, Proxyhelper.CreateLogonPacket(), Proxyhelper.realPeer);
                    return("Sent logon packet!");    // handling logon over proxy
                }
                break;

            case NetTypes.NetMessages.GAME_MESSAGE:
                string str2 = GetProperGenericText(data);

                if (str2.StartsWith("action|"))
                {
                    string actionExecuted = str2.Substring(7);
                    if (actionExecuted.StartsWith("quit") && !actionExecuted.StartsWith("quit_to_exit"))
                    {
                        // super multibotting will not mirror all packets in here (the "quit" action), cuz i found it unnecessary, although, you can enable that by pasting the code that does it.
                        respondToBotPeers = true;
                        Proxyhelper.globalUserData.token          = -1;
                        Proxyhelper.globalUserData.Growtopia_IP   = Proxyhelper.globalUserData.Growtopia_Master_IP;
                        Proxyhelper.globalUserData.Growtopia_Port = Proxyhelper.globalUserData.Growtopia_Master_Port;

                        if (Proxyhelper.realPeer != null)
                        {
                            if (!Proxyhelper.realPeer.IsNull)
                            {
                                if (Proxyhelper.realPeer.State != ENetPeerState.Disconnected)
                                {
                                    Proxyhelper.realPeer.Disconnect(0);
                                }
                            }
                        }
                        if (Proxyhelper.proxyPeer != null)
                        {
                            if (!Proxyhelper.proxyPeer.IsNull)
                            {
                                if (Proxyhelper.proxyPeer.State == ENetPeerState.Connected)
                                {
                                    Proxyhelper.proxyPeer.Disconnect(0);
                                }
                            }
                        }
                    }
                    else if (actionExecuted.StartsWith("join_request\nname|"))     // ghetto fetching of worldname
                    {
                        string[] rest          = actionExecuted.Substring(18).Split('\n');
                        string   joinWorldName = rest[0];
                        Console.WriteLine($"Joining world {joinWorldName}...");
                    }
                }
                break;

            case NetTypes.NetMessages.GAME_PACKET:
            {
                TankPacket p = TankPacket.UnpackFromPacket(data);

                switch ((NetTypes.PacketTypes)(byte) p.PacketType)
                {
                case NetTypes.PacketTypes.APP_INTEGRITY_FAIL:                                             /*rn definitely just blocking autoban packets,
                                                                                                           * usually a failure of an app integrity is never good
                                                                                                           * and usually used for security stuff*/
                    return("Possible autoban packet with id (25) from your GT Client has been blocked."); // remember, returning anything will interrupt sending this packet. To Edit packets, load/parse them and you may just resend them like normally after fetching their bytes.

                case NetTypes.PacketTypes.PLAYER_LOGIC_UPDATE:
                    if (p.PunchX > 0 || p.PunchY > 0)
                    {
                        Proxyhelper.LogText += ("[" + DateTime.UtcNow + "] (PROXY): PunchX/PunchY detected, pX: " + p.PunchX.ToString() + " pY: " + p.PunchY.ToString() + "\n");
                    }
                    Proxyhelper.globalUserData.isFacingSwapped = IsBitSet(p.CharacterState, 4);

                    worldMap.player.X = (int)p.X;
                    worldMap.player.Y = (int)p.Y;
                    break;

                case NetTypes.PacketTypes.PING_REPLY:
                {
                    //SpoofedPingReply(p);
                    return("Blocked ping reply!");
                }

                case NetTypes.PacketTypes.TILE_CHANGE_REQ:
                    respondToBotPeers = true;

                    if (p.MainValue == 32)
                    {
                        /*MessageBox.Show("Log of potentially wanted received GAME_PACKET Data:" +
                         * "\npackettype: " + data[4].ToString() +
                         * "\npadding byte 1|2|3: " + data[5].ToString() + "|" + data[6].ToString() + "|" + data[7].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);*/

                        Proxyhelper.globalUserData.lastWrenchX = (short)p.PunchX;
                        Proxyhelper.globalUserData.lastWrenchY = (short)p.PunchY;
                    }
                    else if (p.MainValue == 18 && Proxyhelper.globalUserData.redDamageToBlock)
                    {
                        // playingo
                        p.SecondaryPadding = -1;
                        p.ExtDataMask     |= 1 << 27;         // 28
                        p.Padding          = 1;
                        packetSender.SendPacketRaw(4, p.PackForSendingRaw(), Proxyhelper.realPeer);
                        return("");
                    }
                    break;

                case NetTypes.PacketTypes.ITEM_ACTIVATE_OBJ:             // just incase, to keep better track of items incase something goes wrong
                    worldMap.dropped_ITEMUID = p.MainValue;
                    if (Proxyhelper.globalUserData.blockCollecting)
                    {
                        return("");
                    }
                    break;

                default:
                    //MainForm.LogText += ("[" + DateTime.UtcNow + "] (CLIENT): Got Packet Type: " + p.PacketType.ToString() + "\n");
                    break;
                }

                if (data[4] > 23)
                {
                    log = $"(CLIENT) Log of potentially wanted received GAME_PACKET Data:" +
                          "\npackettype: " + data[4].ToString() +
                          "\npadding byte 1|2|3: " + data[5].ToString() + "|" + data[6].ToString() + "|" + data[7].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;
                }
            }

            break;

            case NetTypes.NetMessages.TRACK:
                return("Packet with messagetype used for tracking was blocked!");

            case NetTypes.NetMessages.LOG_REQ:
                return("Log request packet from client was blocked!");

            default:
                break;
            }

            packetSender.SendData(data, Proxyhelper.realPeer);

            return(log);
        }
Ejemplo n.º 15
-1
        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);
            }
        }
Ejemplo n.º 16
-1
        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);
            }
        }