Beispiel #1
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());
        }
Beispiel #2
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;
                }
            }
        }
Beispiel #3
0
        public static void CraftItem(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook craftItem while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            int craftingID = p.ReadInt();
            int manualInventoryIndex = p.ReadInt(); // better to be sure, than be rzaah XD
            if(manualInventoryIndex < 0)
            {
                Console.WriteLine("manuel < 0");
                return;
            }

            Inventory inv = chr.getInventory();
            inv.updateInv();

            List<int> seq = new List<int>(inv.getSeqSaved());
            Dictionary<int, Item> items = new Dictionary<int, Item>(inv.getInvSaved());

            if(!items.ContainsKey(seq[manualInventoryIndex]))
            {
                Console.WriteLine("unknown item at index {0}", manualInventoryIndex);
                return;
            }
            Item item = items[seq[manualInventoryIndex]];

            ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID());
            if(itemData == null)
            {
                Console.WriteLine("unknown itemdata for item of ID {0}", item.getItemID());
                return;
            }

            if(itemData.getCategory() != 1010)
            {
                Console.WriteLine("dat shit ain't manual");
                return;
            }

            ManualData manual = ManualDataCache.Instance.getManualData(craftingID);
            if(manual == null)
            {
                Console.WriteLine("manual wasn't found..");
                return;
            }

            List<Item> providedMaterials = new List<Item>();
            List<int> providedMaterialID = new List<int>();
            List<int> providedMaterialQa = new List<int>();
            List<int> providedMaterialIndex = new List<int>();
            for(int i = 0;i < 8;i++)
            {
                int tempMaterialIndex = p.ReadInt();
                Console.WriteLine("indexez of provided mats {0}", tempMaterialIndex);
                if(tempMaterialIndex == -1)
                    break;
                if(seq.ElementAt(tempMaterialIndex) == -1)
                    return;
                if(!items.ContainsKey(seq[tempMaterialIndex]))
                    return;
                Item tempMaterial = items[seq[tempMaterialIndex]];
                if(tempMaterial == null)
                {
                    Console.WriteLine("unknown tempMaterial at index {0}", tempMaterialIndex);
                    return;
                }
                if(tempMaterial.getQuantity() < 1)
                {
                    Console.WriteLine("tempMaterial has less than 1 quantity :< {0}", tempMaterialIndex);
                    return;
                }
                providedMaterials.Add(tempMaterial);
                providedMaterialID.Add(tempMaterial.getItemID());
                providedMaterialQa.Add(tempMaterial.getQuantity());
                providedMaterialIndex.Add(tempMaterialIndex);
            }

            if(providedMaterials.Count == 0)
            {
                Console.WriteLine("playa doesn't supplied materials at all");
                return;
            }

            List<int> deductedAmount = new List<int>(providedMaterialQa);

            List<int> requiredMaterialID = manual.getRequiredMaterials();
            List<int> requiredMaterialQa = manual.getRequiredQuantities();
            for(int i=0;i<providedMaterials.Count;i++) // let's check if playa has satisfied our data provided manual <3
            {
                if(providedMaterialQa[i] < 1)
                    continue;
                for(int x=0;x<requiredMaterialID.Count;x++)
                {
                    if(requiredMaterialQa[x] <= 0)
                        continue;
                    if(requiredMaterialID[x] == providedMaterialID[i])
                    {
                        if(requiredMaterialQa[x] >= providedMaterialQa[i])
                        {
                            requiredMaterialQa[x] -= providedMaterialQa[i];
                            providedMaterialQa[i] = 0;
                        }
                        else
                        {
                            int tempQa = requiredMaterialQa[x];
                            requiredMaterialQa[x] = 0;
                            providedMaterialQa[i] -= tempQa;
                        }
                    }
                }
            }

            if(requiredMaterialQa.Sum() != 0)
            {
                Console.WriteLine("user hasn't applied all of the needed materialz, damn cheatz");
                return;
            }

            int craftedItemID = manual.getProducedItemID();

            p.Position = 73;
            int row = p.ReadByte();
            int line = p.ReadByte();
            if(!inv.craftItem(new Item(craftedItemID)))
            {
                Console.WriteLine("InvCraftItem > Cannot craft item");
                return;
            }

            for(int i = 0;i < providedMaterialIndex.Count;i++)
            {
                if(!inv._decrementItem(providedMaterialIndex[i], providedMaterialQa[i]))
                {
                    Console.WriteLine("damn..?");
                }
            }

            if(!inv._decrementItem(manualInventoryIndex))
            {
                Console.WriteLine("damn man, again, wut happend to u?");
            }

            OutPacket op = new OutPacket(168); // 'it has succeded all the checks n stuff now on to kfc.' - cause we all luv Rzaah
            op.WriteInt(168);
            op.WriteShort(0x04);
            op.WriteShort(0x28);
            op.WriteInt(0x01);
            op.WriteInt(chr.getuID());
            op.WriteInt(0x01);
            p.Position = 4;
            op.WriteBytes(p.ReadBytes(68));
            op.WriteInt(1);
            for(int i = 0;i < 8;i++)
            {
                if(providedMaterialIndex.Count > i)
                {
                    op.WriteInt(deductedAmount[i] - providedMaterialQa[i]);
                } else op.WriteInt(0);
            }
            /* end_time - TODO:
             * op.Position = 153;
             * op.WriteByte(0xff); */
            op.Position = 154;
            p.Position = 73;
            op.WriteShort(p.ReadShort());
            op.WriteInt(craftedItemID);
            /* end_time - TODO:
             * op.WriteInt(craftedItem.getExpiration()); */
            op.WriteInt(); // meanwhile..
            p.Position = 72;
            op.WriteBytes(p.ReadBytes(4));
            c.WriteRawPacket(op.ToArray());

            inv.saveInv();
        }
