Example #1
0
        public void sendAreaInit(Character character)
        {
            MartialClient connection = character.getAccount().mClient;

            if (character.getInnitedAreas().Contains(this.aID))
            {
                return;
            }
            foreach (Character aCharacter in areaCharacters)
            {
                if (aCharacter == character)
                {
                    continue;
                }
                try {
                    Console.WriteLine("AreaInt> Packet sent for {0} from {1}", character.getName(), aCharacter.getName());
                    connection.WriteRawPacket(CharacterPackets.extCharPacket(aCharacter));
                } catch (Exception e) { Console.WriteLine(e); }
            }
            foreach (NPC aNPC in npcs)
            {
                try {
                    connection.WriteRawPacket(aNPC.npcSpawn(character));
                } catch (Exception e) { Console.WriteLine(e); }
            }
            foreach (Mob aMob in mobs)
            {
                try {
                    connection.WriteRawPacket(aMob.getInitialPacket());
                } catch (Exception e) { Console.WriteLine(e); }
            }
        }
Example #2
0
        public static void SendMessage(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook SendMessage handling while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int    messageType = p.ReadInt();          // identifier of message type maybe?
            string receiver    = p.ReadString(20);     // receiver name

            MiscFunctions.obscureString(receiver);
            if (!MySQLTool.NameTaken(receiver))
            {
                return;
            }
            int    messageLength = p.ReadInt();          // message length
            string message       = p.ReadString(messageLength);

            MiscFunctions.obscureString(message);

            OutPacket op = new OutPacket(20);

            op.WriteInt(20);
            op.WriteShort(4);
            op.WriteShort(0x53);
            op.WriteInt(718349825);
            op.WriteInt(chr.getuID());
            op.WriteInt(-1089732352);
            c.WriteRawPacket(op.ToArray());
        }
Example #3
0
 public static void LogCheat(HackTypes type, MartialClient c, string msg = "", params object[] pObjects)
 {
     //Cheaters.Add(type, c);
     FileWriter.Write(Constants.CheatWriting, "[" + c.getAccount().name + "|" + c.Label + "]" + string.Format(msg + "\n", pObjects));
     //TODO:
     //Log msg and such to file.
 }
        private void OnClientAccepted(Socket client)
        {
            MartialClient mc = new MartialClient(client, null, null);

            byte[] ip   = Encoding.ASCII.GetBytes((mc.Label == "127.0.0.1") ? ("127.0.0.1") : (mc.Label == Constants.RouterIP) ? (Constants.RouterIP) : (Constants.ExternalIP));
            byte[] port = Encoding.ASCII.GetBytes(Convert.ToString(Constants.HellPort));
            byte[] pckt = new byte[ip.Length + port.Length + 13];

            pckt[0] = (byte)pckt.Length;      //packet length
            pckt[4] = (byte)0x17;             //packet header

            for (int i = 0; i < ip.Length; i++)
            {
                pckt[i + 8] = ip[i];                 //add ip in the packet
            }

            pckt[(8 + ip.Length)] = (byte)0x20;             //add space between ip and port

            for (int i = 0; i < port.Length; i++)
            {
                pckt[(i + 8 + ip.Length + 1)] = port[i];                 //add port in the packet
            }

            mc.WriteRawPacket(pckt);
            Logger.WriteLog(Logger.LogTypes.CDisp, "Client {0} handled - end connection.", mc.Label);
            mc.PoorDispose();
        }
Example #5
0
        public static void SetFame(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setfame [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);
            if(player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Wrong player name has been given.");
                return;
            }

            int fameAmount;
            if(!Int32.TryParse(cmd.commandArgs[1], out fameAmount))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                return;
            }

            if(fameAmount < 0 || fameAmount > 2147483647)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Setfame range goes from 0 - 2147483647.");
                return;
            }

            StaticPackets.setCharacterFame(player, fameAmount);
            StaticPackets.sendSystemMessageToClient(c, 1, player.getName() + "'s fame has been set up to: " + fameAmount + "!");
            return;
        }
Example #6
0
        public static void SetLevel(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs.Length < 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setlevel [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);
            if(player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Wrong player name has been given.");
                return;
            }

            byte level;
            if(!Byte.TryParse(cmd.commandArgs[1], out level))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                return;
            }

            if(level < 0 || level > 255)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Setlevel range goes from 0 - 255.");
                return;
            }

            StaticPackets.setCharacterLevel(player, level);
            StaticPackets.sendSystemMessageToClient(c, 1, player.getName() + "'s level has been set up to: " + level + "!");
            return;
        }
