public static void UpdateStat(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.CHAR_STATUP_ACK)) { var chr = c.Character; Dictionary <InventoryType.EquipType, int> equip = InventoryPacket.getEquip(chr); plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteShort(chr.MaxHp); plew.WriteShort(chr.MaxMp); plew.WriteShort(chr.Str); plew.WriteShort(chr.Dex); plew.WriteShort(chr.Vit); plew.WriteShort(chr.Int); plew.WriteShort(chr.MaxAttack); plew.WriteShort(chr.Attack); plew.WriteShort(chr.MaxMagic); plew.WriteShort(chr.Magic); plew.WriteShort(chr.Defense); plew.WriteByte(equip.ContainsKey(InventoryType.EquipType.Weapon) ? ItemFactory.weaponData[equip[InventoryType.EquipType.Weapon]].Speed : 0); // 攻擊速度 plew.WriteByte(equip.ContainsKey(InventoryType.EquipType.Weapon) ? ItemFactory.weaponData[equip[InventoryType.EquipType.Weapon]].AttackRange : 0); // 攻擊距離 plew.WriteShort(chr.Avoid); plew.WriteShort(chr.AbilityBonus); plew.WriteShort(chr.SkillBonus); plew.WriteShort(chr.UpgradeStr); plew.WriteShort(chr.UpgradeDex); plew.WriteShort(chr.UpgradeVit); plew.WriteShort(chr.UpgradeInt); plew.WriteShort(chr.UpgradeAttack); plew.WriteShort(chr.UpgradeMagic); plew.WriteShort(chr.UpgradeDefense); c.Send(plew); } }
public static void DeleteItem(MartialClient c, InPacket p) { if (c.getAccount().activeCharacter == null) { Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook deleteItem while not being ingame."); c.Close(); return; } Character chr = c.getAccount().activeCharacter; byte[] decrypted = p.ReadBytes(2); if (!chr.getInventory().removeItem(decrypted[1])) { Console.WriteLine("qq cant remove"); return; } OutPacket op = new OutPacket(20); op.WriteInt(20); op.WriteShort(0x04); op.WriteShort(0x15); op.WriteInt(); op.WriteInt(chr.getuID()); op.WriteShort(0x01); op.WriteByte(decrypted[0]); op.WriteByte(decrypted[1]); c.WriteRawPacket(op.ToArray()); }
private static void SendLoginResult(MapleClient client, LoginResult result) { using (OutPacket oPacket = new OutPacket(SendOps.CheckPasswordResult)) { oPacket .WriteInt((int)result) .WriteByte() .WriteByte(); if (result == LoginResult.Valid) { oPacket .WriteInt(client.Account.ID) .WriteByte() .WriteBool() .WriteByte() .WriteByte() .WriteMapleString(client.Account.Username) .WriteByte() .WriteBool() .WriteLong() .WriteLong() .WriteInt() .WriteShort(2); } client.Send(oPacket); } }
public static void AddCharaterLook(OutPacket p, Character c) { foreach (var kvp in c.Inventory[InventorySlot.Equipped].Items) { if (kvp.Key < -100) { continue; } p.WriteByte((byte)Math.Abs(kvp.Key)); p.WriteInt(kvp.Value.ItemId); } p.WriteByte(); foreach (var kvp in c.Inventory[InventorySlot.Equipped].Items) { if (kvp.Key > -100) { continue; } p.WriteByte((byte)Math.Abs(kvp.Key)); p.WriteInt(kvp.Value.ItemId); } p.WriteByte(); }
public static void AddCharacterData(OutPacket p, Character c) { p.WriteInt(c.CharId); p.WritePaddedString(c.Name, 13); p.WriteByte(c.Gender); p.WriteByte(c.SkinColor); p.WriteInt(c.Face); p.WriteInt(c.Hair); p.WriteLong(); //pet p.WriteByte(c.Level); p.WriteShort(c.Job); p.WriteShort(c.Str); p.WriteShort(c.Dex); p.WriteShort(c.Int); p.WriteShort(c.Luk); p.WriteShort(c.HP); p.WriteShort(c.MaxHP); p.WriteShort(c.MP); p.WriteShort(c.MaxMP); p.WriteShort(c.AP); p.WriteShort(c.SP); p.WriteInt(c.EXP); p.WriteShort(c.Fame); p.WriteInt(c.MapId); p.WriteByte(c.SpawnPoint); p.WriteZero(16); }
public static void regenrMonster(Client c, Monster Monster) { using (OutPacket plew = new OutPacket(ServerOpcode.MON_REGEN)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(Monster.MonsterID); plew.WriteByte(Monster.Level); plew.WriteByte(Monster.AddEffect); plew.WriteByte(Monster.Direction); plew.WriteByte(Monster.MoveType); plew.WriteShort(Monster.PositionX); plew.WriteShort(Monster.PositionY); plew.WriteShort(0); plew.WriteShort(0); plew.WriteInt(Monster.HP); plew.WriteShort(Monster.OriginalID); plew.WriteShort(Monster.Attack1); plew.WriteShort(Monster.Attack2); plew.WriteShort(Monster.CrashAttack); plew.WriteShort(Monster.Defense); plew.WriteShort(Monster.AttackType); // Byte plew.WriteShort(0x630); plew.WriteShort(0); c.Send(plew); } }
public static OutPacket ServerList(int[] channelUserLogged) { using (var packet = new OutPacket(SendOpcodes.Serverlist)) { packet.WriteByte(0); //serverid packet.WriteMapleString(ServerSettings.ServerName); packet.WriteByte(0x03); //0: 正常 1: 火爆 2: 热 3: 新开 packet.WriteMapleString(ServerSettings.ServerName); //eventmsg packet.WriteByte(0x64); packet.WriteByte(0x00); packet.WriteByte(0x64); packet.WriteByte(0x00); packet.WriteByte(ServerSettings.ChannelCount); packet.WriteInt(500); for (var i = 0; i < ServerSettings.ChannelCount; i++) { var load = channelUserLogged[i]; packet.WriteMapleString(ServerSettings.ServerName + "-" + (i + 1)); packet.WriteInt(load); packet.WriteByte(0x00); //serverid packet.WriteShort((short)i); } packet.WriteShort(0); return(packet); } }
public static void PartyUpdate(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.PARTY_UPDATE)) { var chr = c.Character; plew.WriteInt(0); // length + CRC plew.WriteInt(0); for (int i = 0; i < 6; i++) { // 個人 + 其他 5 名隊員 plew.WriteInt(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.CharacterID : -1); plew.WriteShort(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.Level : 0); plew.WriteString((i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.Name : ""), 20); plew.WriteShort(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.MaxHp : 0); plew.WriteShort(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.Hp : 0); plew.WriteShort(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.MaxMp : 0); plew.WriteShort(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.Mp : 0); // 尚未確認 plew.WriteHexString("1F 40"); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[0] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[1] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[2] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[3] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[0] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[1] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[2] : 0); plew.WriteByte(i < chr.Party.getMembers().Count ? chr.Party.getMembers()[i].Character.IP.GetAddressBytes()[3] : 0); } c.Send(plew); } }
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()); }
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()); }
public void SendInventory(ClientSession cs) { using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_VERIFY_INVENTORY_NOT)) { oPacket.WriteHexString("00 00 00 01 00 00 00 01"); oPacket.WriteInt(inventory.Length); for (int i = 0; i < inventory.Length; i++) { oPacket.WriteInt(inventory[i].ItemID); // ItemID oPacket.WriteHexString("00 00 00 01"); oPacket.WriteInt(inventory[i].ItemUID); // ItemUID oPacket.WriteInt(inventory[i].Quantity); oPacket.WriteHexString("FF FF FF FF"); /*oPacket.WriteInt(inventory[i].Quantity); // Quantity * oPacket.WriteInt(inventory[i].Quantity); // Quantity*/ oPacket.WriteHexString("00 00 00 00 00 00 FF FF FF FF 00 00 00 00 56 76 0D AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); //oPacket.WriteHexString("00 00 00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); } oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, ++cs.CRYPT_COUNT); cs.Send(oPacket); } }
public ClientSession(Socket pSocket) : base(pSocket) { IP = BitConverter.ToUInt32(IPAddress.Parse(GetIP()).GetAddressBytes(), 0); InitiateReceive(2, true); CurrentChannel = null; CurrentRoom = null; CRYPT_KEY = CryptoGenerators.GenerateKey(); CRYPT_HMAC = CryptoGenerators.GenerateKey(); byte[] TEMP_PREFIX = CryptoGenerators.GeneratePrefix(); // Prefix LogFactory.GetLog("Main").LogHex("IV: ", CRYPT_KEY); LogFactory.GetLog("Main").LogHex("HMAC: ", CRYPT_HMAC); using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ACCEPT_CONNECTION_NOT)) { oPacket.WriteBytes(TEMP_PREFIX); oPacket.WriteInt((int)8); oPacket.WriteBytes(CRYPT_HMAC); oPacket.WriteInt((int)8); oPacket.WriteBytes(CRYPT_KEY); oPacket.WriteHexString("00 00 00 01 00 00 00 00 00 00 00 00"); oPacket.Assemble(CryptoConstants.GC_DES_KEY, CryptoConstants.GC_HMAC_KEY, CRYPT_PREFIX, ++CRYPT_COUNT); Send(oPacket); } // Prefix CRYPT_PREFIX = TEMP_PREFIX; }
public ClientSession(Socket pSocket) : base(pSocket) { IP = BitConverter.ToUInt32(IPAddress.Parse(GetIP()).GetAddressBytes(), 0); InitiateReceive(2, true); CRYPT_KEY = CryptoGenerators.GenerateKey(); CRYPT_HMAC = CryptoGenerators.GenerateKey(); byte[] TEMP_PREFIX = CryptoGenerators.GeneratePrefix(); using (OutPacket oPacket = new OutPacket(CenterOpcodes.SET_SECURITY_KEY_NOT)) { oPacket.WriteBytes(TEMP_PREFIX); oPacket.WriteInt((int)8); oPacket.WriteBytes(CRYPT_HMAC); oPacket.WriteInt((int)8); oPacket.WriteBytes(CRYPT_KEY); oPacket.WriteHexString("00 00 00 01 00 00 00 00 00 00 00 00"); oPacket.Assemble(CryptoConstants.GC_DES_KEY, CryptoConstants.GC_HMAC_KEY, CRYPT_PREFIX, ++CRYPT_COUNT); Send(oPacket); } CRYPT_PREFIX = TEMP_PREFIX; using (OutPacket oPacket = new OutPacket(CenterOpcodes.ENU_WAIT_TIME_NOT)) { oPacket.WriteHexString("00 00 27 10"); oPacket.Assemble(CRYPT_KEY, CRYPT_HMAC, CRYPT_PREFIX, ++CRYPT_COUNT); Send(oPacket); } }
public void OnChangeEquipInRoom(ClientSession cs, InPacket ip) { if (cs.CurrentRoom == null) { return; } using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_CHANGE_LOOK_EQUIP_NOT)) { oPacket.WriteInt(cs.LoginUID); oPacket.WriteInt(cs.MyCharacter.MyChar.Length); for (int i = 0; i < cs.MyCharacter.MyChar.Length; i++) { oPacket.WriteByte((byte)cs.MyCharacter.MyChar[i].CharType); oPacket.WriteInt(0); // 00 00 00 00 } for (int i = 0; i < 6; i++) { if (cs.CurrentRoom.Slot[i].Active == true) { oPacket.CompressAndAssemble(cs.CurrentRoom.Slot[i].cs.CRYPT_KEY, cs.CurrentRoom.Slot[i].cs.CRYPT_HMAC, cs.CurrentRoom.Slot[i].cs.CRYPT_PREFIX, cs.CurrentRoom.Slot[i].cs.CRYPT_COUNT); cs.CurrentRoom.Slot[i].cs.Send(oPacket); oPacket.CancelAssemble(); } } } }
public static void MyChar_Info_Ack(Client gc, List <Character> chars) { using (OutPacket plew = new OutPacket(ServerOpcode.MYCHAR_INFO_ACK)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(chars.Count); //for (int i = 0; i < 4; i++) //{ // getCharactersData(plew, (i < chars.Count) ? chars[i] : null); //} for (int i = 0; i < 4; i++) { bool isCreate = false; foreach (Character chr in chars) { if (chr.Position == (i + 1)) { getCharactersData(plew, chr); isCreate = true; break; } } if (!isCreate) { getCharactersData(plew, null); } } gc.Send(plew); } }
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()); }
/// <summary> /// Sends the initial patch data packet to the socket. /// </summary> /// <param name="version">The version's information</param> /// <param name="patchLocation">The patch data URL</param> public void SendPatchData(Version version, string patchLocation) { //F**k!!!!! Random rnd = new Random(); uint val_first = 0; //(uint)rnd.Next(); uint val_second = 0; //(uint)rnd.Next() ; using (OutPacket outPacket = new OutPacket()) { outPacket.WriteHexString("80 05 2B 28"); // NOTE: Header. Do not change. Probably typeid() of handler. outPacket.WriteShort(version.Localisation); outPacket.WriteShort(version.Major); outPacket.WriteShort(version.Minor); outPacket.WriteString(patchLocation); outPacket.WriteInt((int)val_first); // NOTE: IV Keys. Should we do random stuffs? outPacket.WriteInt((int)val_second); outPacket.WriteByte(0xE0); // NOTE: Some stuff used on Region / Service Area. outPacket.WriteHexString("03 00 09 03 00 00 03 00 00 00 00 00 83 A3 E5 47 00 00 15 00 0D 00 00 00 03 00 00 00 00 00 65"); this.Send(outPacket); } riv = val_first ^ val_second; siv = val_first ^ val_second; }
public static void getInvenOther4(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.INVEN_OTHER4)) { var chr = c.Character; plew.WriteInt(0); // length + CRC plew.WriteInt(0); for (byte i = 0; i < 24; i++) { // 物品編號 plew.WriteInt(chr.Items.ItemID(InventoryType.ItemType.Other4, i)); } for (byte i = 0; i < 24; i++) { // 物品數量 plew.WriteShort(chr.Items.Quantity(InventoryType.ItemType.Other4, i)); } for (byte i = 0; i < 24; i++) { // 物品Lock plew.WriteByte(chr.Items.IsLocked(InventoryType.ItemType.Other4, i)); } for (byte i = 0; i < 24; i++) { // 截止日期 plew.WriteInt(chr.Items.Term(InventoryType.ItemType.Other4, i)); } for (byte i = 0; i < 24; i++) { // 物品Icon plew.WriteShort(chr.Items.Icon(InventoryType.ItemType.Other4, i)); } c.Send(plew); } }
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()); }
public static OutPacket GetCharInfo(MapleCharacter chr) { using (var packet = new OutPacket(SendOpcodes.WarpToMap)) { packet.WriteInt(chr.Client.ChannelId); packet.WriteByte(0x00); packet.WriteByte(0x01); packet.WriteByte(0x01); packet.WriteShort(0); packet.WriteInt((int)(Randomizer.NextDouble() * 10)); packet.WriteLong(DateUtiliy.GetFileTimestamp(DateTime.Now.GetTimeMilliseconds())); packet.WriteLong(-1); packet.WriteByte(0x00); LoginPacket.AddCharStats(packet, chr); packet.WriteByte((byte)chr.Buddies.Capacity); PacketCreator.AddInventoryInfo(packet, chr); PacketCreator.AddSkillRecord(packet, chr); PacketCreator.AddQuestRecord(packet, chr); PacketCreator.AddRingInfo(packet, chr); PacketCreator.AddTeleportRockRecord(packet, chr); packet.WriteShort(0); packet.WriteLong(0); packet.WriteByte(0x00); packet.WriteInt(0); packet.WriteLong(DateUtiliy.GetFileTimestamp(DateTime.Now.GetTimeMilliseconds())); return(packet); } }
public static void TradeCancel(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.TRADE_CANCEL)) { var chr = c.Character; plew.WriteInt(0); // length + CRC plew.WriteInt(0); c.Send(plew); } }
public static void FriendOnline(Client c) { using (var plew = new OutPacket(MessengerServerOpcode.FRIEND_ONLINE)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteString("", 20); // 玩家名稱 c.Send(plew); } }
public static void FriendAdd(Client c) { using (var plew = new OutPacket(MessengerServerOpcode.FRIEND_ADD)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(0); c.Send(plew); } }
public static void removeUser(Client c, int CharacterID) { using (OutPacket plew = new OutPacket(ServerOpcode.LEAVE_WARP_ACK)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(CharacterID); // 玩家ID c.Send(plew); } }
public static void OpenShop(Client c, int Slots) { using (OutPacket plew = new OutPacket(ServerOpcode.PSHOP_OPENACK)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(Slots); c.Send(plew); } }
public static void SellEnd(Client c, Character chr) { using (OutPacket plew = new OutPacket(ServerOpcode.PSHOP_SELLEND)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(chr.CharacterID); c.Send(plew); } }
public static void PartyDismiss(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.PARTY_DISMISS)) { var chr = c.Character; plew.WriteInt(0); // length + CRC plew.WriteInt(0); c.Send(plew); } }
public static void TradeSuccessful(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.TRADE_SUCCESS)) { var chr = c.Character; plew.WriteInt(0); // length + CRC plew.WriteInt(0); c.Send(plew); } }
public static void BuyCommodity(Client c) { using (OutPacket plew = new OutPacket(ServerOpcode.CASH_BUY_ACK)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(1); // 購買成功 c.Send(plew); } }
public static void UpdateFame(Client c, int fame) { using (OutPacket plew = new OutPacket(ServerOpcode.CHAR_FAME)) { plew.WriteInt(0); // length + CRC plew.WriteInt(0); plew.WriteInt(fame); c.Send(plew); } }