Beispiel #4
0
        public static void CreateNewCharacter(MartialClient c, InPacket p)
        {
            if(c.getAccount().activeCharacter != null)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while being ingame.");
                c.Close();
                return;
            }

            if(c.getAccount().characters.Count() == 5)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character while characters count is 5.");
                c.Close();
                return;
            }

            string charName = MiscFunctions.obscureString(p.ReadString(18));
            if(charName == null)
            {
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }
            if(charName.Length < 3 || Regex.Replace(charName, "[^A-Za-z0-9]+", "") != charName || MySQLTool.NameTaken(charName))
            {
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            byte face = (byte)p.ReadShort();
            if(face < 1 || face > 7)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with face no {0}", face);
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            short unknownShit = p.ReadShort(); // but let's check it
            if(unknownShit > 0) Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit);

            short unknownShit2 = p.ReadShort();
            if(unknownShit2 > 0)
                Logger.WriteLog(Logger.LogTypes.Debug, "Create character's shit: {0}", unknownShit2);

            byte cClass = (byte)p.ReadShort();
            if(cClass < 1 || cClass > 4)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with class no {0}", cClass);
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            byte[] stats = { (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort(), (byte)p.ReadShort() };
            byte statPoints = (byte)p.ReadShort();

            if(stats[0] + stats[1] + stats[2] + stats[3] + stats[4] + statPoints > 55)
            {
                Logger.LogCheat(Logger.HackTypes.CreateCharacter, c, "Attempted to create a character with weird amount of attributes.");
                c.WriteRawPacket(Constants.createNCharNameTaken);
                return;
            }

            Character newChr = new Character();
            newChr.setName(charName);
            newChr.setFace(face);
            newChr.setcClass(cClass);
            newChr.setStr(stats[0]);
            newChr.setDex(stats[1]);
            newChr.setVit(stats[2]);
            newChr.setAgi(stats[3]);
            newChr.setInt(stats[4]);
            newChr.setStatPoints(statPoints);

            newChr.setAccount(c.getAccount());
            if (newChr.Create() == true)
            {
                CharacterFunctions.createEquipments(newChr);
                CharacterFunctions.createInventories(newChr);
                CharacterFunctions.calculateCharacterStatistics(newChr);
                newChr.setCurHP(newChr.getMaxHP());
                newChr.setCurMP(newChr.getMaxMP());
                newChr.setCurSP(newChr.getMaxSP());
                c.getAccount().appendToCharacters(newChr);
                c.WriteRawPacket(Constants.createNewCharacter);
                return;
            }

            c.WriteRawPacket(Constants.createNCharNameTaken);
            return;
        }