Example #7
0
        public static void SetMHP(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs.Length != 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/setmhp [name] [amount]");
                return;
            }

            Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[0]);
            if(player == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found.");
                return;
            }

            int amount = -1;
            if(!Int32.TryParse(cmd.commandArgs[1], out amount))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse amount of MHPoints.");
                return;
            }

            player.getAccount().MHPoints = amount;
            StaticPackets.setMHPoints(player.getAccount().mClient, amount);
            return;
        }
Example #8
0
        public static void LauncherValidate(MartialClient c, InPacket p)
        {
            byte pinLength = p.ReadByte();
            byte uNameLength = p.ReadByte();
            byte passWLength = p.ReadByte();
            p.ReadByte();
            string pin = MiscFunctions.obscureString(p.ReadString(4));
            string uN = MiscFunctions.obscureString(p.ReadString(16));
            string pW = MiscFunctions.obscureString(p.ReadString(12));

            Account account = new Account();
            if(account.Load(uN, pW, pin) != Account.AccountLoadErrors.Success)
            {
                c.WriteRawPacket(Constants.accDoesntExist);
                Logger.WriteLog(Logger.LogTypes.HEmi, "Authorization error for [{0} | {1} | {2}]", uN, pW, pin);
                c.Close();
                return;
            }
            Logger.WriteLog(Logger.LogTypes.HEmi, "User passed authorization [{0} | {1} | {2}]", uN, pW, pin);
            account.mClient = c;
            c.setAccount(account);
            account.LoadCharacters();

            if(c.getAccount().characters.Count() > 0)
            {
                c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), false).Concat(Constants.emptyAccount).ToArray());
            }
            c.WriteRawPacket(Constants.emptyAccount);
            c.WriteRawPacket(LoginPacketCreator.initAccount(c.getAccount()));
        }
Example #9
0
        public static void AttackDefendState(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(0x05);
            op.WriteShort(0x06);
            op.WriteByte(0x01);
            op.WriteByte(0x33);
            op.WriteByte(0x15);
            op.WriteByte(0x08);
            op.WriteInt(chr.getuID());
            op.WriteShort(p.ReadByte());
            op.WriteByte(0x10);
            op.WriteByte(0x29);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), op.ToArray());
        }
Example #10
0
        public static void ViewInventory(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked viewInventory with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(28);

            op.WriteInt(28);
            op.WriteShort(0x04);
            op.WriteShort(0x1e);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteShort(0x01);
            op.WriteByte(0xf8);
            op.WriteByte(0x01);

            p.Skip(4);

            op.WriteBytes(p.ReadBytes(4));
            op.WriteByte(0x9e);
            op.WriteByte(0x0f);
            op.WriteByte(0xbf);
            c.WriteRawPacket(op.ToArray());
        }
Example #11
0
        public static void RequestSpawn(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter != null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to spawn a character while being ingame.");
                c.Close();
                return;
            }

            byte selected_character = p.ReadByte();

            if (!c.getAccount().characters.ContainsKey(selected_character))
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Wrong target '{0}' has been selected by selection packet", selected_character);
                c.Close();
                return;
            }

            Character target = c.getAccount().characters[selected_character];

            c.getAccount().activeCharacter = target;

            WMap.Instance.addToCharacters(target);
            CharacterFunctions.setPlayerPosition(target, target.getPosition()[0], target.getPosition()[1], target.getMap());
            CharacterFunctions.calculateCharacterStatistics(target);
            StaticPackets.sendSystemMessageToClient(c, 1, Constants.WelcomeMessage);
        }
        public static void SendMessage(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook SendMessage handling while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int messageType = p.ReadInt(); // identifier of message type maybe?
            string receiver = p.ReadString(20); // receiver name
            MiscFunctions.obscureString(receiver);
            if(!MySQLTool.NameTaken(receiver))
            {

                return;
            }
            int messageLength = p.ReadInt(); // message length
            string message = p.ReadString(messageLength);
            MiscFunctions.obscureString(message);

            OutPacket op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteShort(4);
            op.WriteShort(0x53);
            op.WriteInt(718349825);
            op.WriteInt(chr.getuID());
            op.WriteInt(-1089732352);
            c.WriteRawPacket(op.ToArray());
        }
        public static void HandleFriends(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook HandleFriends while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte communityIndex = p.ReadByte();
            string personName = MiscFunctions.obscureString(p.ReadString(16));

            Community com = chr.getCommunity();

            switch(managementType)
            {
                case 0:
                    case 1:
                    {
                        if(!com.addPersona(managementType, communityIndex, personName))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                case 2:
                    case 3:
                    {
                        if(!com.removePersona((byte)(managementType - 2), communityIndex))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Sorry. Something went wrong!");
                            return;
                        }
                        break;
                    }
                default:
                {
                    //tuffnucks you!
                    return;
                }
            }

            OutPacket op = new OutPacket(40);
            op.WriteInt(40);
            op.WriteShort(0x04);
            op.WriteShort(0x31);
            op.WriteInt(134652417);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(communityIndex);
            op.WritePaddedString(personName, 16);
            op.WriteInt(-1089495552);
            c.WriteRawPacket(op.ToArray());
        }
