示例#1
0
        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);
            }
        }
示例#2
0
        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;
        }
示例#3
0
 public static OutPacket GetServerIp(IPAddress address, short port, int clientId)
 {
     using (var packet = new OutPacket(SendOpcodes.ServerIp))
     {
         packet.WriteShort(0);
         packet.WriteBytes(address.GetAddressBytes());
         packet.WriteShort(port);
         packet.WriteInt(clientId);
         packet.WriteBytes(new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00 });
         return(packet);
     }
 }
示例#4
0
 public static byte[] Handshake()
 {
     using (OutPacket p = new OutPacket())
     {
         p.WriteShort(14);
         p.WriteShort(Constants.MajorVersion);
         p.WriteMapleString(Constants.MinorVersion);
         p.WriteBytes(Constants.RIV);
         p.WriteBytes(Constants.SIV);
         p.WriteByte(Constants.Locale);
         return(p.ToArray());
     }
 }
示例#5
0
        public static void MoveOrUnequip(MartialClient c, InPacket p)
        {
            Console.WriteLine("move or unequip");

            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook invManag while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte[] decrypted  = p.ReadBytes(12);
            byte[] amountByte = { decrypted[8], decrypted[9], decrypted[10], decrypted[11] };
            int    amount     = BitTools.byteArrayToInt(amountByte);

            if (decrypted[0] == (byte)0x00)
            {
                if (!chr.getInventory().unequipItem(decrypted[1], decrypted[4], decrypted[3], chr.getEquipment()))
                {
                    Console.WriteLine("problem with unequipItem");
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, decrypted[1], 0));
            }
            else
            {
                if (!chr.getInventory().moveItem(decrypted[1], decrypted[2], amount, decrypted[4], decrypted[3]))
                {
                    Console.WriteLine("problem with move item");
                    return;
                }
            }

            OutPacket op = new OutPacket(28);

            op.WriteInt(28);
            op.WriteShort(0x04);
            op.WriteShort(0x10);
            op.WriteInt();
            op.WriteInt(c.getAccount().activeCharacter.getuID());
            op.WriteShort(0x01);
            op.WriteBytes(new byte[] { decrypted[0], decrypted[1], decrypted[2], decrypted[3], decrypted[4] });
            op.WriteByte();
            op.WriteBytes(new byte[] { decrypted[8], decrypted[9], decrypted[10], decrypted[11] });
            c.WriteRawPacket(op.ToArray());

            CharacterFunctions.calculateCharacterStatistics(chr);
        }
示例#6
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());
        }
        protected override void Initialize(params object[] args)
        {
            using (OutPacket outPacket = new OutPacket(InteroperabilityMessage.RegistrationRequest))
            {
                outPacket.WriteByte((byte)ServerUtilities.ServerType.Char);
                outPacket.WriteString((string)args[0]);
                outPacket.WriteBytes(MessageServer.RemoteEndPoint.Address.GetAddressBytes());
                outPacket.WriteUShort((ushort)MessageServer.RemoteEndPoint.Port);

                this.Send(outPacket);
            }
        }
示例#8
0
        public static byte[] SelectWorld(byte worldId, byte channelId)
        {
            using (OutPacket p = new OutPacket(SendOps.SelectWorld))
            {
                p.WriteByte(2); // NOTE: Connection Type.
                p.WriteByte(worldId);
                p.WriteByte(channelId);
                p.WriteBytes(10, 0, 0, 1); // NOTE: IPv4 Address.

                return(p.ToArray());
            }
        }
示例#9
0
        public static void Equip(MartialClient c, InPacket p)
        {
            if (c.getAccount().activeCharacter == null)
            {
                Logger.LogCheat(Logger.HackTypes.NullActive, c, "Attempted to hook equip while not being ingame.");
                c.Close();
                return;
            }

            Character chr = c.getAccount().activeCharacter;

            byte changeType = p.ReadByte();

            byte[] swapSlots = p.ReadBytes(2);

            if (changeType == (byte)0x00)
            {
                if (!chr.getEquipment().swapEquips(swapSlots[0], swapSlots[1]))
                {
                    Logger.LogCheat(Logger.HackTypes.Equip, c, "Attempted to swap weapons, while one of them or even both are null.");
                    c.Close();
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[0], chr.getEquipment().getEquipments()[swapSlots[0]].getItemID()));
                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID()));
            }
            else
            {
                if (!chr.getInventory().equipItem(swapSlots[0], swapSlots[1], chr.getEquipment()))
                {
                    Console.WriteLine("so sorz : >");
                    return;
                }

                WMap.Instance.getGrid(chr.getMap()).sendTo3x3Area(chr, chr.getArea(), CharacterPackets.getExtEquipPacket(chr, swapSlots[1], chr.getEquipment().getEquipments()[swapSlots[1]].getItemID()));
            }

            OutPacket op = new OutPacket(24);

            op.WriteInt(24);
            op.WriteShort(0x04);
            op.WriteShort(0x0c);
            op.WriteInt(135593729);
            op.WriteInt(c.getAccount().activeCharacter.getuID());
            op.WriteShort(0x01);
            op.WriteByte(changeType);
            op.WriteBytes(swapSlots);
            c.WriteRawPacket(op.ToArray());

            CharacterFunctions.calculateCharacterStatistics(chr);
        }
