Exemplo n.º 1
0
 /// <summary>
 /// Safe method of logging you out
 /// </summary>
 /// <returns></returns>
 private void CreateLogoutPacket()
 {
     PacketOut o = new PacketOut( 27 );
     o.FinalizeLengthAndChecksum();
     m_cGameConnection.SendTCP( o );
     m_cGameConnection.Disconnect();
     if ( m_tPingThread != null && m_tPingThread.ThreadState == System.Threading.ThreadState.Running ) {
         m_tPingThread.Abort();
     }
     if( IsConnected ) {
         m_cGameConnection.Disconnect();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Not sure about the content - but it actually sends your GPU with its driver version.
 /// </summary>
 /// <returns></returns>
 private PacketOut CreateReportPacket()
 {
     PacketOut o = new PacketOut( 8000 );
     o.WriteShort( 8704 );
     o.WriteShort( 18197 );
     o.WriteByte( 81 );
     o.WriteByte( 251 );
     o.WriteString( "Windows  (6.2.9200)|ATI Radeon HD 3600 SeriesDrv Version : 8.17.10.1129", 71 ); // Only for testing. And yes, my GPU sucks. Problem?
     o.FinalizeLengthAndChecksum();
     return o;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Sends a Message in game
 /// </summary>
 /// <param name="szSource">Receiver</param>
 /// <param name="szMsg">Message</param>
 /// <param name="nType">Message Type (whisper, global, advertisment, [...]</param>
 /// <returns></returns>
 public void CreateMessagePacket(string szSource, string szMsg, int nType)
 {
     PacketOut o = new PacketOut( 20 );
     o.FillString( szSource, 21 );
     o.WriteByte( 0 );
     o.WriteByte( (byte)szMsg.Length );
     o.WriteByte( (byte)nType );
     o.WriteString( szMsg, szMsg.Length );
     o.FinalizeLengthAndChecksum();
     m_cGameConnection.SendTCP( o );
 }
Exemplo n.º 4
0
 /// <summary>
 /// Lets the server know that you want the character list
 /// </summary>
 /// <returns>Nothing</returns>
 private PacketOut CreateCharacterListPacket()
 {
     PacketOut o = new PacketOut( 2001 );
     o.FillString( m_szAccount, 61 );
     o.FinalizeLengthAndChecksum();
     return o;
 }
Exemplo n.º 5
0
        public XClientGameEmulator(Config.ConfigNet conf, TCPManager man, XChat.XClientEmulator pBase, string pAccount, PacketOut pOut)
        {
            m_szAccount = pAccount;
            m_cGameConnection = new TCPConnection( man, null, this, conf );
            try {
                m_cGameConnection.Start();
                m_cGameConnection.SendTCP(CreateVersionPacket());
                m_cGameConnection.SendTCP( pOut );

            }
            catch {
                XLog.Log( "Can't connect to Game Server!" );
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Logs your character into the game
 /// </summary>
 /// <param name="nIndex">Selected Character Index</param>
 /// <returns></returns>
 public void CreateLoginPacket(int nIndex)
 {
     try {
         PacketOut oLogin = new PacketOut( 1 );
         oLogin.FillString( m_iGameCharacterList.nList[nIndex - 1].szName, 61 );
         oLogin.WriteByte( (byte)m_iGameCharacterList.nList[nIndex - 1].nRace );
         oLogin.FinalizeLengthAndChecksum();
         m_dHandles.Add( 0, m_iGameCharacterList.nList[nIndex - 1].szName );
         m_cGameConnection.SendTCP( oLogin );
         XLog.AddMessage( "", "", -5 ); // Clear box
     }
     catch ( Exception e ) {
         XLog.Log( "Error while logging in to the server: {0}", e.Message );
     }
 }
Exemplo n.º 7
0
 private PacketOut CreateVersionPacket()
 {
     PacketOut o = new PacketOut( 10001 );
     o.FillString( "200701120", 20 );
     return o;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Send the packet via TCP without changing any portion of the packet
 /// </summary>
 /// <param name="packet">Packet to send</param>
 public void SendTCPRaw(PacketOut packet)
 {
     SendTCP((byte[])packet.GetBuffer().Clone());
 }
Exemplo n.º 9
0
        public PacketIn ProcessPacket(TCPConnection con, byte[] buf, int start, int size)
        {
            PacketIn packet = new PacketIn( buf, start, size );
            switch ( packet.ID ) {

                case 72: // TS_AC_AES_KEY_IV
                    var pAES = new AUTH_PACKETS.AES_KEY_IV( packet );
                    m_pAES_KEY = m_cRSA.PrivateDecrypt( pAES.nKey, OpenSSL.Crypto.RSA.Padding.PKCS1 );
                    GenerateLoginPacket( m_pAES_KEY, con );
                    break;
                case 10000: // TS_AC_RESULT
                    var pResult = new AUTH_PACKETS.RESULT( packet.ReadUInt16(), packet.ReadUInt16(), packet.ReadInt32() );
                    if ( pResult.nLoginFlag == 1 ) {
                        PacketOut o = new PacketOut( 10021 );
                        con.SendTCP( o );
                    }
                    else {
                        m_cAuthConnection.Disconnect();
                        XLog.Log( "Login failed. Result: {0} - Disconnecting...", pResult.nResult );
                    }
                    m_szPassword = string.Empty;
                    break;
                case 10022: // TS_AC_SERVER_LIST
                    m_iAuthServerList = new AUTH_PACKETS.SERVER_LIST( packet );
                    XLog.Log( "Server selection. Please use /select ID to connect to one of the listed servers below." );
                    for ( int i = 0; i < m_iAuthServerList.count; i++ ) {
                        XLog.Log( string.Format( "-> Server {0}: {1}", i + 1, m_iAuthServerList.list[i].server_name ) );
                    }
                    break;
                case 10024: // TS_AC_SELECT_SERVER
                    con.Disconnect();

                    var pSelectServer = new AUTH_PACKETS.SELECT_SERVER( packet, ref m_pAES_KEY );

                    Config.ConfigNet conf = new Config.ConfigNet();
                    conf.Port = m_iAuthServerList.list[m_nSelectedServerIdx].server_port;
                    conf.ListenIp = System.Net.IPAddress.Parse( m_iAuthServerList.list[m_nSelectedServerIdx].server_ip );

                    PacketOut oEncrypt = new PacketOut( 2005 );
                    oEncrypt.FillString( m_szName, 61 );
                    oEncrypt.Write( pSelectServer.encrypted_data, 0, pSelectServer.encrypted_data.Length );
                    oEncrypt.FinalizeLengthAndChecksum();
                    con.Close();
                    m_cClientBase.CreateGameServerSession( oEncrypt, conf, m_szName );
                    break;
                default:
                    break;
            }
            return packet;
        }
Exemplo n.º 10
0
 private PacketOut CreateAESPacket()
 {
     PacketOut o = new PacketOut( 71 );
     m_cRSA = new OpenSSL.Crypto.RSA();
     m_cRSA.GenerateKeys( 1024, 65537, null, null );
     o.WriteInt32( m_cRSA.PublicKeyAsPEM.Length );
     o.FillString( m_cRSA.PublicKeyAsPEM, m_cRSA.PublicKeyAsPEM.Length );
     return o;
 }
Exemplo n.º 11
0
 public void CreateServerSelectPacket(int nIndex)
 {
     try {
         PacketOut o = new PacketOut( 10023 );
         o.WriteUInt16( m_iAuthServerList.list[nIndex - 1].server_idx );
         m_nSelectedServerIdx = nIndex - 1;
         m_cAuthConnection.SendTCP( o );
     }
     catch ( Exception e ) {
         m_cAuthConnection.Disconnect();
         XLog.Log( "Can't connect to server: {0}", e.Message );
     }
 }
Exemplo n.º 12
0
 public void CreateGameServerSession(PacketOut pOut, Config.ConfigNet config, string pAccount)
 {
     m_cGameEmulator = new XClientGameEmulator( config, m_cManager, this, pAccount, pOut );
 }
Exemplo n.º 13
0
 /// <summary>
 /// Send the packet via TCP without changing any portion of the packet
 /// </summary>
 /// <param name="packet">Packet to send</param>
 public void SendTCPRaw(PacketOut packet)
 {
     SendTCP((byte[])packet.GetBuffer().Clone());
 }
Exemplo n.º 14
0
 private PacketOut CreateVersionPacket()
 {
     PacketOut o = new PacketOut( 51 );
     o.FillString( "200701120", 20 );
     o.FinalizeLengthAndChecksum();
     return o;
 }
Exemplo n.º 15
0
 private void GenerateLoginPacket(byte[] key, TCPConnection con)
 {
     PacketOut o = new PacketOut( 10010 );
     var a = EncryptAES( key, m_szPassword );
     o.FillString( m_szName, 61 );
     o.WriteInt32( a.Length );
     o.Write( a, 0, a.Length );
     o.Fill( 0, 61 - a.Length );
     con.SendTCP( o );
 }
Exemplo n.º 16
0
        /// <summary>
        /// Sends a ping packet to the server, keeping the connection alive.
        /// </summary>
        /// <returns>Nothing</returns>
        private void SendPingPacket()
        {
            // As long as there is a connection to the game server (sorry for the checks xP)
            while ( m_cGameConnection != null && m_cGameConnection.Socket != null && m_cGameConnection.Socket.Connected ) {
                PacketOut o = new PacketOut( 9999 );
                o.FinalizeLengthAndChecksum();
                m_cGameConnection.SendTCP( o );

                XLog.Debug( "Ping packet sent." );
                System.Threading.Thread.Sleep( 1000 * 60 );
            }
            m_tPingThread.Abort();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Sends a packet via TCP
        /// </summary>
        /// <param name="packet">The packet to be sent</param>
        public void SendTCP(PacketOut packet)
        {
            //Fix the packet size
            packet.FinalizeLengthAndChecksum();

            //SavePacket(packet);

            //Get the packet buffer
            byte[] buf = packet.GetBuffer(); //packet.WritePacketLength sets the Capacity

            //Send the buffer
            SendTCP(buf);
        }