Example #14
0
 public static void ListCommands(MartialClient c, InCommand cmd)
 {
     StaticPackets.sendSystemMessageToClient(c, 1, "Available commands: ");
     foreach (string cmdName in CommandProcessor.getCommandHandlers().Keys)
     {
         StaticPackets.sendSystemMessageToClient(c, 1, cmdName);
     }
 }
Example #15
0
 public static void ListCommands(MartialClient c, InCommand cmd)
 {
     StaticPackets.sendSystemMessageToClient(c, 1, "Available commands: ");
     foreach(string cmdName in CommandProcessor.getCommandHandlers().Keys)
     {
         StaticPackets.sendSystemMessageToClient(c, 1, cmdName);
     }
 }
Example #16
0
        public static void MHShop(MartialClient c, InPacket p)
        {
            byte[] decrypted = p.ReadBytes(80);

            int itemIdentificator = BitConverter.ToInt32(decrypted, 0);

            ShopItem shopItem = ItemShop.Instance.getShopItemData(itemIdentificator);

            if (shopItem == null)
            {
                Console.WriteLine("wrong id selected..");
                return;
            }

            if (c.getAccount().MHPoints < shopItem.getPrice())
            {
                Console.WriteLine("teh hacksorz..");
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            Console.WriteLine("si: {0} | {1} | {2} | {3}", itemIdentificator, shopItem.getItemID(), shopItem.getItemQuantity(), shopItem.getPrice());

            OutPacket op = new OutPacket(156);

            op.WriteInt(156);
            op.WriteShort(0x04);
            op.WriteShort(0x4b);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteInt(1);
            op.WriteRepeatedByte(1, 4);
            op.WriteRepeatedByte(1, 4);
            op.WriteInt(shopItem.getItemID());
            op.WriteInt(shopItem.getItemQuantity());
            op.WriteInt(shopItem.getItemID());
            op.WriteInt(shopItem.getItemQuantity());
            op.WriteInt(shopItem.getItemID());
            op.WriteInt(shopItem.getItemQuantity());
            op.WriteInt(shopItem.getItemID());
            op.WriteInt(shopItem.getItemQuantity());             // item quantity
            op.WriteRepeatedByte(1, 112);
            //op.Position = 152;
            //c.getAccount().MHPoints -= shopItem.getPrice();
            //op.WriteInt(shopItem.getPrice());
            c.WriteRawPacket(op.ToArray());

            Console.WriteLine(BitConverter.ToString(op.ToArray()));

            //TODO: Delivery items

            //System.Console.WriteLine("sent: {0}", System.BitConverter.ToString(op.ToArray()));
        }
Example #17
0
 public static void Announce(MartialClient c, InCommand cmd)
 {
     if(cmd.commandArgs == null)
     {
         StaticPackets.sendSystemMessageToClient(c, 1, "/announce [text]");
         return;
     }
     string announcing = string.Join(" ", cmd.commandArgs);
     StaticPackets.sendWorldAnnounce(announcing);
     return;
 }
Example #18
0
        public static void Announce(MartialClient c, InCommand cmd)
        {
            if (cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/announce [text]");
                return;
            }
            string announcing = string.Join(" ", cmd.commandArgs);

            StaticPackets.sendWorldAnnounce(announcing);
            return;
        }
Example #19
0
 private void OnClientAccepted(Socket client)
 {
     MartialClient mc = new MartialClient(client, null, null);
     byte[] pckt = new byte[16];
     pckt[0] = (byte)pckt.Length; //packet length
     pckt[4] = 0x01; //amount of servers
     pckt[8] = 0x02; //server names are hard coded in client itself. they are distinctable by this byte
     pckt[12] = 0x01; //server status
     mc.WriteRawPacket(pckt);
     Logger.WriteLog(Logger.LogTypes.LList, "Client {0} handled - end connection.", mc.Label);
     mc.PoorDispose();
 }
Example #20
0
        public static void quitGameWorld(MartialClient c)
        {
            if (c.getAccount().activeCharacter == null)
            {
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaLeave(chr, chr.getArea());
            WMap.Instance.removeFromCharacters(chr);
            c.getAccount().activeCharacter = null;
        }
Example #21
0
        public static void MoveToInv(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte fromCargoIndex = p.ReadByte();
            byte toInvSlot      = p.ReadByte();
            byte toInvLine      = p.ReadByte();
            byte toInvRow       = p.ReadByte();

            Cargo     cargo = chr.getCargo();
            Inventory inv   = chr.getInventory();

            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toInvSlot, toInvLine, toInvRow);

            cargo.updateCargo();

            if (!cargo.getCargoSaved().ContainsKey((byte)fromCargoIndex))
            {
                Console.WriteLine("Cannot moveItemToInv [item missing]");
                return;
            }
            Item itemF = cargo.getCargoSaved()[(byte)fromCargoIndex];

            if (!inv.moveFromCargo(itemF, fromCargoIndex, toInvRow, toInvLine))
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "do kurwy nendzy");
                return;
            }
            cargo.saveCargo();

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(45);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteByte(toInvSlot);
            op.WriteByte(toInvLine);
            op.WriteByte(toInvRow);
            op.WriteShort(-16625);
            c.WriteRawPacket(op.ToArray());
        }