示例#10
0
        public override void Dispatch(InPacket inPacket)
        {
            if (inPacket.OperationCode == Program.ServerIP)
            {
                ushort status = inPacket.ReadUShort();
                ushort status2 = inPacket.ReadUShort();
                byte[] ip = inPacket.ReadBytes(4);
                ushort port = inPacket.ReadUShort();
                byte[] leftover = inPacket.ReadLeftoverBytes();

                Program.IP = string.Format("{0}.{1}.{2}.{3}", ip[0], ip[1], ip[2], ip[3]);
                Program.Port = port;

                using (OutPacket outPacket = new OutPacket(Program.ServerIP))
                {
                    outPacket.WriteUShort(status);
                    outPacket.WriteUShort(status2);
                    outPacket.WriteBytes(127, 0, 0, 1);
                    outPacket.WriteUShort(8484);
                    outPacket.WriteBytes(leftover);

                    if (ClientSession.Instance != null)
                    {
                        ClientSession.Instance.Send(outPacket.ToArray());
                    }
                }
            }
            else
            {
                using (OutPacket outPacket = new OutPacket(inPacket))
                {
                    if (ClientSession.Instance != null)
                    {
                        ClientSession.Instance.Send(outPacket.ToArray());
                    }
                }
            }
        }
示例#11
0
        public override void Dispatch(InPacket inPacket)
        {
            if (inPacket.OperationCode == Program.ServerIP)
            {
                ushort status   = inPacket.ReadUShort();
                ushort status2  = inPacket.ReadUShort();
                byte[] ip       = inPacket.ReadBytes(4);
                ushort port     = inPacket.ReadUShort();
                byte[] leftover = inPacket.ReadLeftoverBytes();

                Program.IP   = string.Format("{0}.{1}.{2}.{3}", ip[0], ip[1], ip[2], ip[3]);
                Program.Port = port;

                using (OutPacket outPacket = new OutPacket(Program.ServerIP))
                {
                    outPacket.WriteUShort(status);
                    outPacket.WriteUShort(status2);
                    outPacket.WriteBytes(127, 0, 0, 1);
                    outPacket.WriteUShort(8484);
                    outPacket.WriteBytes(leftover);

                    if (ClientSession.Instance != null)
                    {
                        ClientSession.Instance.Send(outPacket.ToArray());
                    }
                }
            }
            else
            {
                using (OutPacket outPacket = new OutPacket(inPacket))
                {
                    if (ClientSession.Instance != null)
                    {
                        ClientSession.Instance.Send(outPacket.ToArray());
                    }
                }
            }
        }
示例#12
0
        public byte[] CreateCharacter(int accountId, byte worldId, bool isMaster, byte[] data)
        {
            using (OutPacket outPacket = new OutPacket(InteroperabilityMessage.CharacterCreationRequest))
            {
                outPacket.WriteInt(accountId);
                outPacket.WriteByte(worldId);
                outPacket.WriteBool(isMaster);
                outPacket.WriteBytes(data);

                this.RandomChannel.Send(outPacket);
            }

            return(this.CharacterCreationPool.Dequeue(accountId));
        }