Example #22
0
        public static void ShortcutBar(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook bar skill while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte barIndex = p.ReadByte();
            byte actionID = p.ReadByte();

            p.Skip(2);
            int thingID = p.ReadInt();

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(17);
            op.WriteInt(135595521);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(barIndex);
            op.WriteByte(actionID);
            op.WriteInt(thingID);

            if (actionID >= 1 && actionID <= 4)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID);
            }
            else if (actionID == 6)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 256);
            }
            else if (actionID == 0)
            {
                chr.getSkillBar().removeFromSkillBar(barIndex);
            }
            else if (actionID == 5)
            {
                chr.getSkillBar().addToSkillBar(barIndex, thingID + 512);
            }

            c.WriteRawPacket(op.ToArray());
        }
Example #23
0
        public static void ReturnToSelection(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.CharacterSelection, c, "Hooked returnToSelection with null of activeCharacter");
                c.Close();
                return;
            }

            c.getAccount().activeCharacter.getInventory().updateInv();
            c.getAccount().activeCharacter.getInventory().saveInv();
            c.getAccount().activeCharacter.getCommunity().relistCommunities();
            CharacterFunctions.quitGameWorld(c);
            c.getAccount().relistCharacters();
            c.WriteRawPacket(LoginPacketCreator.initCharacters(c.getAccount(), true));
        }
Example #24
0
        public static void UseItem(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook useItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(1);
            byte usingIndex = p.ReadByte();
            Item item       = chr.getInventory().getItemBySeqIndexing(usingIndex);

            if (item == null)
            {
                Logger.LogCheat(Logger.HackTypes.Items, c, "Tried to use not existing item.");
                return;
            }

            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());

            if (!itemData.getClassUsable()[chr.getcClass() - 1])
            {
                Console.WriteLine("not for teh class..");
                return;
            }

            if (itemData.getMinLvl() > chr.getLevel() || itemData.getMaxLvl() < chr.getLevel())
            {
                Console.WriteLine("not for yar level..");
                return;
            }

            if (itemData.getFaction() != 0 && chr.getFaction() != itemData.getFaction())
            {
                Console.WriteLine("not for yah faction..");
                return;
            }

            p.Skip(2);
            MainItemUsage.useItem(chr, item, usingIndex, p);
        }
Example #25
0
        public static void ItemCreate(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs == null)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/item [itemid] [*amount]");
                return;
            }

            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            int itemID = 0;
            Int32.TryParse(cmd.commandArgs[0], out itemID);
            if(itemID < 200000000 || itemID > 299999999)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Item ID range goes from 200.000.000 - 299.999.999.");
                return;
            }
            if(ItemDataCache.Instance.getItemData(itemID).getID() == 0)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Selected item wasn't found.");
                return;
            }

            short itemQuantity = 1;
            Int16.TryParse(cmd.commandArgs[1], out itemQuantity);
            if(itemQuantity > short.MaxValue)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Items amount, can't be bigger than 100!");
                return;
            }

            c.WriteRawPacket(ItemPackets.createDroppedItem(WMap.Instance.items.Count, chr.getPosition()[0], chr.getPosition()[1], itemID, itemQuantity));
            StaticPackets.sendSystemMessageToClient(c, 1, "Item of ID: " + itemID + "|" + WMap.Instance.items.Count + "|" + itemQuantity + ", has been created at coords: ");
            StaticPackets.sendSystemMessageToClient(c, 1, chr.getPosition()[0] + ":" + chr.getPosition()[1] + ":" + chr.getMap() + "!");
            WMap.Instance.items.Add(WMap.Instance.items.Count, new Item(itemID, itemQuantity));
            return;
        }
Example #26
0
        public static void MoveFromInv(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo -> inv while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte managementType = p.ReadByte();
            byte fromInvIndex = p.ReadByte();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();

            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3} | {4}", managementType, fromInvIndex, toCargoSlot, toCargoLine, toCargoRow);
            if(!cargo.insertItemFromInventory(chr.getInventory(), fromInvIndex, toCargoRow, toCargoLine))
            {
                Console.WriteLine("da fuaaark");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(44);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(managementType);
            op.WriteByte(fromInvIndex);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            op.WriteByte(42);
            c.WriteRawPacket(op.ToArray());
        }
Example #27
0
        public static void Move(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook cargo movement while not being ingame.");
                c.Close();
                return;
            }

            byte fromCargoIndex = p.ReadByte();
            short unknownMovement = p.ReadShort();
            byte toCargoSlot = p.ReadByte();
            byte toCargoLine = p.ReadByte();
            byte toCargoRow = p.ReadByte();
            Character chr = c.getAccount().activeCharacter;
            Cargo cargo = chr.getCargo();
            Console.WriteLine("Cargo > {0} | {1} | {2} | {3}", fromCargoIndex, toCargoSlot, toCargoLine, toCargoRow);

            if(!cargo.moveItem(fromCargoIndex, toCargoSlot, toCargoRow, toCargoLine))
            {
                Console.WriteLine("problem with move item");
                return;
            }

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(46);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteShort(1);
            op.WriteByte(fromCargoIndex);
            op.WriteShort(unknownMovement);
            op.WriteByte(toCargoSlot);
            op.WriteByte(toCargoLine);
            op.WriteByte(toCargoRow);
            c.WriteRawPacket(op.ToArray());
        }
        private void OnClientAccepted(Socket client)
        {
            MartialClient mc = new MartialClient(client, null, null);
            byte[] ip = Encoding.ASCII.GetBytes((mc.Label == "127.0.0.1") ? ("127.0.0.1") : (mc.Label == Constants.RouterIP) ? (Constants.RouterIP) : (Constants.ExternalIP));
            byte[] port = Encoding.ASCII.GetBytes(Convert.ToString(Constants.HellPort));
            byte[] pckt = new byte[ip.Length + port.Length + 13];

            pckt[0] = (byte)pckt.Length; //packet length
            pckt[4] = (byte)0x17; //packet header

            for(int i = 0;i < ip.Length;i++) {
                pckt[i + 8] = ip[i]; //add ip in the packet
            }

            pckt[(8 + ip.Length)] = (byte)0x20; //add space between ip and port

            for(int i = 0;i < port.Length;i++) {
                pckt[(i + 8 + ip.Length + 1)] = port[i]; //add port in the packet
            }

            mc.WriteRawPacket(pckt);
            Logger.WriteLog(Logger.LogTypes.CDisp, "Client {0} handled - end connection.", mc.Label);
            mc.PoorDispose();
        }