示例#13
0
        /* NetCafe
         * 會員於特約網咖連線
         */
        public static void Login_Ack(Client c, ServerState.LoginState state, short encryptKey = 0, bool netCafe = false)
        {
            using (var plew = new OutPacket(LoginServerOpcode.LOGIN_ACK))
            {
#if DEBUG
                plew.WriteByte(0);                 //bypass password check in debug mode
#else
                plew.WriteByte((byte)state);
#endif
                plew.WriteByte(0);
                plew.WriteByte(c.Account.Master);
                plew.WriteByte(c.Account.isTwoFactor);
                plew.WriteBytes(new byte[]
                                { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
                c.Send(plew);
            }
        }
示例#14
0
 public static OutPacket AuthSuccess(string username, int accountId, bool gender)
 {
     using (var packet = new OutPacket(SendOpcodes.LoginStatus))
     {
         packet.WriteByte(0x00);
         packet.WriteInt(accountId);
         packet.WriteBool(gender);
         packet.WriteShort(0);
         packet.WriteMapleString(username);
         packet.WriteBytes(new byte[]
                           { 0x00, 0x00, 0x00, 0x03, 0x01, 0x00, 0x00, 0x00, 0xE2, 0xED, 0xA3, 0x7A, 0xFA, 0xC9, 0x01 });
         packet.WriteInt(0);
         packet.WriteLong(0);
         packet.WriteMapleString(accountId.ToString());
         packet.WriteMapleString(username);
         packet.WriteByte(0x01);
         return(packet);
     }
 }
示例#15
0
        public static void OnSelectCharacter(MapleClient c, InPacket p)
        {
            int charId = p.ReadInt();

            Character target = c.Characters.FindOne((chr) => chr.CharId == charId);

            if (target != default(Character))
            {
                using (OutPacket packet = new OutPacket(SendOps.SelectCharacterResult))
                {
                    packet.WriteShort();
                    packet.WriteBytes(127, 0, 0, 1); //TODO : non const ip
                    packet.WriteShort(MasterServer.Instance.Channels[c.Channel].Port);
                    packet.WriteInt(charId);
                    packet.WriteByte();

                    c.Send(packet);
                }
            }
            else
            {
                c.Close();
            }
        }
示例#16
0
文件: Channel.cs 项目: Raymonf/GCV
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;//default is 0
                //LogFactory.GetLog("Main").LogInfo("HUEHUE ROOMS Count: " + roomcount);
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);
                for (int j = 0; j < roomcount; j++)
                {
                    /*ushort roomid = 38;//00 26
                    *  string nameRoom = "test";
                    *  string passRoom = "";//01
                    *  ushort fresslots = 4;
                    *  ushort players = 1;
                    *  bool playing = false;
                    *  string nick = "[ADM]Hiro";*/

                    //Room room = new Room();

                    /*
                     * oPacket.WriteUShort(1);//00 26
                     * oPacket.WriteInt("Vamos jogar!".Length * 2);//00 00 00 0C
                     * oPacket.WriteUnicodeString("Vamos jogar!");//68 BE AC B9 68 BE AC B9 21 00 21 00
                     * oPacket.WriteByte(1);
                     * oPacket.WriteByte(0);//00
                     * oPacket.WriteInt("".Length * 2);//00 00 00 00
                     * oPacket.WriteUnicodeString("");
                     * oPacket.WriteUShort(4);//00 04
                     * oPacket.WriteUShort(1);//00 01
                     * oPacket.WriteBool(false);//00
                     * oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                     * oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                     * oPacket.WriteUnicodeString("[ADM]SkelletonX");
                     * oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                     */
                    foreach (Room room in RoomsList)
                    {
                        ushort roomid    = room.ID;       //00 26
                        string nameRoom  = room.RoomName;
                        string passRoom  = room.RoomPass; //01
                        ushort fresslots = 4;
                        ushort players   = (ushort)room.GetPlayerCount();
                        bool   playing   = room.Playing;
                        string nick      = room.GetRoomLeaderCS().Nick;

                        //LogFactory.GetLog("Main").LogInfo("roomID: " + roomid);
                        //LogFactory.GetLog("Main").LogInfo("Name Room: " + nameRoom);
                        //LogFactory.GetLog("Main").LogInfo("Pass Room: " + passRoom);
                        //LogFactory.GetLog("Main").LogInfo("Slots: " + fresslots);
                        //LogFactory.GetLog("Main").LogInfo("players: " + players);
                        //LogFactory.GetLog("Main").LogInfo("Playing: " + playing);

                        if (RoomType == 1)
                        {
                            if (room.Playing == true || room.GetFreeSlot() == 0)
                            {
                                continue;
                            }
                        }
                        oPacket.WriteUShort(roomid);           //00 26
                        oPacket.WriteInt(nameRoom.Length * 2); //00 00 00 0C
                        oPacket.WriteUnicodeString(nameRoom);  //68 BE AC B9 68 BE AC B9 21 00 21 00
                        if (passRoom.Length > 0)               //01
                        {
                            oPacket.WriteByte(0);
                        }
                        else
                        {
                            oPacket.WriteByte(1);
                        }
                        oPacket.WriteByte(0);                  //00
                        oPacket.WriteInt(passRoom.Length * 2); //00 00 00 00
                        oPacket.WriteUnicodeString(passRoom);
                        oPacket.WriteUShort(fresslots);        //00 04
                        oPacket.WriteUShort(players);          //00 01
                        oPacket.WriteBool(playing);            //00
                        oPacket.WriteHexString("28 5C DA F2 02 02 00 00 00 08 32 25 A5 77 00 00 00 03 00 00 00 00 00 00 00 01");
                        oPacket.WriteInt(nick.Length * 2);
                        oPacket.WriteUnicodeString(nick);
                        oPacket.WriteHexString("02 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 01");
                    }
                }
                //}

                /* 방 정보 조합
                 * foreach (Room room in RoomsList)
                 * {
                 *  // 대기방만 보여주는 것이라면...
                 *  if( RoomType == 1 )
                 *  {
                 *      // 게임시작이거나, 남는자리가 없다면 생략
                 *      if (room.Playing == true || room.GetFreeSlot() == 0)
                 *          continue;
                 *  }
                 *
                 *  oPacket.WriteUShort(1);
                 *  oPacket.WriteInt("kkk".Length * 2);
                 *  oPacket.WriteUnicodeString("kkk");
                 *
                 *  if (room.RoomPass.Length > 0)
                 *      oPacket.WriteByte(0); // 비밀방
                 *  else
                 *      oPacket.WriteByte(1); // 공개방
                 *  oPacket.WriteByte(0);
                 *  oPacket.WriteInt("hue".Length * 2);
                 *  oPacket.WriteUnicodeString("hue");
                 *  //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                 *
                 *  // 빈자리 + 유저수 = 총 자리 개수
                 *  oPacket.WriteShort(3 + 1);
                 *  //LogFactory.GetLog("Main").LogInfo(3);
                 *  oPacket.WriteShort(1);
                 *  //LogFactory.GetLog("Main").LogInfo(1);
                 *  oPacket.WriteBool(false);
                 *  //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                 *
                 *  oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");
                 *
                 *  oPacket.WriteInt("[ADM]SkelletonX".Length * 2);
                 *  //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                 *  oPacket.WriteUnicodeString("[ADM]SkelletonX");
                 *
                 *  oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                 * }*/

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
示例#17
0
文件: Channel.cs 项目: Raymonf/GCV
        public void OnRoomList2(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte(); // 1 = 대기방보기, 0 = 모든방보기

            //LogFactory.GetLog("Main").LogInfo("RoomTYPE: " + RoomType);

            // 그 뒤로
            // FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00
            // 어딘가에 페이지가 있겠다.

            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                // 방 정보를 조합한 다음에 압축하고, 실제 패킷을 작성한다.

                // 방 개수 구하기
                int roomcount = 0;

                //LogFactory.GetLog("Main").LogInfo("ROOMS Count: " + roomcount);

                foreach (Room room in RoomsList)
                {
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);
                    // 대기방만 보여주는 것이라면...
                    if (RoomType == 1)
                    {
                        // 게임시작이거나, 남는자리가 없다면 생략
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                    //LogFactory.GetLog("Main").LogInfo("Rooms: " + roomcount);
                }
                oPacket.WriteInt(roomcount);

                // 방 정보 조합
                foreach (Room room in RoomsList)
                {
                    // 대기방만 보여주는 것이라면...

                    /*if (RoomType == 1)
                     * {
                     *  // 게임시작이거나, 남는자리가 없다면 생략
                     *  if (room.Playing == true || room.GetFreeSlot() == 0)
                     *      continue;
                     * }
                     */
                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0); // 비밀방
                    }
                    else
                    {
                        oPacket.WriteByte(1); // 공개방
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);
                    //LogFactory.GetLog("Main").LogInfo("PasswdRoom: " + room.RoomPass);

                    // 빈자리 + 유저수 = 총 자리 개수
                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    //LogFactory.GetLog("Main").LogInfo("Slots: " + room.GetFreeSlot());
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    //LogFactory.GetLog("Main").LogInfo("Players: " + room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);
                    //LogFactory.GetLog("Main").LogInfo("Playing: " + room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    //LogFactory.GetLog("Main").LogInfo("LEADER NICK: " + room.GetRoomLeaderCS().Nick);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }

                // 여태껏 조합된 방 정보를 압축한다.
                int RoomInfoSize = oPacket.ToArray().Length; // 압축하기 전 사이즈
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer(); // 초기화

                // 실제 패킷 작성
                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);                   // 압축된 정보크기 + 4(실제 크기버퍼)
                oPacket.WriteByte(1);                                    // 압축된 데이터다.
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize)); // 압축전 사이즈를 일반적으로 넣는다.
                oPacket.WriteBytes(RoomInfo);                            // 압축된 방 정보

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
                //LogFactory.GetLog("Main").LogHex("ROOMLIST: ", oPacket.getBuffer());
            }
        }