Example #29
0
 public static void sendSystemMessageToClient(MartialClient c, byte messageType, string message, string sender = null)
 {
     OutPacket p = new OutPacket(45 + message.Length);
     p.WriteInt(45 + message.Length);
     p.WriteShort(0x05);
     p.WriteShort(0x07);
     p.WriteShort(0x01);
     p.WriteZero(7);
     p.WriteByte(0x01);
     p.WriteShort(messageType);
     if(sender == null)
         p.WritePaddedString("*", 20);
     else
         p.WritePaddedString(sender, 20);
     p.WriteInt(0x3e);
     p.WriteString(message);
     c.WriteRawPacket(p.ToArray());
 }
Example #30
0
 public static void setMHPoints(MartialClient c, int amount)
 {
     OutPacket p = new OutPacket(12);
     p.WriteInt(12);
     p.WriteShort(3);
     p.WriteShort(8);
     p.WriteInt(amount);
     c.WriteRawPacket(p.ToArray());
 }
Example #31
0
 private void OnClientAccepted(Socket client)
 {
     MartialClient mc = new MartialClient(client, m_processor, m_clients.Remove);
     m_clients.Add(mc);
     mc.WriteRawPacket(Constants.authSuccess);
     Logger.WriteLog(Logger.LogTypes.HEmi, "Client {0} connected to Hell Emissary.", mc.Label);
 }
Example #32
0
        public static void Chat(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked chat with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte messageType = (byte)p.ReadShort();
            string receiver = MiscFunctions.obscureString(p.ReadString(17));
            byte messageLength = (byte)p.ReadInt();
            if(messageLength > 65)
            {
                Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to send a message of size {0}", messageLength);
                c.Close();
                return;
            }
            string message = p.ReadString(messageLength);

            switch(messageType)
            {
                case 0: WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), StaticPackets.chatRelay(chr, messageType, message)); break;
                case 1:
                {
                    if(receiver == null)
                        return;

                    Character player = WMap.Instance.findPlayerByName(receiver);
                    if(player == null)
                    {
                        chr.getAccount().mClient.WriteRawPacket(StaticPackets.playerIsntConnected(chr));
                        break;
                    }

                    player.getAccount().mClient.WriteRawPacket(StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 6: // karma notice
                {
                    if(chr.getKarmaMessagingTimes() == 0)
                    {

                    }

                    WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 7: // "GM Shout"
                {
                    if(chr.getAccount().gmLvl == 0 && chr.getGMShoutMessagingCounts() == 0)
                    {

                    }

                    WMap.Instance.sendToAllCharactersExcept(chr, StaticPackets.chatRelay(chr, messageType, message));
                    break;
                }
                case 9: // admin commands
                {
                    string[] cmd = Regex.Split(message, " ");
                    if(chr.getAccount().gmLvl == 0)
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse GM Command {0}", cmd[0]);
                        c.Close();
                        break;
                    }

                    if(cmd.Length == 0)
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse null GM Command");
                        c.Close();
                        break;
                    }

                    if(cmd[0][0] != '/')
                    {
                        Logger.LogCheat(Logger.HackTypes.Chat, c, "Tried to parse command without '/' slash");
                        c.Close();
                        break;
                    }

                    CommandProcessor.ParseCommand(c, cmd);
                    break;
                }
                default:
                {
                    break;
                }
            }
        }
Example #33
0
        public static void CreateGuild(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            Guild guild = chr.getGuild();

            byte managementType = p.ReadByte(); // 0 - disband; 1 - create; 2 - donate; 3 - hat
            byte managementArg	= p.ReadByte(); // 1 - bang, 2 - mun, 3 - pa, 4 - nohing, 5 - dan, 6 - gak, 7 - gyo, 8 - gung
            string managementName = MiscFunctions.obscureString(p.ReadString(18));

            switch(managementType)
            {
                case 0:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild disband with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    guild.Delete();
                    WMap.Instance.removeGuild(guild);
                    foreach(GuildMember i in guild.guildMembers)
                    {
                        Character tmp = i.getOnlineCharacter();
                        tmp.getAccount().mClient.WriteRawPacket(GuildPackets.quitGuildForInternal(tmp));
                        WMap.Instance.getGrid(tmp.getMap()).sendTo3x3Area(tmp, tmp.getArea(), GuildPackets.quitGuildForExternals(tmp));
                        tmp.setGuild(null);
                        i.setOnlineCharacter(null);
                    }
                    return;
                }
                case 1:
                {
                    if(guild != null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild create with char that is in guild");
                        c.Close();
                        return;
                    }

                    Guild newGuild = new Guild(managementArg, managementName);
                    c.WriteRawPacket(GuildPackets.createGuildResponse(chr, managementType, managementArg, managementName));
                    WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                    return;
                }
                case 2:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild donate with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    return;
                }
                case 3:
                {
                    if(guild == null)
                    {
                        Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild hat change with char that ain't in guild");
                        c.Close();
                        return;
                    }

                    guild.guildHat = managementArg;
                    WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), GuildPackets.extCharGuild(chr));
                    c.WriteRawPacket(GuildPackets.refreshGuild(chr));
                    return;
                }
            }
            return;
        }
Example #34
0
        public static void ToggleMutationEffect(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked toggleMutationEffect with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte toggleType = p.ReadByte();

            OutPacket op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteShort(0x05);
            op.WriteShort(0X7c);
            op.WriteInt(140235265);
            op.WriteInt(chr.getuID());
            op.WriteInt(toggleType == 0 ? 716251136 : 716251314);

            WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr.getArea(), op.ToArray());
        }
Example #35
0
        public static void Warp(MartialClient c, InCommand cmd)
        {
            if(cmd.commandArgs.Length < 2)
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                return;
            }

            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Null activity in command handler");
                c.Close();
                return;
            }
            Character chr = c.getAccount().activeCharacter;

            short goMap = -1;
            float goX = -1;
            float goY = -1;

            if(cmd.commandArgs.Length == 2)
            {
                switch(cmd.commandArgs[0].ToLower())
                {
                    case "npc":
                    {
                        int npcID = -1;
                        if(!Int32.TryParse(cmd.commandArgs[1], out npcID))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse NPC's ID.");
                            return;
                        }

                        if(WMap.Instance.getNpcs().ElementAtOrDefault(npcID) == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find NPC of ID " + npcID + "!");
                            return;
                        }

                        NPC npc = WMap.Instance.getNpcs()[npcID];

                        goMap = npc.getMap();
                        goX = npc.getPosition()[0];
                        goY = npc.getPosition()[1];
                        break;
                    }
                    /*case "mob":
                    {
                        int mobID = -1;
                        if(!Int32.TryParse(cmd.commandArgs[1], out mobID))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse Mob's ID.");
                            return;
                        }

                        Mob mob = WMap.Instance.getGrid(chr.getMap()).findMobByuID(mobID);
                        if(mob == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to find Mob of ID " + mobID + "!");
                            return;
                        }

                        goMap = mob.getMap();
                        goX = mob.getPosition()[0];
                        goY = mob.getPosition()[1];
                        break;
                    }*/
                    case "player":
                    {
                        Character player = WMap.Instance.findPlayerByName(cmd.commandArgs[1]);
                        if(player == null)
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Player wasn't found.");
                            return;
                        }

                        goMap = player.getMap();
                        goX = player.getPosition()[0];
                        goY = player.getPosition()[1];
                        break;
                    }
                    default:
                    {
                        if(!MiscFunctions.IsNumeric(cmd.commandArgs[0]) || cmd.commandArgs[1] != "true" && !MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "/goto [x] [y] [map] | [Mob|NPC|Player] [uID/name] | [map] true");
                            return;
                        }

                        Waypoint closestTown = null;
                        short _desiredMap = -1;
                        if(!Int16.TryParse(cmd.commandArgs[0], out _desiredMap))
                        {
                            StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired map's ID!");
                            return;
                        }

                        if(cmd.commandArgs[1] == "true")
                        {
                            closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(_desiredMap, new Waypoint(0, 0));
                            if(closestTown == null)
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + "!");
                                return;
                            }
                        }
                        else if(MiscFunctions.IsNumeric(cmd.commandArgs[1]))
                        {
                            int _desiredTown = -1;
                            if(!Int32.TryParse(cmd.commandArgs[1], out _desiredTown))
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "Server wasn't able to parse your desired town's index!");
                                return;
                            }

                            closestTown = TownCoordsCache.Instance.getWaypointAtIndexForMap(_desiredMap, _desiredTown);
                            if(closestTown == null)
                            {
                                StaticPackets.sendSystemMessageToClient(c, 1, "There's not any town on map " + _desiredMap + " with index " + _desiredTown + "!");
                                return;
                            }
                        }

                        goMap = Convert.ToInt16(cmd.commandArgs[0]);
                        goX = closestTown.getX();
                        goY = closestTown.getY();
                        break;
                    }
                }
            }
            else if(cmd.commandArgs.Length == 3)
            {
                foreach(string parser in cmd.commandArgs)
                    if(!MiscFunctions.IsNumeric(parser))
                    {
                        StaticPackets.sendSystemMessageToClient(c, 1, "Parameters must be values!");
                        return;
                    }

                goMap = Convert.ToInt16(cmd.commandArgs[2]);
                goX = Convert.ToSingle(cmd.commandArgs[0]);
                goY = Convert.ToSingle(cmd.commandArgs[1]);
            } else return;

            CharacterFunctions.setPlayerPosition(c.getAccount().activeCharacter, goX, goY, goMap);
            return;
        }