示例#18
0
        /*public void LoadSkilltree(ClientSession cs)
         * {
         *  DataSet ds3 = new DataSet();
         *  Database.Query(ref ds3, "SELECT * FROM `skilltree` WHERE `LoginUI` = '{0}'", cs.LoginUID);
         *  Array.Resize(ref skillinfo, ds3.Tables[0].Rows.Count);
         *  for (int i = 0; i < skillinfo.Length; i++)
         *  {
         *      skillinfo[i].charindex =Convert.ToByte(ds3.Tables[0].Rows[i]["charindex"].ToString());
         *      LogFactory.GetLog("SKILL").LogInfo("CHARID: " + skillinfo[i].charindex);
         *      skillinfo[i].ui1 = Convert.ToByte(ds3.Tables[0].Rows[i]["ui1"].ToString());
         *      LogFactory.GetLog("SKILL").LogInfo("CHARID: " + skillinfo[i].ui1);
         *      skillinfo[i].ui2 = Convert.ToInt32(ds3.Tables[0].Rows[i]["ui2"].ToString());
         *      LogFactory.GetLog("SKILL").LogInfo("CHARID: " + skillinfo[i].ui2);
         *  }
         * }*/

        public void OnSetSkill(ClientSession cs, InPacket ip)
        {
            int unknown1       = ip.ReadInt();
            int LoginUID       = ip.ReadInt();
            int UnknownCharNum = ip.ReadInt();

            /*
             * for(int i = 0; i < UnknownCharNum; i++)
             * {
             *  int c = ip.ReadByte();
             *  byte u1= ip.ReadByte(); // ???
             *  int u2 = ip.ReadInt(); // ???
             *
             *  LogFactory.GetLog("MAIN").LogInfo("    {0} / {1} / {2}", c, u1, u2);
             * }
             */
            int CharNum = ip.ReadInt();

            for (int i = 0; i < CharNum; i++)
            {
                int CharType = ip.ReadByte();
                ip.ReadByte(); // ?
                ip.ReadInt();  // ? 00 00 00 02
                ip.ReadInt();  // ? 00 00 00 00

                int SkillCount = ip.ReadInt();

                LogFactory.GetLog("MAIN").LogInfo("    CHARID :{0} / SKILLID: {1}", CharType, SkillCount);

                int CharPos = findCharIndex(CharType);

                if (CharPos != -1)
                {
                    Array.Resize(ref MyChar[CharPos].EquipSkill, SkillCount);


                    for (int j = 0; j < SkillCount; j++)
                    {
                        ip.ReadInt(); // ? 00 00 00 00
                        int SkillGruop = ip.ReadInt();
                        int SkillID    = ip.ReadInt();

                        MyChar[CharPos].EquipSkill[j].SkillGroup = SkillGruop;
                        MyChar[CharPos].EquipSkill[j].SkillID    = SkillID;
                    }
                }

                ip.ReadInt(); // 00 00 00 01
                ip.ReadInt(); // 00 00 00 00
            }


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SET_SKILL_BROAD))
            {
                oPacket.WriteInt(0);

                byte[] data = ip.ToArray();
                data = BytesUtil.ReadBytes(data, 4, data.Length - 4);

                oPacket.WriteBytes(data);

                /*
                 * oPacket.WriteInt(0);
                 * oPacket.WriteInt(cs.LoginUID);
                 * oPacket.WriteHexString("00 00 00 0B 00 00 00 00 00 00 01 00 00 00 00 00 02 00 00 00 00 00 05 00 00 00 00 00 0A FF 00 00 00 00 0A 00 00 00 00 00 0D 00 00 00 00 00 0E 00 00 00 00 00 0F 00 00 00 00 00 11 00 00 00 00 00 12 00 00 00 00 00");
                 * oPacket.WriteInt(MyChar.Length);
                 * for (int i = 0; i < MyChar.Length; i++)
                 * {
                 *  oPacket.WriteByte((byte)MyChar[i].CharType);
                 *  oPacket.WriteByte(0);
                 *  oPacket.WriteInt(2);
                 *  oPacket.WriteInt(0);
                 *
                 *  oPacket.WriteInt(MyChar[i].skillinfo.Length);
                 *  for (int j = 0; j < MyChar[i].skillinfo.Length; j++)
                 *  {
                 *      oPacket.WriteInt(0);
                 *      oPacket.WriteInt(MyChar[i].skillinfo[j].SkillGroup);
                 *      oPacket.WriteInt(MyChar[i].skillinfo[j].SkilliD);
                 *  }
                 *
                 *  oPacket.WriteInt(1);
                 *  oPacket.WriteInt(0);
                 * }
                 *  /*
                 *  oPacket.WriteInt(0); // ??
                 *  oPacket.WriteInt(LoginUID);
                 *
                 *  oPacket.WriteInt(MyChar.Length);
                 *  for (int i = 0; i < MyChar.Length; i++)
                 *  {
                 *      oPacket.WriteByte((byte)i); // 캐릭터 번호
                 *      oPacket.WriteByte(0); // ???
                 *      oPacket.WriteInt(); // ???
                 *  }
                 *
                 *  oPacket.WriteInt(MyChar.Length);
                 *  for (int i = 0; i < MyChar.Length; i++)
                 *  {
                 *      oPacket.WriteByte((byte)MyChar[i].CharType);
                 *      oPacket.WriteByte(0);
                 *      oPacket.WriteInt(2);
                 *      oPacket.WriteInt(0);
                 *
                 *      oPacket.WriteInt(MyChar[i].EquipSkill.Length);
                 *      for (int j = 0; j < MyChar[i].EquipSkill.Length; j++)
                 *      {
                 *          oPacket.WriteInt(0);
                 *          oPacket.WriteInt(MyChar[i].EquipSkill[j].SkillGroup);
                 *          oPacket.WriteInt(MyChar[i].EquipSkill[j].SkillID);
                 *      }
                 *
                 *      oPacket.WriteInt(1);
                 *      oPacket.WriteInt(0);
                 *  }
                 */

                oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
示例#19
0
        public void OnSetSkill(ClientSession cs, InPacket ip)
        {
            //Log.Hex("패킷", ip.ToArray());

            int unknown1       = ip.ReadInt();
            int LoginUID       = ip.ReadInt();
            int UnknownCharNum = ip.ReadInt();

            for (int i = 0; i < UnknownCharNum; i++)
            {
                int  c  = ip.ReadByte(); // 캐릭터 번호
                byte u1 = ip.ReadByte(); // ???
                int  u2 = ip.ReadInt();  // ???
                LogFactory.GetLog("Main").LogInfo("    {0} / {1} / {2}", c, u1, u2);
            }

            int CharNum = ip.ReadInt();

            for (int i = 0; i < CharNum; i++)
            {
                int CharType = ip.ReadByte(); // 캐릭터 번호
                ip.ReadByte();                // ?
                ip.ReadInt();                 // ? 00 00 00 02
                ip.ReadInt();                 // ? 00 00 00 00

                int SkillCount = ip.ReadInt();

                LogFactory.GetLog("Main").LogInfo("Caracteres {0} / {1} habilidades do número", CharType, SkillCount);

                int CharPos = findCharIndex(CharType); // 캐릭터가 있는 배열 위치
                // 캐릭터가 있으면 동작
                if (CharPos != -1)
                {
                    Array.Resize(ref MyChar[CharPos].EquipSkill, SkillCount);

                    // 스킬 개수만큼 배열에 담는다
                    for (int j = 0; j < SkillCount; j++)
                    {
                        ip.ReadInt();                  // ? 00 00 00 00
                        int SkillGruop = ip.ReadInt(); // 아마도 스킬 그룹일 가능성 높음.
                        int SkillID    = ip.ReadInt();

                        MyChar[CharPos].EquipSkill[j].SkillGroup = SkillGruop;
                        MyChar[CharPos].EquipSkill[j].SkillID    = SkillID;
                    }
                }

                ip.ReadInt(); // 00 00 00 01
                ip.ReadInt(); // 00 00 00 00
            }

            // 패킷은 똑같이 보내면 된다.
            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_SET_SKILL_BROAD))
            {
                oPacket.WriteInt(0);

                byte[] data = ip.ToArray();
                data = BytesUtil.ReadBytes(data, 4, data.Length - 4);

                oPacket.WriteBytes(data);

                /*
                 * oPacket.WriteInt(0); // ??
                 * oPacket.WriteInt(LoginUID);
                 *
                 * oPacket.WriteInt(MyChar.Length);
                 * for (int i = 0; i < MyChar.Length; i++)
                 * {
                 *  oPacket.WriteByte((byte)i); // 캐릭터 번호
                 *  oPacket.WriteByte(0); // ???
                 *  oPacket.WriteInt(); // ???
                 * }
                 *
                 * oPacket.WriteInt(MyChar.Length);
                 * for (int i = 0; i < MyChar.Length; i++)
                 * {
                 *  oPacket.WriteByte((byte)MyChar[i].CharType);
                 *  oPacket.WriteByte(0);
                 *  oPacket.WriteInt(2);
                 *  oPacket.WriteInt(0);
                 *
                 *  oPacket.WriteInt(MyChar[i].EquipSkill.Length);
                 *  for (int j = 0; j < MyChar[i].EquipSkill.Length; j++)
                 *  {
                 *      oPacket.WriteInt(0);
                 *      oPacket.WriteInt(MyChar[i].EquipSkill[j].SkillGroup);
                 *      oPacket.WriteInt(MyChar[i].EquipSkill[j].SkillID);
                 *  }
                 *
                 *  oPacket.WriteInt(1);
                 *  oPacket.WriteInt(0);
                 * }
                 */

                oPacket.CompressAndAssemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }
示例#20
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();
        }
示例#21
0
        public void OnRoomList(ClientSession cs, InPacket ip)
        {
            byte RoomType = ip.ReadByte();


            using (OutPacket oPacket = new OutPacket(GameOpcodes.EVENT_ROOM_LIST_ACK))
            {
                int roomcount = 0;
                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }
                    roomcount++;
                }
                oPacket.WriteInt(roomcount);

                foreach (Room room in RoomsList)
                {
                    if (RoomType == 1)
                    {
                        if (room.Playing == true || room.GetFreeSlot() == 0)
                        {
                            continue;
                        }
                    }

                    oPacket.WriteUShort(room.ID);
                    oPacket.WriteInt(room.RoomName.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomName);

                    if (room.RoomPass.Length > 0)
                    {
                        oPacket.WriteByte(0);
                    }
                    else
                    {
                        oPacket.WriteByte(1);
                    }
                    oPacket.WriteByte(0);
                    oPacket.WriteInt(room.RoomPass.Length * 2);
                    oPacket.WriteUnicodeString(room.RoomPass);

                    oPacket.WriteShort((short)(room.GetFreeSlot() + room.GetPlayerCount()));
                    oPacket.WriteShort((short)room.GetPlayerCount());
                    oPacket.WriteBool(room.Playing);

                    oPacket.WriteHexString("2E 02 1B 25 01 00 00 00 00 01 6B F9 38 77 00 00 00 0C 00 00 00 00 00 00 00 01");

                    oPacket.WriteInt(room.GetRoomLeaderCS().Nick.Length * 2);
                    oPacket.WriteUnicodeString(room.GetRoomLeaderCS().Nick);

                    oPacket.WriteHexString("0B 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 01");
                }


                int RoomInfoSize = oPacket.ToArray().Length;
                oPacket.CompressBuffer();
                byte[] RoomInfo = oPacket.getBuffer();

                oPacket.InitBuffer();

                oPacket.WriteHexString("00 00 00 00 00 00 00 00 00 00 00 01");
                oPacket.WriteInt(4 + RoomInfo.Length);
                oPacket.WriteByte(1);
                oPacket.WriteBytes(BitConverter.GetBytes(RoomInfoSize));
                oPacket.WriteBytes(RoomInfo);

                oPacket.Assemble(cs.CRYPT_KEY, cs.CRYPT_HMAC, cs.CRYPT_PREFIX, cs.CRYPT_COUNT);
                cs.Send(oPacket);
            }
        }