Example #36
0
 public static void Fury(MartialClient c, InPacket p)
 {
     return;
 }
Example #37
0
 public static void DeclareWar(MartialClient c, InPacket p)
 {
     return;
 }
Example #38
0
        public static void ParseCommand(MartialClient c, string[] cmd)
        {
            InCommand p = new InCommand(cmd[0].ToLower(), cmd.Length == 1 ? null : cmd.Skip(1).ToArray());

            CommandHandler handler = null;
            handler = c_processor[p.commandName];

            if(handler != null)
            {
                handler(c, p);
            }
            else
            {
                StaticPackets.sendSystemMessageToClient(c, 1, "Command '" + cmd[0] + "' wasn't found.");
                return;
            }
        }
Example #39
0
        public static void Refresh(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(40);
            op.WriteInt(40);
            op.WriteShort(5);
            op.WriteShort(0x41);
            op.WriteInt(1);
            op.WriteShort(13413);
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(32);
            op.WriteInt(32);
            op.WriteShort(4);
            op.WriteShort(97);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteLong();
            op.WriteLong();
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(136);
            op.WriteInt(136);
            op.WriteShort(4);
            op.WriteShort(81);
            op.WriteInt(1);
            op.WriteShort(-15349);
            op.WriteShort((short)chr.getuID());
            op.WriteShort(1);
            op.WriteShort(30726);
            op.WriteString("PolishPoverty");
            c.WriteRawPacket(op.ToArray());

            op = new OutPacket(20);
            op.WriteInt(20);
            op.WriteInt(5);
            op.WriteInt(937683714); // those values.. lelellele
            op.WriteInt(680);
            op.WriteInt(939117056);
            c.WriteRawPacket(op.ToArray());
        }
Example #40
0
 public static void Message(MartialClient c, InCommand cmd)
 {
 }
Example #41
0
        public static void UnknownStatimizer(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked playerState with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            OutPacket op = new OutPacket(24);
            op.WriteInt(24);
            op.WriteShort(4);
            op.WriteShort(47);
            op.WriteInt(1);
            op.WriteInt(chr.getuID());
            op.WriteByte();
            op.WriteByte();
            op.WriteByte(1);
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte();
            op.WriteByte(); // ok, there's some magic on those bytes, for ex. 3rd byte tells you, if you're able to trade in wild zone
            chr.getAccount().mClient.WriteRawPacket(op.ToArray());
        }
Example #42
0
        public static void Movement(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked Movement with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            p.Skip(4);
            byte[] locationToX = p.ReadBytes(4);
            byte[] locationToY = p.ReadBytes(4);
            p.Skip(1);
            byte movingMode = p.ReadByte();
            MoveCharacterPacket.HandleMovement(chr, locationToX, locationToY, movingMode);
        }
Example #43
0
        public static void UpdateNews(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Hooked guild.Refresh with null of activeCharacter");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            if(chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            Guild guild = chr.getGuild();

            if(chr.getGuild() == null)
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guild news with char that ain't in guild");
                c.Close();
                return;
            }

            GuildMember gMember = guild.findGuildMember(chr.getuID());

            if(gMember.getGuildRank() < 4) // aint master?
            {
                Logger.LogCheat(Logger.HackTypes.Guild, c, "Hooked guildManagement with char that ain't a guild master");
                c.Close();
                return;
            }

            string news = MiscFunctions.obscureString(p.ReadString(195));

            guild.guildNews = news;

            guild.sendToGuildMembers(GuildPackets.getRefreshNewsGuildPacket(news));
        }